replace setConfig+allocPixels with alloc-or-install-pixels

BUG=skia:
R=scroggo@google.com, halcanary@google.com, reed@google.com

Author: reed@chromium.org

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

git-svn-id: http://skia.googlecode.com/svn/trunk@13442 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tests/AAClipTest.cpp b/tests/AAClipTest.cpp
index 961d57a..cadd180 100644
--- a/tests/AAClipTest.cpp
+++ b/tests/AAClipTest.cpp
@@ -71,10 +71,12 @@
     mask->fImage = SkMask::AllocImage(mask->computeImageSize());
     sk_bzero(mask->fImage, mask->computeImageSize());
 
+    SkImageInfo info = SkImageInfo::Make(mask->fBounds.width(),
+                                         mask->fBounds.height(),
+                                         kAlpha_8_SkColorType,
+                                         kPremul_SkAlphaType);
     SkBitmap bitmap;
-    bitmap.setConfig(SkBitmap::kA8_Config, mask->fBounds.width(),
-                     mask->fBounds.height(), mask->fRowBytes);
-    bitmap.setPixels(mask->fImage);
+    bitmap.installPixels(info, mask->fImage, mask->fRowBytes, NULL, NULL);
 
     // canvas expects its coordinate system to always be 0,0 in the top/left
     // so we translate the rgn to match that before drawing into the mask.
