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 "effects/GrBicubicEffect.h" | 10 #include "effects/GrBicubicEffect.h" |
(...skipping 1409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1420 | 1420 |
1421 SkImageFilter* filter = paint.getImageFilter(); | 1421 SkImageFilter* filter = paint.getImageFilter(); |
1422 // This bitmap will own the filtered result as a texture. | 1422 // This bitmap will own the filtered result as a texture. |
1423 SkBitmap filteredBitmap; | 1423 SkBitmap filteredBitmap; |
1424 | 1424 |
1425 if (NULL != filter) { | 1425 if (NULL != filter) { |
1426 SkIPoint offset = SkIPoint::Make(0, 0); | 1426 SkIPoint offset = SkIPoint::Make(0, 0); |
1427 SkMatrix matrix(*draw.fMatrix); | 1427 SkMatrix matrix(*draw.fMatrix); |
1428 matrix.postTranslate(SkIntToScalar(-left), SkIntToScalar(-top)); | 1428 matrix.postTranslate(SkIntToScalar(-left), SkIntToScalar(-top)); |
1429 SkIRect clipBounds = SkIRect::MakeWH(bitmap.width(), bitmap.height()); | 1429 SkIRect clipBounds = SkIRect::MakeWH(bitmap.width(), bitmap.height()); |
1430 SkAutoTUnref<SkImageFilter::UniqueIDCache> cache(getImageFilterCache()); | 1430 SkAutoTUnref<SkImageFilter::Cache> cache(getImageFilterCache()); |
1431 // This cache is transient, and is freed (along with all its contained | 1431 // This cache is transient, and is freed (along with all its contained |
1432 // textures) when it goes out of scope. | 1432 // textures) when it goes out of scope. |
1433 SkImageFilter::Context ctx(matrix, clipBounds, cache); | 1433 SkImageFilter::Context ctx(matrix, clipBounds, cache); |
1434 if (filter_texture(this, fContext, texture, filter, w, h, ctx, &filtered
Bitmap, | 1434 if (filter_texture(this, fContext, texture, filter, w, h, ctx, &filtered
Bitmap, |
1435 &offset)) { | 1435 &offset)) { |
1436 texture = (GrTexture*) filteredBitmap.getTexture(); | 1436 texture = (GrTexture*) filteredBitmap.getTexture(); |
1437 w = filteredBitmap.width(); | 1437 w = filteredBitmap.width(); |
1438 h = filteredBitmap.height(); | 1438 h = filteredBitmap.height(); |
1439 left += offset.x(); | 1439 left += offset.x(); |
1440 top += offset.y(); | 1440 top += offset.y(); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1533 // This bitmap will own the filtered result as a texture. | 1533 // This bitmap will own the filtered result as a texture. |
1534 SkBitmap filteredBitmap; | 1534 SkBitmap filteredBitmap; |
1535 | 1535 |
1536 if (NULL != filter) { | 1536 if (NULL != filter) { |
1537 SkIPoint offset = SkIPoint::Make(0, 0); | 1537 SkIPoint offset = SkIPoint::Make(0, 0); |
1538 SkMatrix matrix(*draw.fMatrix); | 1538 SkMatrix matrix(*draw.fMatrix); |
1539 matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y)); | 1539 matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y)); |
1540 SkIRect clipBounds = SkIRect::MakeWH(devTex->width(), devTex->height()); | 1540 SkIRect clipBounds = SkIRect::MakeWH(devTex->width(), devTex->height()); |
1541 // This cache is transient, and is freed (along with all its contained | 1541 // This cache is transient, and is freed (along with all its contained |
1542 // textures) when it goes out of scope. | 1542 // textures) when it goes out of scope. |
1543 SkAutoTUnref<SkImageFilter::UniqueIDCache> cache(getImageFilterCache()); | 1543 SkAutoTUnref<SkImageFilter::Cache> cache(getImageFilterCache()); |
1544 SkImageFilter::Context ctx(matrix, clipBounds, cache); | 1544 SkImageFilter::Context ctx(matrix, clipBounds, cache); |
1545 if (filter_texture(this, fContext, devTex, filter, w, h, ctx, &filteredB
itmap, | 1545 if (filter_texture(this, fContext, devTex, filter, w, h, ctx, &filteredB
itmap, |
1546 &offset)) { | 1546 &offset)) { |
1547 devTex = filteredBitmap.getTexture(); | 1547 devTex = filteredBitmap.getTexture(); |
1548 w = filteredBitmap.width(); | 1548 w = filteredBitmap.width(); |
1549 h = filteredBitmap.height(); | 1549 h = filteredBitmap.height(); |
1550 x += offset.fX; | 1550 x += offset.fX; |
1551 y += offset.fY; | 1551 y += offset.fY; |
1552 } else { | 1552 } else { |
1553 return; | 1553 return; |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2119 GrCachedLayer* layer = fContext->getLayerCache()->findLayer(picture, | 2119 GrCachedLayer* layer = fContext->getLayerCache()->findLayer(picture, |
2120 info.fSaveLa
yerOpID, | 2120 info.fSaveLa
yerOpID, |
2121 info.fRestor
eOpID, | 2121 info.fRestor
eOpID, |
2122 info.fCTM); | 2122 info.fCTM); |
2123 fContext->getLayerCache()->unlock(layer); | 2123 fContext->getLayerCache()->unlock(layer); |
2124 } | 2124 } |
2125 | 2125 |
2126 return true; | 2126 return true; |
2127 } | 2127 } |
2128 | 2128 |
2129 SkImageFilter::UniqueIDCache* SkGpuDevice::getImageFilterCache() { | 2129 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { |
2130 // We always return a transient cache, so it is freed after each | 2130 // We always return a transient cache, so it is freed after each |
2131 // filter traversal. | 2131 // filter traversal. |
2132 return SkImageFilter::UniqueIDCache::Create(kDefaultImageFilterCacheSize); | 2132 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); |
2133 } | 2133 } |
OLD | NEW |