/src/skia/src/core/SkBigPicture.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright 2015 Google Inc. |
3 | | * |
4 | | * Use of this source code is governed by a BSD-style license that can be |
5 | | * found in the LICENSE file. |
6 | | */ |
7 | | |
8 | | #ifndef SkBigPicture_DEFINED |
9 | | #define SkBigPicture_DEFINED |
10 | | |
11 | | #include "include/core/SkBBHFactory.h" |
12 | | #include "include/core/SkPicture.h" |
13 | | #include "include/core/SkRect.h" |
14 | | #include "include/core/SkRefCnt.h" |
15 | | #include "include/private/base/SkNoncopyable.h" |
16 | | #include "include/private/base/SkTemplates.h" |
17 | | #include "src/core/SkRecord.h" |
18 | | |
19 | | #include <cstddef> |
20 | | #include <memory> |
21 | | |
22 | | class SkCanvas; |
23 | | |
24 | | // An implementation of SkPicture supporting an arbitrary number of drawing commands. |
25 | | // This is called "big" because there used to be a "mini" that only supported a subset of the |
26 | | // calls as an optimization. |
27 | | class SkBigPicture final : public SkPicture { |
28 | | public: |
29 | | // An array of refcounted const SkPicture pointers. |
30 | | class SnapshotArray : ::SkNoncopyable { |
31 | | public: |
32 | 0 | SnapshotArray(const SkPicture* pics[], int count) : fPics(pics), fCount(count) {} |
33 | 0 | ~SnapshotArray() { for (int i = 0; i < fCount; i++) { fPics[i]->unref(); } } |
34 | | |
35 | 0 | const SkPicture* const* begin() const { return fPics; } |
36 | 0 | int count() const { return fCount; } |
37 | | private: |
38 | | skia_private::AutoTMalloc<const SkPicture*> fPics; |
39 | | int fCount; |
40 | | }; |
41 | | |
42 | | SkBigPicture(const SkRect& cull, |
43 | | sk_sp<SkRecord>, |
44 | | std::unique_ptr<SnapshotArray>, |
45 | | sk_sp<SkBBoxHierarchy>, |
46 | | size_t approxBytesUsedBySubPictures); |
47 | | |
48 | | |
49 | | // SkPicture overrides |
50 | | void playback(SkCanvas*, AbortCallback*) const override; |
51 | | SkRect cullRect() const override; |
52 | | int approximateOpCount(bool nested) const override; |
53 | | size_t approximateBytesUsed() const override; |
54 | 0 | const SkBigPicture* asSkBigPicture() const override { return this; } |
55 | | |
56 | | // Used by GrRecordReplaceDraw |
57 | 0 | const SkBBoxHierarchy* bbh() const { return fBBH.get(); } |
58 | 0 | const SkRecord* record() const { return fRecord.get(); } |
59 | | |
60 | | private: |
61 | | int drawableCount() const; |
62 | | SkPicture const* const* drawablePicts() const; |
63 | | |
64 | | const SkRect fCullRect; |
65 | | const size_t fApproxBytesUsedBySubPictures; |
66 | | sk_sp<const SkRecord> fRecord; |
67 | | std::unique_ptr<const SnapshotArray> fDrawablePicts; |
68 | | sk_sp<const SkBBoxHierarchy> fBBH; |
69 | | }; |
70 | | |
71 | | #endif//SkBigPicture_DEFINED |