Revert of Override SkCanvas::drawImage() in SkDeferredCanvas and SkGPipe (patchset...
authorrmistry <rmistry@google.com>
Fri, 17 Oct 2014 13:19:27 +0000 (06:19 -0700)
committerCommit bot <commit-bot@chromium.org>
Fri, 17 Oct 2014 13:19:27 +0000 (06:19 -0700)
Reason for revert:
Trying to fix DEPS roll failure:
https://codereview.chromium.org/660113002/

Link to failing builds:
http://build.chromium.org/p/tryserver.blink/builders/linux_blink_rel/builds/29578
http://build.chromium.org/p/tryserver.blink/builders/linux_blink_dbg/builds/29354

Original issue's description:
> Override SkCanvas::drawImage() in SkDeferredCanvas and SkGPipe
>
> BUG=skia:2947
>
> Committed: https://skia.googlesource.com/skia/+/687732fe046c9cfec940f2d7f661cd97651d10a8

TBR=junov@chromium.org,reed@google.com,bsalomon@chromium.org,piotaixr@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=skia:2947

Review URL: https://codereview.chromium.org/658293004

include/utils/SkDeferredCanvas.h
src/pipe/SkGPipePriv.h
src/pipe/SkGPipeRead.cpp
src/pipe/SkGPipeWrite.cpp
src/utils/SkDeferredCanvas.cpp

index a1ac295185dae0a8b3248970c92f77f70111f8f1..5f781f88594e4fb48ece47189ff37bd80dddc5d6 100644 (file)
@@ -164,12 +164,8 @@ public:
     virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
                                   const SkPaint* paint) SK_OVERRIDE;
     virtual void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
-                                const SkRect& dst, const SkPaint* paint) SK_OVERRIDE;
-    virtual void drawImage(const SkImage* image, SkScalar left, SkScalar top,
-                           const SkPaint* paint) SK_OVERRIDE;
-    virtual void drawImageRect(const SkImage* image, const SkRect* src,
-                               const SkRect& dst,
-                               const SkPaint* paint) SK_OVERRIDE;
+                                const SkRect& dst, const SkPaint* paint)
+                                SK_OVERRIDE;
     virtual void drawSprite(const SkBitmap& bitmap, int left, int top,
                             const SkPaint* paint) SK_OVERRIDE;
     virtual void drawVertices(VertexMode vmode, int vertexCount,
@@ -201,7 +197,7 @@ protected:
     virtual void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
                              const SkPoint texCoords[4], SkXfermode* xmode,
                              const SkPaint& paint) SK_OVERRIDE;
-
+    
     virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
     virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
     virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE;
index 8d2a2af294b718c26fbace2db99cfa8113a11727..121512d42a7837328dccc9a90ea85a42721abf29 100644 (file)
@@ -46,8 +46,6 @@ enum DrawOps {
     kDrawClear_DrawOp,
     kDrawData_DrawOp,
     kDrawDRRect_DrawOp,
-    kDrawImage_DrawOp,
-    kDrawImageRect_DrawOp,
     kDrawOval_DrawOp,
     kDrawPaint_DrawOp,
     kDrawPatch_DrawOp,
@@ -158,10 +156,6 @@ enum {
     // converted into and out of this flag to save space
     kDrawBitmap_Bleed_DrawOpFlag      = 1 << 2,
 };
-enum {
-    kDrawImage_HasPaint_DrawOpFlag   = 1 << 0,
-    kDrawImage_HasSrcRect_DrawOpFlag = 1 << 1,
-};
 enum {
     kClip_HasAntiAlias_DrawOpFlag = 1 << 0,
 };
index 222dc99e1ae9b676a208aa565c14e47f9cdd2a5d..8cb0e34d0a5d9c844ffa638b4ef081906d76a52d 100644 (file)
@@ -408,11 +408,11 @@ static void drawDRRect_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32,
 
 static void drawPatch_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32,
                          SkGPipeState* state) {
-
+    
     unsigned flags = DrawOp_unpackFlags(op32);
-
+    
     const SkPoint* cubics = skip<SkPoint>(reader, SkPatchUtils::kNumCtrlPts);
-
+    
     const SkColor* colors = NULL;
     if (flags & kDrawVertices_HasColors_DrawOpFlag) {
         colors = skip<SkColor>(reader, SkPatchUtils::kNumCorners);
@@ -651,40 +651,6 @@ static void drawSprite_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32,
     }
 }
 
