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

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

Issue 1905383002: Retract SkDevice a bit more (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 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/GrLayerHoister.h ('k') | src/gpu/text/GrStencilAndCoverTextContext.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 "GrLayerCache.h" 9 #include "GrLayerCache.h"
9 #include "GrLayerHoister.h" 10 #include "GrLayerHoister.h"
10 #include "GrRecordReplaceDraw.h" 11 #include "GrRecordReplaceDraw.h"
11 12
12 #include "SkBigPicture.h" 13 #include "SkBigPicture.h"
13 #include "SkCanvas.h" 14 #include "SkCanvas.h"
14 #include "SkGpuDevice.h"
15 #include "SkLayerInfo.h" 15 #include "SkLayerInfo.h"
16 #include "SkRecordDraw.h" 16 #include "SkRecordDraw.h"
17 #include "SkSpecialImage.h" 17 #include "SkSpecialImage.h"
18 #include "SkSurface.h" 18 #include "SkSurface.h"
19 #include "SkSurface_Gpu.h"
20 19
21 // Create the layer information for the hoisted layer and secure the 20 // Create the layer information for the hoisted layer and secure the
22 // required texture/render target resources. 21 // required texture/render target resources.
23 static void prepare_for_hoisting(GrLayerCache* layerCache, 22 static void prepare_for_hoisting(GrLayerCache* layerCache,
24 const SkPicture* topLevelPicture, 23 const SkPicture* topLevelPicture,
25 const SkMatrix& initialMat, 24 const SkMatrix& initialMat,
26 const SkLayerInfo::BlockInfo& info, 25 const SkLayerInfo::BlockInfo& info,
27 const SkIRect& srcIR, 26 const SkIRect& srcIR,
28 const SkIRect& dstIR, 27 const SkIRect& dstIR,
29 SkTDArray<GrHoistedLayer>* needRendering, 28 SkTDArray<GrHoistedLayer>* needRendering,
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 270
272 pict->partialPlayback(atlasCanvas, layer->start() + 1, layer->stop() , initialCTM); 271 pict->partialPlayback(atlasCanvas, layer->start() + 1, layer->stop() , initialCTM);
273 atlasCanvas->restore(); 272 atlasCanvas->restore();
274 } 273 }
275 274
276 atlasCanvas->flush(); 275 atlasCanvas->flush();
277 } 276 }
278 } 277 }
279 278
280 void GrLayerHoister::FilterLayer(GrContext* context, 279 void GrLayerHoister::FilterLayer(GrContext* context,
281 SkGpuDevice* device, 280 const SkSurfaceProps* props,
282 const GrHoistedLayer& info) { 281 const GrHoistedLayer& info) {
283 GrCachedLayer* layer = info.fLayer; 282 GrCachedLayer* layer = info.fLayer;
284 283
285 SkASSERT(layer->filter()); 284 SkASSERT(layer->filter());
286 285
287 static const int kDefaultCacheSize = 32 * 1024 * 1024; 286 static const int kDefaultCacheSize = 32 * 1024 * 1024;
288 287
289 const SkIPoint filterOffset = SkIPoint::Make(layer->srcIR().fLeft, layer->sr cIR().fTop); 288 const SkIPoint filterOffset = SkIPoint::Make(layer->srcIR().fLeft, layer->sr cIR().fTop);
290 289
291 SkMatrix totMat(info.fPreMat); 290 SkMatrix totMat(info.fPreMat);
292 totMat.preConcat(info.fLocalMat); 291 totMat.preConcat(info.fLocalMat);
293 totMat.postTranslate(-SkIntToScalar(filterOffset.fX), -SkIntToScalar(filterO ffset.fY)); 292 totMat.postTranslate(-SkIntToScalar(filterOffset.fX), -SkIntToScalar(filterO ffset.fY));
294 293
295 SkASSERT(0 == layer->rect().fLeft && 0 == layer->rect().fTop); 294 SkASSERT(0 == layer->rect().fLeft && 0 == layer->rect().fTop);
296 const SkIRect& clipBounds = layer->rect(); 295 const SkIRect& clipBounds = layer->rect();
297 296
298 // This cache is transient, and is freed (along with all its contained 297 // This cache is transient, and is freed (along with all its contained
299 // textures) when it goes out of scope. 298 // textures) when it goes out of scope.
300 SkAutoTUnref<SkImageFilter::Cache> cache(SkImageFilter::Cache::Create(kDefau ltCacheSize)); 299 SkAutoTUnref<SkImageFilter::Cache> cache(SkImageFilter::Cache::Create(kDefau ltCacheSize));
301 SkImageFilter::Context filterContext(totMat, clipBounds, cache); 300 SkImageFilter::Context filterContext(totMat, clipBounds, cache);
302 301
303 // TODO: should the layer hoister store stand alone layers as SkSpecialImage s internally? 302 // 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()); 303 const SkIRect subset = SkIRect::MakeWH(layer->texture()->width(), layer->tex ture()->height());
305 sk_sp<SkSpecialImage> img(SkSpecialImage::MakeFromGpu(subset, 304 sk_sp<SkSpecialImage> img(SkSpecialImage::MakeFromGpu(subset,
306 kNeedNewImageUniqueID_ SpecialImage, 305 kNeedNewImageUniqueID_ SpecialImage,
307 layer->texture(), 306 layer->texture(),
308 &device->surfaceProps( ))); 307 props));
309 308
310 SkIPoint offset = SkIPoint::Make(0, 0); 309 SkIPoint offset = SkIPoint::Make(0, 0);
311 sk_sp<SkSpecialImage> result(layer->filter()->filterImage(img.get(), 310 sk_sp<SkSpecialImage> result(layer->filter()->filterImage(img.get(),
312 filterContext, 311 filterContext,
313 &offset)); 312 &offset));
314 if (!result) { 313 if (!result) {
315 // Filtering failed. Press on with the unfiltered version. 314 // Filtering failed. Press on with the unfiltered version.
316 return; 315 return;
317 } 316 }
318 317
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 initialCTM.setTranslate(SkIntToScalar(-offset.fX), SkIntToScalar(-offset .fY)); 350 initialCTM.setTranslate(SkIntToScalar(-offset.fX), SkIntToScalar(-offset .fY));
352 initialCTM.preConcat(layers[i].fPreMat); 351 initialCTM.preConcat(layers[i].fPreMat);
353 352
354 layerCanvas->setMatrix(initialCTM); 353 layerCanvas->setMatrix(initialCTM);
355 layerCanvas->concat(layers[i].fLocalMat); 354 layerCanvas->concat(layers[i].fLocalMat);
356 355
357 pict->partialPlayback(layerCanvas, layer->start()+1, layer->stop(), init ialCTM); 356 pict->partialPlayback(layerCanvas, layer->start()+1, layer->stop(), init ialCTM);
358 layerCanvas->flush(); 357 layerCanvas->flush();
359 358
360 if (layer->filter()) { 359 if (layer->filter()) {
361 SkSurface_Gpu* gpuSurf = static_cast<SkSurface_Gpu*>(surface.get()); 360 FilterLayer(context, &surface->props(), layers[i]);
362
363 FilterLayer(context, gpuSurf->getDevice(), layers[i]);
364 } 361 }
365 } 362 }
366 } 363 }
367 364
368 void GrLayerHoister::UnlockLayers(GrContext* context, 365 void GrLayerHoister::UnlockLayers(GrContext* context,
369 const SkTDArray<GrHoistedLayer>& layers) { 366 const SkTDArray<GrHoistedLayer>& layers) {
370 GrLayerCache* layerCache = context->getLayerCache(); 367 GrLayerCache* layerCache = context->getLayerCache();
371 368
372 for (int i = 0; i < layers.count(); ++i) { 369 for (int i = 0; i < layers.count(); ++i) {
373 layerCache->removeUse(layers[i].fLayer); 370 layerCache->removeUse(layers[i].fLayer);
(...skipping 14 matching lines...) Expand all
388 #if !GR_CACHE_HOISTED_LAYERS 385 #if !GR_CACHE_HOISTED_LAYERS
389 386
390 // This code completely clears out the atlas. It is required when 387 // This code completely clears out the atlas. It is required when
391 // caching is disabled so the atlas doesn't fill up and force more 388 // caching is disabled so the atlas doesn't fill up and force more
392 // free floating layers 389 // free floating layers
393 layerCache->purgeAll(); 390 layerCache->purgeAll();
394 #endif 391 #endif
395 392
396 layerCache->end(); 393 layerCache->end();
397 } 394 }
OLDNEW
« no previous file with comments | « src/gpu/GrLayerHoister.h ('k') | src/gpu/text/GrStencilAndCoverTextContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698