Add missing null device checks in SkCanvas
Review URL: https://codereview.appspot.com/6092056

git-svn-id: http://skia.googlecode.com/svn/trunk@3810 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index af55958..b0f85d9 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -604,6 +604,9 @@
 
 bool SkCanvas::readPixels(const SkIRect& srcRect, SkBitmap* bitmap) {
     SkDevice* device = this->getDevice();
+    if (!device) {
+        return false;
+    }
 
     SkIRect bounds;
     bounds.set(0, 0, device->width(), device->height());
@@ -1129,6 +1132,10 @@
         }
     } else {
         const SkDevice* device = canvas->getDevice();
+        if (!device) {
+            return currClip->setEmpty();
+        }
+
         base.setRect(0, 0, device->width(), device->height());
 
         if (SkRegion::kReplace_Op == op) {
@@ -1185,6 +1192,11 @@
 void SkCanvas::validateClip() const {
     // construct clipRgn from the clipstack
     const SkDevice* device = this->getDevice();
+    if (!device) {
+        SkASSERT(this->getTotalClip().isEmpty());
+        return;
+    }
+
     SkIRect ir;
     ir.set(0, 0, device->width(), device->height());
     SkRasterClip tmpClip(ir);