OSDN Git Service

AI 143477: respect the srcRect parameter in drawPattern, so we can correctly show...
authorMike Reed <>
Mon, 30 Mar 2009 15:35:27 +0000 (08:35 -0700)
committerThe Android Open Source Project <initial-contribution@android.com>
Mon, 30 Mar 2009 15:35:27 +0000 (08:35 -0700)
  BUG=1745838

Automated import of CL 143477

WebCore/platform/graphics/android/ImageAndroid.cpp

index 6997a9e..f750781 100644 (file)
@@ -213,7 +213,7 @@ void BitmapImage::setURL(const String& str)
 
 ///////////////////////////////////////////////////////////////////////////////
 
-void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect,
+void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& srcRect,
                         const TransformationMatrix& patternTransform,
                         const FloatPoint& phase, CompositeOperator compositeOp,
                         const FloatRect& destRect)
@@ -224,8 +224,8 @@ void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect,
     }
     
     // in case we get called with an incomplete bitmap
-    const SkBitmap& bitmap = image->bitmap();
-    if (bitmap.getPixels() == NULL && bitmap.pixelRef() == NULL) {
+    const SkBitmap& origBitmap = image->bitmap();
+    if (origBitmap.getPixels() == NULL && origBitmap.pixelRef() == NULL) {
         return;
     }
     
@@ -234,7 +234,15 @@ void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect,
     if (dstR.isEmpty()) {
         return;
     }
-    
+
+    // now extract the proper subset of the src image
+    SkBitmap bitmap;
+    SkIRect srcR;
+    if (!origBitmap.extractSubset(&bitmap, *android_setrect(&srcR, srcRect))) {
+        SkDebugf("--- Image::drawPattern calling extractSubset failed\n");
+        return;
+    }
+
     SkCanvas*   canvas = ctxt->platformContext()->mCanvas;
     SkPaint     paint;