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 1415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1426 SkBitmap filteredBitmap; | 1426 SkBitmap filteredBitmap; |
1427 | 1427 |
1428 if (filter) { | 1428 if (filter) { |
1429 SkIPoint offset = SkIPoint::Make(0, 0); | 1429 SkIPoint offset = SkIPoint::Make(0, 0); |
1430 SkMatrix matrix(*draw.fMatrix); | 1430 SkMatrix matrix(*draw.fMatrix); |
1431 matrix.postTranslate(SkIntToScalar(-left), SkIntToScalar(-top)); | 1431 matrix.postTranslate(SkIntToScalar(-left), SkIntToScalar(-top)); |
1432 SkIRect clipBounds = SkIRect::MakeWH(bitmap.width(), bitmap.height()); | 1432 SkIRect clipBounds = SkIRect::MakeWH(bitmap.width(), bitmap.height()); |
1433 SkAutoTUnref<SkImageFilter::Cache> cache(getImageFilterCache()); | 1433 SkAutoTUnref<SkImageFilter::Cache> cache(getImageFilterCache()); |
1434 // This cache is transient, and is freed (along with all its contained | 1434 // This cache is transient, and is freed (along with all its contained |
1435 // textures) when it goes out of scope. | 1435 // textures) when it goes out of scope. |
1436 SkImageFilter::Context ctx(matrix, clipBounds, cache); | 1436 SkImageFilter::Context ctx(matrix, clipBounds, cache, SkImageFilter::kAp
prox_SizeConstraint); |
1437 if (this->filterTexture(fContext, texture, w, h, filter, ctx, &filteredB
itmap, | 1437 if (this->filterTexture(fContext, texture, w, h, filter, ctx, &filteredB
itmap, |
1438 &offset)) { | 1438 &offset)) { |
1439 texture = (GrTexture*) filteredBitmap.getTexture(); | 1439 texture = (GrTexture*) filteredBitmap.getTexture(); |
1440 w = filteredBitmap.width(); | 1440 w = filteredBitmap.width(); |
1441 h = filteredBitmap.height(); | 1441 h = filteredBitmap.height(); |
1442 left += offset.x(); | 1442 left += offset.x(); |
1443 top += offset.y(); | 1443 top += offset.y(); |
1444 } else { | 1444 } else { |
1445 return; | 1445 return; |
1446 } | 1446 } |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1546 SkBitmap filteredBitmap; | 1546 SkBitmap filteredBitmap; |
1547 | 1547 |
1548 if (filter) { | 1548 if (filter) { |
1549 SkIPoint offset = SkIPoint::Make(0, 0); | 1549 SkIPoint offset = SkIPoint::Make(0, 0); |
1550 SkMatrix matrix(*draw.fMatrix); | 1550 SkMatrix matrix(*draw.fMatrix); |
1551 matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y)); | 1551 matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y)); |
1552 SkIRect clipBounds = SkIRect::MakeWH(devTex->width(), devTex->height()); | 1552 SkIRect clipBounds = SkIRect::MakeWH(devTex->width(), devTex->height()); |
1553 // This cache is transient, and is freed (along with all its contained | 1553 // This cache is transient, and is freed (along with all its contained |
1554 // textures) when it goes out of scope. | 1554 // textures) when it goes out of scope. |
1555 SkAutoTUnref<SkImageFilter::Cache> cache(getImageFilterCache()); | 1555 SkAutoTUnref<SkImageFilter::Cache> cache(getImageFilterCache()); |
1556 SkImageFilter::Context ctx(matrix, clipBounds, cache); | 1556 SkImageFilter::Context ctx(matrix, clipBounds, cache, SkImageFilter::kAp
prox_SizeConstraint); |
1557 if (this->filterTexture(fContext, devTex, device->width(), device->heigh
t(), | 1557 if (this->filterTexture(fContext, devTex, device->width(), device->heigh
t(), |
1558 filter, ctx, &filteredBitmap, &offset)) { | 1558 filter, ctx, &filteredBitmap, &offset)) { |
1559 devTex = filteredBitmap.getTexture(); | 1559 devTex = filteredBitmap.getTexture(); |
1560 w = filteredBitmap.width(); | 1560 w = filteredBitmap.width(); |
1561 h = filteredBitmap.height(); | 1561 h = filteredBitmap.height(); |
1562 x += offset.fX; | 1562 x += offset.fX; |
1563 y += offset.fY; | 1563 y += offset.fY; |
1564 } else { | 1564 } else { |
1565 return; | 1565 return; |
1566 } | 1566 } |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2019 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); | 2019 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); |
2020 } | 2020 } |
2021 | 2021 |
2022 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { | 2022 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { |
2023 // We always return a transient cache, so it is freed after each | 2023 // We always return a transient cache, so it is freed after each |
2024 // filter traversal. | 2024 // filter traversal. |
2025 return SkGpuDevice::NewImageFilterCache(); | 2025 return SkGpuDevice::NewImageFilterCache(); |
2026 } | 2026 } |
2027 | 2027 |
2028 #endif | 2028 #endif |
OLD | NEW |