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 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1157 bool alphaOnly = kAlpha_8_SkColorType == bitmap.colorType(); | 1157 bool alphaOnly = kAlpha_8_SkColorType == bitmap.colorType(); |
1158 | 1158 |
1159 SkImageFilter* filter = paint.getImageFilter(); | 1159 SkImageFilter* filter = paint.getImageFilter(); |
1160 // This bitmap will own the filtered result as a texture. | 1160 // This bitmap will own the filtered result as a texture. |
1161 SkBitmap filteredBitmap; | 1161 SkBitmap filteredBitmap; |
1162 | 1162 |
1163 if (filter) { | 1163 if (filter) { |
1164 SkIPoint offset = SkIPoint::Make(0, 0); | 1164 SkIPoint offset = SkIPoint::Make(0, 0); |
1165 SkMatrix matrix(*draw.fMatrix); | 1165 SkMatrix matrix(*draw.fMatrix); |
1166 matrix.postTranslate(SkIntToScalar(-left), SkIntToScalar(-top)); | 1166 matrix.postTranslate(SkIntToScalar(-left), SkIntToScalar(-top)); |
| 1167 #ifdef SK_SUPPORT_SRC_BOUNDS_BLOAT_FOR_IMAGEFILTERS |
1167 SkIRect clipBounds = SkIRect::MakeWH(bitmap.width(), bitmap.height()); | 1168 SkIRect clipBounds = SkIRect::MakeWH(bitmap.width(), bitmap.height()); |
| 1169 #else |
| 1170 SkIRect clipBounds = draw.fClip->getBounds().makeOffset(-left, -top); |
| 1171 #endif |
1168 SkAutoTUnref<SkImageFilter::Cache> cache(getImageFilterCache()); | 1172 SkAutoTUnref<SkImageFilter::Cache> cache(getImageFilterCache()); |
1169 // This cache is transient, and is freed (along with all its contained | 1173 // This cache is transient, and is freed (along with all its contained |
1170 // textures) when it goes out of scope. | 1174 // textures) when it goes out of scope. |
1171 SkImageFilter::Context ctx(matrix, clipBounds, cache, SkImageFilter::kAp
prox_SizeConstraint); | 1175 SkImageFilter::Context ctx(matrix, clipBounds, cache, SkImageFilter::kAp
prox_SizeConstraint); |
1172 if (this->filterTexture(fContext, texture, w, h, filter, ctx, &filteredB
itmap, | 1176 if (this->filterTexture(fContext, texture, w, h, filter, ctx, &filteredB
itmap, |
1173 &offset)) { | 1177 &offset)) { |
1174 texture = (GrTexture*) filteredBitmap.getTexture(); | 1178 texture = (GrTexture*) filteredBitmap.getTexture(); |
1175 w = filteredBitmap.width(); | 1179 w = filteredBitmap.width(); |
1176 h = filteredBitmap.height(); | 1180 h = filteredBitmap.height(); |
1177 left += offset.x(); | 1181 left += offset.x(); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1320 int h = ii.height(); | 1324 int h = ii.height(); |
1321 | 1325 |
1322 SkImageFilter* filter = paint.getImageFilter(); | 1326 SkImageFilter* filter = paint.getImageFilter(); |
1323 // This bitmap will own the filtered result as a texture. | 1327 // This bitmap will own the filtered result as a texture. |
1324 SkBitmap filteredBitmap; | 1328 SkBitmap filteredBitmap; |
1325 | 1329 |
1326 if (filter) { | 1330 if (filter) { |
1327 SkIPoint offset = SkIPoint::Make(0, 0); | 1331 SkIPoint offset = SkIPoint::Make(0, 0); |
1328 SkMatrix matrix(*draw.fMatrix); | 1332 SkMatrix matrix(*draw.fMatrix); |
1329 matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y)); | 1333 matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y)); |
| 1334 #ifdef SK_SUPPORT_SRC_BOUNDS_BLOAT_FOR_IMAGEFILTERS |
1330 SkIRect clipBounds = SkIRect::MakeWH(devTex->width(), devTex->height()); | 1335 SkIRect clipBounds = SkIRect::MakeWH(devTex->width(), devTex->height()); |
| 1336 #else |
| 1337 SkIRect clipBounds = draw.fClip->getBounds().makeOffset(-x, -y); |
| 1338 #endif |
1331 // This cache is transient, and is freed (along with all its contained | 1339 // This cache is transient, and is freed (along with all its contained |
1332 // textures) when it goes out of scope. | 1340 // textures) when it goes out of scope. |
1333 SkAutoTUnref<SkImageFilter::Cache> cache(getImageFilterCache()); | 1341 SkAutoTUnref<SkImageFilter::Cache> cache(getImageFilterCache()); |
1334 SkImageFilter::Context ctx(matrix, clipBounds, cache, SkImageFilter::kAp
prox_SizeConstraint); | 1342 SkImageFilter::Context ctx(matrix, clipBounds, cache, SkImageFilter::kAp
prox_SizeConstraint); |
1335 if (this->filterTexture(fContext, devTex, device->width(), device->heigh
t(), | 1343 if (this->filterTexture(fContext, devTex, device->width(), device->heigh
t(), |
1336 filter, ctx, &filteredBitmap, &offset)) { | 1344 filter, ctx, &filteredBitmap, &offset)) { |
1337 devTex = filteredBitmap.getTexture(); | 1345 devTex = filteredBitmap.getTexture(); |
1338 w = filteredBitmap.width(); | 1346 w = filteredBitmap.width(); |
1339 h = filteredBitmap.height(); | 1347 h = filteredBitmap.height(); |
1340 x += offset.fX; | 1348 x += offset.fX; |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1877 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); | 1885 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); |
1878 } | 1886 } |
1879 | 1887 |
1880 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { | 1888 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { |
1881 // We always return a transient cache, so it is freed after each | 1889 // We always return a transient cache, so it is freed after each |
1882 // filter traversal. | 1890 // filter traversal. |
1883 return SkGpuDevice::NewImageFilterCache(); | 1891 return SkGpuDevice::NewImageFilterCache(); |
1884 } | 1892 } |
1885 | 1893 |
1886 #endif | 1894 #endif |
OLD | NEW |