stop calling SkCanvas::getDevice

BUG=skia:
R=bsalomon@google.com, robertphillips@google.com, junov@google.com

Author: reed@google.com

Review URL: https://codereview.chromium.org/355193006
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index df10b1e..8825f53 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -1007,7 +1007,7 @@
 
 static bool bitmap_diff(SkCanvas* canvas, const SkBitmap& orig,
                         SkBitmap* diff) {
-    const SkBitmap& src = canvas->getDevice()->accessBitmap(false);
+    SkBitmap src = capture_bitmap(canvas);
 
     SkAutoLockPixels alp0(src);
     SkAutoLockPixels alp1(orig);
@@ -1282,7 +1282,7 @@
 
 SkCanvas* SampleWindow::beforeChildren(SkCanvas* canvas) {
     if (fSaveToPdf) {
-        const SkBitmap& bmp = canvas->getDevice()->accessBitmap(false);
+        const SkBitmap bmp = capture_bitmap(canvas);
         SkISize size = SkISize::Make(bmp.width(), bmp.height());
         SkPDFDevice* pdfDevice = new SkPDFDevice(size, size,
                 canvas->getTotalMatrix());
@@ -1308,15 +1308,6 @@
     return canvas;
 }
 
-static void paint_rgn(const SkBitmap& bm, const SkIRect& r,
-                      const SkRegion& rgn) {
-    SkCanvas    canvas(bm);
-    SkRegion    inval(rgn);
-
-    inval.translate(r.fLeft, r.fTop);
-    canvas.clipRegion(inval);
-    canvas.drawColor(0xFFFF8080);
-}
 #include "SkData.h"
 void SampleWindow::afterChildren(SkCanvas* orig) {
     if (fSaveToPdf) {
@@ -1327,7 +1318,8 @@
         SkString name;
         name.printf("%s.pdf", this->getTitle());
         SkPDFDocument doc;
-        SkPDFDevice* device = static_cast<SkPDFDevice*>(fPdfCanvas->getDevice());
+        SkPDFDevice* device = NULL;//static_cast<SkPDFDevice*>(fPdfCanvas->getDevice());
+        SkASSERT(false);
         doc.appendPage(device);
 #ifdef SK_BUILD_FOR_ANDROID
         name.prepend("/sdcard/");
@@ -1357,9 +1349,8 @@
     if (fRequestGrabImage) {
         fRequestGrabImage = false;
 
-        SkBaseDevice* device = orig->getDevice();
-        SkBitmap bmp;
-        if (device->accessBitmap(false).copyTo(&bmp, kN32_SkColorType)) {
+        SkBitmap bmp = capture_bitmap(orig);
+        if (!bmp.isNull()) {
             static int gSampleGrabCounter;
             SkString name;
             name.printf("sample_grab_%d.png", gSampleGrabCounter++);
@@ -1395,19 +1386,6 @@
     if (fMeasureFPS && fMeasureFPS_StartTime) {
         fMeasureFPS_Time += SkTime::GetMSecs() - fMeasureFPS_StartTime;
     }
-
-    //    if ((fScrollTestX | fScrollTestY) != 0)
-    if (false) {
-        const SkBitmap& bm = orig->getDevice()->accessBitmap(true);
-        int dx = fScrollTestX * 7;
-        int dy = fScrollTestY * 7;
-        SkIRect r;
-        SkRegion inval;
-
-        r.set(50, 50, 50+100, 50+100);
-        bm.scrollRect(&r, dx, dy, &inval);
-        paint_rgn(bm, r, inval);
-    }
 }
 
 void SampleWindow::beforeChild(SkView* child, SkCanvas* canvas) {
@@ -2257,9 +2235,8 @@
     } else {
         SkGPipeWriter writer;
         SimplePC controller(canvas);
-        TiledPipeController tc(canvas->getDevice()->accessBitmap(false),
-                               &SkImageDecoder::DecodeMemory,
-                               &canvas->getTotalMatrix());
+        SkBitmap bitmap = capture_bitmap(canvas);
+        TiledPipeController tc(bitmap, &SkImageDecoder::DecodeMemory, &canvas->getTotalMatrix());
         SkGPipeController* pc;
         if (SkOSMenu::kMixedState == fPipeState) {
             pc = &tc;