-static void drawImage_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32,
-                          SkGPipeState* state) {
-    bool hasPaint = SkToBool(DrawOp_unpackFlags(op32) & kDrawBitmap_HasPaint_DrawOpFlag);
-    // Balances call to ref() in SkGPipeWrite
-    SkAutoTUnref<const SkImage> image (static_cast<const SkImage*>(reader->readPtr()));
-
-    SkScalar left = reader->readScalar();
-    SkScalar top = reader->readScalar();
-
-    if (state->shouldDraw()) {
-        canvas->drawImage(image, left, top, hasPaint ? &state->paint() : NULL);
-    }
-}
-
-static void drawImageRect_rp(SkCanvas* canvas, SkReader32* reader,
-                              uint32_t op32, SkGPipeState* state) {
-    unsigned flags = DrawOp_unpackFlags(op32);
-    bool hasPaint = SkToBool(flags & kDrawBitmap_HasPaint_DrawOpFlag);
-    bool hasSrc = SkToBool(flags & kDrawBitmap_HasSrcRect_DrawOpFlag);
-    // Balances call to ref() in SkGPipeWrite
-    SkAutoTUnref<const SkImage> image (static_cast<const SkImage*>(reader->readPtr()));
-
-    const SkRect* src;
-    if (hasSrc) {
-        src = skip<SkRect>(reader);
-    } else {
-        src = NULL;
-    }
-    const SkRect* dst = skip<SkRect>(reader);
-    if (state->shouldDraw()) {
-        canvas->drawImageRect(image, src, *dst, hasPaint ? &state->paint() : NULL);
-    }
-}
-
 ///////////////////////////////////////////////////////////////////////////////
 
 static void drawData_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32,
@@ -865,8 +831,6 @@ static const ReadProc gReadTable[] = {
     drawClear_rp,
     drawData_rp,
     drawDRRect_rp,
-    drawImage_rp,
-    drawImageRect_rp,
     drawOval_rp,
     drawPaint_rp,
     drawPatch_rp,
index a1e7dc2872405f5e26ab630a537276ff7956b12b..41b02344805ffceb09c1797367a78355024a7e1d 100644 (file)
@@ -250,11 +250,6 @@ public:
                                   const SkPaint*) SK_OVERRIDE;
     virtual void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
                                 const SkRect& dst, const SkPaint* paint = NULL) SK_OVERRIDE;
-    virtual void drawImage(const SkImage* image, SkScalar left, SkScalar top,
-                           const SkPaint* paint) SK_OVERRIDE;
-    virtual void drawImageRect(const SkImage* image, const SkRect* src,
-                               const SkRect& dst,
-                               const SkPaint* paint) SK_OVERRIDE;
     virtual void drawSprite(const SkBitmap&, int left, int top,
                             const SkPaint*) SK_OVERRIDE;
     virtual void drawVertices(VertexMode, int vertexCount,
@@ -364,9 +359,6 @@ private:
     bool commonDrawBitmap(const SkBitmap& bm, DrawOps op, unsigned flags,
                           size_t opBytesNeeded, const SkPaint* paint);
 
-    bool commonDrawImage(const SkImage* image, DrawOps op, unsigned flags,
-                         size_t opBytesNeeded, const SkPaint* paint);
-
     SkPaint fPaint;
     void writePaint(const SkPaint&);
 
@@ -479,7 +471,6 @@ SkGPipeCanvas::SkGPipeCanvas(SkGPipeController* controller,
         }
     }
     fFlattenableHeap.setBitmapStorage(fBitmapHeap);
-
     this->doNotify();
 }
 
@@ -808,79 +799,6 @@ bool SkGPipeCanvas::commonDrawBitmap(const SkBitmap& bm, DrawOps op,
     return false;
 }
 
