unify peekPixels around pixmap parameter

requires this chrome CL to land first
https://codereview.chromium.org/1775393003/

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1784563002

Review URL: https://codereview.chromium.org/1784563002
diff --git a/example/HelloWorld.cpp b/example/HelloWorld.cpp
index 1cc18fd..e13cb3b 100644
--- a/example/HelloWorld.cpp
+++ b/example/HelloWorld.cpp
@@ -156,18 +156,18 @@
 
     if (kRaster_DeviceType == fType) {
         // need to send the raster bits to the (gpu) window
-        SkImage* snap = fSurface->newImageSnapshot();
-        size_t rowBytes = 0;
-        SkImageInfo info;
-        const void* pixels = snap->peekPixels(&info, &rowBytes);
-        fRenderTarget->writePixels(0, 0, snap->width(), snap->height(),
-                                        SkImageInfo2GrPixelConfig(info.colorType(),
-                                                                info.alphaType(),
-                                                                info.profileType()),
-                                        pixels,
-                                        rowBytes,
-                                        GrContext::kFlushWrites_PixelOp);
-        SkSafeUnref(snap);
+        sk_sp<SkImage> snap = sk_sp<SkImage>(fSurface->newImageSnapshot());
+        SkPixmap pmap;
+        if (snap->peekPixels(&pmap)) {
+            const SkImageInfo& info = pmap.info();
+            fRenderTarget->writePixels(0, 0, snap->width(), snap->height(),
+                                            SkImageInfo2GrPixelConfig(info.colorType(),
+                                                                    info.alphaType(),
+                                                                    info.profileType()),
+                                            pmap.addr(),
+                                            pmap.rowBytes(),
+                                            GrContext::kFlushWrites_PixelOp);
+        }
     }
     INHERITED::present();
 }
