| 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 "SkBigPicture.h" | 11 #include "SkBigPicture.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 SkBigPicture::AccelData { | 16 class SkLayerInfo : public SkBigPicture::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), fKey(NULL), fKeySize(0) {} | 21 BlockInfo() : fPicture(nullptr), fPaint(nullptr), fKey(nullptr), fKeySiz
e(0) {} |
| 22 ~BlockInfo() { | 22 ~BlockInfo() { |
| 23 SkSafeUnref(fPicture); | 23 SkSafeUnref(fPicture); |
| 24 delete fPaint; | 24 delete fPaint; |
| 25 delete[] fKey; | 25 delete[] fKey; |
| 26 } | 26 } |
| 27 | 27 |
| 28 // The picture owning the layer. If the owning picture is the top-most | 28 // The picture owning the layer. If the owning picture is the top-most |
| 29 // one (i.e., the picture for which this SkLayerInfo was created) then | 29 // one (i.e., the picture for which this SkLayerInfo was created) then |
| 30 // this pointer is NULL. If it is a nested picture then the pointer | 30 // this pointer is nullptr. If it is a nested picture then the pointer |
| 31 // is non-NULL and owns a ref on the picture. | 31 // is non-nullptr and owns a ref on the picture. |
| 32 const SkPicture* fPicture; | 32 const SkPicture* fPicture; |
| 33 // The device space bounds of this layer. | 33 // The device space bounds of this layer. |
| 34 SkRect fBounds; | 34 SkRect fBounds; |
| 35 // If not-empty, the optional bounds parameter passed in to the saveLaye
r | 35 // If not-empty, the optional bounds parameter passed in to the saveLaye
r |
| 36 // call. | 36 // call. |
| 37 SkRect fSrcBounds; | 37 SkRect fSrcBounds; |
| 38 // The pre-matrix begins as the identity and accumulates the transforms | 38 // The pre-matrix begins as the identity and accumulates the transforms |
| 39 // of the containing SkPictures (if any). This matrix state has to be | 39 // of the containing SkPictures (if any). This matrix state has to be |
| 40 // part of the initial matrix during replay so that it will be | 40 // part of the initial matrix during replay so that it will be |
| 41 // preserved across setMatrix calls. | 41 // preserved across setMatrix calls. |
| 42 SkMatrix fPreMat; | 42 SkMatrix fPreMat; |
| 43 // The matrix state (in the leaf picture) in which this layer's draws | 43 // The matrix state (in the leaf picture) in which this layer's draws |
| 44 // must occur. It will/can be overridden by setMatrix calls in the | 44 // must occur. It will/can be overridden by setMatrix calls in the |
| 45 // layer itself. It does not include the translation needed to map the | 45 // layer itself. It does not include the translation needed to map the |
| 46 // layer's top-left point to the origin (which must be part of the | 46 // layer's top-left point to the origin (which must be part of the |
| 47 // initial matrix). | 47 // initial matrix). |
| 48 SkMatrix fLocalMat; | 48 SkMatrix fLocalMat; |
| 49 // The paint to use on restore. Can be NULL since it is optional. | 49 // The paint to use on restore. Can be nullptr since it is optional. |
| 50 const SkPaint* fPaint; | 50 const SkPaint* fPaint; |
| 51 // The index of this saveLayer in the picture. | 51 // The index of this saveLayer in the picture. |
| 52 size_t fSaveLayerOpID; | 52 size_t fSaveLayerOpID; |
| 53 // The index of the matching restore in the picture. | 53 // The index of the matching restore in the picture. |
| 54 size_t fRestoreOpID; | 54 size_t fRestoreOpID; |
| 55 // True if this saveLayer has at least one other saveLayer nested within
it. | 55 // True if this saveLayer has at least one other saveLayer nested within
it. |
| 56 // False otherwise. | 56 // False otherwise. |
| 57 bool fHasNestedLayers; | 57 bool fHasNestedLayers; |
| 58 // True if this saveLayer is nested within another. False otherwise. | 58 // True if this saveLayer is nested within another. False otherwise. |
| 59 bool fIsNested; | 59 bool fIsNested; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 76 return fBlocks[index]; | 76 return fBlocks[index]; |
| 77 } | 77 } |
| 78 | 78 |
| 79 private: | 79 private: |
| 80 SkTArray<BlockInfo, true> fBlocks; | 80 SkTArray<BlockInfo, true> fBlocks; |
| 81 | 81 |
| 82 typedef SkBigPicture::AccelData INHERITED; | 82 typedef SkBigPicture::AccelData INHERITED; |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 #endif // SkLayerInfo_DEFINED | 85 #endif // SkLayerInfo_DEFINED |
| OLD | NEW |