use colortype instead of config
authorreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 20 Feb 2014 20:55:37 +0000 (20:55 +0000)
committerreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 20 Feb 2014 20:55:37 +0000 (20:55 +0000)
patch from issue 172063004

BUG=skia:
R=scroggo@google.com

Review URL: https://codereview.chromium.org/173893002

git-svn-id: http://skia.googlecode.com/svn/trunk@13520 2bbb7eff-a529-9590-31e7-b0007b416f81

18 files changed:
include/core/SkImageInfo.h
src/core/SkBitmapFilter.cpp
src/core/SkBitmapProcShader.cpp
src/core/SkBitmapScaler.cpp
src/core/SkBitmap_scroll.cpp
src/core/SkBlitter.cpp
src/core/SkBlitter_Sprite.cpp
src/core/SkCanvas.cpp
src/core/SkDevice.cpp
src/core/SkDraw.cpp
src/core/SkScaledImageCache.cpp
src/core/SkScalerContext.cpp
src/core/SkSpriteBlitter_ARGB32.cpp
src/core/SkSpriteBlitter_RGB16.cpp
src/device/xps/SkXPSDevice.cpp
src/lazy/SkDiscardablePixelRef.cpp
src/pdf/SkPDFDevice.cpp
src/utils/SkPictureUtils.cpp

index 2b449dc2132cf029ddfa2c6ec7b2991b532b5317..1c73d959af54d55852516ca369bd933591a22655 100644 (file)
@@ -165,6 +165,13 @@ struct SkImageInfo {
         return info;
     }
 
+    static SkImageInfo MakeUnknown(int width, int height) {
+        SkImageInfo info = {
+            width, height, kUnknown_SkColorType, kIgnore_SkAlphaType
+        };
+        return info;
+    }
+
     int width() const { return fWidth; }
     int height() const { return fHeight; }
     SkColorType colorType() const { return fColorType; }
index 7443cb61b7c9953faf8517e5973c395e7c0a3810..1653cbb20ec313b2287eca543339f1e8ec970a7d 100644 (file)
@@ -123,8 +123,8 @@ bool SkBitmapProcState::setBitmapFilterProcs() {
         return false;
     }
 
