OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkGpuDevice.h" | 8 #include "SkGpuDevice.h" |
9 | 9 |
10 #include "GrBlurUtils.h" | 10 #include "GrBlurUtils.h" |
(...skipping 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1156 bool alphaOnly = kAlpha_8_SkColorType == bitmap.colorType(); | 1156 bool alphaOnly = kAlpha_8_SkColorType == bitmap.colorType(); |
1157 | 1157 |
1158 SkImageFilter* filter = paint.getImageFilter(); | 1158 SkImageFilter* filter = paint.getImageFilter(); |
1159 // This bitmap will own the filtered result as a texture. | 1159 // This bitmap will own the filtered result as a texture. |
1160 SkBitmap filteredBitmap; | 1160 SkBitmap filteredBitmap; |
1161 | 1161 |
1162 if (filter) { | 1162 if (filter) { |
1163 SkIPoint offset = SkIPoint::Make(0, 0); | 1163 SkIPoint offset = SkIPoint::Make(0, 0); |
1164 SkMatrix matrix(*draw.fMatrix); | 1164 SkMatrix matrix(*draw.fMatrix); |
1165 matrix.postTranslate(SkIntToScalar(-left), SkIntToScalar(-top)); | 1165 matrix.postTranslate(SkIntToScalar(-left), SkIntToScalar(-top)); |
1166 SkIRect clipBounds = SkIRect::MakeWH(bitmap.width(), bitmap.height()); | 1166 SkIRect clipBounds = draw.fClip->getBounds(); |
reed1
2015/12/07 20:26:20
option: could use (your pref)
SkIRect clipBounds
Stephen White
2015/12/07 21:34:23
Good idea! Done.
| |
1167 clipBounds.offset(-left, -top); | |
1167 SkAutoTUnref<SkImageFilter::Cache> cache(getImageFilterCache()); | 1168 SkAutoTUnref<SkImageFilter::Cache> cache(getImageFilterCache()); |
1168 // This cache is transient, and is freed (along with all its contained | 1169 // This cache is transient, and is freed (along with all its contained |
1169 // textures) when it goes out of scope. | 1170 // textures) when it goes out of scope. |
1170 SkImageFilter::Context ctx(matrix, clipBounds, cache, SkImageFilter::kAp prox_SizeConstraint); | 1171 SkImageFilter::Context ctx(matrix, clipBounds, cache, SkImageFilter::kAp prox_SizeConstraint); |
1171 if (this->filterTexture(fContext, texture, w, h, filter, ctx, &filteredB itmap, | 1172 if (this->filterTexture(fContext, texture, w, h, filter, ctx, &filteredB itmap, |
1172 &offset)) { | 1173 &offset)) { |
1173 texture = (GrTexture*) filteredBitmap.getTexture(); | 1174 texture = (GrTexture*) filteredBitmap.getTexture(); |
1174 w = filteredBitmap.width(); | 1175 w = filteredBitmap.width(); |
1175 h = filteredBitmap.height(); | 1176 h = filteredBitmap.height(); |
1176 left += offset.x(); | 1177 left += offset.x(); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1319 int h = ii.height(); | 1320 int h = ii.height(); |
1320 | 1321 |
1321 SkImageFilter* filter = paint.getImageFilter(); | 1322 SkImageFilter* filter = paint.getImageFilter(); |
1322 // This bitmap will own the filtered result as a texture. | 1323 // This bitmap will own the filtered result as a texture. |
1323 SkBitmap filteredBitmap; | 1324 SkBitmap filteredBitmap; |
1324 | 1325 |
1325 if (filter) { | 1326 if (filter) { |
1326 SkIPoint offset = SkIPoint::Make(0, 0); | 1327 SkIPoint offset = SkIPoint::Make(0, 0); |
1327 SkMatrix matrix(*draw.fMatrix); | 1328 SkMatrix matrix(*draw.fMatrix); |
1328 matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y)); | 1329 matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y)); |
1329 SkIRect clipBounds = SkIRect::MakeWH(devTex->width(), devTex->height()); | 1330 SkIRect clipBounds = draw.fClip->getBounds(); |
1331 clipBounds.offset(-x, -y); | |
1330 // This cache is transient, and is freed (along with all its contained | 1332 // This cache is transient, and is freed (along with all its contained |
1331 // textures) when it goes out of scope. | 1333 // textures) when it goes out of scope. |
1332 SkAutoTUnref<SkImageFilter::Cache> cache(getImageFilterCache()); | 1334 SkAutoTUnref<SkImageFilter::Cache> cache(getImageFilterCache()); |
1333 SkImageFilter::Context ctx(matrix, clipBounds, cache, SkImageFilter::kAp prox_SizeConstraint); | 1335 SkImageFilter::Context ctx(matrix, clipBounds, cache, SkImageFilter::kAp prox_SizeConstraint); |
1334 if (this->filterTexture(fContext, devTex, device->width(), device->heigh t(), | 1336 if (this->filterTexture(fContext, devTex, device->width(), device->heigh t(), |
1335 filter, ctx, &filteredBitmap, &offset)) { | 1337 filter, ctx, &filteredBitmap, &offset)) { |
1336 devTex = filteredBitmap.getTexture(); | 1338 devTex = filteredBitmap.getTexture(); |
1337 w = filteredBitmap.width(); | 1339 w = filteredBitmap.width(); |
1338 h = filteredBitmap.height(); | 1340 h = filteredBitmap.height(); |
1339 x += offset.fX; | 1341 x += offset.fX; |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1868 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); | 1870 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); |
1869 } | 1871 } |
1870 | 1872 |
1871 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { | 1873 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { |
1872 // We always return a transient cache, so it is freed after each | 1874 // We always return a transient cache, so it is freed after each |
1873 // filter traversal. | 1875 // filter traversal. |
1874 return SkGpuDevice::NewImageFilterCache(); | 1876 return SkGpuDevice::NewImageFilterCache(); |
1875 } | 1877 } |
1876 | 1878 |
1877 #endif | 1879 #endif |
OLD | NEW |