diff --git a/gm/blend.cpp b/gm/blend.cpp
index 94dc4c7..6ecea4c 100644
--- a/gm/blend.cpp
+++ b/gm/blend.cpp
@@ -36,7 +36,8 @@
 
     // Print out the colors in each block (if we're looking at 8888 raster).
     if (canvas->imageInfo().colorType() == kN32_SkColorType) {
-        if (const SkPMColor* px = (const SkPMColor*)canvas->peekPixels(nullptr, nullptr)) {
+        SkPixmap pmap;
+        if (const SkPMColor* px = canvas->peekPixels(&pmap) ? pmap.addr32() : nullptr) {
             p.setColor(SK_ColorWHITE);
             for (int i = 0; i < 3; i++) {
                 SkPMColor c = px[i * 100];
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index 1b4571a..034e405 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -212,16 +212,19 @@
     /**
      *  If the canvas has readable pixels in its base layer (and is not recording to a picture
      *  or other non-raster target) and has direct access to its pixels (i.e. they are in
-     *  local RAM) return the const-address of those pixels, and if not null,
-     *  return the ImageInfo and rowBytes. The returned address is only valid
+     *  local RAM) return true, and if not null, return in the pixmap parameter information about
+     *  the pixels. The pixmap's pixel address is only valid
      *  while the canvas object is in scope and unchanged. Any API calls made on
-     *  canvas (or its parent surface if any) will invalidate the
-     *  returned address (and associated information).
+     *  canvas (or its parent surface if any) will invalidate the pixel address
+     *  (and associated information).
      *
-     *  On failure, returns NULL and the info and rowBytes parameters are
-     *  ignored.
+     *  On failure, returns false and the pixmap parameter will be ignored.
      */
+    bool peekPixels(SkPixmap*);
+
+#ifdef SK_SUPPORT_LEGACY_PEEKPIXELS_PARMS
     const void* peekPixels(SkImageInfo* info, size_t* rowBytes);
+#endif
 
     /**
      *  Copy the pixels from the base-layer into the specified buffer (pixels + rowBytes),
diff --git a/include/core/SkImage.h b/include/core/SkImage.h
index 0474195..c920c54 100644
--- a/include/core/SkImage.h
+++ b/include/core/SkImage.h
@@ -168,6 +168,16 @@
                                 const SkMatrix* localMatrix = NULL) const;
 
     /**
+     *  If the image has direct access to its pixels (i.e. they are in local RAM)
+     *  return true, and if not null, return in the pixmap parameter the info about the
+     *  images pixels.
+     *
+     *  On failure, return false and ignore the pixmap parameter.
+     */
+    bool peekPixels(SkPixmap* pixmap) const;
+
+#ifdef SK_SUPPORT_LEGACY_PEEKPIXELS_PARMS
+    /**
      *  If the image has direct access to its pixels (i.e. they are in local
      *  RAM) return the (const) address of those pixels, and if not null, return
      *  the ImageInfo and rowBytes. The returned address is only valid while
@@ -175,17 +185,11 @@
      *
      *  On failure, returns NULL and the info and rowBytes parameters are
      *  ignored.
+     *
+     *  DEPRECATED -- use the SkPixmap variant instead
      */
     const void* peekPixels(SkImageInfo* info, size_t* rowBytes) const;
-
-    /**
-     *  If the image has direct access to its pixels (i.e. they are in local
-     *  RAM) return the (const) address of those pixels, and if not null, return
-     *  true, and if pixmap is not NULL, set it to point into the image.
-     *
-     *  On failure, return false and ignore the pixmap parameter.
-     */
-    bool peekPixels(SkPixmap* pixmap) const;
+#endif
 
     /**
      *  Some images have to perform preliminary work in preparation for drawing. This can be
diff --git a/include/core/SkSurface.h b/include/core/SkSurface.h
index 7a03529..b873c24 100644
--- a/include/core/SkSurface.h
+++ b/include/core/SkSurface.h
@@ -257,15 +257,18 @@
 
     /**
      *  If the surface has direct access to its pixels (i.e. they are in local
-     *  RAM) return the const-address of those pixels, and if not null, return
-     *  the ImageInfo and rowBytes. The returned address is only valid while
+     *  RAM) return true, and if not null, set the pixmap parameter to point to the information
+     *  about the surface's pixels. The pixel address in the pixmap is only valid while
      *  the surface object is in scope, and no API call is made on the surface
      *  or its canvas.
      *
-     *  On failure, returns NULL and the info and rowBytes parameters are
-     *  ignored.
+     *  On failure, returns false and the pixmap parameter is ignored.
      */
+    bool peekPixels(SkPixmap*);
+
+#ifdef SK_SUPPORT_LEGACY_PEEKPIXELS_PARMS
     const void* peekPixels(SkImageInfo* info, size_t* rowBytes);
+#endif
 
     /**
      *  Copy the pixels from the surface into the specified buffer (pixels + rowBytes),
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 35710fb..d60e0e9 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -1335,18 +1335,24 @@
     }
 }
 
+#ifdef SK_SUPPORT_LEGACY_PEEKPIXELS_PARMS
 const void* SkCanvas::peekPixels(SkImageInfo* info, size_t* rowBytes) {
     SkPixmap pmap;
-    if (!this->onPeekPixels(&pmap)) {
-        return nullptr;
+    if (this->peekPixels(&pmap)) {
+        if (info) {
+            *info = pmap.info();
+        }
+        if (rowBytes) {
+            *rowBytes = pmap.rowBytes();
+        }
+        return pmap.addr();
     }
-    if (info) {
-        *info = pmap.info();
-    }
-    if (rowBytes) {
-        *rowBytes = pmap.rowBytes();
-    }
-    return pmap.addr();
+    return nullptr;
+}
+#endif
+
+bool SkCanvas::peekPixels(SkPixmap* pmap) {
+    return this->onPeekPixels(pmap);
 }
 
 bool SkCanvas::onPeekPixels(SkPixmap* pmap) {
diff --git a/src/core/SkSpecialImage.cpp b/src/core/SkSpecialImage.cpp
index f5f8832..a55fe65 100644
--- a/src/core/SkSpecialImage.cpp
+++ b/src/core/SkSpecialImage.cpp
@@ -114,11 +114,9 @@
         } else
 #endif
         {
-            SkImageInfo info;
-            size_t rowBytes;
-
-            if (fImage->peekPixels(&info, &rowBytes)) {
-                return info.height() * rowBytes;
+            SkPixmap pm;
+            if (fImage->peekPixels(&pm)) {
+                return pm.height() * pm.rowBytes();
             }
         }
         return 0;
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index d7af825..81a3502 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -263,6 +263,8 @@
                 return nullptr;
             }
             pmap = &tmpPixmap;
+            // must rebuild desc, since we've forced the info to be N32
+            desc = GrImageInfoToSurfaceDesc(pmap->info());
         }
     }
 
diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp
index 0727950..5e7cb07 100644
--- a/src/image/SkImage.cpp
+++ b/src/image/SkImage.cpp
@@ -36,18 +36,30 @@
     SkASSERT(height > 0);
 }
 
-const void* SkImage::peekPixels(SkImageInfo* info, size_t* rowBytes) const {
-    SkImageInfo infoStorage;
-    size_t rowBytesStorage;
-    if (nullptr == info) {
-        info = &infoStorage;
+bool SkImage::peekPixels(SkPixmap* pm) const {
+    SkPixmap tmp;
+    if (!pm) {
+        pm = &tmp;
     }
-    if (nullptr == rowBytes) {
-        rowBytes = &rowBytesStorage;
-    }
-    return as_IB(this)->onPeekPixels(info, rowBytes);
+    return as_IB(this)->onPeekPixels(pm);
 }
 
+#ifdef SK_SUPPORT_LEGACY_PEEKPIXELS_PARMS
+const void* SkImage::peekPixels(SkImageInfo* info, size_t* rowBytes) const {
+    SkPixmap pm;
+    if (this->peekPixels(&pm)) {
+        if (info) {
+            *info = pm.info();
+        }
+        if (rowBytes) {
+            *rowBytes = pm.rowBytes();
+        }
+        return pm.addr();
+    }
+    return nullptr;
+}
+#endif
+
 bool SkImage::readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
                            int srcX, int srcY, CachingHint chint) const {
     SkReadPixelsRec rec(dstInfo, dstPixels, dstRowBytes, srcX, srcY);
@@ -241,19 +253,6 @@
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-bool SkImage::peekPixels(SkPixmap* pmap) const {
-    SkImageInfo info;
-    size_t rowBytes;
-    const void* pixels = this->peekPixels(&info, &rowBytes);
-    if (pixels) {
-        if (pmap) {
-            pmap->reset(info, pixels, rowBytes);
-        }
-        return true;
-    }
-    return false;
-}
-
 bool SkImage::readPixels(const SkPixmap& pmap, int srcX, int srcY, CachingHint chint) const {
     return this->readPixels(pmap.info(), pmap.writable_addr(), pmap.rowBytes(), srcX, srcY, chint);
 }
diff --git a/src/image/SkImage_Base.h b/src/image/SkImage_Base.h
index da87e42..9e2efe9 100644
--- a/src/image/SkImage_Base.h
+++ b/src/image/SkImage_Base.h
@@ -26,7 +26,7 @@
     SkImage_Base(int width, int height, uint32_t uniqueID);
     virtual ~SkImage_Base();
 
-    virtual const void* onPeekPixels(SkImageInfo*, size_t* /*rowBytes*/) const { return nullptr; }
+    virtual bool onPeekPixels(SkPixmap*) const { return false; }
 
     // Default impl calls onDraw
     virtual bool onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
@@ -74,7 +74,7 @@
     typedef SkImage INHERITED;
 };
 
-static inline SkImage_Base*     as_IB(SkImage* image) {
+static inline SkImage_Base* as_IB(SkImage* image) {
     return static_cast<SkImage_Base*>(image);
 }
 
diff --git a/src/image/SkImage_Generator.cpp b/src/image/SkImage_Generator.cpp
index 688b4ff..95cc426 100644
--- a/src/image/SkImage_Generator.cpp
+++ b/src/image/SkImage_Generator.cpp
@@ -22,7 +22,6 @@
     {}
 
     bool onReadPixels(const SkImageInfo&, void*, size_t, int srcX, int srcY, CachingHint) const override;
-    const void* onPeekPixels(SkImageInfo*, size_t* /*rowBytes*/) const override;
     SkImageCacherator* peekCacherator() const override { return fCache; }
     SkData* onRefEncoded(GrContext*) const override;
     bool isOpaque() const override { return fCache->info().isOpaque(); }
@@ -62,10 +61,6 @@
     return false;
 }
 
-const void* SkImage_Generator::onPeekPixels(SkImageInfo* infoPtr, size_t* rowBytesPtr) const {
-    return NULL;
-}
-
 SkData* SkImage_Generator::onRefEncoded(GrContext* ctx) const {
     return fCache->refEncoded(ctx);
 }
diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp
index d4debdf..5bd0e1d 100644
--- a/src/image/SkImage_Raster.cpp
+++ b/src/image/SkImage_Raster.cpp
@@ -67,7 +67,7 @@
     virtual ~SkImage_Raster();
 
     bool onReadPixels(const SkImageInfo&, void*, size_t, int srcX, int srcY, CachingHint) const override;
-    const void* onPeekPixels(SkImageInfo*, size_t* /*rowBytes*/) const override;
+    bool onPeekPixels(SkPixmap*) const override;
     SkData* onRefEncoded(GrContext*) const override;
     bool getROPixels(SkBitmap*, CachingHint) const override;
     GrTexture* asTextureRef(GrContext*, const GrTextureParams&) const override;
@@ -140,14 +140,8 @@
     return shallowCopy.readPixels(dstInfo, dstPixels, dstRowBytes, srcX, srcY);
 }
 
-const void* SkImage_Raster::onPeekPixels(SkImageInfo* infoPtr, size_t* rowBytesPtr) const {
-    const SkImageInfo info = fBitmap.info();
-    if ((kUnknown_SkColorType == info.colorType()) || !fBitmap.getPixels()) {
-        return nullptr;
-    }
-    *infoPtr = info;
-    *rowBytesPtr = fBitmap.rowBytes();
-    return fBitmap.getPixels();
+bool SkImage_Raster::onPeekPixels(SkPixmap* pm) const {
+    return fBitmap.peekPixels(pm);
 }
 
 SkData* SkImage_Raster::onRefEncoded(GrContext*) const {
diff --git a/src/image/SkSurface.cpp b/src/image/SkSurface.cpp
index b018ef9..9bec562 100644
--- a/src/image/SkSurface.cpp
+++ b/src/image/SkSurface.cpp
@@ -182,10 +182,26 @@
     return asSB(this)->onDraw(canvas, x, y, paint);
 }
 
-const void* SkSurface::peekPixels(SkImageInfo* info, size_t* rowBytes) {
-    return this->getCanvas()->peekPixels(info, rowBytes);
+bool SkSurface::peekPixels(SkPixmap* pmap) {
+    return this->getCanvas()->peekPixels(pmap);
 }
 
+#ifdef SK_SUPPORT_LEGACY_PEEKPIXELS_PARMS
+const void* SkSurface::peekPixels(SkImageInfo* info, size_t* rowBytes) {
+    SkPixmap pm;
+    if (this->peekPixels(&pm)) {
+        if (info) {
+            *info = pm.info();
+        }
+        if (rowBytes) {
+            *rowBytes = pm.rowBytes();
+        }
+        return pm.addr();
+    }
+    return nullptr;
+}
+#endif
+
 bool SkSurface::readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
                            int srcX, int srcY) {
     return this->getCanvas()->readPixels(dstInfo, dstPixels, dstRowBytes, srcX, srcY);
diff --git a/tests/CanvasTest.cpp b/tests/CanvasTest.cpp
index 2390c74..f34430f 100644
--- a/tests/CanvasTest.cpp
+++ b/tests/CanvasTest.cpp
@@ -646,17 +646,16 @@
     SkCanvas* canvas = SkCanvas::NewRasterDirect(info, baseAddr, minRowBytes);
     REPORTER_ASSERT(reporter, canvas);
 
-    SkImageInfo info2;
-    size_t rowBytes;
-    const SkPMColor* addr = (const SkPMColor*)canvas->peekPixels(&info2, &rowBytes);
+    SkPixmap pmap;
+    const SkPMColor* addr = canvas->peekPixels(&pmap) ? pmap.addr32() : nullptr;
     REPORTER_ASSERT(reporter, addr);
-    REPORTER_ASSERT(reporter, info == info2);
-    REPORTER_ASSERT(reporter, minRowBytes == rowBytes);
+    REPORTER_ASSERT(reporter, info == pmap.info());
+    REPORTER_ASSERT(reporter, minRowBytes == pmap.rowBytes());
     for (int y = 0; y < info.height(); ++y) {
         for (int x = 0; x < info.width(); ++x) {
             REPORTER_ASSERT(reporter, 0 == addr[x]);
         }
-        addr = (const SkPMColor*)((const char*)addr + rowBytes);
+        addr = (const SkPMColor*)((const char*)addr + pmap.rowBytes());
     }
     delete canvas;
 
diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp
index ff1b4be..1a2e109 100644
--- a/tests/ImageTest.cpp
+++ b/tests/ImageTest.cpp
@@ -32,12 +32,7 @@
 
     REPORTER_ASSERT(reporter, widthA == b->width());
     REPORTER_ASSERT(reporter, heightA == b->height());
-#if 0
-    // see https://bug.skia.org/3965
-    bool AO = a->isOpaque();
-    bool BO = b->isOpaque();
-    REPORTER_ASSERT(reporter, AO == BO);
-#endif
+    REPORTER_ASSERT(reporter, a->isOpaque() == b->isOpaque());
 
     SkImageInfo info = SkImageInfo::MakeN32(widthA, heightA,
                                         a->isOpaque() ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
@@ -76,7 +71,6 @@
     return surface->newImageSnapshot();
 }
 #endif
-#if 0
 static SkImage* create_image_ct() {
     SkPMColor colors[] = {
         SkPreMultiplyARGB(0xFF, 0xFF, 0xFF, 0x00),
@@ -94,7 +88,6 @@
     SkImageInfo info = SkImageInfo::Make(5, 5, kIndex_8_SkColorType, kPremul_SkAlphaType);
     return SkImage::NewRasterCopy(info, data, 5, colorTable);
 }
-#endif
 static SkData* create_image_data(SkImageInfo* info) {
     *info = SkImageInfo::MakeN32(20, 20, kOpaque_SkAlphaType);
     const size_t rowBytes = info->minRowBytes();
@@ -658,19 +651,18 @@
 #endif
 
 static void test_peek(skiatest::Reporter* reporter, SkImage* image, bool expectPeekSuccess) {
-    SkImageInfo info;
-    size_t rowBytes;
-    const void* addr = image->peekPixels(&info, &rowBytes);
-    bool success = SkToBool(addr);
+    SkPixmap pm;
+    bool success = image->peekPixels(&pm);
     REPORTER_ASSERT(reporter, expectPeekSuccess == success);
     if (success) {
+        const SkImageInfo& info = pm.info();
         REPORTER_ASSERT(reporter, 20 == info.width());
         REPORTER_ASSERT(reporter, 20 == info.height());
         REPORTER_ASSERT(reporter, kN32_SkColorType == info.colorType());
         REPORTER_ASSERT(reporter, kPremul_SkAlphaType == info.alphaType() ||
                         kOpaque_SkAlphaType == info.alphaType());
-        REPORTER_ASSERT(reporter, info.minRowBytes() <= rowBytes);
-        REPORTER_ASSERT(reporter, SkPreMultiplyColor(SK_ColorWHITE) == *(const SkPMColor*)addr);
+        REPORTER_ASSERT(reporter, info.minRowBytes() <= pm.rowBytes());
+        REPORTER_ASSERT(reporter, SkPreMultiplyColor(SK_ColorWHITE) == *pm.addr32(0, 0));
     }
 }
 DEF_TEST(ImagePeek, reporter) {
@@ -806,13 +798,11 @@
 }
 
 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(NewTextureFromPixmap, reporter, context) {
-    for (auto create : {&create_image,
+    for (auto create : {&create_image
 #if 0 // read pixels failing for non RT formats (565 not a RT on some desktop GLs).
-                        &create_image_565
-#if 0 // peekPixels on color table images is currently broken.
+                        , &create_image_565
+#endif
                         , &create_image_ct
-#endif
-#endif
                         }) {
         SkAutoTUnref<SkImage> image((*create)());
         if (!image) {
diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp
index 971e6b5..d6c7acd 100644
--- a/tests/SurfaceTest.cpp
+++ b/tests/SurfaceTest.cpp
@@ -157,26 +157,23 @@
                              bool expectPeekSuccess) {
     const SkColor color = SK_ColorRED;
     const SkPMColor pmcolor = SkPreMultiplyColor(color);
-    SkImageInfo info;
-    size_t rowBytes;
     surface->getCanvas()->clear(color);
 
-    const void* addr = surface->getCanvas()->peekPixels(&info, &rowBytes);
-    bool success = SkToBool(addr);
+    SkPixmap pmap;
+    bool success = surface->getCanvas()->peekPixels(&pmap);
     REPORTER_ASSERT(reporter, expectPeekSuccess == success);
 
-    SkImageInfo info2;
-    size_t rb2;
-    const void* addr2 = surface->peekPixels(&info2, &rb2);
+    SkPixmap pmap2;
+    const void* addr2 = surface->peekPixels(&pmap2) ? pmap2.addr() : nullptr;
 
     if (success) {
-        REPORTER_ASSERT(reporter, requestInfo == info);
-        REPORTER_ASSERT(reporter, requestInfo.minRowBytes() <= rowBytes);
-        REPORTER_ASSERT(reporter, pmcolor == *(const SkPMColor*)addr);
+        REPORTER_ASSERT(reporter, requestInfo == pmap.info());
+        REPORTER_ASSERT(reporter, requestInfo.minRowBytes() <= pmap.rowBytes());
+        REPORTER_ASSERT(reporter, pmcolor == *pmap.addr32());
 
-        REPORTER_ASSERT(reporter, addr2 == addr);
-        REPORTER_ASSERT(reporter, info2 == info);
-        REPORTER_ASSERT(reporter, rb2 == rowBytes);
+        REPORTER_ASSERT(reporter, pmap.addr() == pmap2.addr());
+        REPORTER_ASSERT(reporter, pmap.info() == pmap2.info());
+        REPORTER_ASSERT(reporter, pmap.rowBytes() == pmap2.rowBytes());
     } else {
         REPORTER_ASSERT(reporter, nullptr == addr2);
     }
@@ -387,9 +384,8 @@
         return reinterpret_cast<intptr_t>(pm.addr());
     };
     auto getSufaceBackingStore = [reporter](SkSurface* surface) {
-        SkImageInfo info;
-        size_t rowBytes;
-        const void* pixels = surface->getCanvas()->peekPixels(&info, &rowBytes);
+        SkPixmap pmap;
+        const void* pixels = surface->getCanvas()->peekPixels(&pmap) ? pmap.addr() : nullptr;
         REPORTER_ASSERT(reporter, pixels);
         return reinterpret_cast<intptr_t>(pixels);
     };
@@ -785,27 +781,23 @@
 #endif
 
 static void check_rowbytes_remain_consistent(SkSurface* surface, skiatest::Reporter* reporter) {
-    SkImageInfo info;
-    size_t rowBytes;
-    REPORTER_ASSERT(reporter, surface->peekPixels(&info, &rowBytes));
+    SkPixmap surfacePM;
+    REPORTER_ASSERT(reporter, surface->peekPixels(&surfacePM));
 
     SkAutoTUnref<SkImage> image(surface->newImageSnapshot());
-    SkImageInfo im_info;
-    size_t im_rowbytes;
-    REPORTER_ASSERT(reporter, image->peekPixels(&im_info, &im_rowbytes));
+    SkPixmap pm;
+    REPORTER_ASSERT(reporter, image->peekPixels(&pm));
 
-    REPORTER_ASSERT(reporter, rowBytes == im_rowbytes);
+    REPORTER_ASSERT(reporter, surfacePM.rowBytes() == pm.rowBytes());
 
     // trigger a copy-on-write
     surface->getCanvas()->drawPaint(SkPaint());
     SkAutoTUnref<SkImage> image2(surface->newImageSnapshot());
     REPORTER_ASSERT(reporter, image->uniqueID() != image2->uniqueID());
 
-    SkImageInfo im_info2;
-    size_t im_rowbytes2;
-    REPORTER_ASSERT(reporter, image2->peekPixels(&im_info2, &im_rowbytes2));
-
-    REPORTER_ASSERT(reporter, im_rowbytes2 == im_rowbytes);
+    SkPixmap pm2;
+    REPORTER_ASSERT(reporter, image2->peekPixels(&pm2));
+    REPORTER_ASSERT(reporter, pm2.rowBytes() == pm.rowBytes());
 }
 
 DEF_TEST(surface_rowbytes, reporter) {
diff --git a/tools/android/SkAndroidSDKCanvas.cpp b/tools/android/SkAndroidSDKCanvas.cpp
index 45fcc75..1deb97c 100644
--- a/tools/android/SkAndroidSDKCanvas.cpp
+++ b/tools/android/SkAndroidSDKCanvas.cpp
@@ -292,15 +292,7 @@
 }
 
 bool SkAndroidSDKCanvas::onPeekPixels(SkPixmap* pmap) {
-    SkASSERT(pmap);
-    SkImageInfo info;
-    size_t rowBytes;
-    const void* addr = fProxyTarget->peekPixels(&info, &rowBytes);
-    if (addr) {
-        pmap->reset(info, addr, rowBytes);
-        return true;
-    }
-    return false;
+    return fProxyTarget->peekPixels(pmap);
 }
 
 bool SkAndroidSDKCanvas::onAccessTopLayerPixels(SkPixmap* pmap) {