From 85591831b2fc0f67968116d73c79ee1232a59935 Mon Sep 17 00:00:00 2001 From: Matt Sarett Date: Wed, 3 May 2017 13:20:33 -0400 Subject: [PATCH] Delete SkBitmap::copyTo() Bug: skia:6465 Change-Id: Ied95fe3aaed9126906fde15bfda73bd6597e3347 Reviewed-on: https://skia-review.googlesource.com/15220 Reviewed-by: Matt Sarett Commit-Queue: Matt Sarett --- include/core/SkBitmap.h | 12 --------- src/core/SkBitmap.cpp | 70 ------------------------------------------------- 2 files changed, 82 deletions(-) diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h index d38898c..6e6a578 100644 --- a/include/core/SkBitmap.h +++ b/include/core/SkBitmap.h @@ -552,16 +552,6 @@ public: */ bool extractSubset(SkBitmap* dst, const SkIRect& subset) const; -#ifdef SK_SUPPORT_LEGACY_BITMAP_COPYTO - bool copyTo(SkBitmap* dst, SkColorType ct) const; - bool copyTo(SkBitmap* dst) const { - return this->copyTo(dst, this->colorType()); - } - bool deepCopyTo(SkBitmap* dst) const { - return this->copyTo(dst, this->colorType()); - } -#endif - /** * Copy the bitmap's pixels into the specified buffer (pixels + rowBytes), * converting them into the requested format (SkImageInfo). The src pixels are read @@ -699,8 +689,6 @@ private: bool writePixels(const SkPixmap& src, int x, int y, SkTransferFunctionBehavior behavior); - bool canCopyTo(SkColorType colorType) const; - /* Unreference any pixelrefs or colortables */ void freePixels(); diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp index c23b5e2..51b8826 100644 --- a/src/core/SkBitmap.cpp +++ b/src/core/SkBitmap.cpp @@ -513,36 +513,6 @@ bool SkBitmap::extractSubset(SkBitmap* result, const SkIRect& subset) const { /////////////////////////////////////////////////////////////////////////////// -bool SkBitmap::canCopyTo(SkColorType dstCT) const { - const SkColorType srcCT = this->colorType(); - - if (srcCT == kUnknown_SkColorType) { - return false; - } - if (srcCT == kAlpha_8_SkColorType && dstCT != kAlpha_8_SkColorType) { - return false; // can't convert from alpha to non-alpha - } - - bool sameConfigs = (srcCT == dstCT); - switch (dstCT) { - case kAlpha_8_SkColorType: - case kRGB_565_SkColorType: - case kRGBA_8888_SkColorType: - case kBGRA_8888_SkColorType: - break; - case kGray_8_SkColorType: - if (!sameConfigs) { - return false; - } - break; - case kARGB_4444_SkColorType: - return sameConfigs || kN32_SkColorType == srcCT || kIndex_8_SkColorType == srcCT; - default: - return false; - } - return true; -} - bool SkBitmap::readPixels(const SkImageInfo& requestedDstInfo, void* dstPixels, size_t dstRB, int x, int y) const { SkPixmap src; @@ -574,46 +544,6 @@ bool SkBitmap::writePixels(const SkPixmap& src, int dstX, int dstY, return true; } -#ifdef SK_SUPPORT_LEGACY_BITMAP_COPYTO -bool SkBitmap::copyTo(SkBitmap* dst, SkColorType dstColorType) const { - if (!this->canCopyTo(dstColorType)) { - return false; - } - - SkPixmap srcPM; - if (!this->peekPixels(&srcPM)) { - return false; - } - - SkBitmap tmpDst; - SkImageInfo dstInfo = srcPM.info().makeColorType(dstColorType); - if (!tmpDst.setInfo(dstInfo)) { - return false; - } - - // allocate colortable if srcConfig == kIndex8_Config - sk_sp ctable; - if (dstColorType == kIndex_8_SkColorType) { - ctable.reset(SkRef(srcPM.ctable())); - } - if (!tmpDst.tryAllocPixels(ctable.get())) { - return false; - } - - SkPixmap dstPM; - if (!tmpDst.peekPixels(&dstPM)) { - return false; - } - - if (!srcPM.readPixels(dstPM)) { - return false; - } - - dst->swap(tmpDst); - return true; -} -#endif - /////////////////////////////////////////////////////////////////////////////// static bool GetBitmapAlpha(const SkBitmap& src, uint8_t* SK_RESTRICT alpha, int alphaRowBytes) { -- 2.7.4