OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright 2014 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 SkLayerInfo_DEFINED | |
9 #define SkLayerInfo_DEFINED | |
10 | |
11 #include "SkBigPicture.h" | |
12 #include "SkMatrix.h" | |
13 #include "SkPaint.h" | |
14 #include "SkTArray.h" | |
15 | |
16 // This class stores information about the saveLayer/restore pairs found | |
17 // within an SkPicture. It is used by Ganesh to perform layer hoisting. | |
18 class SkLayerInfo : public SkBigPicture::AccelData { | |
19 public: | |
20 // Information about a given saveLayer/restore block in an SkPicture | |
21 class BlockInfo { | |
22 public: | |
23 BlockInfo() : fPicture(nullptr), fPaint(nullptr), fKey(nullptr), fKeySiz
e(0) {} | |
24 ~BlockInfo() { | |
25 SkSafeUnref(fPicture); | |
26 delete fPaint; | |
27 delete[] fKey; | |
28 } | |
29 | |
30 // The picture owning the layer. If the owning picture is the top-most | |
31 // one (i.e., the picture for which this SkLayerInfo was created) then | |
32 // this pointer is nullptr. If it is a nested picture then the pointer | |
33 // is non-nullptr and owns a ref on the picture. | |
34 const SkPicture* fPicture; | |
35 // The device space bounds of this layer. | |
36 SkRect fBounds; | |
37 // If not-empty, the optional bounds parameter passed in to the saveLaye
r | |
38 // call. | |
39 SkRect fSrcBounds; | |
40 // The pre-matrix begins as the identity and accumulates the transforms | |
41 // of the containing SkPictures (if any). This matrix state has to be | |
42 // part of the initial matrix during replay so that it will be | |
43 // preserved across setMatrix calls. | |
44 SkMatrix fPreMat; | |
45 // The matrix state (in the leaf picture) in which this layer's draws | |
46 // must occur. It will/can be overridden by setMatrix calls in the | |
47 // layer itself. It does not include the translation needed to map the | |
48 // layer's top-left point to the origin (which must be part of the | |
49 // initial matrix). | |
50 SkMatrix fLocalMat; | |
51 // The paint to use on restore. Can be nullptr since it is optional. | |
52 const SkPaint* fPaint; | |
53 // The index of this saveLayer in the picture. | |
54 size_t fSaveLayerOpID; | |
55 // The index of the matching restore in the picture. | |
56 size_t fRestoreOpID; | |
57 // True if this saveLayer has at least one other saveLayer nested within
it. | |
58 // False otherwise. | |
59 bool fHasNestedLayers; | |
60 // True if this saveLayer is nested within another. False otherwise. | |
61 bool fIsNested; | |
62 // The variable length key for this saveLayer block. It stores the | |
63 // thread of drawPicture and saveLayer operation indices that lead to th
is | |
64 // saveLayer (including its own op index). The BlockInfo owns this memor
y. | |
65 int* fKey; | |
66 int fKeySize; // # of ints | |
67 }; | |
68 | |
69 SkLayerInfo() {} | |
70 | |
71 BlockInfo& addBlock() { return fBlocks.push_back(); } | |
72 | |
73 int numBlocks() const { return fBlocks.count(); } | |
74 | |
75 const BlockInfo& block(int index) const { | |
76 SkASSERT(index < fBlocks.count()); | |
77 | |
78 return fBlocks[index]; | |
79 } | |
80 | |
81 private: | |
82 SkTArray<BlockInfo, true> fBlocks; | |
83 | |
84 typedef SkBigPicture::AccelData INHERITED; | |
85 }; | |
86 | |
87 #endif // SkLayerInfo_DEFINED | |
OLD | NEW |