Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(344)

Unified Diff: src/image/SkImagePriv.cpp

Issue 147733004: Revert "SkBitmap now really stores SkImageInfo -- config is just a ruse" (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/image/SkImagePriv.h ('k') | src/images/SkDecodingImageGenerator.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/image/SkImagePriv.cpp
diff --git a/src/image/SkImagePriv.cpp b/src/image/SkImagePriv.cpp
index a044aad0a0da343ca3eed7d301500d3c3c808da6..43cc44b2fa25aa5762611e3bfcf39e467f2e29f8 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)) {
« no previous file with comments | « src/image/SkImagePriv.h ('k') | src/images/SkDecodingImageGenerator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698