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

Unified Diff: src/image/SkImagePriv.cpp

Issue 108663004: make info real in SkPixelRef, and add bitmap::asImageInfo (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years 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 f1916c6c1cf91e2649778da58b7935e58f6ff26c..1e24c48c5b38aa320ec139e7957fb6de2fdaceb5 100644
--- a/src/image/SkImagePriv.cpp
+++ b/src/image/SkImagePriv.cpp
@@ -14,13 +14,16 @@ SkBitmap::Config SkImageInfoToBitmapConfig(const SkImageInfo& info) {
case kAlpha_8_SkColorType:
return SkBitmap::kA8_Config;
+ case kARGB_4444_SkColorType:
+ return SkBitmap::kARGB_4444_Config;
+
case kRGB_565_SkColorType:
return SkBitmap::kRGB_565_Config;
-
+
case kPMColor_SkColorType:
return SkBitmap::kARGB_8888_Config;
- case kIndex8_SkColorType:
+ case kIndex_8_SkColorType:
return SkBitmap::kIndex8_Config;
default:
@@ -30,52 +33,9 @@ SkBitmap::Config SkImageInfoToBitmapConfig(const SkImageInfo& info) {
return SkBitmap::kNo_Config;
}
-int SkImageBytesPerPixel(SkColorType ct) {
- static const uint8_t gColorTypeBytesPerPixel[] = {
- 1, // kAlpha_8_SkColorType
- 2, // kRGB_565_SkColorType
- 4, // kRGBA_8888_SkColorType
- 4, // kBGRA_8888_SkColorType
- 4, // kPMColor_SkColorType
- 1, // kIndex8_SkColorType
- };
-
- SkASSERT((size_t)ct < SK_ARRAY_COUNT(gColorTypeBytesPerPixel));
- return gColorTypeBytesPerPixel[ct];
-}
-
-bool SkBitmapToImageInfo(const SkBitmap& bm, SkImageInfo* info) {
- switch (bm.config()) {
- case SkBitmap::kA8_Config:
- info->fColorType = kAlpha_8_SkColorType;
- break;
-
- case SkBitmap::kIndex8_Config:
- info->fColorType = kIndex8_SkColorType;
- break;
-
- case SkBitmap::kRGB_565_Config:
- info->fColorType = kRGB_565_SkColorType;
- break;
-
- case SkBitmap::kARGB_8888_Config:
- info->fColorType = kPMColor_SkColorType;
- break;
-
- default:
- return false;
- }
-
- info->fWidth = bm.width();
- info->fHeight = bm.height();
- info->fAlphaType = bm.isOpaque() ? kOpaque_SkAlphaType :
- kPremul_SkAlphaType;
- return true;
-}
-
SkImage* SkNewImageFromBitmap(const SkBitmap& bm, bool canSharePixelRef) {
SkImageInfo info;
- if (!SkBitmapToImageInfo(bm, &info)) {
+ if (!bm.asImageInfo(&info)) {
return NULL;
}
« 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