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

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

Issue 640773004: Add clip to layer cache (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: clean up Created 6 years, 2 months 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 | « src/gpu/GrLayerCache.h ('k') | src/gpu/GrLayerHoister.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 #include "GrAtlas.h" 8 #include "GrAtlas.h"
9 #include "GrGpu.h" 9 #include "GrGpu.h"
10 #include "GrLayerCache.h" 10 #include "GrLayerCache.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 fAtlas.free(); 122 fAtlas.free();
123 // GrLayerCache always assumes an atlas exists so recreate it. The atlas 123 // GrLayerCache always assumes an atlas exists so recreate it. The atlas
124 // lazily allocates a replacement texture so reallocating a new 124 // lazily allocates a replacement texture so reallocating a new
125 // atlas here won't disrupt a GrContext::abandonContext or freeGpuResources. 125 // atlas here won't disrupt a GrContext::abandonContext or freeGpuResources.
126 // TODO: Make GrLayerCache lazily allocate the atlas manager? 126 // TODO: Make GrLayerCache lazily allocate the atlas manager?
127 this->initAtlas(); 127 this->initAtlas();
128 } 128 }
129 129
130 GrCachedLayer* GrLayerCache::createLayer(uint32_t pictureID, 130 GrCachedLayer* GrLayerCache::createLayer(uint32_t pictureID,
131 int start, int stop, 131 int start, int stop,
132 const SkIRect& bounds,
132 const SkMatrix& ctm, 133 const SkMatrix& ctm,
133 const SkPaint* paint) { 134 const SkPaint* paint) {
134 SkASSERT(pictureID != SK_InvalidGenID && start >= 0 && stop > 0); 135 SkASSERT(pictureID != SK_InvalidGenID && start >= 0 && stop > 0);
135 136
136 GrCachedLayer* layer = SkNEW_ARGS(GrCachedLayer, (pictureID, start, stop, ct m, paint)); 137 GrCachedLayer* layer = SkNEW_ARGS(GrCachedLayer, (pictureID, start, stop, bo unds, ctm, paint));
137 fLayerHash.add(layer); 138 fLayerHash.add(layer);
138 return layer; 139 return layer;
139 } 140 }
140 141
141 GrCachedLayer* GrLayerCache::findLayer(uint32_t pictureID, 142 GrCachedLayer* GrLayerCache::findLayer(uint32_t pictureID,
142 int start, 143 int start,
144 const SkIRect& bounds,
143 const SkMatrix& ctm) { 145 const SkMatrix& ctm) {
144 SkASSERT(pictureID != SK_InvalidGenID && start > 0); 146 SkASSERT(pictureID != SK_InvalidGenID && start > 0);
145 return fLayerHash.find(GrCachedLayer::Key(pictureID, start, ctm)); 147 return fLayerHash.find(GrCachedLayer::Key(pictureID, start, bounds, ctm));
146 } 148 }
147 149
148 GrCachedLayer* GrLayerCache::findLayerOrCreate(uint32_t pictureID, 150 GrCachedLayer* GrLayerCache::findLayerOrCreate(uint32_t pictureID,
149 int start, int stop, 151 int start, int stop,
152 const SkIRect& bounds,
150 const SkMatrix& ctm, 153 const SkMatrix& ctm,
151 const SkPaint* paint) { 154 const SkPaint* paint) {
152 SkASSERT(pictureID != SK_InvalidGenID && start >= 0 && stop > 0); 155 SkASSERT(pictureID != SK_InvalidGenID && start >= 0 && stop > 0);
153 GrCachedLayer* layer = fLayerHash.find(GrCachedLayer::Key(pictureID, start, ctm)); 156 GrCachedLayer* layer = fLayerHash.find(GrCachedLayer::Key(pictureID, start, bounds, ctm));
154 if (NULL == layer) { 157 if (NULL == layer) {
155 layer = this->createLayer(pictureID, start, stop, ctm, paint); 158 layer = this->createLayer(pictureID, start, stop, bounds, ctm, paint);
156 } 159 }
157 160
158 return layer; 161 return layer;
159 } 162 }
160 163
161 bool GrLayerCache::lock(GrCachedLayer* layer, const GrTextureDesc& desc, bool do ntAtlas) { 164 bool GrLayerCache::lock(GrCachedLayer* layer, const GrTextureDesc& desc, bool do ntAtlas) {
162 SkDEBUGCODE(GrAutoValidateLayer avl(fAtlas->getTexture(), layer);) 165 SkDEBUGCODE(GrAutoValidateLayer avl(fAtlas->getTexture(), layer);)
163 166
164 if (layer->locked()) { 167 if (layer->locked()) {
165 // This layer is already locked 168 // This layer is already locked
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 451
449 SkTDynamicHash<GrCachedLayer, GrCachedLayer::Key>::Iter iter(&fLayerHash); 452 SkTDynamicHash<GrCachedLayer, GrCachedLayer::Key>::Iter iter(&fLayerHash);
450 for (; !iter.done(); ++iter) { 453 for (; !iter.done(); ++iter) {
451 GrCachedLayer* layer = &(*iter); 454 GrCachedLayer* layer = &(*iter);
452 455
453 if (layer->isAtlased() || !layer->texture()) { 456 if (layer->isAtlased() || !layer->texture()) {
454 continue; 457 continue;
455 } 458 }
456 459
457 SkString fileName(dirName); 460 SkString fileName(dirName);
458 fileName.append("\\"); 461 fileName.appendf("\\%d-%d.png", layer->fKey.pictureID(), layer->fKey.sta rt());
459 fileName.appendU32(layer->fKey.pictureID());
460 fileName.append("-");
461 fileName.appendU32(layer->fKey.start());
462 fileName.append(".png");
463 462
464 layer->texture()->surfacePriv().savePixels(fileName.c_str()); 463 layer->texture()->surfacePriv().savePixels(fileName.c_str());
465 } 464 }
466 } 465 }
467 #endif 466 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrLayerCache.h ('k') | src/gpu/GrLayerHoister.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698