commit-bot@chromium.org | 8ddc26b | 2014-03-31 17:55:12 +0000 | [diff] [blame] | 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 GrPictureUtils_DEFINED |
| 9 | #define GrPictureUtils_DEFINED |
| 10 | |
| 11 | #include "SkPicture.h" |
| 12 | #include "SkTDArray.h" |
| 13 | |
| 14 | // This class encapsulates the GPU-backend-specific acceleration data |
| 15 | // for a single SkPicture |
| 16 | class GPUAccelData : public SkPicture::AccelData { |
| 17 | public: |
| 18 | // Information about a given saveLayer in an SkPicture |
| 19 | struct SaveLayerInfo { |
| 20 | // The size of the saveLayer |
| 21 | SkISize fSize; |
| 22 | // The ID of this saveLayer in the picture. 0 is an invalid ID. |
| 23 | size_t fSaveLayerOpID; |
| 24 | // The ID of the matching restore in the picture. 0 is an invalid ID. |
| 25 | size_t fRestoreOpID; |
| 26 | // True if this saveLayer has at least one other saveLayer nested within it. |
| 27 | // False otherwise. |
| 28 | bool fHasNestedLayers; |
| 29 | }; |
| 30 | |
| 31 | GPUAccelData(Key key) : INHERITED(key) { } |
| 32 | |
| 33 | void addSaveLayerInfo(const SaveLayerInfo& info) { |
| 34 | SkASSERT(info.fSaveLayerOpID < info.fRestoreOpID); |
| 35 | *fSaveLayerInfo.push() = info; |
| 36 | } |
| 37 | |
| 38 | int numSaveLayers() const { return fSaveLayerInfo.count(); } |
| 39 | |
| 40 | const SaveLayerInfo& saveLayerInfo(int index) const { |
| 41 | SkASSERT(index < fSaveLayerInfo.count()); |
| 42 | |
| 43 | return fSaveLayerInfo[index]; |
| 44 | } |
| 45 | |
commit-bot@chromium.org | 8ddc26b | 2014-03-31 17:55:12 +0000 | [diff] [blame] | 46 | protected: |
| 47 | SkTDArray<SaveLayerInfo> fSaveLayerInfo; |
| 48 | |
| 49 | private: |
| 50 | typedef SkPicture::AccelData INHERITED; |
| 51 | }; |
| 52 | |
| 53 | void GatherGPUInfo(SkPicture* pict, GPUAccelData* accelData); |
| 54 | |
| 55 | #endif // GrPictureUtils_DEFINED |