Make SkImage_Base::onReadPixels() pure virtual
authorMatt Sarett <msarett@google.com>
Tue, 10 Jan 2017 14:29:04 +0000 (09:29 -0500)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Tue, 10 Jan 2017 16:25:08 +0000 (16:25 +0000)
BUG=skia:

Change-Id: I52504b21313717bf8321ec3f1df770773703a1a1
Reviewed-on: https://skia-review.googlesource.com/6831
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Matt Sarett <msarett@google.com>

src/image/SkImage.cpp
src/image/SkImage_Base.h

index 6630134..417a29a 100644 (file)
@@ -200,20 +200,6 @@ GrBackendObject SkImage::getTextureHandle(bool) const { return 0; }
 
 ///////////////////////////////////////////////////////////////////////////////
 
-static bool raster_canvas_supports(const SkImageInfo& info) {
-    switch (info.colorType()) {
-        case kN32_SkColorType:
-            return kUnpremul_SkAlphaType != info.alphaType();
-        case kRGB_565_SkColorType:
-            return true;
-        case kAlpha_8_SkColorType:
-            return true;
-        default:
-            break;
-    }
-    return false;
-}
-
 SkImage_Base::SkImage_Base(int width, int height, uint32_t uniqueID)
     : INHERITED(width, height, uniqueID)
     , fAddedToCache(false)
@@ -225,23 +211,6 @@ SkImage_Base::~SkImage_Base() {
     }
 }
 
-bool SkImage_Base::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
-                                int srcX, int srcY, CachingHint) const {
-    if (!raster_canvas_supports(dstInfo)) {
-        return false;
-    }
-
-    SkBitmap bm;
-    bm.installPixels(dstInfo, dstPixels, dstRowBytes);
-    SkCanvas canvas(bm);
-
-    SkPaint paint;
-    paint.setBlendMode(SkBlendMode::kSrc);
-    canvas.drawImage(this, -SkIntToScalar(srcX), -SkIntToScalar(srcY), &paint);
-
-    return true;
-}
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 bool SkImage::readPixels(const SkPixmap& pmap, int srcX, int srcY, CachingHint chint) const {
index ebb38d4..e839a05 100644 (file)
@@ -40,9 +40,8 @@ public:
 
     virtual const SkBitmap* onPeekBitmap() const { return nullptr; }
 
-    // Default impl calls onDraw
     virtual bool onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
-                              int srcX, int srcY, CachingHint) const;
+                              int srcX, int srcY, CachingHint) const = 0;
 
     virtual GrTexture* peekTexture() const { return nullptr; }
 #if SK_SUPPORT_GPU