stop using SkBitmap::Config

R=scroggo@google.com

Author: reed@chromium.org

Review URL: https://codereview.chromium.org/338493005
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 11a79db..72b0737 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1376,7 +1376,7 @@
     // the rest from the SkPaint.
     GrPaint grPaint;
     grPaint.addColorEffect(effect);
-    bool alphaOnly = !(SkBitmap::kA8_Config == bitmap.config());
+    bool alphaOnly = !(kAlpha_8_SkColorType == bitmap.colorType());
     GrColor grColor = (alphaOnly) ? SkColor2GrColorJustAlpha(paint.getColor()) :
                                     SkColor2GrColor(paint.getColor());
     SkPaint2GrPaintNoShader(this->context(), paint, grColor, false, &grPaint);
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index c4720b5..34e5d0f 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -32,7 +32,7 @@
  as the colortable.count says it is.
  */
 static void build_compressed_data(void* buffer, const SkBitmap& bitmap) {
-    SkASSERT(SkBitmap::kIndex8_Config == bitmap.config());
+    SkASSERT(kIndex_8_SkColorType == bitmap.colorType());
 
     SkAutoLockPixels alp(bitmap);
     if (!bitmap.readyToDraw()) {
@@ -203,7 +203,7 @@
     GrTextureDesc desc;
     generate_bitmap_texture_desc(*bitmap, &desc);
 
-    if (SkBitmap::kIndex8_Config == bitmap->config()) {
+    if (kIndex_8_SkColorType == bitmap->colorType()) {
         // build_compressed_data doesn't do npot->pot expansion
         // and paletted textures can't be sub-updated
         if (ctx->supportsIndex8PixelConfig(params, bitmap->width(), bitmap->height())) {
diff --git a/src/images/SkImageDecoder.cpp b/src/images/SkImageDecoder.cpp
index 3c6ff69..b124187 100644
--- a/src/images/SkImageDecoder.cpp
+++ b/src/images/SkImageDecoder.cpp
@@ -209,7 +209,7 @@
                                 int srcX, int srcY) {
     int w = width / sampleSize;
     int h = height / sampleSize;
-    if (src->config() == SkBitmap::kIndex8_Config) {
+    if (src->colorType() == kIndex_8_SkColorType) {
         // kIndex8 does not allow drawing via an SkCanvas, as is done below.
         // Instead, use extractSubset. Note that this shares the SkPixelRef and
         // SkColorTable.
diff --git a/src/images/SkImageDecoder_libgif.cpp b/src/images/SkImageDecoder_libgif.cpp
index 7b6a474..0c8461f 100644
--- a/src/images/SkImageDecoder_libgif.cpp
+++ b/src/images/SkImageDecoder_libgif.cpp
@@ -192,7 +192,7 @@
  *  fixes it.  This makes the output image consistantly deterministic.
  */
 static void sanitize_indexed_bitmap(SkBitmap* bm) {
-    if ((SkBitmap::kIndex8_Config == bm->config()) && !(bm->empty())) {
+    if ((kIndex_8_SkColorType == bm->colorType()) && !(bm->empty())) {
         SkAutoLockPixels alp(*bm);
         if (NULL != bm->getPixels()) {
             SkColorTable* ct = bm->getColorTable();  // Index8 must have it.
diff --git a/src/images/SkImageDecoder_libpng.cpp b/src/images/SkImageDecoder_libpng.cpp
index 9c911e2..7ff1558 100644
--- a/src/images/SkImageDecoder_libpng.cpp
+++ b/src/images/SkImageDecoder_libpng.cpp
@@ -100,8 +100,8 @@
     bool decodePalette(png_structp png_ptr, png_infop info_ptr,
                        bool * SK_RESTRICT hasAlphap, bool *reallyHasAlphap,
                        SkColorTable **colorTablep);
-    bool getBitmapConfig(png_structp, png_infop, SkColorType*, bool* hasAlpha,
-                         SkPMColor* theTranspColor);
+    bool getBitmapColorType(png_structp, png_infop, SkColorType*, bool* hasAlpha,
+                            SkPMColor* theTranspColor);
 
     typedef SkImageDecoder INHERITED;
 };
@@ -166,7 +166,7 @@
 }
 
 static bool substituteTranspColor(SkBitmap* bm, SkPMColor match) {
-    SkASSERT(bm->config() == SkBitmap::kARGB_8888_Config);
+    SkASSERT(bm->colorType() == kN32_SkColorType);
 
     bool reallyHasAlpha = false;
 
@@ -321,7 +321,7 @@
     bool                hasAlpha = false;
     SkPMColor           theTranspColor = 0; // 0 tells us not to try to match
 
-    if (!this->getBitmapConfig(png_ptr, info_ptr, &colorType, &hasAlpha, &theTranspColor)) {
+    if (!this->getBitmapColorType(png_ptr, info_ptr, &colorType, &hasAlpha, &theTranspColor)) {
         return false;
     }
 
@@ -462,14 +462,14 @@
         reallyHasAlpha |= substituteTranspColor(decodedBitmap, theTranspColor);
     }
     if (reallyHasAlpha && this->getRequireUnpremultipliedColors()) {
-        switch (decodedBitmap->config()) {
-            case SkBitmap::kIndex8_Config:
+        switch (decodedBitmap->colorType()) {
+            case kIndex_8_SkColorType:
                 // Fall through.
-            case SkBitmap::kARGB_4444_Config:
-                // We have chosen not to support unpremul for these configs.
+            case kARGB_4444_SkColorType:
+                // We have chosen not to support unpremul for these colortypes.
                 return false;
             default: {
-                // Fall through to finish the decode. This config either
+                // Fall through to finish the decode. This colortype either
                 // supports unpremul or it is irrelevant because it has no
                 // alpha (or only alpha).
                 // These brackets prevent a warning.
@@ -485,10 +485,10 @@
 
 
 
-bool SkPNGImageDecoder::getBitmapConfig(png_structp png_ptr, png_infop info_ptr,
-                                        SkColorType* colorTypep,
-                                        bool* hasAlphap,
-                                        SkPMColor* SK_RESTRICT theTranspColorp) {
+bool SkPNGImageDecoder::getBitmapColorType(png_structp png_ptr, png_infop info_ptr,
+                                           SkColorType* colorTypep,
+                                           bool* hasAlphap,
+                                           SkPMColor* SK_RESTRICT theTranspColorp) {
     png_uint_32 origWidth, origHeight;
     int bitDepth, colorType;
     png_get_IHDR(png_ptr, info_ptr, &origWidth, &origHeight, &bitDepth,
@@ -513,7 +513,7 @@
     if (colorType == PNG_COLOR_TYPE_PALETTE) {
         bool paletteHasAlpha = hasTransparencyInPalette(png_ptr, info_ptr);
         *colorTypep = this->getPrefColorType(kIndex_SrcDepth, paletteHasAlpha);
-        // now see if we can upscale to their requested config
+        // now see if we can upscale to their requested colortype
         if (!canUpscalePaletteToConfig(*colorTypep, paletteHasAlpha)) {
             *colorTypep = kIndex_8_SkColorType;
         }
@@ -614,7 +614,7 @@
 #endif
 
     // If the image has alpha and the decoder wants unpremultiplied
-    // colors, the only supported config is 8888.
+    // colors, the only supported colortype is 8888.
     if (this->getRequireUnpremultipliedColors() && *hasAlphap) {
         *colorTypep = kN32_SkColorType;
     }
@@ -622,7 +622,7 @@
     if (fImageIndex != NULL) {
         if (kUnknown_SkColorType == fImageIndex->fColorType) {
             // This is the first time for this subset decode. From now on,
-            // all decodes must be in the same config.
+            // all decodes must be in the same colortype.
             fImageIndex->fColorType = *colorTypep;
         } else if (fImageIndex->fColorType != *colorTypep) {
             // Requesting a different colortype for a subsequent decode is not
@@ -685,7 +685,7 @@
     int transLessThanFF = 0;
 
     // Choose which function to use to create the color table. If the final destination's
-    // config is unpremultiplied, the color table will store unpremultiplied colors.
+    // colortype is unpremultiplied, the color table will store unpremultiplied colors.
     PackColorProc proc;
     if (this->getRequireUnpremultipliedColors()) {
         proc = &SkPackARGB32NoCheck;
@@ -785,7 +785,7 @@
     bool                hasAlpha = false;
     SkPMColor           theTranspColor = 0; // 0 tells us not to try to match
 
-    if (!this->getBitmapConfig(png_ptr, info_ptr, &colorType, &hasAlpha, &theTranspColor)) {
+    if (!this->getBitmapColorType(png_ptr, info_ptr, &colorType, &hasAlpha, &theTranspColor)) {
         return false;
     }
 
@@ -998,29 +998,28 @@
     }
 }
 
-static transform_scanline_proc choose_proc(SkBitmap::Config config,
-                                           bool hasAlpha) {
+static transform_scanline_proc choose_proc(SkColorType ct, bool hasAlpha) {
     // we don't care about search on alpha if we're kIndex8, since only the
     // colortable packing cares about that distinction, not the pixels
-    if (SkBitmap::kIndex8_Config == config) {
+    if (kIndex_8_SkColorType == ct) {
         hasAlpha = false;   // we store false in the table entries for kIndex8
     }
 
     static const struct {
-        SkBitmap::Config        fConfig;
+        SkColorType             fColorType;
         bool                    fHasAlpha;
         transform_scanline_proc fProc;
     } gMap[] = {
-        { SkBitmap::kRGB_565_Config,    false,  transform_scanline_565 },
-        { SkBitmap::kARGB_8888_Config,  false,  transform_scanline_888 },
-        { SkBitmap::kARGB_8888_Config,  true,   transform_scanline_8888 },
-        { SkBitmap::kARGB_4444_Config,  false,  transform_scanline_444 },
-        { SkBitmap::kARGB_4444_Config,  true,   transform_scanline_4444 },
-        { SkBitmap::kIndex8_Config,     false,  transform_scanline_memcpy },
+        { kRGB_565_SkColorType,     false,  transform_scanline_565 },
+        { kN32_SkColorType,         false,  transform_scanline_888 },
+        { kN32_SkColorType,         true,   transform_scanline_8888 },
+        { kARGB_4444_SkColorType,   false,  transform_scanline_444 },
+        { kARGB_4444_SkColorType,   true,   transform_scanline_4444 },
+        { kIndex_8_SkColorType,     false,  transform_scanline_memcpy },
     };
 
     for (int i = SK_ARRAY_COUNT(gMap) - 1; i >= 0; --i) {
-        if (gMap[i].fConfig == config && gMap[i].fHasAlpha == hasAlpha) {
+        if (gMap[i].fColorType == ct && gMap[i].fHasAlpha == hasAlpha) {
             return gMap[i].fProc;
         }
     }
@@ -1107,38 +1106,37 @@
 private:
     bool doEncode(SkWStream* stream, const SkBitmap& bm,
                   const bool& hasAlpha, int colorType,
-                  int bitDepth, SkBitmap::Config config,
+                  int bitDepth, SkColorType ct,
                   png_color_8& sig_bit);
 
     typedef SkImageEncoder INHERITED;
 };
 
-bool SkPNGImageEncoder::onEncode(SkWStream* stream, const SkBitmap& bitmap,
-                                 int /*quality*/) {
-    SkBitmap::Config config = bitmap.config();
+bool SkPNGImageEncoder::onEncode(SkWStream* stream, const SkBitmap& bitmap, int /*quality*/) {
+    SkColorType ct = bitmap.colorType();
 
     const bool hasAlpha = !bitmap.isOpaque();
     int colorType = PNG_COLOR_MASK_COLOR;
     int bitDepth = 8;   // default for color
     png_color_8 sig_bit;
 
-    switch (config) {
-        case SkBitmap::kIndex8_Config:
+    switch (ct) {
+        case kIndex_8_SkColorType:
             colorType |= PNG_COLOR_MASK_PALETTE;
             // fall through to the ARGB_8888 case
-        case SkBitmap::kARGB_8888_Config:
+        case kN32_SkColorType:
             sig_bit.red = 8;
             sig_bit.green = 8;
             sig_bit.blue = 8;
             sig_bit.alpha = 8;
             break;
-        case SkBitmap::kARGB_4444_Config:
+        case kARGB_4444_SkColorType:
             sig_bit.red = 4;
             sig_bit.green = 4;
             sig_bit.blue = 4;
             sig_bit.alpha = 4;
             break;
-        case SkBitmap::kRGB_565_Config:
+        case kRGB_565_SkColorType:
             sig_bit.red = 5;
             sig_bit.green = 6;
             sig_bit.blue = 5;
@@ -1173,13 +1171,12 @@
         bitDepth = computeBitDepth(ctable->count());
     }
 
-    return doEncode(stream, bitmap, hasAlpha, colorType,
-                    bitDepth, config, sig_bit);
+    return doEncode(stream, bitmap, hasAlpha, colorType, bitDepth, ct, sig_bit);
 }
 
 bool SkPNGImageEncoder::doEncode(SkWStream* stream, const SkBitmap& bitmap,
                   const bool& hasAlpha, int colorType,
-                  int bitDepth, SkBitmap::Config config,
+                  int bitDepth, SkColorType ct,
                   png_color_8& sig_bit) {
 
     png_structp png_ptr;
@@ -1224,7 +1221,7 @@
     // set our colortable/trans arrays if needed
     png_color paletteColors[256];
     png_byte trans[256];
-    if (SkBitmap::kIndex8_Config == config) {
+    if (kIndex_8_SkColorType == ct) {
         SkColorTable* ct = bitmap.getColorTable();
         int numTrans = pack_palette(ct, paletteColors, trans, hasAlpha);
         png_set_PLTE(png_ptr, info_ptr, paletteColors, ct->count());
@@ -1239,7 +1236,7 @@
     const char* srcImage = (const char*)bitmap.getPixels();
     SkAutoSMalloc<1024> rowStorage(bitmap.width() << 2);
     char* storage = (char*)rowStorage.get();
-    transform_scanline_proc proc = choose_proc(config, hasAlpha);
+    transform_scanline_proc proc = choose_proc(ct, hasAlpha);
 
     for (int y = 0; y < bitmap.height(); y++) {
         png_bytep row_ptr = (png_bytep)storage;
diff --git a/src/images/SkImageDecoder_libwebp.cpp b/src/images/SkImageDecoder_libwebp.cpp
index 7a3c658..f7cfa8b 100644
--- a/src/images/SkImageDecoder_libwebp.cpp
+++ b/src/images/SkImageDecoder_libwebp.cpp
@@ -169,9 +169,9 @@
 
 static WEBP_CSP_MODE webp_decode_mode(const SkBitmap* decodedBitmap, bool premultiply) {
     WEBP_CSP_MODE mode = MODE_LAST;
-    SkBitmap::Config config = decodedBitmap->config();
+    const SkColorType ct = decodedBitmap->colorType();
 
-    if (config == SkBitmap::kARGB_8888_Config) {
+    if (ct == kN32_SkColorType) {
         #if SK_PMCOLOR_BYTE_ORDER(B,G,R,A)
             mode = premultiply ? MODE_bgrA : MODE_BGRA;
         #elif SK_PMCOLOR_BYTE_ORDER(R,G,B,A)
@@ -179,9 +179,9 @@
         #else
             #error "Skia uses BGRA or RGBA byte order"
         #endif
-    } else if (config == SkBitmap::kARGB_4444_Config) {
+    } else if (ct == kARGB_4444_SkColorType) {
         mode = premultiply ? MODE_rgbA_4444 : MODE_RGBA_4444;
-    } else if (config == SkBitmap::kRGB_565_Config) {
+    } else if (ct == kRGB_565_SkColorType) {
         mode = MODE_RGB_565;
     }
     SkASSERT(MODE_LAST != mode);
@@ -333,10 +333,8 @@
 }
 
 static bool is_config_compatible(const SkBitmap& bitmap) {
-    SkBitmap::Config config = bitmap.config();
-    return config == SkBitmap::kARGB_4444_Config ||
-           config == SkBitmap::kRGB_565_Config ||
-           config == SkBitmap::kARGB_8888_Config;
+    const SkColorType ct = bitmap.colorType();
+    return ct == kARGB_4444_SkColorType || ct == kRGB_565_SkColorType || ct == kN32_SkColorType;
 }
 
 bool SkWEBPImageDecoder::onDecodeSubset(SkBitmap* decodedBitmap,
@@ -556,11 +554,9 @@
   }
 }
 
-static ScanlineImporter ChooseImporter(const SkBitmap::Config& config,
-                                       bool  hasAlpha,
-                                       int*  bpp) {
-    switch (config) {
-        case SkBitmap::kARGB_8888_Config:
+static ScanlineImporter ChooseImporter(SkColorType ct, bool  hasAlpha, int*  bpp) {
+    switch (ct) {
+        case kN32_SkColorType:
             if (hasAlpha) {
                 *bpp = 4;
                 return ARGB_8888_To_RGBA;
@@ -568,7 +564,7 @@
                 *bpp = 3;
                 return ARGB_8888_To_RGB;
             }
-        case SkBitmap::kARGB_4444_Config:
+        case kARGB_4444_SkColorType:
             if (hasAlpha) {
                 *bpp = 4;
                 return ARGB_4444_To_RGBA;
@@ -576,10 +572,10 @@
                 *bpp = 3;
                 return ARGB_4444_To_RGB;
             }
-        case SkBitmap::kRGB_565_Config:
+        case kRGB_565_SkColorType:
             *bpp = 3;
             return RGB_565_To_RGB;
-        case SkBitmap::kIndex8_Config:
+        case kIndex_8_SkColorType:
             *bpp = 3;
             return Index8_To_RGB;
         default:
@@ -603,11 +599,9 @@
 
 bool SkWEBPImageEncoder::onEncode(SkWStream* stream, const SkBitmap& bm,
                                   int quality) {
-    const SkBitmap::Config config = bm.config();
     const bool hasAlpha = !bm.isOpaque();
     int bpp = -1;
-    const ScanlineImporter scanline_import = ChooseImporter(config, hasAlpha,
-                                                            &bpp);
+    const ScanlineImporter scanline_import = ChooseImporter(bm.colorType(), hasAlpha, &bpp);
     if (NULL == scanline_import) {
         return false;
     }
diff --git a/src/images/SkImageEncoder_argb.cpp b/src/images/SkImageEncoder_argb.cpp
index 97b741b..296491e 100644
--- a/src/images/SkImageEncoder_argb.cpp
+++ b/src/images/SkImageEncoder_argb.cpp
@@ -71,15 +71,15 @@
   }
 }
 
-static ScanlineImporter ChooseImporter(const SkBitmap::Config& config) {
-    switch (config) {
-        case SkBitmap::kARGB_8888_Config:
+static ScanlineImporter ChooseImporter(SkColorType ct) {
+    switch (ct) {
+        case kN32_SkColorType:
             return ARGB_8888_To_ARGB;
-        case SkBitmap::kRGB_565_Config:
+        case kRGB_565_SkColorType:
             return RGB_565_To_ARGB;
-        case SkBitmap::kARGB_4444_Config:
+        case kARGB_4444_SkColorType:
             return ARGB_4444_To_ARGB;
-        case SkBitmap::kIndex8_Config:
+        case kIndex_8_SkColorType:
             return Index8_To_ARGB;
         default:
             return NULL;
@@ -87,8 +87,7 @@
 }
 
 bool SkARGBImageEncoder::onEncode(SkWStream* stream, const SkBitmap& bitmap, int) {
-    const SkBitmap::Config config = bitmap.config();
-    const ScanlineImporter scanline_import = ChooseImporter(config);
+    const ScanlineImporter scanline_import = ChooseImporter(bitmap.colorType());
     if (NULL == scanline_import) {
         return false;
     }
diff --git a/src/images/SkScaledBitmapSampler.cpp b/src/images/SkScaledBitmapSampler.cpp
index 7fd8718..d78502d 100644
--- a/src/images/SkScaledBitmapSampler.cpp
+++ b/src/images/SkScaledBitmapSampler.cpp
@@ -696,20 +696,20 @@
             return false;
     }
 
-    switch (dst->config()) {
-        case SkBitmap::kARGB_8888_Config:
+    switch (dst->colorType()) {
+        case kN32_SkColorType:
             index += 0 * gProcDstConfigSpan;
             break;
-        case SkBitmap::kRGB_565_Config:
+        case kRGB_565_SkColorType:
             index += 1 * gProcDstConfigSpan;
             break;
-        case SkBitmap::kARGB_4444_Config:
+        case kARGB_4444_SkColorType:
             index += 2 * gProcDstConfigSpan;
             break;
-        case SkBitmap::kIndex8_Config:
+        case kIndex_8_SkColorType:
             index += 3 * gProcDstConfigSpan;
             break;
-        case SkBitmap::kA8_Config:
+        case kAlpha_8_SkColorType:
             index += 4 * gProcDstConfigSpan;
             break;
         default:
diff --git a/src/utils/SkTextureCompressor.cpp b/src/utils/SkTextureCompressor.cpp
index 5ef1ae3..fb41928 100644
--- a/src/utils/SkTextureCompressor.cpp
+++ b/src/utils/SkTextureCompressor.cpp
@@ -197,7 +197,7 @@
     memset(kProcMap, 0, sizeof(kProcMap));
 
     // Map available bitmap configs to compression functions
-    kProcMap[SkBitmap::kA8_Config][kLATC_Format] = compress_a8_to_latc;
+    kProcMap[kAlpha_8_SkColorType][kLATC_Format] = compress_a8_to_latc;
 
     CompressBitmapProc proc = kProcMap[bitmap.colorType()][format];
     if (NULL != proc) {