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 GrPictureUtils_DEFINED | 8 #ifndef GrPictureUtils_DEFINED |
9 #define GrPictureUtils_DEFINED | 9 #define GrPictureUtils_DEFINED |
10 | 10 |
11 #include "SkPicture.h" | 11 #include "SkPicture.h" |
12 #include "SkTArray.h" | 12 #include "SkTArray.h" |
13 | 13 |
14 // This class encapsulates the GPU-backend-specific acceleration data | 14 // This class encapsulates the GPU-backend-specific acceleration data |
15 // for a single SkPicture | 15 // for a single SkPicture |
16 class GrAccelData : public SkPicture::AccelData { | 16 class GrAccelData : public SkPicture::AccelData { |
17 public: | 17 public: |
18 // Information about a given saveLayer in an SkPicture | 18 // Information about a given saveLayer in an SkPicture |
19 class SaveLayerInfo { | 19 class SaveLayerInfo { |
20 public: | 20 public: |
21 SaveLayerInfo() : fPicture(NULL), fPaint(NULL) {} | 21 SaveLayerInfo() : fPicture(NULL), fPaint(NULL) {} |
22 ~SaveLayerInfo() { SkSafeUnref(fPicture); SkDELETE(fPaint); } | 22 ~SaveLayerInfo() { SkSafeUnref(fPicture); SkDELETE(fPaint); } |
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 GrAccelData was created) then | 25 // one (i.e., the picture for which this GrAccelData 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 size of the saveLayer | 29 // The device space bounds of this layer. |
30 SkISize fSize; | 30 SkIRect fBounds; |
31 // The matrix state in which this layer's draws must occur. It does not | 31 // The matrix state in which this layer's draws must occur. It does not |
32 // include the translation needed to map the layer's top-left point to t
he origin. | 32 // include the translation needed to map the layer's top-left point to t
he origin. |
33 SkMatrix fOriginXform; | 33 SkMatrix fOriginXform; |
34 // The offset that needs to be passed to drawBitmap to correctly | |
35 // position the pre-rendered layer. It is in device space. | |
36 SkIPoint fOffset; | |
37 // The paint to use on restore. Can be NULL since it is optional. | 34 // The paint to use on restore. Can be NULL since it is optional. |
38 const SkPaint* fPaint; | 35 const SkPaint* fPaint; |
39 // The ID of this saveLayer in the picture. 0 is an invalid ID. | 36 // The ID of this saveLayer in the picture. 0 is an invalid ID. |
40 size_t fSaveLayerOpID; | 37 size_t fSaveLayerOpID; |
41 // The ID of the matching restore in the picture. 0 is an invalid ID. | 38 // The ID of the matching restore in the picture. 0 is an invalid ID. |
42 size_t fRestoreOpID; | 39 size_t fRestoreOpID; |
43 // True if this saveLayer has at least one other saveLayer nested within
it. | 40 // True if this saveLayer has at least one other saveLayer nested within
it. |
44 // False otherwise. | 41 // False otherwise. |
45 bool fHasNestedLayers; | 42 bool fHasNestedLayers; |
46 // True if this saveLayer is nested within another. False otherwise. | 43 // True if this saveLayer is nested within another. False otherwise. |
(...skipping 20 matching lines...) Expand all Loading... |
67 | 64 |
68 private: | 65 private: |
69 SkTArray<SaveLayerInfo, true> fSaveLayerInfo; | 66 SkTArray<SaveLayerInfo, true> fSaveLayerInfo; |
70 | 67 |
71 typedef SkPicture::AccelData INHERITED; | 68 typedef SkPicture::AccelData INHERITED; |
72 }; | 69 }; |
73 | 70 |
74 const GrAccelData* GPUOptimize(const SkPicture* pict); | 71 const GrAccelData* GPUOptimize(const SkPicture* pict); |
75 | 72 |
76 #endif // GrPictureUtils_DEFINED | 73 #endif // GrPictureUtils_DEFINED |
OLD | NEW |