Hold on to image-filtered texture in SkGpuDevice
authorcommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 18 Jul 2013 19:21:44 +0000 (19:21 +0000)
committercommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 18 Jul 2013 19:21:44 +0000 (19:21 +0000)
R=robertphillips@google.com

Author: bsalomon@google.com

Review URL: https://chromiumcodereview.appspot.com/19729006

git-svn-id: http://skia.googlecode.com/svn/trunk@10156 2bbb7eff-a529-9590-31e7-b0007b416f81

src/gpu/SkGpuDevice.cpp

index 81b25b8..eaac5ab 100644 (file)
@@ -1388,12 +1388,14 @@ void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap,
 
     SkImageFilter* filter = paint.getImageFilter();
     SkIPoint offset = SkIPoint::Make(0, 0);
+    // This bitmap will own the filtered result as a texture.
+    SkBitmap filteredBitmap;
+
     if (NULL != filter) {
-        SkBitmap filterBitmap;
-        if (filter_texture(this, fContext, texture, filter, w, h, &filterBitmap, &offset)) {
-            texture = (GrTexture*) filterBitmap.getTexture();
-            w = filterBitmap.width();
-            h = filterBitmap.height();
+        if (filter_texture(this, fContext, texture, filter, w, h, &filteredBitmap, &offset)) {
+            texture = (GrTexture*) filteredBitmap.getTexture();
+            w = filteredBitmap.width();
+            h = filteredBitmap.height();
         }
     }
 
@@ -1468,14 +1470,15 @@ void SkGpuDevice::drawDevice(const SkDraw& draw, SkDevice* device,
     int h = bm.height();
 
     SkImageFilter* filter = paint.getImageFilter();
+    // This bitmap will own the filtered result as a texture.
+    SkBitmap filteredBitmap;
 
     if (NULL != filter) {
-        SkBitmap filterBitmap;
         SkIPoint offset = SkIPoint::Make(0, 0);
-        if (filter_texture(this, fContext, devTex, filter, w, h, &filterBitmap, &offset)) {
-            devTex = filterBitmap.getTexture();
-            w = filterBitmap.width();
-            h = filterBitmap.height();
+        if (filter_texture(this, fContext, devTex, filter, w, h, &filteredBitmap, &offset)) {
+            devTex = filteredBitmap.getTexture();
+            w = filteredBitmap.width();
+            h = filteredBitmap.height();
             x += offset.fX;
             y += offset.fY;
         }