-bool SkGPipeCanvas::commonDrawImage(const SkImage* image, DrawOps op,
-                                    unsigned flags,
-                                    size_t opBytesNeeded,
-                                    const SkPaint* paint) {
-     if (fDone) {
-        return false;
-    }
-
-    if (paint != NULL) {
-        flags |= kDrawBitmap_HasPaint_DrawOpFlag;
-        this->writePaint(*paint);
-    }
-
-     opBytesNeeded += sizeof (SkImage*);
-
-    if (this->needOpBytes(opBytesNeeded)) {
-        this->writeOp(op, flags, 0);
-
-        image->ref(); // The SkGPipeReader will have to call unref()
-        fWriter.writePtr(static_cast<void*>(const_cast<SkImage*>(image)));
-
-        return true;
-    }
-    return false;
-}
-
-void SkGPipeCanvas::drawImage(const SkImage* image, SkScalar left, SkScalar top,
-                       const SkPaint* paint) {
-    if (is_cross_process(fFlags)){
-        // If the SkGPipe is cross-process, we will have to flatten the data in the SkImage, so
-        // fallback to the default implementation in SkCanvas (which calls SkImage::draw())
-        // https://code.google.com//p/skia/issues/detail?id=2985
-        this->INHERITED::drawImage(image, left, top, paint);
-    } else {
-        NOTIFY_SETUP(this);
-        size_t opBytesNeeded = sizeof(SkScalar) * 2;
-
-        if (this->commonDrawImage(image, kDrawImage_DrawOp, 0, opBytesNeeded, paint)) {
-            fWriter.writeScalar(left);
-            fWriter.writeScalar(top);
-        }
-    }
-}
-
-void SkGPipeCanvas::drawImageRect(const SkImage* image, const SkRect* src,
-                                  const SkRect& dst,
-                                  const SkPaint* paint) {
-    if (is_cross_process(fFlags)){
-        // If the SkGPipe is cross-process, we will have to flatten the data in the SkImage, so
-        // fallback to the default implementation in SkCanvas (which calls SkImage::drawRect())
-        // https://code.google.com//p/skia/issues/detail?id=2985
-       this->INHERITED::drawImageRect(image, src, dst, paint);
-    } else {
-        NOTIFY_SETUP(this);
-        size_t opBytesNeeded = sizeof (SkRect);
-        bool hasSrc = src != NULL;
-        unsigned flags;
-        if (hasSrc) {
-            flags = kDrawImage_HasSrcRect_DrawOpFlag;
-            opBytesNeeded += sizeof (SkRect);
-        } else {
-            flags = 0;
-        }
-
-        if (this->commonDrawImage(image, kDrawImageRect_DrawOp, flags, opBytesNeeded, paint)) {
-            if (hasSrc) {
-                fWriter.writeRect(*src);
-            }
-            fWriter.writeRect(dst);
-        }
-    }
-}
-
 void SkGPipeCanvas::drawBitmap(const SkBitmap& bm, SkScalar left, SkScalar top,
                                const SkPaint* paint) {
     NOTIFY_SETUP(this);
@@ -1172,7 +1090,7 @@ void SkGPipeCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4
                                 const SkPoint texCoords[4], SkXfermode* xmode,
                                 const SkPaint& paint) {
     NOTIFY_SETUP(this);
-
+    
     size_t size = SkPatchUtils::kNumCtrlPts * sizeof(SkPoint);
     unsigned flags = 0;
     if (colors) {
@@ -1190,21 +1108,21 @@ void SkGPipeCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4
             size += sizeof(int32_t);
         }
     }
-
+    
     this->writePaint(paint);
     if (this->needOpBytes(size)) {
         this->writeOp(kDrawPatch_DrawOp, flags, 0);
-
+        
         fWriter.write(cubics, SkPatchUtils::kNumCtrlPts * sizeof(SkPoint));
-
+        
         if (colors) {
             fWriter.write(colors, SkPatchUtils::kNumCorners * sizeof(SkColor));
         }
-
+        
         if (texCoords) {
             fWriter.write(texCoords, SkPatchUtils::kNumCorners * sizeof(SkPoint));
         }
-
+        
         if (flags & kDrawVertices_HasXfermode_DrawOpFlag) {
             SkXfermode::Mode mode = SkXfermode::kModulate_Mode;
             SkAssertResult(xmode->asMode(&mode));
index 826865feed54943bc7f127343792721ad1e89900..06f7bb089ab07ebebfd9ad7a99c9f8af0a5e11d9 100644 (file)
@@ -866,35 +866,6 @@ void SkDeferredCanvas::drawBitmapNine(const SkBitmap& bitmap,
     this->recordedDrawCommand();
 }
 
-void SkDeferredCanvas::drawImage(const SkImage* image, SkScalar left, SkScalar top,
-                                 const SkPaint* paint) {
-    SkRect imageRect = SkRect::MakeXYWH(left, top,
-        SkIntToScalar(image->width()), SkIntToScalar(image->height()));
-    if (fDeferredDrawing &&
-        this->isFullFrame(&imageRect, paint) &&
-        (image->isOpaque() || isPaintOpaque(paint, 0))) {
-        this->getDeferredDevice()->skipPendingCommands();
-    }
-
-    AutoImmediateDrawIfNeeded autoDraw(*this, paint);
-    this->drawingCanvas()->drawImage(image, left, top, paint);
-    this->recordedDrawCommand();
-}
-
-void SkDeferredCanvas::drawImageRect(const SkImage* image, const SkRect* src,
-                                     const SkRect& dst,
-                                     const SkPaint* paint) {
-    if (fDeferredDrawing &&
-        this->isFullFrame(&dst, paint) &&
-        (image->isOpaque() || isPaintOpaque(paint, 0))) {
-        this->getDeferredDevice()->skipPendingCommands();
-    }
-
-    AutoImmediateDrawIfNeeded autoDraw(*this, paint);
-    this->drawingCanvas()->drawImageRect(image, src, dst, paint);
-    this->recordedDrawCommand();
-}
-
 void SkDeferredCanvas::drawSprite(const SkBitmap& bitmap, int left, int top,
                                   const SkPaint* paint) {
     SkRect bitmapRect = SkRect::MakeXYWH(