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

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

Issue 1947593002: Minor refactor of GrLayerHoister (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update to ToT Created 4 years, 7 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 | « no previous file | tests/GpuLayerCacheTest.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 "GrContext.h" 8 #include "GrContext.h"
9 #include "GrLayerCache.h" 9 #include "GrLayerCache.h"
10 #include "GrLayerHoister.h" 10 #include "GrLayerHoister.h"
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 prepare_for_hoisting(layerCache, topLevelPicture, initialMat, info, srcI R, dstIR, 225 prepare_for_hoisting(layerCache, topLevelPicture, initialMat, info, srcI R, dstIR,
226 needRendering, recycled, false, numSamples); 226 needRendering, recycled, false, numSamples);
227 } 227 }
228 } 228 }
229 229
230 void GrLayerHoister::DrawLayersToAtlas(GrContext* context, 230 void GrLayerHoister::DrawLayersToAtlas(GrContext* context,
231 const SkTDArray<GrHoistedLayer>& atlased) { 231 const SkTDArray<GrHoistedLayer>& atlased) {
232 if (atlased.count() > 0) { 232 if (atlased.count() > 0) {
233 // All the atlased layers are rendered into the same GrTexture 233 // All the atlased layers are rendered into the same GrTexture
234 SkSurfaceProps props(0, kUnknown_SkPixelGeometry); 234 SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
235 auto surface(SkSurface::MakeRenderTargetDirect( 235 sk_sp<SkSurface> surface(SkSurface::MakeRenderTargetDirect(
236 atlased[0].fLayer->texture()->asRenderTa rget(), &props)); 236 atlased[0].fLayer->texture()->asRenderTa rget(), &props));
237 237
238 SkCanvas* atlasCanvas = surface->getCanvas(); 238 SkCanvas* atlasCanvas = surface->getCanvas();
239 239
240 for (int i = 0; i < atlased.count(); ++i) { 240 for (int i = 0; i < atlased.count(); ++i) {
241 const GrCachedLayer* layer = atlased[i].fLayer; 241 const GrCachedLayer* layer = atlased[i].fLayer;
242 const SkBigPicture* pict = atlased[i].fPicture->asSkBigPicture(); 242 const SkBigPicture* pict = atlased[i].fPicture->asSkBigPicture();
243 if (!pict) { 243 if (!pict) {
244 // TODO: can we assume / assert this? 244 // TODO: can we assume / assert this?
245 continue; 245 continue;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 294
295 SkASSERT(0 == layer->rect().fLeft && 0 == layer->rect().fTop); 295 SkASSERT(0 == layer->rect().fLeft && 0 == layer->rect().fTop);
296 const SkIRect& clipBounds = layer->rect(); 296 const SkIRect& clipBounds = layer->rect();
297 297
298 // This cache is transient, and is freed (along with all its contained 298 // This cache is transient, and is freed (along with all its contained
299 // textures) when it goes out of scope. 299 // textures) when it goes out of scope.
300 SkAutoTUnref<SkImageFilterCache> cache(SkImageFilterCache::Create(kDefaultCa cheSize)); 300 SkAutoTUnref<SkImageFilterCache> cache(SkImageFilterCache::Create(kDefaultCa cheSize));
301 SkImageFilter::Context filterContext(totMat, clipBounds, cache); 301 SkImageFilter::Context filterContext(totMat, clipBounds, cache);
302 302
303 // TODO: should the layer hoister store stand alone layers as SkSpecialImage s internally? 303 // TODO: should the layer hoister store stand alone layers as SkSpecialImage s internally?
304 const SkIRect subset = SkIRect::MakeWH(layer->texture()->width(), layer->tex ture()->height()); 304 SkASSERT(layer->rect().width() == layer->texture()->width() &&
305 layer->rect().height() == layer->texture()->height());
306 const SkIRect subset = SkIRect::MakeWH(layer->rect().width(), layer->rect(). height());
305 sk_sp<SkSpecialImage> img(SkSpecialImage::MakeFromGpu(subset, 307 sk_sp<SkSpecialImage> img(SkSpecialImage::MakeFromGpu(subset,
306 kNeedNewImageUniqueID_ SpecialImage, 308 kNeedNewImageUniqueID_ SpecialImage,
307 sk_ref_sp(layer->textu re()), 309 sk_ref_sp(layer->textu re()),
308 props)); 310 props));
309 311
310 SkIPoint offset = SkIPoint::Make(0, 0); 312 SkIPoint offset = SkIPoint::Make(0, 0);
311 sk_sp<SkSpecialImage> result(layer->filter()->filterImage(img.get(), 313 sk_sp<SkSpecialImage> result(layer->filter()->filterImage(img.get(),
312 filterContext, 314 filterContext,
313 &offset)); 315 &offset));
314 if (!result) { 316 if (!result) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 #if !GR_CACHE_HOISTED_LAYERS 388 #if !GR_CACHE_HOISTED_LAYERS
387 389
388 // This code completely clears out the atlas. It is required when 390 // This code completely clears out the atlas. It is required when
389 // caching is disabled so the atlas doesn't fill up and force more 391 // caching is disabled so the atlas doesn't fill up and force more
390 // free floating layers 392 // free floating layers
391 layerCache->purgeAll(); 393 layerCache->purgeAll();
392 #endif 394 #endif
393 395
394 layerCache->end(); 396 layerCache->end();
395 } 397 }
OLDNEW
« no previous file with comments | « no previous file | tests/GpuLayerCacheTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698