From e2609594466336305bedfa61f98510d127a8ec85 Mon Sep 17 00:00:00 2001 From: Matt Sarett Date: Tue, 10 Jan 2017 09:29:04 -0500 Subject: [PATCH] Make SkImage_Base::onReadPixels() pure virtual BUG=skia: Change-Id: I52504b21313717bf8321ec3f1df770773703a1a1 Reviewed-on: https://skia-review.googlesource.com/6831 Reviewed-by: Brian Osman Commit-Queue: Matt Sarett --- src/image/SkImage.cpp | 31 ------------------------------- src/image/SkImage_Base.h | 3 +-- 2 files changed, 1 insertion(+), 33 deletions(-) diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp index 66301341d3..417a29a1ed 100644 --- a/src/image/SkImage.cpp +++ b/src/image/SkImage.cpp @@ -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 { diff --git a/src/image/SkImage_Base.h b/src/image/SkImage_Base.h index ebb38d4731..e839a05cd2 100644 --- a/src/image/SkImage_Base.h +++ b/src/image/SkImage_Base.h @@ -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