Reverting r1775 at Mike and Brian's request
authorepoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 1 Jul 2011 21:12:20 +0000 (21:12 +0000)
committerepoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 1 Jul 2011 21:12:20 +0000 (21:12 +0000)
git-svn-id: http://skia.googlecode.com/svn/trunk@1786 2bbb7eff-a529-9590-31e7-b0007b416f81

include/core/SkBitmap.h
samplecode/SampleTextureDomain.cpp
src/gpu/SkGpuDevice.cpp

index 469252a..58af571 100644 (file)
@@ -464,7 +464,7 @@ public:
      */
     inline SkPMColor getIndex8Color(int x, int y) const;
 
-    /** Set dst to be a subset of this bitmap. If possible, it will share the
+    /** Set dst to be a setset of this bitmap. If possible, it will share the
         pixel memory, and just point into a subset of it. However, if the config
         does not support this, a local copy will be made and associated with
         the dst bitmap. If the subset rectangle, intersected with the bitmap's
index 939dbcd..1f895e5 100755 (executable)
@@ -77,21 +77,15 @@ protected:
         SkMaskFilter* mf = SkBlurMaskFilter::Create(
             5,
             SkBlurMaskFilter::kNormal_BlurStyle,
-            SkBlurMaskFilter::kHighQuality_BlurFlag | 
-            SkBlurMaskFilter::kIgnoreTransform_BlurFlag );
+            SkBlurMaskFilter::kHighQuality_BlurFlag);
         paint.setMaskFilter(mf)->unref();
         canvas->drawBitmapRect(deviceBitmap, &srcRect, dstRect, &paint);
 
-        // Blur and a rotation + NULL src rect + transform applies to filter
+        // Blur and a rotation + NULL src rect
         // This should not trigger the texture domain code
         // but it will test a code path in SkGpuDevice::drawBitmap
         // that handles blurs with rects transformed to non-
         // orthogonal rects. It also tests the NULL src rect handling
-        mf = SkBlurMaskFilter::Create(
-            3,
-            SkBlurMaskFilter::kNormal_BlurStyle,
-            SkBlurMaskFilter::kHighQuality_BlurFlag);
-        paint.setMaskFilter(mf)->unref();
         dstRect.setXYWH(-150.0f, -150.0f, 300.0f, 300.0f);
         canvas->translate(550, 550);
         canvas->rotate(45);
index af31ee5..4f2d7c4 100644 (file)
@@ -962,46 +962,33 @@ void SkGpuDevice::drawBitmap(const SkDraw& draw,
     }
 
     if (paint.getMaskFilter()){
-        SkBitmap tmpBitmap; // local copy of bitmap
+        SkBitmap        tmp;    // storage if we need a subset of bitmap
         const SkBitmap* bitmapPtr = &bitmap;
-        
-        // FIXME : texture-backed bitmaps not yet supported
-        SkAutoLockPixels alp(bitmap);
-        if (!bitmap.getPixels())
-            return;
-
-        // A temporary copy of the bitmap may be necessary
-        // to prevent color bleeding if a sub rect is used
-        if (NULL != srcRectPtr) {
-            tmpBitmap.setConfig(bitmap.config(), srcRect.width(), 
-                srcRect.height());
-
-            size_t pixelOffset = srcRect.fTop * bitmap.rowBytes()
-                + srcRect.fLeft * bitmap.bytesPerPixel();
-            tmpBitmap.copyPixelsFrom(
-                (uint8_t*)bitmap.getPixels() + pixelOffset, 
-                bitmap.getSafeSize() - pixelOffset,
-                bitmap.rowBytes());
-
-            bitmapPtr = &tmpBitmap;
+        if (srcRectPtr) {
+            if (!bitmap.extractSubset(&tmp, srcRect)) {
+                return;     // extraction failed
+            }
+            bitmapPtr = &tmp;
         }
-
         SkPaint paintWithTexture(paint);
         paintWithTexture.setShader(SkShader::CreateBitmapShader( *bitmapPtr,
             SkShader::kClamp_TileMode, SkShader::kClamp_TileMode))->unref();
         paintWithTexture.getShader()->setLocalMatrix(m);
 
         SkRect ScalarRect;
-        ScalarRect.setXYWH(0, 0, srcRect.width(), srcRect.height());
-
-        // Transform 'm' must be applied globally so that it will
-        // affect the blur radius.
-        SkMatrix matrix = *draw.fMatrix;
-        matrix.preConcat(m);
-        SkDraw myDraw(draw);
-        myDraw.fMatrix = &matrix;
+        ScalarRect.set(srcRect);
 
-        this->drawRect(myDraw, ScalarRect, paintWithTexture);
+        if (m.rectStaysRect()) {
+            // Preferred drawing method, optimized for rectangles
+            m.mapRect(&ScalarRect);
+            this->drawRect(draw, ScalarRect, paintWithTexture);
+        } else {
+            // Slower drawing method, for warped or rotated rectangles
+            SkPath path;
+            path.addRect(ScalarRect);
+            path.transform(m);
+            this->drawPath(draw, path, paintWithTexture, NULL, true);
+        }
         return;
     }