remove call to setBitmapDevice (deprecated).
Review URL: https://codereview.appspot.com/6569070

git-svn-id: http://skia.googlecode.com/svn/trunk@5715 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp
index 944fd18..60e51d1 100644
--- a/src/core/SkPictureRecord.cpp
+++ b/src/core/SkPictureRecord.cpp
@@ -15,10 +15,12 @@
 #define HEAP_BLOCK_SIZE 4096
 
 enum {
+    // just need a value that save or getSaveCount would never return
     kNoInitialSave = -1,
 };
 
-SkPictureRecord::SkPictureRecord(uint32_t flags) :
+SkPictureRecord::SkPictureRecord(uint32_t flags, SkDevice* device) :
+        INHERITED(device),
         fBoundingHierarchy(NULL),
         fStateTree(NULL),
         fFlattenableHeap(HEAP_BLOCK_SIZE),
@@ -33,12 +35,13 @@
 #endif
 
     fRestoreOffsetStack.setReserve(32);
-    fInitialSaveCount = kNoInitialSave;
 
     fBitmapHeap = SkNEW(SkBitmapHeap);
     fFlattenableHeap.setBitmapStorage(fBitmapHeap);
     fPathHeap = NULL;   // lazy allocate
     fFirstSavedLayerIndex = kNoSavedLayerIndex;
+
+    fInitialSaveCount = kNoInitialSave;
 }
 
 SkPictureRecord::~SkPictureRecord() {
@@ -53,13 +56,8 @@
 ///////////////////////////////////////////////////////////////////////////////
 
 SkDevice* SkPictureRecord::setDevice(SkDevice* device) {
-    SkASSERT(kNoInitialSave == fInitialSaveCount);
-    this->INHERITED::setDevice(device);
-
-    // The bracketting save() call needs to be recorded after setting the
-    // device otherwise the clip stack will get messed-up
-    fInitialSaveCount = this->save(SkCanvas::kMatrixClip_SaveFlag);
-    return device;
+    SkASSERT(!"eeek, don't try to change the device on a recording canvas");
+    return this->INHERITED::setDevice(device);
 }
 
 int SkPictureRecord::save(SaveFlags flags) {
@@ -321,6 +319,13 @@
 #endif
 }
 
+void SkPictureRecord::beginRecording() {
+    // we have to call this *after* our constructor, to ensure that it gets
+    // recorded. This is balanced by restoreToCount() call from endRecording,
+    // which in-turn calls our overridden restore(), so those get recorded too.
+    fInitialSaveCount = this->save(kMatrixClip_SaveFlag);
+}
+
 void SkPictureRecord::endRecording() {
     SkASSERT(kNoInitialSave != fInitialSaveCount);
     this->restoreToCount(fInitialSaveCount);