From: commit-bot@chromium.org Date: Tue, 27 May 2014 21:30:37 +0000 (+0000) Subject: remove SkBitmap::asImageInfo X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~7554 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=466f5f3e44e703ca58b43ac1c4ac3bfa0e1ff024;p=platform%2Fupstream%2FlibSkiaSharp.git remove SkBitmap::asImageInfo BUG=skia: R=scroggo@google.com, halcanary@google.com Author: reed@google.com Review URL: https://codereview.chromium.org/305483005 git-svn-id: http://skia.googlecode.com/svn/trunk@14909 2bbb7eff-a529-9590-31e7-b0007b416f81 --- diff --git a/gm/gmmain.cpp b/gm/gmmain.cpp index 5c91204..4833975 100644 --- a/gm/gmmain.cpp +++ b/gm/gmmain.cpp @@ -561,8 +561,7 @@ public: bool deferred) { SkISize size (gm->getISize()); setup_bitmap(gRec, size, bitmap); - SkImageInfo info; - bitmap->asImageInfo(&info); + const SkImageInfo info = bitmap->info(); SkAutoTUnref surface; SkAutoTUnref canvas; diff --git a/gyp/skia_for_chromium_defines.gypi b/gyp/skia_for_chromium_defines.gypi index 6c64a82..c114b71 100644 --- a/gyp/skia_for_chromium_defines.gypi +++ b/gyp/skia_for_chromium_defines.gypi @@ -14,6 +14,7 @@ # 'skia_for_chromium_defines': [ 'SK_SUPPORT_LEGACY_GETTOPDEVICE', + 'SK_SUPPORT_LEGACY_ASIMAGEINFO', 'SK_SUPPORT_LEGACY_N32_NAME', ], }, diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h index d87f01d..ef59e31 100644 --- a/include/core/SkBitmap.h +++ b/include/core/SkBitmap.h @@ -88,6 +88,19 @@ public: SkColorType colorType() const { return fInfo.fColorType; } SkAlphaType alphaType() const { return fInfo.fAlphaType; } +#ifdef SK_SUPPORT_LEGACY_ASIMAGEINFO + bool asImageInfo(SkImageInfo* info) const { + // compatibility: return false for kUnknown + if (kUnknown_SkColorType == this->colorType()) { + return false; + } + if (info) { + *info = this->info(); + } + return true; + } +#endif + /** Return the number of bytes per pixel based on the config. If the config does not have at least 1 byte per (e.g. kA1_Config) then 0 is returned. */ @@ -324,20 +337,6 @@ public: */ bool installMaskPixels(const SkMask&); - /** - * DEPRECATED: call info(). - */ - bool asImageInfo(SkImageInfo* info) const { - // compatibility: return false for kUnknown - if (kUnknown_SkColorType == this->colorType()) { - return false; - } - if (info) { - *info = this->info(); - } - return true; - } - /** Use this to assign a new pixel address for an existing bitmap. This will automatically release any pixelref previously installed. Only call this if you are handling ownership/lifetime of the pixel memory. diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp index cc3c165..a89ca35 100644 --- a/src/core/SkBitmap.cpp +++ b/src/core/SkBitmap.cpp @@ -310,24 +310,23 @@ static bool config_to_colorType(SkBitmap::Config config, SkColorType* ctOut) { SkPixelRef* SkBitmap::setPixelRef(SkPixelRef* pr, int dx, int dy) { #ifdef SK_DEBUG if (pr) { - SkImageInfo info; - if (this->asImageInfo(&info)) { + if (kUnknown_SkColorType != fInfo.colorType()) { const SkImageInfo& prInfo = pr->info(); - SkASSERT(info.fWidth <= prInfo.fWidth); - SkASSERT(info.fHeight <= prInfo.fHeight); - SkASSERT(info.fColorType == prInfo.fColorType); + SkASSERT(fInfo.fWidth <= prInfo.fWidth); + SkASSERT(fInfo.fHeight <= prInfo.fHeight); + SkASSERT(fInfo.fColorType == prInfo.fColorType); switch (prInfo.fAlphaType) { case kIgnore_SkAlphaType: SkASSERT(fInfo.fAlphaType == kIgnore_SkAlphaType); break; case kOpaque_SkAlphaType: case kPremul_SkAlphaType: - SkASSERT(info.fAlphaType == kOpaque_SkAlphaType || - info.fAlphaType == kPremul_SkAlphaType); + SkASSERT(fInfo.fAlphaType == kOpaque_SkAlphaType || + fInfo.fAlphaType == kPremul_SkAlphaType); break; case kUnpremul_SkAlphaType: - SkASSERT(info.fAlphaType == kOpaque_SkAlphaType || - info.fAlphaType == kUnpremul_SkAlphaType); + SkASSERT(fInfo.fAlphaType == kOpaque_SkAlphaType || + fInfo.fAlphaType == kUnpremul_SkAlphaType); break; } } @@ -386,13 +385,12 @@ void SkBitmap::setPixels(void* p, SkColorTable* ctable) { return; } - SkImageInfo info; - if (!this->asImageInfo(&info)) { + if (kUnknown_SkColorType == fInfo.colorType()) { this->setPixelRef(NULL); return; } - SkPixelRef* pr = SkMallocPixelRef::NewDirect(info, p, fRowBytes, ctable); + SkPixelRef* pr = SkMallocPixelRef::NewDirect(fInfo, p, fRowBytes, ctable); if (NULL == pr) { this->setPixelRef(NULL); return; @@ -526,14 +524,13 @@ GrTexture* SkBitmap::getTexture() const { */ bool SkBitmap::HeapAllocator::allocPixelRef(SkBitmap* dst, SkColorTable* ctable) { - SkImageInfo info; - if (!dst->asImageInfo(&info)) { + const SkImageInfo info = dst->info(); + if (kUnknown_SkColorType == info.colorType()) { // SkDebugf("unsupported config for info %d\n", dst->config()); return false; } - SkPixelRef* pr = SkMallocPixelRef::NewAllocate(info, dst->rowBytes(), - ctable); + SkPixelRef* pr = SkMallocPixelRef::NewAllocate(info, dst->rowBytes(), ctable); if (NULL == pr) { return false; } diff --git a/src/core/SkBitmapDevice.cpp b/src/core/SkBitmapDevice.cpp index 311e72f..76553ef 100644 --- a/src/core/SkBitmapDevice.cpp +++ b/src/core/SkBitmapDevice.cpp @@ -440,7 +440,11 @@ SkSurface* SkBitmapDevice::newSurface(const SkImageInfo& info) { } const void* SkBitmapDevice::peekPixels(SkImageInfo* info, size_t* rowBytes) { - if (fBitmap.getPixels() && fBitmap.asImageInfo(info)) { + const SkImageInfo bmInfo = fBitmap.info(); + if (fBitmap.getPixels() && (kUnknown_SkColorType != bmInfo.colorType())) { + if (info) { + *info = bmInfo; + } if (rowBytes) { *rowBytes = fBitmap.rowBytes(); } diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp index 05f559b..582f899 100644 --- a/src/core/SkImageFilter.cpp +++ b/src/core/SkImageFilter.cpp @@ -326,8 +326,8 @@ bool SkImageFilter::getInputResultGPU(SkImageFilter::Proxy* proxy, } else { if (this->filterImage(proxy, src, ctx, result, offset)) { if (!result->getTexture()) { - SkImageInfo info; - if (!result->asImageInfo(&info)) { + const SkImageInfo info = result->info(); + if (kUnknown_SkColorType == info.colorType()) { return false; } GrTexture* resultTex = GrLockAndRefCachedBitmapTexture(context, *result, NULL); diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp index 4cbfd81..e0a13f9 100644 --- a/src/image/SkImage.cpp +++ b/src/image/SkImage.cpp @@ -103,18 +103,16 @@ static bool raster_canvas_supports(const SkImageInfo& info) { } bool SkImage_Base::onReadPixels(SkBitmap* bitmap, const SkIRect& subset) const { - SkImageInfo info; - if (bitmap->pixelRef()) { - if (!bitmap->asImageInfo(&info)) { + const SkImageInfo info = bitmap->info(); + if (kUnknown_SkColorType == info.colorType()) { return false; } if (!raster_canvas_supports(info)) { return false; } } else { - SkImageInfo info = SkImageInfo::MakeN32Premul(subset.width(), - subset.height()); + const SkImageInfo info = SkImageInfo::MakeN32Premul(subset.width(), subset.height()); SkBitmap tmp; if (!tmp.allocPixels(info)) { return false; diff --git a/src/image/SkImagePriv.cpp b/src/image/SkImagePriv.cpp index 538c6bb..56afd66 100644 --- a/src/image/SkImagePriv.cpp +++ b/src/image/SkImagePriv.cpp @@ -51,8 +51,8 @@ SkColorType SkBitmapConfigToColorType(SkBitmap::Config config) { } SkImage* SkNewImageFromBitmap(const SkBitmap& bm, bool canSharePixelRef) { - SkImageInfo info; - if (!bm.asImageInfo(&info)) { + const SkImageInfo info = bm.info(); + if (kUnknown_SkColorType == info.colorType()) { return NULL; } diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp index abf6dc8..7a8091c 100644 --- a/src/image/SkImage_Raster.cpp +++ b/src/image/SkImage_Raster.cpp @@ -133,8 +133,8 @@ bool SkImage_Raster::onReadPixels(SkBitmap* dst, const SkIRect& subset) const { const void* SkImage_Raster::onPeekPixels(SkImageInfo* infoPtr, size_t* rowBytesPtr) const { - SkImageInfo info; - if (!fBitmap.asImageInfo(&info) || !fBitmap.getPixels()) { + const SkImageInfo info = fBitmap.info(); + if ((kUnknown_SkColorType == info.colorType()) || !fBitmap.getPixels()) { return NULL; } *infoPtr = info;