-    // TODO: consider supporting other configs (e.g. 565, A8)
-    if (fBitmap->config() != SkBitmap::kARGB_8888_Config) {
+    // TODO: consider supporting other colortypes (e.g. 565, A8)
+    if (fBitmap->colorType() != kPMColor_SkColorType) {
         return false;
     }
 
index d7c7269c894c9cc4398875df4038d0b9f9f7c853..74b9e86669eead31a270822791558e2b2c2c0adc 100644 (file)
 #endif
 
 bool SkBitmapProcShader::CanDo(const SkBitmap& bm, TileMode tx, TileMode ty) {
-    switch (bm.config()) {
-        case SkBitmap::kA8_Config:
-        case SkBitmap::kRGB_565_Config:
-        case SkBitmap::kIndex8_Config:
-        case SkBitmap::kARGB_8888_Config:
+    switch (bm.colorType()) {
+        case kAlpha_8_SkColorType:
+        case kRGB_565_SkColorType:
+        case kIndex_8_SkColorType:
+        case kPMColor_SkColorType:
     //        if (tx == ty && (kClamp_TileMode == tx || kRepeat_TileMode == tx))
                 return true;
         default:
@@ -88,7 +88,7 @@ static bool valid_for_drawing(const SkBitmap& bm) {
     if (NULL == bm.pixelRef()) {
         return false;   // no pixels to read
     }
-    if (SkBitmap::kIndex8_Config == bm.config()) {
+    if (kIndex_8_SkColorType == bm.colorType()) {
         // ugh, I have to lock-pixels to inspect the colortable
         SkAutoLockPixels alp(bm);
         if (!bm.getColorTable()) {
@@ -125,23 +125,23 @@ bool SkBitmapProcShader::setContext(const SkBitmap& device,
         flags |= kOpaqueAlpha_Flag;
     }
 
-    switch (bitmap.config()) {
-        case SkBitmap::kRGB_565_Config:
+    switch (bitmap.colorType()) {
+        case kRGB_565_SkColorType:
             flags |= (kHasSpan16_Flag | kIntrinsicly16_Flag);
             break;
-        case SkBitmap::kIndex8_Config:
-        case SkBitmap::kARGB_8888_Config:
+        case kIndex_8_SkColorType:
+        case kPMColor_SkColorType:
             if (bitmapIsOpaque) {
                 flags |= kHasSpan16_Flag;
             }
             break;
-        case SkBitmap::kA8_Config:
+        case kAlpha_8_SkColorType:
             break;  // never set kHasSpan16_Flag
         default:
             break;
     }
 
-    if (paint.isDither() && bitmap.config() != SkBitmap::kRGB_565_Config) {
+    if (paint.isDither() && bitmap.colorType() != kRGB_565_SkColorType) {
         // gradients can auto-dither in their 16bit sampler, but we don't so
         // we clear the flag here.
         flags &= ~kHasSpan16_Flag;
@@ -278,14 +278,14 @@ static bool canUseColorShader(const SkBitmap& bm, SkColor* color) {
         return false;
     }
 
-    switch (bm.config()) {
-        case SkBitmap::kARGB_8888_Config:
+    switch (bm.colorType()) {
+        case kPMColor_SkColorType:
             *color = SkUnPreMultiply::PMColorToColor(*bm.getAddr32(0, 0));
             return true;
-        case SkBitmap::kRGB_565_Config:
+        case kRGB_565_SkColorType:
             *color = SkPixel16ToColor(*bm.getAddr16(0, 0));
             return true;
-        case SkBitmap::kIndex8_Config:
+        case kIndex_8_SkColorType:
             *color = SkUnPreMultiply::PMColorToColor(bm.getIndex8Color(0, 0));
             return true;
         default: // just skip the other configs for now
index dc50464e54c837220811a2c55dc91bd321ab16a3..a90be05d634ba7491a1dca22bc8acc1423a85788 100644 (file)
@@ -275,7 +275,7 @@ bool SkBitmapScaler::Resize(SkBitmap* resultPtr,
 
     SkAutoLockPixels locker(source);
     if (!source.readyToDraw() ||
-        source.config() != SkBitmap::kARGB_8888_Config) {
+        source.colorType() != kPMColor_SkColorType) {
         return false;
     }
 
@@ -290,9 +290,9 @@ bool SkBitmapScaler::Resize(SkBitmap* resultPtr,
 
     // Convolve into the result.
     SkBitmap result;
-    result.setConfig(SkBitmap::kARGB_8888_Config,
-                     destSubset.width(), destSubset.height(), 0,
-                     source.alphaType());
+    result.setConfig(SkImageInfo::MakeN32(destSubset.width(),
+                                          destSubset.height(),
+                                          source.alphaType()));
     result.allocPixels(allocator, NULL);
     if (!result.readyToDraw()) {
         return false;
index e9c886f4a0e7c43d5a1762fdf6f514660adf87e1..00a72aa1cab983f5a9ad089bbca7298c2da2c445 100644 (file)
@@ -11,7 +11,7 @@
 bool SkBitmap::scrollRect(const SkIRect* subset, int dx, int dy,
                           SkRegion* inval) const
 {
-    if (this->isImmutable()) {
+    if (this->isImmutable() || kUnknown_SkColorType == this->colorType()) {
         return false;
     }
 
@@ -23,25 +23,7 @@ bool SkBitmap::scrollRect(const SkIRect* subset, int dx, int dy,
                 tmp.scrollRect(NULL, dx, dy, inval);
     }
 
-    int shift;
-
-    switch (this->config()) {
-    case kIndex8_Config:
-    case kA8_Config:
-        shift = 0;
-        break;
-    case kARGB_4444_Config:
-    case kRGB_565_Config:
-        shift = 1;
-        break;
-    case kARGB_8888_Config:
-        shift = 2;
-        break;
-    default:
-        // can't scroll this config
-        return false;
-    }
-
+    int shift = this->bytesPerPixel() >> 1;
     int width = this->width();
     int height = this->height();
 
index 31a3edea769a3f68de7e4978a2e8d36bfb870c49..98325c024501aad838387952cfffdf6fcac98d58 100644 (file)
@@ -812,7 +812,7 @@ enum XferInterp {
 };
 
 static XferInterp interpret_xfermode(const SkPaint& paint, SkXfermode* xfer,
-                                     SkBitmap::Config deviceConfig) {
+                                     SkColorType deviceCT) {
     SkXfermode::Mode  mode;
 
     if (SkXfermode::AsMode(xfer, &mode)) {
@@ -827,12 +827,12 @@ static XferInterp interpret_xfermode(const SkPaint& paint, SkXfermode* xfer,
             case SkXfermode::kSrcOver_Mode:
                 return kSrcOver_XferInterp;
             case SkXfermode::kDstOver_Mode:
-                if (SkBitmap::kRGB_565_Config == deviceConfig) {
+                if (kRGB_565_SkColorType == deviceCT) {
                     return kSkipDrawing_XferInterp;
                 }
                 break;
             case SkXfermode::kSrcIn_Mode:
-                if (SkBitmap::kRGB_565_Config == deviceConfig &&
+                if (kRGB_565_SkColorType == deviceCT &&
                     just_solid_color(paint)) {
                     return kSrcOver_XferInterp;
                 }
@@ -860,8 +860,8 @@ SkBlitter* SkBlitter::Choose(const SkBitmap& device,
 
     // which check, in case we're being called by a client with a dummy device
     // (e.g. they have a bounder that always aborts the draw)
-    if (SkBitmap::kNo_Config == device.config() ||
-            (drawCoverage && (SkBitmap::kA8_Config != device.config()))) {
+    if (kUnknown_SkColorType == device.colorType() ||
+            (drawCoverage && (kAlpha_8_SkColorType != device.colorType()))) {
         SK_PLACEMENT_NEW(blitter, SkNullBlitter, storage, storageSize);
         return blitter;
     }
@@ -882,7 +882,7 @@ SkBlitter* SkBlitter::Choose(const SkBitmap& device,
     }
 
     if (NULL != mode) {
-        switch (interpret_xfermode(*paint, mode, device.config())) {
+        switch (interpret_xfermode(*paint, mode, device.colorType())) {
             case kSrcOver_XferInterp:
                 mode = NULL;
                 paint.writable()->setXfermode(NULL);
@@ -945,8 +945,8 @@ SkBlitter* SkBlitter::Choose(const SkBitmap& device,
     }
 
 
-    switch (device.config()) {
-        case SkBitmap::kA8_Config:
+    switch (device.colorType()) {
+        case kAlpha_8_SkColorType:
             if (drawCoverage) {
                 SkASSERT(NULL == shader);
                 SkASSERT(NULL == paint->getXfermode());
@@ -961,11 +961,11 @@ SkBlitter* SkBlitter::Choose(const SkBitmap& device,
             }
             break;
 
-        case SkBitmap::kRGB_565_Config:
+        case kRGB_565_SkColorType:
             blitter = SkBlitter_ChooseD565(device, *paint, storage, storageSize);
             break;
 
-        case SkBitmap::kARGB_8888_Config:
+        case kPMColor_SkColorType:
             if (shader) {
                 SK_PLACEMENT_NEW_ARGS(blitter, SkARGB32_Shader_Blitter,
                                       storage, storageSize, (device, *paint));
index 9322e203967376fdb5b20654f5223c3fdc1ea1a7..86251ff59f501fe064c3c59f9208990970f82bb1 100644 (file)
@@ -66,12 +66,12 @@ SkBlitter* SkBlitter::ChooseSprite( const SkBitmap& device,
 
     SkSpriteBlitter* blitter;
 
-    switch (device.config()) {
-        case SkBitmap::kRGB_565_Config:
+    switch (device.colorType()) {
+        case kRGB_565_SkColorType:
             blitter = SkSpriteBlitter::ChooseD16(source, paint, storage,
                                                  storageSize);
             break;
-        case SkBitmap::kARGB_8888_Config:
+        case kPMColor_SkColorType:
             blitter = SkSpriteBlitter::ChooseD32(source, paint, storage,
                                                  storageSize);
             break;
index 4462b4cc2ad2308ca3fcab2a343084143f7f62eb..93dc14bd1e5e6700c7b2bef784255dc86b4fff90 100644 (file)
@@ -518,7 +518,7 @@ SkCanvas::SkCanvas(int width, int height)
     inc_canvas();
 
     SkBitmap bitmap;
-    bitmap.setConfig(SkBitmap::kNo_Config, width, height);
+    bitmap.setConfig(SkImageInfo::MakeUnknown(width, height));
     this->init(SkNEW_ARGS(SkBitmapDevice, (bitmap)))->unref();
 }
 
@@ -950,9 +950,7 @@ SkImageInfo SkCanvas::imageInfo() const {
     if (dev) {
         return dev->imageInfo();
     } else {
-        // TODO: need a real unknown for alphatype it seems.
-        SkAlphaType unknownAlphaType = kIgnore_SkAlphaType;
-        return SkImageInfo::Make(0, 0, kUnknown_SkColorType, unknownAlphaType);
+        return SkImageInfo::MakeUnknown(0, 0);
     }
 }
 
index d69e4afab2b6817c3642578247e609fbcf8f18ad..40663b2e039f93d00bbf71aaffd007147eb62434 100644 (file)
@@ -101,8 +101,7 @@ SkMetaData& SkBaseDevice::getMetaData() {
 
 // TODO: should make this guy pure-virtual.
 SkImageInfo SkBaseDevice::imageInfo() const {
-    return SkImageInfo::Make(this->width(), this->height(),
-                             kUnknown_SkColorType, kIgnore_SkAlphaType);
+    return SkImageInfo::MakeUnknown(this->width(), this->height());
 }
 
 const SkBitmap& SkBaseDevice::accessBitmap(bool changePixels) {
index 5f81073068b98a2467a492d7f078576057245bbf..175abb68440b34de7270c543c354fd9c273415b6 100644 (file)
@@ -200,20 +200,20 @@ static BitmapXferProc ChooseBitmapXferProc(const SkBitmap& bitmap,
                 should I worry about dithering for the lower depths?
             */
             SkPMColor pmc = SkPreMultiplyColor(color);
-            switch (bitmap.config()) {
-                case SkBitmap::kARGB_8888_Config:
+            switch (bitmap.colorType()) {
+                case kPMColor_SkColorType:
                     if (data) {
                         *data = pmc;
                     }
 //                    SkDebugf("--- D32_Src_BitmapXferProc\n");
                     return D32_Src_BitmapXferProc;
-                case SkBitmap::kRGB_565_Config:
+                case kRGB_565_SkColorType:
                     if (data) {
                         *data = SkPixel32ToPixel16(pmc);
                     }
 //                    SkDebugf("--- D16_Src_BitmapXferProc\n");
                     return D16_Src_BitmapXferProc;
-                case SkBitmap::kA8_Config:
+                case kAlpha_8_SkColorType:
                     if (data) {
                         *data = SkGetPackedA32(pmc);
                     }
@@ -233,14 +233,14 @@ static BitmapXferProc ChooseBitmapXferProc(const SkBitmap& bitmap,
 static void CallBitmapXferProc(const SkBitmap& bitmap, const SkIRect& rect,
                                BitmapXferProc proc, uint32_t procData) {
     int shiftPerPixel;
-    switch (bitmap.config()) {
-        case SkBitmap::kARGB_8888_Config:
+    switch (bitmap.colorType()) {
+        case kPMColor_SkColorType:
             shiftPerPixel = 2;
             break;
-        case SkBitmap::kRGB_565_Config:
+        case kRGB_565_SkColorType:
             shiftPerPixel = 1;
             break;
-        case SkBitmap::kA8_Config:
+        case kAlpha_8_SkColorType:
             shiftPerPixel = 0;
             break;
         default:
@@ -526,9 +526,9 @@ PtProcRec::Proc PtProcRec::chooseProc(SkBlitter** blitterPtr) {
             if (SkCanvas::kPoints_PointMode == fMode && fClip->isRect()) {
                 uint32_t value;
                 const SkBitmap* bm = blitter->justAnOpaqueColor(&value);
-                if (bm && SkBitmap::kRGB_565_Config == bm->config()) {
+                if (bm && kRGB_565_SkColorType == bm->colorType()) {
                     proc = bw_pt_rect_16_hair_proc;
-                } else if (bm && SkBitmap::kARGB_8888_Config == bm->config()) {
+                } else if (bm && kPMColor_SkColorType == bm->colorType()) {
                     proc = bw_pt_rect_32_hair_proc;
                 } else {
                     proc = bw_pt_rect_hair_proc;
@@ -1176,7 +1176,7 @@ static bool just_translate(const SkMatrix& matrix, const SkBitmap& bitmap) {
 
 void SkDraw::drawBitmapAsMask(const SkBitmap& bitmap,
                               const SkPaint& paint) const {
-    SkASSERT(bitmap.config() == SkBitmap::kA8_Config);
+    SkASSERT(bitmap.colorType() == kAlpha_8_SkColorType);
 
     if (just_translate(*fMatrix, bitmap)) {
         int ix = SkScalarRoundToInt(fMatrix->getTranslateX());
@@ -1284,7 +1284,7 @@ void SkDraw::drawBitmap(const SkBitmap& bitmap, const SkMatrix& prematrix,
     // nothing to draw
     if (fRC->isEmpty() ||
             bitmap.width() == 0 || bitmap.height() == 0 ||
-            bitmap.config() == SkBitmap::kNo_Config) {
+            bitmap.colorType() == kUnknown_SkColorType) {
         return;
     }
 
@@ -1310,7 +1310,7 @@ void SkDraw::drawBitmap(const SkBitmap& bitmap, const SkMatrix& prematrix,
         }
     }
 
-    if (bitmap.config() != SkBitmap::kA8_Config &&
+    if (bitmap.colorType() != kAlpha_8_SkColorType &&
             just_translate(matrix, bitmap)) {
         //
         // It is safe to call lock pixels now, since we know the matrix is
@@ -1343,7 +1343,7 @@ void SkDraw::drawBitmap(const SkBitmap& bitmap, const SkMatrix& prematrix,
     SkDraw draw(*this);
     draw.fMatrix = &matrix;
 
-    if (bitmap.config() == SkBitmap::kA8_Config) {
+    if (bitmap.colorType() == kAlpha_8_SkColorType) {
         draw.drawBitmapAsMask(bitmap, paint);
     } else {
         SkAutoBitmapShaderInstall install(bitmap, paint);
@@ -1363,7 +1363,7 @@ void SkDraw::drawSprite(const SkBitmap& bitmap, int x, int y,
     // nothing to draw
     if (fRC->isEmpty() ||
             bitmap.width() == 0 || bitmap.height() == 0 ||
-            bitmap.config() == SkBitmap::kNo_Config) {
+            bitmap.colorType() == kUnknown_SkColorType) {
         return;
     }
 
index 6a1264eb6a3393ac165af18ba954f1657c2d7d31..f0f34ccbf17533d5f019907343b7d13fb124d03c 100644 (file)
@@ -289,13 +289,12 @@ bool SkScaledImageCacheDiscardableAllocator::allocPixelRef(SkBitmap* bitmap,
         return false;
     }
 
-    // can relax when we have bitmap::asImageInfo
-    if (SkBitmap::kARGB_8888_Config != bitmap->config()) {
+    // can we relax this?
+    if (kPMColor_SkColorType != bitmap->colorType()) {
         return false;
     }
 
-    SkImageInfo info = SkImageInfo::MakeN32(bitmap->width(), bitmap->height(),
-                                            bitmap->alphaType());
+    SkImageInfo info = bitmap->info();
     bitmap->setPixelRef(SkNEW_ARGS(SkOneShotDiscardablePixelRef,
                                    (info, dm, bitmap->rowBytes())))->unref();
     bitmap->lockPixels();
index 1c148776674d6f39311ce8d52d9b478079e11eeb..d0d24eebe8c0f077404bc8b96630b7ddbd06ef1c 100644 (file)
@@ -428,7 +428,7 @@ static void pack4xHToLCD16(const SkBitmap& src, const SkMask& dst,
                            const SkMaskGamma::PreBlend& maskPreBlend) {
 #define SAMPLES_PER_PIXEL 4
 #define LCD_PER_PIXEL 3
-    SkASSERT(SkBitmap::kA8_Config == src.config());
+    SkASSERT(kAlpha_8_SkColorType == src.colorType());
     SkASSERT(SkMask::kLCD16_Format == dst.fFormat);
 
     const int sample_width = src.width();
@@ -502,7 +502,7 @@ static void pack4xHToLCD16(const SkBitmap& src, const SkMask& dst,
 template<bool APPLY_PREBLEND>
 static void pack4xHToLCD32(const SkBitmap& src, const SkMask& dst,
                            const SkMaskGamma::PreBlend& maskPreBlend) {
-    SkASSERT(SkBitmap::kA8_Config == src.config());
+    SkASSERT(kAlpha_8_SkColorType == src.colorType());
     SkASSERT(SkMask::kLCD32_Format == dst.fFormat);
 
     const int width = dst.fBounds.width();
index 8255336c6599ef8da5ecbf04c4d9d898cf745ee9..3e8612dda3e9e6cdace44dbfb8ff73877efe5e83 100644 (file)
@@ -20,7 +20,7 @@
 class Sprite_D32_S32 : public SkSpriteBlitter {
 public:
     Sprite_D32_S32(const SkBitmap& src, U8CPU alpha)  : INHERITED(src) {
-        SkASSERT(src.config() == SkBitmap::kARGB_8888_Config);
+        SkASSERT(src.colorType() == kPMColor_SkColorType);
 
         unsigned flags32 = 0;
         if (255 != alpha) {
@@ -277,8 +277,8 @@ SkSpriteBlitter* SkSpriteBlitter::ChooseD32(const SkBitmap& source,
     SkColorFilter* filter = paint.getColorFilter();
     SkSpriteBlitter* blitter = NULL;
 
-    switch (source.config()) {
-        case SkBitmap::kARGB_4444_Config:
+    switch (source.colorType()) {
+        case kARGB_4444_SkColorType:
             if (alpha != 0xFF) {
                 return NULL;    // we only have opaque sprites
             }
@@ -293,7 +293,7 @@ SkSpriteBlitter* SkSpriteBlitter::ChooseD32(const SkBitmap& source,
                                       storage, storageSize, (source));
             }
             break;
-        case SkBitmap::kARGB_8888_Config:
+        case kPMColor_SkColorType:
             if (xfermode || filter) {
                 if (255 == alpha) {
                     // this can handle xfermode or filter, but not alpha
index 2bce41e993b7dfe90f183e3f5a2e1b4b6d829ee0..7428c8a74a38b8cf525efbf7c73151eb4cb8a9f6 100644 (file)
@@ -324,12 +324,12 @@ SkSpriteBlitter* SkSpriteBlitter::ChooseD16(const SkBitmap& source,
     SkSpriteBlitter* blitter = NULL;
     unsigned alpha = paint.getAlpha();
 
-    switch (source.config()) {
-        case SkBitmap::kARGB_8888_Config:
+    switch (source.colorType()) {
+        case kPMColor_SkColorType:
             SK_PLACEMENT_NEW_ARGS(blitter, Sprite_D16_S32_BlitRowProc,
                                   storage, storageSize, (source));
             break;
-        case SkBitmap::kARGB_4444_Config:
+        case kARGB_4444_SkColorType:
             if (255 == alpha) {
                 SK_PLACEMENT_NEW_ARGS(blitter, Sprite_D16_S4444_Opaque,
                                       storage, storageSize, (source));
@@ -338,7 +338,7 @@ SkSpriteBlitter* SkSpriteBlitter::ChooseD16(const SkBitmap& source,
                                     storage, storageSize, (source, alpha >> 4));
             }
             break;
-        case SkBitmap::kRGB_565_Config:
+        case kRGB_565_SkColorType:
             if (255 == alpha) {
                 SK_PLACEMENT_NEW_ARGS(blitter, Sprite_D16_S16_Opaque,
                                       storage, storageSize, (source));
@@ -347,7 +347,7 @@ SkSpriteBlitter* SkSpriteBlitter::ChooseD16(const SkBitmap& source,
                                       storage, storageSize, (source, alpha));
             }
             break;
-        case SkBitmap::kIndex8_Config:
+        case kIndex_8_SkColorType:
             if (paint.isDither()) {
                 // we don't support dither yet in these special cases
                 break;
index 7b97d3f8b5285335a3b538a8096047ab4093ce91..f2901316c28d9dcdc42d573a0023933e1fabeb81 100644 (file)
@@ -106,10 +106,11 @@ static HRESULT create_id(wchar_t* buffer, size_t bufferSize,
 
 static SkBitmap make_fake_bitmap(int width, int height) {
     SkBitmap bitmap;
-    bitmap.setConfig(SkBitmap::kNo_Config, width, height);
+    bitmap.setConfig(SkImageInfo::MakeUnknown(width, height));
     return bitmap;
 }
 
+// TODO: should inherit from SkBaseDevice instead of SkBitmapDevice...
 SkXPSDevice::SkXPSDevice()
     : SkBitmapDevice(make_fake_bitmap(10000, 10000))
     , fCurrentPage(0) {
index 0878d00335d09e7fb7da12c64d2c0a7c02ed1ce2..56b94b734e310d12e9febd22d15177453cc42801 100644 (file)
@@ -87,7 +87,7 @@ bool SkInstallDiscardablePixelRef(SkImageGenerator* generator,
         || (!dst->setConfig(info, 0))) {
         return false;
     }
-    SkASSERT(dst->config() != SkBitmap::kNo_Config);
+    SkASSERT(dst->colorType() != kUnknown_SkColorType);
     if (dst->empty()) {  // Use a normal pixelref.
         return dst->allocPixels();
     }
index a7ef08d21d56c22c8f20490896b1f6b9ac35b3de..ff3878b803189d336541230425c87c847b0be631 100644 (file)
@@ -704,7 +704,7 @@ private:
 
 static inline SkBitmap makeContentBitmap(const SkISize& contentSize,
                                          const SkMatrix* initialTransform) {
-    SkBitmap bitmap;
+    SkImageInfo info;
     if (initialTransform) {
         // Compute the size of the drawing area.
         SkVector drawingSize;
@@ -718,17 +718,19 @@ static inline SkBitmap makeContentBitmap(const SkISize& contentSize,
         }
         inverse.mapVectors(&drawingSize, 1);
         SkISize size = SkSize::Make(drawingSize.fX, drawingSize.fY).toRound();
-        bitmap.setConfig(SkBitmap::kNo_Config, abs(size.fWidth),
-                         abs(size.fHeight));
+        info = SkImageInfo::MakeUnknown(abs(size.fWidth), abs(size.fHeight));
     } else {
-        bitmap.setConfig(SkBitmap::kNo_Config, abs(contentSize.fWidth),
-                         abs(contentSize.fHeight));
+        info = SkImageInfo::MakeUnknown(abs(contentSize.fWidth),
+                                        abs(contentSize.fHeight));
     }
 
+    SkBitmap bitmap;
+    bitmap.setConfig(info);
     return bitmap;
 }
 
 // TODO(vandebo) change pageSize to SkSize.
+// TODO: inherit from SkBaseDevice instead of SkBitmapDevice
 SkPDFDevice::SkPDFDevice(const SkISize& pageSize, const SkISize& contentSize,
                          const SkMatrix& initialTransform)
     : SkBitmapDevice(makeContentBitmap(contentSize, &initialTransform)),
index a7ec7aea0ed634b037fa01acd4b0862467874b44..cda64052c35b51dada77d8a8ac9a8e07ee0bd8c5 100644 (file)
@@ -54,7 +54,7 @@ public:
 
     GatherPixelRefDevice(int width, int height, PixelRefSet* prset) {
         fSize.set(width, height);
-        fEmptyBitmap.setConfig(SkBitmap::kNo_Config, width, height);
+        fEmptyBitmap.setConfig(SkImageInfo::MakeUnknown(width, height));
         fPRSet = prset;
     }