OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 GrClipMaskCache_DEFINED | 8 #ifndef GrClipMaskCache_DEFINED |
9 #define GrClipMaskCache_DEFINED | 9 #define GrClipMaskCache_DEFINED |
10 | 10 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 back->fLastBound == bounds && | 48 back->fLastBound == bounds && |
49 back->fLastClipGenID == clipGenID) { | 49 back->fLastClipGenID == clipGenID) { |
50 return true; | 50 return true; |
51 } | 51 } |
52 | 52 |
53 return false; | 53 return false; |
54 } | 54 } |
55 | 55 |
56 void reset() { | 56 void reset() { |
57 if (fStack.empty()) { | 57 if (fStack.empty()) { |
58 // GrAssert(false); | 58 // SkASSERT(false); |
59 return; | 59 return; |
60 } | 60 } |
61 | 61 |
62 GrClipStackFrame* back = (GrClipStackFrame*) fStack.back(); | 62 GrClipStackFrame* back = (GrClipStackFrame*) fStack.back(); |
63 | 63 |
64 back->reset(); | 64 back->reset(); |
65 } | 65 } |
66 | 66 |
67 /** | 67 /** |
68 * After a "push" the clip state is entirely open. Currently, the | 68 * After a "push" the clip state is entirely open. Currently, the |
69 * entire clip stack will be re-rendered into a new clip mask. | 69 * entire clip stack will be re-rendered into a new clip mask. |
70 * TODO: can we take advantage of the nested nature of the clips to | 70 * TODO: can we take advantage of the nested nature of the clips to |
71 * reduce the mask creation cost? | 71 * reduce the mask creation cost? |
72 */ | 72 */ |
73 void push(); | 73 void push(); |
74 | 74 |
75 void pop() { | 75 void pop() { |
76 //GrAssert(!fStack.empty()); | 76 //SkASSERT(!fStack.empty()); |
77 | 77 |
78 if (!fStack.empty()) { | 78 if (!fStack.empty()) { |
79 GrClipStackFrame* back = (GrClipStackFrame*) fStack.back(); | 79 GrClipStackFrame* back = (GrClipStackFrame*) fStack.back(); |
80 | 80 |
81 back->~GrClipStackFrame(); | 81 back->~GrClipStackFrame(); |
82 fStack.pop_back(); | 82 fStack.pop_back(); |
83 } | 83 } |
84 } | 84 } |
85 | 85 |
86 int32_t getLastClipGenID() const { | 86 int32_t getLastClipGenID() const { |
87 | 87 |
88 if (fStack.empty()) { | 88 if (fStack.empty()) { |
89 return SkClipStack::kInvalidGenID; | 89 return SkClipStack::kInvalidGenID; |
90 } | 90 } |
91 | 91 |
92 return ((GrClipStackFrame*) fStack.back())->fLastClipGenID; | 92 return ((GrClipStackFrame*) fStack.back())->fLastClipGenID; |
93 } | 93 } |
94 | 94 |
95 GrTexture* getLastMask() { | 95 GrTexture* getLastMask() { |
96 | 96 |
97 if (fStack.empty()) { | 97 if (fStack.empty()) { |
98 GrAssert(false); | 98 SkASSERT(false); |
99 return NULL; | 99 return NULL; |
100 } | 100 } |
101 | 101 |
102 GrClipStackFrame* back = (GrClipStackFrame*) fStack.back(); | 102 GrClipStackFrame* back = (GrClipStackFrame*) fStack.back(); |
103 | 103 |
104 return back->fLastMask.texture(); | 104 return back->fLastMask.texture(); |
105 } | 105 } |
106 | 106 |
107 const GrTexture* getLastMask() const { | 107 const GrTexture* getLastMask() const { |
108 | 108 |
109 if (fStack.empty()) { | 109 if (fStack.empty()) { |
110 GrAssert(false); | 110 SkASSERT(false); |
111 return NULL; | 111 return NULL; |
112 } | 112 } |
113 | 113 |
114 GrClipStackFrame* back = (GrClipStackFrame*) fStack.back(); | 114 GrClipStackFrame* back = (GrClipStackFrame*) fStack.back(); |
115 | 115 |
116 return back->fLastMask.texture(); | 116 return back->fLastMask.texture(); |
117 } | 117 } |
118 | 118 |
119 void acquireMask(int32_t clipGenID, | 119 void acquireMask(int32_t clipGenID, |
120 const GrTextureDesc& desc, | 120 const GrTextureDesc& desc, |
121 const SkIRect& bound) { | 121 const SkIRect& bound) { |
122 | 122 |
123 if (fStack.empty()) { | 123 if (fStack.empty()) { |
124 GrAssert(false); | 124 SkASSERT(false); |
125 return; | 125 return; |
126 } | 126 } |
127 | 127 |
128 GrClipStackFrame* back = (GrClipStackFrame*) fStack.back(); | 128 GrClipStackFrame* back = (GrClipStackFrame*) fStack.back(); |
129 | 129 |
130 back->acquireMask(fContext, clipGenID, desc, bound); | 130 back->acquireMask(fContext, clipGenID, desc, bound); |
131 } | 131 } |
132 | 132 |
133 int getLastMaskWidth() const { | 133 int getLastMaskWidth() const { |
134 | 134 |
135 if (fStack.empty()) { | 135 if (fStack.empty()) { |
136 GrAssert(false); | 136 SkASSERT(false); |
137 return -1; | 137 return -1; |
138 } | 138 } |
139 | 139 |
140 GrClipStackFrame* back = (GrClipStackFrame*) fStack.back(); | 140 GrClipStackFrame* back = (GrClipStackFrame*) fStack.back(); |
141 | 141 |
142 if (NULL == back->fLastMask.texture()) { | 142 if (NULL == back->fLastMask.texture()) { |
143 return -1; | 143 return -1; |
144 } | 144 } |
145 | 145 |
146 return back->fLastMask.texture()->width(); | 146 return back->fLastMask.texture()->width(); |
147 } | 147 } |
148 | 148 |
149 int getLastMaskHeight() const { | 149 int getLastMaskHeight() const { |
150 | 150 |
151 if (fStack.empty()) { | 151 if (fStack.empty()) { |
152 GrAssert(false); | 152 SkASSERT(false); |
153 return -1; | 153 return -1; |
154 } | 154 } |
155 | 155 |
156 GrClipStackFrame* back = (GrClipStackFrame*) fStack.back(); | 156 GrClipStackFrame* back = (GrClipStackFrame*) fStack.back(); |
157 | 157 |
158 if (NULL == back->fLastMask.texture()) { | 158 if (NULL == back->fLastMask.texture()) { |
159 return -1; | 159 return -1; |
160 } | 160 } |
161 | 161 |
162 return back->fLastMask.texture()->height(); | 162 return back->fLastMask.texture()->height(); |
163 } | 163 } |
164 | 164 |
165 void getLastBound(SkIRect* bound) const { | 165 void getLastBound(SkIRect* bound) const { |
166 | 166 |
167 if (fStack.empty()) { | 167 if (fStack.empty()) { |
168 GrAssert(false); | 168 SkASSERT(false); |
169 bound->setEmpty(); | 169 bound->setEmpty(); |
170 return; | 170 return; |
171 } | 171 } |
172 | 172 |
173 GrClipStackFrame* back = (GrClipStackFrame*) fStack.back(); | 173 GrClipStackFrame* back = (GrClipStackFrame*) fStack.back(); |
174 | 174 |
175 *bound = back->fLastBound; | 175 *bound = back->fLastBound; |
176 } | 176 } |
177 | 177 |
178 void setContext(GrContext* context) { | 178 void setContext(GrContext* context) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 SkIRect fLastBound; | 230 SkIRect fLastBound; |
231 }; | 231 }; |
232 | 232 |
233 GrContext* fContext; | 233 GrContext* fContext; |
234 SkDeque fStack; | 234 SkDeque fStack; |
235 | 235 |
236 typedef GrNoncopyable INHERITED; | 236 typedef GrNoncopyable INHERITED; |
237 }; | 237 }; |
238 | 238 |
239 #endif // GrClipMaskCache_DEFINED | 239 #endif // GrClipMaskCache_DEFINED |
OLD | NEW |