Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(201)

Side by Side Diff: src/core/SkLayerInfo.h

Issue 719133002: Rename GrAccelData to SkLayerInfo and move it to src/core (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix up unit test Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/core/SkPicture.h ('k') | src/core/SkLayerInfo.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 SkLayerInfo_DEFINED
9 #define GrPictureUtils_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 encapsulates the GPU-backend-specific acceleration data 14 // This class stores information about the saveLayer/restore pairs found
15 // for a single SkPicture 15 // within an SkPicture. It is used by Ganesh to perform layer hoisting.
16 class GrAccelData : public SkPicture::AccelData { 16 class SkLayerInfo : public SkPicture::AccelData {
17 public: 17 public:
18 // Information about a given saveLayer in an SkPicture 18 // Information about a given saveLayer/restore block in an SkPicture
19 class SaveLayerInfo { 19 class BlockInfo {
20 public: 20 public:
21 SaveLayerInfo() : fPicture(NULL), fPaint(NULL) {} 21 BlockInfo() : fPicture(NULL), fPaint(NULL) {}
22 ~SaveLayerInfo() { SkSafeUnref(fPicture); SkDELETE(fPaint); } 22 ~BlockInfo() { 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 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
33 // part of the initial matrix during replay so that it will be 33 // part of the initial matrix during replay so that it will be
34 // preserved across setMatrix calls. 34 // preserved across setMatrix calls.
35 SkMatrix fPreMat; 35 SkMatrix fPreMat;
36 // The matrix state (in the leaf picture) in which this layer's draws 36 // The matrix state (in the leaf picture) in which this layer's draws
37 // must occur. It will/can be overridden by setMatrix calls in the 37 // must occur. It will/can be overridden by setMatrix calls in the
38 // layer itself. It does not include the translation needed to map the 38 // layer itself. It does not include the translation needed to map the
39 // layer's top-left point to the origin (which must be part of the 39 // layer's top-left point to the origin (which must be part of the
40 // initial matrix). 40 // initial matrix).
41 SkMatrix fLocalMat; 41 SkMatrix fLocalMat;
42 // The paint to use on restore. Can be NULL since it is optional. 42 // The paint to use on restore. Can be NULL since it is optional.
43 const SkPaint* fPaint; 43 const SkPaint* fPaint;
44 // The ID of this saveLayer in the picture. 0 is an invalid ID. 44 // The index of this saveLayer in the picture.
45 size_t fSaveLayerOpID; 45 size_t fSaveLayerOpID;
46 // The ID of the matching restore in the picture. 0 is an invalid ID. 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 }; 53 };
54 54
55 GrAccelData(Key key) : INHERITED(key) { } 55 SkLayerInfo(Key key) : INHERITED(key) { }
56 56
57 virtual ~GrAccelData() { } 57 BlockInfo& addBlock() { return fBlocks.push_back(); }
58 58
59 SaveLayerInfo& addSaveLayerInfo() { return fSaveLayerInfo.push_back(); } 59 int numBlocks() const { return fBlocks.count(); }
60 60
61 int numSaveLayers() const { return fSaveLayerInfo.count(); } 61 const BlockInfo& block(int index) const {
62 SkASSERT(index < fBlocks.count());
62 63
63 const SaveLayerInfo& saveLayerInfo(int index) const { 64 return fBlocks[index];
64 SkASSERT(index < fSaveLayerInfo.count());
65
66 return fSaveLayerInfo[index];
67 } 65 }
68 66
69 // We may, in the future, need to pass in the GPUDevice in order to 67 // We may, in the future, need to pass in the GPUDevice in order to
70 // incorporate the clip and matrix state into the key 68 // incorporate the clip and matrix state into the key
71 static SkPicture::AccelData::Key ComputeAccelDataKey(); 69 static SkPicture::AccelData::Key ComputeKey();
72 70
73 private: 71 private:
74 SkTArray<SaveLayerInfo, true> fSaveLayerInfo; 72 SkTArray<BlockInfo, true> fBlocks;
75 73
76 typedef SkPicture::AccelData INHERITED; 74 typedef SkPicture::AccelData INHERITED;
77 }; 75 };
78 76
79 #endif // GrPictureUtils_DEFINED 77 #endif // SkLayerInfo_DEFINED
OLDNEW
« no previous file with comments | « include/core/SkPicture.h ('k') | src/core/SkLayerInfo.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698