| OLD | NEW |
| 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 "GrLayerCache.h" | 8 #include "GrLayerCache.h" |
| 9 #include "GrLayerHoister.h" | 9 #include "GrLayerHoister.h" |
| 10 #include "GrRecordReplaceDraw.h" | 10 #include "GrRecordReplaceDraw.h" |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 totMat.postTranslate(-SkIntToScalar(filterOffset.fX), -SkIntToScalar(filterO
ffset.fY)); | 293 totMat.postTranslate(-SkIntToScalar(filterOffset.fX), -SkIntToScalar(filterO
ffset.fY)); |
| 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<SkImageFilter::Cache> cache(SkImageFilter::Cache::Create(kDefau
ltCacheSize)); | 300 SkAutoTUnref<SkImageFilter::Cache> cache(SkImageFilter::Cache::Create(kDefau
ltCacheSize)); |
| 301 SkImageFilter::Context filterContext(totMat, clipBounds, cache); | 301 SkImageFilter::Context filterContext(totMat, clipBounds, cache); |
| 302 | 302 |
| 303 SkImageFilter::DeviceProxy proxy(device); | |
| 304 | |
| 305 // 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? |
| 306 const SkIRect subset = SkIRect::MakeWH(layer->texture()->width(), layer->tex
ture()->height()); | 304 const SkIRect subset = SkIRect::MakeWH(layer->texture()->width(), layer->tex
ture()->height()); |
| 307 sk_sp<SkSpecialImage> img(SkSpecialImage::MakeFromGpu(&proxy, subset, | 305 sk_sp<SkSpecialImage> img(SkSpecialImage::MakeFromGpu(subset, |
| 308 kNeedNewImageUniqueID_
SpecialImage, | 306 kNeedNewImageUniqueID_
SpecialImage, |
| 309 layer->texture(), | 307 layer->texture(), |
| 310 &device->surfaceProps(
))); | 308 &device->surfaceProps(
))); |
| 311 | 309 |
| 312 SkIPoint offset = SkIPoint::Make(0, 0); | 310 SkIPoint offset = SkIPoint::Make(0, 0); |
| 313 sk_sp<SkSpecialImage> result(layer->filter()->filterImage(img.get(), | 311 sk_sp<SkSpecialImage> result(layer->filter()->filterImage(img.get(), |
| 314 filterContext, | 312 filterContext, |
| 315 &offset)); | 313 &offset)); |
| 316 if (!result) { | 314 if (!result) { |
| 317 // Filtering failed. Press on with the unfiltered version. | 315 // Filtering failed. Press on with the unfiltered version. |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 #if !GR_CACHE_HOISTED_LAYERS | 388 #if !GR_CACHE_HOISTED_LAYERS |
| 391 | 389 |
| 392 // This code completely clears out the atlas. It is required when | 390 // This code completely clears out the atlas. It is required when |
| 393 // 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 |
| 394 // free floating layers | 392 // free floating layers |
| 395 layerCache->purgeAll(); | 393 layerCache->purgeAll(); |
| 396 #endif | 394 #endif |
| 397 | 395 |
| 398 layerCache->end(); | 396 layerCache->end(); |
| 399 } | 397 } |
| OLD | NEW |