store SkAlphaType inside SkBitmap, on road to support unpremul
BUG=
R=bsalomon@google.com, scroggo@google.com
Review URL: https://codereview.chromium.org/25275004
git-svn-id: http://skia.googlecode.com/svn/trunk@11877 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/image/SkSurface_Raster.cpp b/src/image/SkSurface_Raster.cpp
index ccfdd27..5beabf7 100644
--- a/src/image/SkSurface_Raster.cpp
+++ b/src/image/SkSurface_Raster.cpp
@@ -39,8 +39,7 @@
bool SkSurface_Raster::Valid(const SkImage::Info& info, size_t rowBytes) {
static const size_t kMaxTotalSize = SK_MaxS32;
- bool isOpaque;
- SkBitmap::Config config = SkImageInfoToBitmapConfig(info, &isOpaque);
+ SkBitmap::Config config = SkImageInfoToBitmapConfig(info);
int shift = 0;
switch (config) {
@@ -83,26 +82,20 @@
SkSurface_Raster::SkSurface_Raster(const SkImage::Info& info, void* pixels, size_t rb)
: INHERITED(info.fWidth, info.fHeight) {
- bool isOpaque;
- SkBitmap::Config config = SkImageInfoToBitmapConfig(info, &isOpaque);
-
- fBitmap.setConfig(config, info.fWidth, info.fHeight, rb);
+ SkBitmap::Config config = SkImageInfoToBitmapConfig(info);
+ fBitmap.setConfig(config, info.fWidth, info.fHeight, rb, info.fAlphaType);
fBitmap.setPixels(pixels);
- fBitmap.setIsOpaque(isOpaque);
fWeOwnThePixels = false; // We are "Direct"
}
SkSurface_Raster::SkSurface_Raster(const SkImage::Info& info, SkPixelRef* pr, size_t rb)
: INHERITED(info.fWidth, info.fHeight) {
- bool isOpaque;
- SkBitmap::Config config = SkImageInfoToBitmapConfig(info, &isOpaque);
-
- fBitmap.setConfig(config, info.fWidth, info.fHeight, rb);
+ SkBitmap::Config config = SkImageInfoToBitmapConfig(info);
+ fBitmap.setConfig(config, info.fWidth, info.fHeight, rb, info.fAlphaType);
fBitmap.setPixelRef(pr);
- fBitmap.setIsOpaque(isOpaque);
fWeOwnThePixels = true;
- if (!isOpaque) {
+ if (!SkAlphaTypeIsOpaque(info.fAlphaType)) {
fBitmap.eraseColor(SK_ColorTRANSPARENT);
}
}