OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkLayerInfo_DEFINED | 8 #ifndef SkLayerInfo_DEFINED |
9 #define SkLayerInfo_DEFINED | 9 #define SkLayerInfo_DEFINED |
10 | 10 |
11 #include "SkPicture.h" | 11 #include "SkPicture.h" |
12 #include "SkTArray.h" | 12 #include "SkTArray.h" |
13 | 13 |
14 // This class stores information about the saveLayer/restore pairs found | 14 // This class stores information about the saveLayer/restore pairs found |
15 // within an SkPicture. It is used by Ganesh to perform layer hoisting. | 15 // within an SkPicture. It is used by Ganesh to perform layer hoisting. |
16 class SkLayerInfo : public SkPicture::AccelData { | 16 class SkLayerInfo : public SkPicture::AccelData { |
17 public: | 17 public: |
18 // Information about a given saveLayer/restore block in an SkPicture | 18 // Information about a given saveLayer/restore block in an SkPicture |
19 class BlockInfo { | 19 class BlockInfo { |
20 public: | 20 public: |
21 BlockInfo() : fPicture(NULL), fPaint(NULL) {} | 21 BlockInfo() : fPicture(NULL), fPaint(NULL), fKey(NULL), fKeySize(0) {} |
22 ~BlockInfo() { SkSafeUnref(fPicture); SkDELETE(fPaint); } | 22 ~BlockInfo() { SkSafeUnref(fPicture); SkDELETE(fPaint); SkDELETE_ARRAY(f
Key); } |
23 | 23 |
24 // The picture owning the layer. If the owning picture is the top-most | 24 // The picture owning the layer. If the owning picture is the top-most |
25 // one (i.e., the picture for which this SkLayerInfo was created) then | 25 // one (i.e., the picture for which this SkLayerInfo was created) then |
26 // this pointer is NULL. If it is a nested picture then the pointer | 26 // this pointer is NULL. If it is a nested picture then the pointer |
27 // is non-NULL and owns a ref on the picture. | 27 // is non-NULL and owns a ref on the picture. |
28 const SkPicture* fPicture; | 28 const SkPicture* fPicture; |
29 // The device space bounds of this layer. | 29 // The device space bounds of this layer. |
30 SkRect fBounds; | 30 SkRect fBounds; |
31 // The pre-matrix begins as the identity and accumulates the transforms | 31 // The pre-matrix begins as the identity and accumulates the transforms |
32 // of the containing SkPictures (if any). This matrix state has to be | 32 // of the containing SkPictures (if any). This matrix state has to be |
(...skipping 10 matching lines...) Expand all Loading... |
43 const SkPaint* fPaint; | 43 const SkPaint* fPaint; |
44 // The index of this saveLayer in the picture. | 44 // The index of this saveLayer in the picture. |
45 size_t fSaveLayerOpID; | 45 size_t fSaveLayerOpID; |
46 // The index of the matching restore in the picture. | 46 // The index of the matching restore in the picture. |
47 size_t fRestoreOpID; | 47 size_t fRestoreOpID; |
48 // True if this saveLayer has at least one other saveLayer nested within
it. | 48 // True if this saveLayer has at least one other saveLayer nested within
it. |
49 // False otherwise. | 49 // False otherwise. |
50 bool fHasNestedLayers; | 50 bool fHasNestedLayers; |
51 // True if this saveLayer is nested within another. False otherwise. | 51 // True if this saveLayer is nested within another. False otherwise. |
52 bool fIsNested; | 52 bool fIsNested; |
| 53 // The variable length key for this saveLayer block. It stores the |
| 54 // thread of drawPicture and saveLayer operation indices that lead to th
is |
| 55 // saveLayer (including its own op index). The BlockInfo owns this memor
y. |
| 56 int* fKey; |
| 57 int fKeySize; // # of ints |
53 }; | 58 }; |
54 | 59 |
55 SkLayerInfo(Key key) : INHERITED(key) { } | 60 SkLayerInfo(Key key) : INHERITED(key) { } |
56 | 61 |
57 BlockInfo& addBlock() { return fBlocks.push_back(); } | 62 BlockInfo& addBlock() { return fBlocks.push_back(); } |
58 | 63 |
59 int numBlocks() const { return fBlocks.count(); } | 64 int numBlocks() const { return fBlocks.count(); } |
60 | 65 |
61 const BlockInfo& block(int index) const { | 66 const BlockInfo& block(int index) const { |
62 SkASSERT(index < fBlocks.count()); | 67 SkASSERT(index < fBlocks.count()); |
63 | 68 |
64 return fBlocks[index]; | 69 return fBlocks[index]; |
65 } | 70 } |
66 | 71 |
67 // We may, in the future, need to pass in the GPUDevice in order to | 72 // We may, in the future, need to pass in the GPUDevice in order to |
68 // incorporate the clip and matrix state into the key | 73 // incorporate the clip and matrix state into the key |
69 static SkPicture::AccelData::Key ComputeKey(); | 74 static SkPicture::AccelData::Key ComputeKey(); |
70 | 75 |
71 private: | 76 private: |
72 SkTArray<BlockInfo, true> fBlocks; | 77 SkTArray<BlockInfo, true> fBlocks; |
73 | 78 |
74 typedef SkPicture::AccelData INHERITED; | 79 typedef SkPicture::AccelData INHERITED; |
75 }; | 80 }; |
76 | 81 |
77 #endif // SkLayerInfo_DEFINED | 82 #endif // SkLayerInfo_DEFINED |
OLD | NEW |