diff options
author | mike@reedtribe.org <mike@reedtribe.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-02-11 03:24:02 +0000 |
---|---|---|
committer | mike@reedtribe.org <mike@reedtribe.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-02-11 03:24:02 +0000 |
commit | 1195a28892d37ae9632e81e1bc2407cf644522d2 (patch) | |
tree | 7898adca3ed3c902becf9389214c4e80ccd9c95f /src/image | |
parent | b53317c6fa0d7b2f86e9d069bb49dc157f04120a (diff) |
Revert "SkBitmap now really stores SkImageInfo -- config is just a ruse"
BUG=skia:
Review URL: https://codereview.chromium.org/147733004
git-svn-id: http://skia.googlecode.com/svn/trunk@13395 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/image')
-rw-r--r-- | src/image/SkImagePriv.cpp | 38 | ||||
-rw-r--r-- | src/image/SkImagePriv.h | 2 |
2 files changed, 28 insertions, 12 deletions
diff --git a/src/image/SkImagePriv.cpp b/src/image/SkImagePriv.cpp index a044aad0a0..43cc44b2fa 100644 --- a/src/image/SkImagePriv.cpp +++ b/src/image/SkImagePriv.cpp @@ -37,19 +37,35 @@ SkBitmap::Config SkImageInfoToBitmapConfig(const SkImageInfo& info) { return SkColorTypeToBitmapConfig(info.fColorType); } -SkColorType SkBitmapConfigToColorType(SkBitmap::Config config) { - static const SkColorType gCT[] = { - kUnknown_SkColorType, // kNo_Config - kAlpha_8_SkColorType, // kA8_Config - kIndex_8_SkColorType, // kIndex8_Config - kRGB_565_SkColorType, // kRGB_565_Config - kARGB_4444_SkColorType, // kARGB_4444_Config - kPMColor_SkColorType, // kARGB_8888_Config - }; - SkASSERT((unsigned)config < SK_ARRAY_COUNT(gCT)); - return gCT[config]; +bool SkBitmapConfigToColorType(SkBitmap::Config config, SkColorType* ctOut) { + SkColorType ct; + switch (config) { + case SkBitmap::kA8_Config: + ct = kAlpha_8_SkColorType; + break; + case SkBitmap::kIndex8_Config: + ct = kIndex_8_SkColorType; + break; + case SkBitmap::kRGB_565_Config: + ct = kRGB_565_SkColorType; + break; + case SkBitmap::kARGB_4444_Config: + ct = kARGB_4444_SkColorType; + break; + case SkBitmap::kARGB_8888_Config: + ct = kPMColor_SkColorType; + break; + case SkBitmap::kNo_Config: + default: + return false; + } + if (ctOut) { + *ctOut = ct; + } + return true; } + SkImage* SkNewImageFromBitmap(const SkBitmap& bm, bool canSharePixelRef) { SkImageInfo info; if (!bm.asImageInfo(&info)) { diff --git a/src/image/SkImagePriv.h b/src/image/SkImagePriv.h index 8883e2c070..7c19c734c2 100644 --- a/src/image/SkImagePriv.h +++ b/src/image/SkImagePriv.h @@ -15,7 +15,7 @@ class SkPicture; extern SkBitmap::Config SkImageInfoToBitmapConfig(const SkImageInfo&); extern SkBitmap::Config SkColorTypeToBitmapConfig(SkColorType); -extern SkColorType SkBitmapConfigToColorType(SkBitmap::Config); +extern bool SkBitmapConfigToColorType(SkBitmap::Config, SkColorType* ctOut); // Call this if you explicitly want to use/share this pixelRef in the image extern SkImage* SkNewImageFromPixelRef(const SkImageInfo&, SkPixelRef*, |