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

Side by Side Diff: src/gpu/GrLayerCache.h

Issue 792923002: Apply the layer's image filter to the hoisted image (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix cast Created 6 years 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 | « gyp/gpu.gypi ('k') | src/gpu/GrLayerHoister.h » ('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 GrLayerCache_DEFINED 8 #ifndef GrLayerCache_DEFINED
9 #define GrLayerCache_DEFINED 9 #define GrLayerCache_DEFINED
10 10
11 #include "GrAtlas.h" 11 #include "GrAtlas.h"
12 #include "GrRect.h" 12 #include "GrRect.h"
13 13
14 #include "SkChecksum.h" 14 #include "SkChecksum.h"
15 #include "SkImageFilter.h"
15 #include "SkMessageBus.h" 16 #include "SkMessageBus.h"
16 #include "SkPicture.h" 17 #include "SkPicture.h"
17 #include "SkTDynamicHash.h" 18 #include "SkTDynamicHash.h"
18 19
19 // Set to 0 to disable caching of hoisted layers 20 // Set to 0 to disable caching of hoisted layers
20 #define GR_CACHE_HOISTED_LAYERS 0 21 #define GR_CACHE_HOISTED_LAYERS 0
21 22
22 // GrPictureInfo stores the atlas plots used by a single picture. A single 23 // GrPictureInfo stores the atlas plots used by a single picture. A single
23 // plot may be used to store layers from multiple pictures. 24 // plot may be used to store layers from multiple pictures.
24 struct GrPictureInfo { 25 struct GrPictureInfo {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 // GrCachedLayer proper 145 // GrCachedLayer proper
145 GrCachedLayer(uint32_t pictureID, unsigned start, unsigned stop, 146 GrCachedLayer(uint32_t pictureID, unsigned start, unsigned stop,
146 const SkIRect& bounds, const SkMatrix& ctm, 147 const SkIRect& bounds, const SkMatrix& ctm,
147 const unsigned* key, int keySize, 148 const unsigned* key, int keySize,
148 const SkPaint* paint) 149 const SkPaint* paint)
149 : fKey(pictureID, ctm, key, keySize, true) 150 : fKey(pictureID, ctm, key, keySize, true)
150 , fStart(start) 151 , fStart(start)
151 , fStop(stop) 152 , fStop(stop)
152 , fBounds(bounds) 153 , fBounds(bounds)
153 , fPaint(paint ? SkNEW_ARGS(SkPaint, (*paint)) : NULL) 154 , fPaint(paint ? SkNEW_ARGS(SkPaint, (*paint)) : NULL)
155 , fFilter(NULL)
154 , fTexture(NULL) 156 , fTexture(NULL)
155 , fRect(SkIRect::MakeEmpty()) 157 , fRect(SkIRect::MakeEmpty())
156 , fPlot(NULL) 158 , fPlot(NULL)
157 , fUses(0) 159 , fUses(0)
158 , fLocked(false) { 160 , fLocked(false) {
159 SkASSERT(SK_InvalidGenID != pictureID); 161 SkASSERT(SK_InvalidGenID != pictureID);
162
163 if (fPaint) {
164 fFilter = SkSafeRef(fPaint->getImageFilter());
165 fPaint->setImageFilter(NULL);
166 }
160 } 167 }
161 168
162 ~GrCachedLayer() { 169 ~GrCachedLayer() {
163 SkSafeUnref(fTexture); 170 SkSafeUnref(fTexture);
171 SkSafeUnref(fFilter);
164 SkDELETE(fPaint); 172 SkDELETE(fPaint);
165 } 173 }
166 174
167 uint32_t pictureID() const { return fKey.pictureID(); } 175 uint32_t pictureID() const { return fKey.pictureID(); }
168 // TODO: remove these when GrCachedLayer & ReplacementInfo fuse 176 // TODO: remove these when GrCachedLayer & ReplacementInfo fuse
169 const unsigned* key() const { return fKey.key(); } 177 const unsigned* key() const { return fKey.key(); }
170 int keySize() const { return fKey.keySize(); } 178 int keySize() const { return fKey.keySize(); }
171 179
172 unsigned start() const { return fStart; } 180 unsigned start() const { return fStart; }
173 // TODO: make bound debug only 181 // TODO: make bound debug only
174 const SkIRect& bound() const { return fBounds; } 182 const SkIRect& bound() const { return fBounds; }
175 unsigned stop() const { return fStop; } 183 unsigned stop() const { return fStop; }
176 void setTexture(GrTexture* texture, const SkIRect& rect) { 184 void setTexture(GrTexture* texture, const SkIRect& rect) {
177 SkRefCnt_SafeAssign(fTexture, texture); 185 SkRefCnt_SafeAssign(fTexture, texture);
178 fRect = rect; 186 fRect = rect;
179 } 187 }
180 GrTexture* texture() { return fTexture; } 188 GrTexture* texture() { return fTexture; }
181 const SkPaint* paint() const { return fPaint; } 189 const SkPaint* paint() const { return fPaint; }
190 const SkImageFilter* filter() const { return fFilter; }
182 const SkIRect& rect() const { return fRect; } 191 const SkIRect& rect() const { return fRect; }
183 192
184 void setPlot(GrPlot* plot) { 193 void setPlot(GrPlot* plot) {
185 SkASSERT(NULL == plot || NULL == fPlot); 194 SkASSERT(NULL == plot || NULL == fPlot);
186 fPlot = plot; 195 fPlot = plot;
187 } 196 }
188 GrPlot* plot() { return fPlot; } 197 GrPlot* plot() { return fPlot; }
189 198
190 bool isAtlased() const { return SkToBool(fPlot); } 199 bool isAtlased() const { return SkToBool(fPlot); }
191 200
192 void setLocked(bool locked) { fLocked = locked; } 201 void setLocked(bool locked) { fLocked = locked; }
193 bool locked() const { return fLocked; } 202 bool locked() const { return fLocked; }
194 203
195 SkDEBUGCODE(const GrPlot* plot() const { return fPlot; }) 204 SkDEBUGCODE(const GrPlot* plot() const { return fPlot; })
196 SkDEBUGCODE(void validate(const GrTexture* backingTexture) const;) 205 SkDEBUGCODE(void validate(const GrTexture* backingTexture) const;)
197 206
198 private: 207 private:
199 const Key fKey; 208 const Key fKey;
200 209
201 // The "saveLayer" operation index of the cached layer 210 // The "saveLayer" operation index of the cached layer
202 const unsigned fStart; 211 const unsigned fStart;
203 // The final "restore" operation index of the cached layer 212 // The final "restore" operation index of the cached layer
204 const unsigned fStop; 213 const unsigned fStop;
205 214
206 const SkIRect fBounds; 215 const SkIRect fBounds;
207 216
208 // The paint used when dropping the layer down into the owning canvas. 217 // The paint used when dropping the layer down into the owning canvas.
209 // Can be NULL. This class makes a copy for itself. 218 // Can be NULL. This class makes a copy for itself.
210 const SkPaint* fPaint; 219 SkPaint* fPaint;
220
221 // The imagefilter that needs to be applied to the layer prior to it being
222 // composited with the rest of the scene.
223 const SkImageFilter* fFilter;
211 224
212 // fTexture is a ref on the atlasing texture for atlased layers and a 225 // fTexture is a ref on the atlasing texture for atlased layers and a
213 // ref on a GrTexture for non-atlased textures. 226 // ref on a GrTexture for non-atlased textures.
214 GrTexture* fTexture; 227 GrTexture* fTexture;
215 228
216 // For both atlased and non-atlased layers 'fRect' contains the bound of 229 // For both atlased and non-atlased layers 'fRect' contains the bound of
217 // the layer in whichever texture it resides. It is empty when 'fTexture' 230 // the layer in whichever texture it resides. It is empty when 'fTexture'
218 // is NULL. 231 // is NULL.
219 SkIRect fRect; 232 SkIRect fRect;
220 233
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 SkASSERT(fPlotLocks[plotIdx] > 0); 378 SkASSERT(fPlotLocks[plotIdx] > 0);
366 --fPlotLocks[plotIdx]; 379 --fPlotLocks[plotIdx];
367 } 380 }
368 381
369 // for testing 382 // for testing
370 friend class TestingAccess; 383 friend class TestingAccess;
371 int numLayers() const { return fLayerHash.count(); } 384 int numLayers() const { return fLayerHash.count(); }
372 }; 385 };
373 386
374 #endif 387 #endif
OLDNEW
« no previous file with comments | « gyp/gpu.gypi ('k') | src/gpu/GrLayerHoister.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698