diff --git a/tests/AnnotationTest.cpp b/tests/AnnotationTest.cpp
index 3d14664..274d53e 100644
--- a/tests/AnnotationTest.cpp
+++ b/tests/AnnotationTest.cpp
@@ -26,8 +26,7 @@
 
 DEF_TEST(Annotation_NoDraw, reporter) {
     SkBitmap bm;
-    bm.setConfig(SkBitmap::kARGB_8888_Config, 10, 10);
-    bm.allocPixels();
+    bm.allocN32Pixels(10, 10);
     bm.eraseColor(SK_ColorTRANSPARENT);
 
     SkCanvas canvas(bm);
diff --git a/tests/BitmapHeapTest.cpp b/tests/BitmapHeapTest.cpp
index da41f47..c6144b7 100644
--- a/tests/BitmapHeapTest.cpp
+++ b/tests/BitmapHeapTest.cpp
@@ -33,8 +33,7 @@
 DEF_TEST(BitmapHeap, reporter) {
     // Create a bitmap shader.
     SkBitmap bm;
-    bm.setConfig(SkBitmap::kARGB_8888_Config, 2, 2);
-    bm.allocPixels();
+    bm.allocN32Pixels(2, 2);
     bm.eraseColor(SK_ColorRED);
     uint32_t* pixel = bm.getAddr32(1,0);
     *pixel = SK_ColorBLUE;
diff --git a/tests/BitmapTest.cpp b/tests/BitmapTest.cpp
index e304076..0167d52 100644
--- a/tests/BitmapTest.cpp
+++ b/tests/BitmapTest.cpp
@@ -13,8 +13,11 @@
     SkBitmap bm;
     int width = 1 << 29;    // *4 will be the high-bit of 32bit int
 
-    REPORTER_ASSERT(reporter, bm.setConfig(SkBitmap::kA8_Config, width, 1));
-    REPORTER_ASSERT(reporter, bm.setConfig(SkBitmap::kRGB_565_Config, width, 1));
+    SkImageInfo info = SkImageInfo::Make(width, 1, kAlpha_8_SkColorType,
+                                         kPremul_SkAlphaType);
+    REPORTER_ASSERT(reporter, bm.setConfig(info));
+    info.fColorType = kRGB_565_SkColorType;
+    REPORTER_ASSERT(reporter, bm.setConfig(info));
 
     // for a 4-byte config, this width will compute a rowbytes of 0x80000000,
     // which does not fit in a int32_t. setConfig should detect this, and fail.
@@ -22,19 +25,20 @@
     // TODO: perhaps skia can relax this, and only require that rowBytes fit
     //       in a uint32_t (or larger), but for now this is the constraint.
 
-    REPORTER_ASSERT(reporter, !bm.setConfig(SkBitmap::kARGB_8888_Config, width, 1));
+    info.fColorType = kPMColor_SkColorType;
+    REPORTER_ASSERT(reporter, !bm.setConfig(info));
 }
 
 /**
  *  This test contains basic sanity checks concerning bitmaps.
  */
 DEF_TEST(Bitmap, reporter) {
-    const SkBitmap::Config conf = SkBitmap::kARGB_8888_Config;
     // Zero-sized bitmaps are allowed
     for (int width = 0; width < 2; ++width) {
         for (int height = 0; height < 2; ++height) {
             SkBitmap bm;
-            bool setConf = bm.setConfig(conf, width, height);
+            bool setConf = bm.setConfig(SkImageInfo::MakeN32Premul(width,
+                                                                   height));
             REPORTER_ASSERT(reporter, setConf);
             if (setConf) {
                 REPORTER_ASSERT(reporter, bm.allocPixels(NULL));
diff --git a/tests/BlitRowTest.cpp b/tests/BlitRowTest.cpp
index 9ab620e..84e61f3 100644
--- a/tests/BlitRowTest.cpp
+++ b/tests/BlitRowTest.cpp
@@ -12,9 +12,9 @@
 #include "SkRect.h"
 #include "Test.h"
 
-// these are in the same order as the SkBitmap::Config enum
+// these are in the same order as the SkColorType enum
 static const char* gConfigName[] = {
-    "None", "A8", "Index8", "565", "4444", "8888"
+    "Unknown", "Alpha8", "565", "4444", "RGBA", "BGRA", "Index8"
 };
 
 /** Returns -1 on success, else the x coord of the first bad pixel, return its
@@ -100,11 +100,9 @@
 static void test_00_FF(skiatest::Reporter* reporter) {
     static const int W = 256;
 
-    static const SkBitmap::Config gDstConfig[] = {
-        SkBitmap::kARGB_8888_Config,
-        SkBitmap::kRGB_565_Config,
-//        SkBitmap::kARGB_4444_Config,
-//        SkBitmap::kA8_Config,
+    static const SkColorType gDstColorType[] = {
+        kPMColor_SkColorType,
+        kRGB_565_SkColorType,
     };
 
     static const struct {
@@ -123,13 +121,13 @@
     SkPaint paint;
 
     SkBitmap srcBM;
-    srcBM.setConfig(SkBitmap::kARGB_8888_Config, W, 1);
-    srcBM.allocPixels();
+    srcBM.allocN32Pixels(W, 1);
 
-    for (size_t i = 0; i < SK_ARRAY_COUNT(gDstConfig); i++) {
+    for (size_t i = 0; i < SK_ARRAY_COUNT(gDstColorType); i++) {
+        SkImageInfo info = SkImageInfo::Make(W, 1, gDstColorType[i],
+                                             kPremul_SkAlphaType);
         SkBitmap dstBM;
-        dstBM.setConfig(gDstConfig[i], W, 1);
-        dstBM.allocPixels();
+        dstBM.allocPixels(info);
 
         SkCanvas canvas(dstBM);
         for (size_t j = 0; j < SK_ARRAY_COUNT(gSrcRec); j++) {
@@ -193,11 +191,9 @@
     static const int W = 64;
     static const int H = W;
 
-    static const SkBitmap::Config gDstConfig[] = {
-        SkBitmap::kARGB_8888_Config,
-        SkBitmap::kRGB_565_Config,
-        //        SkBitmap::kARGB_4444_Config,
-        //        SkBitmap::kA8_Config,
+    static const SkColorType gDstColorType[] = {
+        kPMColor_SkColorType,
+        kRGB_565_SkColorType,
     };
 
     static const SkColor gDstBG[] = { 0, 0xFFFFFFFF };
@@ -205,20 +201,22 @@
     SkPaint paint;
 
     SkBitmap srcBM;
-    srcBM.setConfig(SkBitmap::kARGB_8888_Config, W, H);
-    srcBM.allocPixels();
+    srcBM.allocN32Pixels(W, H);
     SkRect srcR = {
         0, 0, SkIntToScalar(srcBM.width()), SkIntToScalar(srcBM.height()) };
 
     // cons up a mesh to draw the bitmap with
     Mesh mesh(srcBM, &paint);
 
-    for (size_t i = 0; i < SK_ARRAY_COUNT(gDstConfig); i++) {
+    SkImageInfo info = SkImageInfo::Make(W, H, kUnknown_SkColorType,
+                                         kPremul_SkAlphaType);
+
+    for (size_t i = 0; i < SK_ARRAY_COUNT(gDstColorType); i++) {
+        info.fColorType = gDstColorType[i];
+
         SkBitmap dstBM0, dstBM1;
-        dstBM0.setConfig(gDstConfig[i], W, H);
-        dstBM1.setConfig(gDstConfig[i], W, H);
-        dstBM0.allocPixels();
-        dstBM1.allocPixels();
+        dstBM0.allocPixels(info);
+        dstBM1.allocPixels(info);
 
         SkCanvas canvas0(dstBM0);
         SkCanvas canvas1(dstBM1);
@@ -249,9 +247,9 @@
                     }
 
                     if (memcmp(dstBM0.getPixels(), dstBM1.getPixels(), dstBM0.getSize())) {
-                        ERRORF(reporter, "Diagonal config=%s bg=0x%x dither=%d"
+                        ERRORF(reporter, "Diagonal colortype=%s bg=0x%x dither=%d"
                                " alpha=0x%x src=0x%x",
-                               gConfigName[gDstConfig[i]], bgColor, dither,
+                               gConfigName[gDstColorType[i]], bgColor, dither,
                                alpha, c);
                     }
                 }
diff --git a/tests/BlurTest.cpp b/tests/BlurTest.cpp
index 386581c..1e9f314 100644
--- a/tests/BlurTest.cpp
+++ b/tests/BlurTest.cpp
@@ -27,9 +27,8 @@
 static const SkColor bgColor = SK_ColorWHITE;
 static const int strokeWidth = 4;
 
-static void create(SkBitmap* bm, SkIRect bound, SkBitmap::Config config) {
-    bm->setConfig(config, bound.width(), bound.height());
-    bm->allocPixels();
+static void create(SkBitmap* bm, const SkIRect& bound) {
+    bm->allocN32Pixels(bound.width(), bound.height());
 }
 
 static void drawBG(SkCanvas* canvas) {
@@ -126,7 +125,7 @@
                 refBound.roundOut(&iref);
                 iref.inset(-outset, -outset);
                 SkBitmap refBitmap;
-                create(&refBitmap, iref, SkBitmap::kARGB_8888_Config);
+                create(&refBitmap, iref);
 
                 SkCanvas refCanvas(refBitmap);
                 refCanvas.translate(SkIntToScalar(-iref.fLeft),
@@ -137,7 +136,7 @@
                 for (int view = 0; view < tests[test].viewLen; ++view) {
                     SkIRect itest = tests[test].views[view];
                     SkBitmap testBitmap;
-                    create(&testBitmap, itest, SkBitmap::kARGB_8888_Config);
+                    create(&testBitmap, itest);
 
                     SkCanvas testCanvas(testBitmap);
                     testCanvas.translate(SkIntToScalar(-itest.fLeft),
@@ -244,8 +243,7 @@
 // Readback the blurred draw results from the canvas
 static void readback(SkCanvas* canvas, int* result, int resultCount) {
     SkBitmap readback;
-    readback.setConfig(SkBitmap::kARGB_8888_Config, resultCount, 30);
-    readback.allocPixels();
+    readback.allocN32Pixels(resultCount, 30);
 
     SkIRect readBackRect = { 0, 0, resultCount, 30 };
 
@@ -265,8 +263,7 @@
                           int* result, int resultCount) {
 
     SkBitmap bitmap;
-    bitmap.setConfig(SkBitmap::kARGB_8888_Config, resultCount, 30);
-    bitmap.allocPixels();
+    bitmap.allocN32Pixels(resultCount, 30);
     SkCanvas canvas(bitmap);
 
     blur_path(&canvas, path, gaussianSigma);
diff --git a/tests/CanvasStateTest.cpp b/tests/CanvasStateTest.cpp
index f1c3592..7c441a4 100644
--- a/tests/CanvasStateTest.cpp
+++ b/tests/CanvasStateTest.cpp
@@ -24,10 +24,10 @@
                                    SkIntToScalar(WIDTH-(2*SPACER)),
                                    SkIntToScalar((HEIGHT-(2*SPACER)) / 7));
 
-    const SkBitmap::Config configs[] = { SkBitmap::kRGB_565_Config,
-                                         SkBitmap::kARGB_8888_Config
+    const SkColorType colorTypes[] = {
+        kRGB_565_SkColorType, kPMColor_SkColorType
     };
-    const int configCount = sizeof(configs) / sizeof(SkBitmap::Config);
+    const int configCount = sizeof(colorTypes) / sizeof(SkBitmap::Config);
 
     const int layerAlpha[] = { 255, 255, 0 };
     const SkCanvas::SaveFlags flags[] = { SkCanvas::kARGB_NoClipLayer_SaveFlag,
@@ -40,8 +40,9 @@
     for (int i = 0; i < configCount; ++i) {
         SkBitmap bitmaps[2];
         for (int j = 0; j < 2; ++j) {
-            bitmaps[j].setConfig(configs[i], WIDTH, HEIGHT);
-            bitmaps[j].allocPixels();
+            bitmaps[j].allocPixels(SkImageInfo::Make(WIDTH, HEIGHT,
+                                                     colorTypes[i],
+                                                     kPremul_SkAlphaType));
 
             SkCanvas canvas(bitmaps[j]);
 
@@ -127,8 +128,7 @@
 
     SkBitmap bitmaps[2];
     for (int i = 0; i < 2; ++i) {
-        bitmaps[i].setConfig(SkBitmap::kARGB_8888_Config, WIDTH, HEIGHT);
-        bitmaps[i].allocPixels();
+        bitmaps[i].allocN32Pixels(WIDTH, HEIGHT);
 
         SkCanvas canvas(bitmaps[i]);
 
diff --git a/tests/CanvasTest.cpp b/tests/CanvasTest.cpp
index 55169cc..b3b1a37 100644
--- a/tests/CanvasTest.cpp
+++ b/tests/CanvasTest.cpp
@@ -84,7 +84,7 @@
     SkISize size = canvas->getDeviceSize();
 
     SkBitmap bm;
-    bm.setConfig(SkBitmap::kARGB_8888_Config, size.width(), size.height());
+    bm.setConfig(SkImageInfo::MakeN32Premul(size.width(), size.height()));
     SkCanvas c(bm);
 
     Canvas2CanvasClipVisitor visitor(&c);
@@ -135,9 +135,8 @@
 static const char* const kPdfAssertMessageFormat =
     "PDF sanity check failed %s";
 
-static void createBitmap(SkBitmap* bm, SkBitmap::Config config, SkColor color) {
-    bm->setConfig(config, kWidth, kHeight);
-    bm->allocPixels();
+static void createBitmap(SkBitmap* bm, SkColor color) {
+    bm->allocN32Pixels(kWidth, kHeight);
     bm->eraseColor(color);
 }
 
@@ -220,7 +219,7 @@
 const size_t kTestPointCount = 3;
 static SkBitmap testBitmap() {
     SkBitmap bitmap;
-    createBitmap(&bitmap, SkBitmap::kARGB_8888_Config, 0x05060708);
+    createBitmap(&bitmap, 0x05060708);
     return bitmap;
 }
 SkBitmap kTestBitmap; // cannot be created during static init
@@ -798,7 +797,7 @@
     const SkCanvas& referenceCanvas) {
 
     SkBitmap indirectStore;
-    createBitmap(&indirectStore, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF);
+    createBitmap(&indirectStore, 0xFFFFFFFF);
     SkBitmapDevice indirectDevice(indirectStore);
     SkCanvas indirectCanvas(&indirectDevice);
     SkProxyCanvas proxyCanvas(&indirectCanvas);
@@ -821,12 +820,12 @@
     const SkCanvas& referenceCanvas) {
 
     SkBitmap indirectStore1;
-    createBitmap(&indirectStore1, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF);
+    createBitmap(&indirectStore1, 0xFFFFFFFF);
     SkBitmapDevice indirectDevice1(indirectStore1);
     SkCanvas indirectCanvas1(&indirectDevice1);
 
     SkBitmap indirectStore2;
-    createBitmap(&indirectStore2, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF);
+    createBitmap(&indirectStore2, 0xFFFFFFFF);
     SkBitmapDevice indirectDevice2(indirectStore2);
     SkCanvas indirectCanvas2(&indirectDevice2);
 
@@ -859,7 +858,7 @@
 static void TestOverrideStateConsistency(skiatest::Reporter* reporter,
                                          CanvasTestStep* testStep) {
     SkBitmap referenceStore;
-    createBitmap(&referenceStore, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF);
+    createBitmap(&referenceStore, 0xFFFFFFFF);
     SkBitmapDevice referenceDevice(referenceStore);
     SkCanvas referenceCanvas(&referenceDevice);
     testStep->setAssertMessageFormat(kCanvasDrawAssertMessageFormat);
diff --git a/tests/ClipCubicTest.cpp b/tests/ClipCubicTest.cpp
index db6ae80..31b38f2 100644
--- a/tests/ClipCubicTest.cpp
+++ b/tests/ClipCubicTest.cpp
@@ -16,8 +16,7 @@
 // with a device/clip that is larger.
 static void test_giantClip() {
     SkBitmap bm;
-    bm.setConfig(SkBitmap::kARGB_8888_Config, 64919, 1);
-    bm.allocPixels();
+    bm.allocN32Pixels(64919, 1);
     SkCanvas canvas(bm);
     canvas.clear(SK_ColorTRANSPARENT);
 
diff --git a/tests/ClipperTest.cpp b/tests/ClipperTest.cpp
index c8f65db..00b6229 100644
--- a/tests/ClipperTest.cpp
+++ b/tests/ClipperTest.cpp
@@ -13,8 +13,7 @@
 
 static void test_hairclipping(skiatest::Reporter* reporter) {
     SkBitmap bm;
-    bm.setConfig(SkBitmap::kARGB_8888_Config, 4, 4);
-    bm.allocPixels();
+    bm.allocN32Pixels(4, 4);
     bm.eraseColor(SK_ColorWHITE);
 
     SkPaint paint;
diff --git a/tests/DeferredCanvasTest.cpp b/tests/DeferredCanvasTest.cpp
index a40c667..4b67f19 100644
--- a/tests/DeferredCanvasTest.cpp
+++ b/tests/DeferredCanvasTest.cpp
@@ -24,9 +24,8 @@
 static const int gWidth = 2;
 static const int gHeight = 2;
 
-static void create(SkBitmap* bm, SkBitmap::Config config, SkColor color) {
-    bm->setConfig(config, gWidth, gHeight);
-    bm->allocPixels();
+static void create(SkBitmap* bm, SkColor color) {
+    bm->allocN32Pixels(gWidth, gHeight);
     bm->eraseColor(color);
 }
 
@@ -69,8 +68,7 @@
 public:
     MockSurface(int width, int height) : SkSurface_Base(width, height) {
         clearCounts();
-        fBitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
-        fBitmap.allocPixels();
+        fBitmap.allocN32Pixels(width, height);
     }
 
     virtual SkCanvas* onNewCanvas() SK_OVERRIDE {
@@ -107,8 +105,7 @@
     SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(surface.get()));
 
     SkBitmap srcBitmap;
-    srcBitmap.setConfig(SkBitmap::kARGB_8888_Config, 10, 10);
-    srcBitmap.allocPixels();
+    srcBitmap.allocN32Pixels(10, 10);
     srcBitmap.eraseColor(SK_ColorGREEN);
     // Tests below depend on this bitmap being recognized as opaque
 
@@ -351,7 +348,7 @@
         SkPaint paint;
         paint.setStyle(SkPaint::kFill_Style);
         SkBitmap bmp;
-        create(&bmp, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF);
+        create(&bmp, 0xFFFFFFFF);
         bmp.setAlphaType(kOpaque_SkAlphaType);
         SkShader* shader = SkShader::CreateBitmapShader(bmp,
             SkShader::kClamp_TileMode, SkShader::kClamp_TileMode);
@@ -389,7 +386,7 @@
         SkPaint paint;
         paint.setStyle(SkPaint::kFill_Style);
         SkBitmap bmp;
-        create(&bmp, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF);
+        create(&bmp, 0xFFFFFFFF);
         bmp.setAlphaType(kPremul_SkAlphaType);
         SkShader* shader = SkShader::CreateBitmapShader(bmp,
             SkShader::kClamp_TileMode, SkShader::kClamp_TileMode);
@@ -507,8 +504,7 @@
 
     SkBitmap sourceImage;
     // 100 by 100 image, takes 40,000 bytes in memory
-    sourceImage.setConfig(SkBitmap::kARGB_8888_Config, 100, 100);
-    sourceImage.allocPixels();
+    sourceImage.allocN32Pixels(100, 100);
 
     for (int i = 0; i < 5; i++) {
         sourceImage.notifyPixelsChanged(); // to force re-serialization
@@ -527,10 +523,8 @@
 
     const int imageCount = 2;
     SkBitmap sourceImages[imageCount];
-    for (int i = 0; i < imageCount; i++)
-    {
-        sourceImages[i].setConfig(SkBitmap::kARGB_8888_Config, 100, 100);
-        sourceImages[i].allocPixels();
+    for (int i = 0; i < imageCount; i++) {
+        sourceImages[i].allocN32Pixels(100, 100);
     }
 
     size_t bitmapSize = sourceImages[0].getSize();
@@ -629,8 +623,7 @@
         for(int i = 0; i < nbIterations; ++i) {
             SkPaint paint;
             SkBitmap paintPattern;
-            paintPattern.setConfig(SkBitmap::kARGB_8888_Config, 10, 10);
-            paintPattern.allocPixels();
+            paintPattern.allocN32Pixels(10, 10);
             paint.setShader(SkNEW_ARGS(SkBitmapProcShader,
                 (paintPattern, SkShader::kClamp_TileMode, SkShader::kClamp_TileMode)))->unref();
             canvas->drawPaint(paint);
@@ -658,8 +651,7 @@
 
     SkBitmap sourceImage;
     // 100 by 100 image, takes 40,000 bytes in memory
-    sourceImage.setConfig(SkBitmap::kARGB_8888_Config, 100, 100);
-    sourceImage.allocPixels();
+    sourceImage.allocN32Pixels(100, 100);
 
     // 1 under : should not store the image
     {
diff --git a/tests/DeviceLooperTest.cpp b/tests/DeviceLooperTest.cpp
index ab5841b..5735043 100644
--- a/tests/DeviceLooperTest.cpp
+++ b/tests/DeviceLooperTest.cpp
@@ -10,8 +10,8 @@
 #include "Test.h"
 
 static void make_bm(SkBitmap* bm, int w, int h) {
-    bm->setConfig(SkBitmap::kA8_Config, w, h);
-    bm->allocPixels();
+    bm->allocPixels(SkImageInfo::Make(w, h, kAlpha_8_SkColorType,
+                                      kPremul_SkAlphaType));
 }
 
 static bool equal(const SkRasterClip& a, const SkRasterClip& b) {
diff --git a/tests/DrawBitmapRectTest.cpp b/tests/DrawBitmapRectTest.cpp
index a168146..f51bf53 100644
--- a/tests/DrawBitmapRectTest.cpp
+++ b/tests/DrawBitmapRectTest.cpp
@@ -178,8 +178,7 @@
 static void test_wacky_bitmapshader(skiatest::Reporter* reporter,
                                     int width, int height, bool shouldBeDrawn) {
     SkBitmap dev;
-    dev.setConfig(SkBitmap::kARGB_8888_Config, 0x56F, 0x4f6);
-    dev.allocPixels();
+    dev.allocN32Pixels(0x56F, 0x4f6);
     dev.eraseColor(SK_ColorTRANSPARENT);  // necessary, so we know if we draw to it
 
     SkMatrix matrix;
@@ -195,8 +194,7 @@
     c.concat(matrix);
 
     SkBitmap bm;
-    bm.setConfig(SkBitmap::kARGB_8888_Config, width, height);
-    bm.allocPixels();
+    bm.allocN32Pixels(width, height);
     bm.eraseColor(SK_ColorRED);
 
     SkShader* s = SkShader::CreateBitmapShader(bm, SkShader::kRepeat_TileMode,
@@ -260,8 +258,7 @@
 
 static void test_nan_antihair() {
     SkBitmap bm;
-    bm.setConfig(SkBitmap::kARGB_8888_Config, 20, 20);
-    bm.allocPixels();
+    bm.allocN32Pixels(20, 20);
 
     SkCanvas canvas(bm);
 
@@ -298,17 +295,16 @@
 static const int gWidth = 256;
 static const int gHeight = 256;
 
-static void create(SkBitmap* bm, SkBitmap::Config config, SkColor color) {
-    bm->setConfig(config, gWidth, gHeight);
-    bm->allocPixels();
+static void create(SkBitmap* bm, SkColor color) {
+    bm->allocN32Pixels(gWidth, gHeight);
     bm->eraseColor(color);
 }
 
 DEF_TEST(DrawBitmapRect, reporter) {
     SkBitmap src, dst;
 
-    create(&src, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF);
-    create(&dst, SkBitmap::kARGB_8888_Config, 0);
+    create(&src, 0xFFFFFFFF);
+    create(&dst, 0);
 
     SkCanvas canvas(dst);
 
diff --git a/tests/DrawPathTest.cpp b/tests/DrawPathTest.cpp
index 2cf1bc5..e7f7005 100644
--- a/tests/DrawPathTest.cpp
+++ b/tests/DrawPathTest.cpp
@@ -11,20 +11,10 @@
 #include "SkSurface.h"
 #include "Test.h"
 
-static SkCanvas* create(SkBitmap::Config config, int w, int h, int rb,
-                        void* addr = NULL) {
-    SkBitmap bm;
-    bm.setConfig(config, w, h, rb);
-    if (addr) {
-        bm.setPixels(addr);
-    } else {
-        bm.allocPixels();
-    }
-    return new SkCanvas(bm);
-}
-
 static SkCanvas* new_canvas(int w, int h) {
-    return create(SkBitmap::kARGB_8888_Config, w, h, 0, NULL);
+    SkBitmap bm;
+    bm.allocN32Pixels(w, h);
+    return new SkCanvas(bm);
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -33,8 +23,8 @@
 static void test_big_aa_rect(skiatest::Reporter* reporter) {
     SkBitmap output;
     SkPMColor pixel[1];
-    output.setConfig(SkBitmap::kARGB_8888_Config, 1, 1, 4);
-    output.setPixels(pixel);
+    output.installPixels(SkImageInfo::MakeN32Premul(1, 1),
+                         pixel, 4, NULL, NULL);
 
     SkSurface* surf = SkSurface::NewRasterPMColor(300, 33300);
     SkCanvas* canvas = surf->getCanvas();
@@ -125,8 +115,7 @@
 // stepper for the quadratic. Now we bias that value by 1/2 so we don't overflow
 static void test_crbug_140803() {
     SkBitmap bm;
-    bm.setConfig(SkBitmap::kARGB_8888_Config, 2700, 30*1024);
-    bm.allocPixels();
+    bm.allocN32Pixels(2700, 30*1024);
     SkCanvas canvas(bm);
 
     SkPath path;
diff --git a/tests/ReadPixelsTest.cpp b/tests/ReadPixelsTest.cpp
index 5f25007..50f55fd 100644
--- a/tests/ReadPixelsTest.cpp
+++ b/tests/ReadPixelsTest.cpp
@@ -107,8 +107,7 @@
 static void fillCanvas(SkCanvas* canvas) {
     static SkBitmap bmp;
     if (bmp.isNull()) {
-        bmp.setConfig(SkBitmap::kARGB_8888_Config, DEV_W, DEV_H);
-        SkDEBUGCODE(bool alloc =) bmp.allocPixels();
+        SkDEBUGCODE(bool alloc =) bmp.allocN32Pixels(DEV_W, DEV_H);
         SkASSERT(alloc);
         SkAutoLockPixels alp(bmp);
         intptr_t pixels = reinterpret_cast<intptr_t>(bmp.getPixels());
@@ -230,9 +229,8 @@
 }
 
 static void init_bitmap(SkBitmap* bitmap, const SkIRect& rect, BitmapInit init) {
-    int w = rect.width();
-    int h = rect.height();
-    int rowBytes = 0;
+    SkImageInfo info = SkImageInfo::MakeN32Premul(rect.width(), rect.height());
+    size_t rowBytes = 0;
     bool alloc = true;
     switch (init) {
         case kNoPixels_BitmapInit:
@@ -240,15 +238,17 @@
         case kTight_BitmapInit:
             break;
         case kRowBytes_BitmapInit:
-            rowBytes = w * sizeof(SkPMColor) + 16 * sizeof(SkPMColor);
+            rowBytes = (info.width() + 16) * sizeof(SkPMColor);
             break;
         default:
             SkASSERT(0);
             break;
     }
-    bitmap->setConfig(SkBitmap::kARGB_8888_Config, w, h, rowBytes);
+    
     if (alloc) {
-        bitmap->allocPixels();
+        bitmap->allocPixels(info);
+    } else {
+        bitmap->setConfig(info, rowBytes);
     }
 }
 
diff --git a/tests/WritePixelsTest.cpp b/tests/WritePixelsTest.cpp
index 43d17e7..e2e4a0c 100644
--- a/tests/WritePixelsTest.cpp
+++ b/tests/WritePixelsTest.cpp
@@ -136,8 +136,7 @@
 static void fillCanvas(SkCanvas* canvas) {
     static SkBitmap bmp;
     if (bmp.isNull()) {
-        bmp.setConfig(SkBitmap::kARGB_8888_Config, DEV_W, DEV_H);
-        SkDEBUGCODE(bool alloc = ) bmp.allocPixels();
+        SkDEBUGCODE(bool alloc = ) bmp.allocN32Pixels(DEV_W, DEV_H);
         SkASSERT(alloc);
         SkAutoLockPixels alp(bmp);
         intptr_t pixels = reinterpret_cast<intptr_t>(bmp.getPixels());
@@ -304,13 +303,28 @@
 #endif
 };
 
+#include "SkMallocPixelRef.h"
+
+// This is a tricky pattern, because we have to setConfig+rowBytes AND specify
+// a custom pixelRef (which also has to specify its rowBytes), so we have to be
+// sure that the two rowBytes match (and the infos match).
+//
+static bool allocRowBytes(SkBitmap* bm, const SkImageInfo& info, size_t rowBytes) {
+    if (!bm->setConfig(info, rowBytes)) {
+        return false;
+    }
+    SkPixelRef* pr = SkMallocPixelRef::NewAllocate(info, rowBytes, NULL);
+    bm->setPixelRef(pr)->unref();
+    return true;
+}
+
 static SkBaseDevice* createDevice(const CanvasConfig& c, GrContext* grCtx) {
     switch (c.fDevType) {
         case kRaster_DevType: {
             SkBitmap bmp;
             size_t rowBytes = c.fTightRowBytes ? 0 : 4 * DEV_W + 100;
-            bmp.setConfig(SkBitmap::kARGB_8888_Config, DEV_W, DEV_H, rowBytes);
-            if (!bmp.allocPixels()) {
+            SkImageInfo info = SkImageInfo::MakeN32Premul(DEV_W, DEV_H);
+            if (!allocRowBytes(&bmp, info, rowBytes)) {
                 sk_throw();
                 return NULL;
             }
@@ -344,8 +358,8 @@
                         int w, int h,
                         bool tightRowBytes) {
     size_t rowBytes = tightRowBytes ? 0 : 4 * w + 60;
-    bitmap->setConfig(SkBitmap::kARGB_8888_Config, w, h, rowBytes);
-    if (!bitmap->allocPixels()) {
+    SkImageInfo info = SkImageInfo::MakeN32Premul(w, h);
+    if (!allocRowBytes(bitmap, info, rowBytes)) {
         return false;
     }
     SkAutoLockPixels alp(*bitmap);