diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-09-27 20:31:31 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-09-27 20:31:31 +0000 |
commit | d86e7ab6044e4aba017cb126a26dd378eec9fcba (patch) | |
tree | db6283459541a83aacde094c8881fbe0830601fd | |
parent | 7d44059b6ce099db117a70b8ea0929d7c7e4b02a (diff) |
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
-rw-r--r-- | src/core/SkBBoxHierarchyRecord.cpp | 6 | ||||
-rw-r--r-- | src/core/SkBBoxHierarchyRecord.h | 3 | ||||
-rw-r--r-- | src/core/SkBBoxRecord.h | 3 | ||||
-rw-r--r-- | src/core/SkPicture.cpp | 14 | ||||
-rw-r--r-- | src/core/SkPictureRecord.cpp | 23 | ||||
-rw-r--r-- | src/core/SkPictureRecord.h | 4 |
6 files changed, 33 insertions, 20 deletions
diff --git a/src/core/SkBBoxHierarchyRecord.cpp b/src/core/SkBBoxHierarchyRecord.cpp index 35949b6760..c27940af6f 100644 --- a/src/core/SkBBoxHierarchyRecord.cpp +++ b/src/core/SkBBoxHierarchyRecord.cpp @@ -10,8 +10,10 @@ #include "SkPictureStateTree.h" #include "SkBBoxHierarchy.h" -SkBBoxHierarchyRecord::SkBBoxHierarchyRecord(uint32_t recordFlags, SkBBoxHierarchy* h) - : INHERITED(recordFlags) { +SkBBoxHierarchyRecord::SkBBoxHierarchyRecord(uint32_t recordFlags, + SkBBoxHierarchy* h, + SkDevice* device) + : INHERITED(recordFlags, device) { fStateTree = SkNEW(SkPictureStateTree); fBoundingHierarchy = h; fBoundingHierarchy->ref(); diff --git a/src/core/SkBBoxHierarchyRecord.h b/src/core/SkBBoxHierarchyRecord.h index c0cf365e76..4741338f2a 100644 --- a/src/core/SkBBoxHierarchyRecord.h +++ b/src/core/SkBBoxHierarchyRecord.h @@ -18,7 +18,8 @@ class SkBBoxHierarchyRecord : public SkBBoxRecord { public: /** This will take a ref of h */ - SkBBoxHierarchyRecord(uint32_t recordFlags, SkBBoxHierarchy* h); + SkBBoxHierarchyRecord(uint32_t recordFlags, SkBBoxHierarchy* h, + SkDevice*); virtual void handleBBox(const SkRect& bounds) SK_OVERRIDE; diff --git a/src/core/SkBBoxRecord.h b/src/core/SkBBoxRecord.h index c13a7f01c4..e6b85db5f7 100644 --- a/src/core/SkBBoxRecord.h +++ b/src/core/SkBBoxRecord.h @@ -19,7 +19,8 @@ class SkBBoxRecord : public SkPictureRecord { public: - SkBBoxRecord(uint32_t recordFlags) :INHERITED(recordFlags) { } + SkBBoxRecord(uint32_t recordFlags, SkDevice* device) + : INHERITED(recordFlags, device) { } virtual ~SkBBoxRecord() { } /** diff --git a/src/core/SkPicture.cpp b/src/core/SkPicture.cpp index 7e8b371b58..b3d3751e36 100644 --- a/src/core/SkPicture.cpp +++ b/src/core/SkPicture.cpp @@ -13,6 +13,7 @@ #include "SkCanvas.h" #include "SkChunkAlloc.h" +#include "SkDevice.h" #include "SkPicture.h" #include "SkRegion.h" #include "SkStream.h" @@ -185,25 +186,26 @@ SkCanvas* SkPicture::beginRecording(int width, int height, fRecord = NULL; } + SkBitmap bm; + bm.setConfig(SkBitmap::kNo_Config, width, height); + SkAutoTUnref<SkDevice> dev(SkNEW_ARGS(SkDevice, (bm))); + if (recordingFlags & kOptimizeForClippedPlayback_RecordingFlag) { SkScalar aspectRatio = SkScalarDiv(SkIntToScalar(width), SkIntToScalar(height)); SkRTree* tree = SkRTree::Create(kRTreeMinChildren, kRTreeMaxChildren, aspectRatio); SkASSERT(NULL != tree); - fRecord = SkNEW_ARGS(SkBBoxHierarchyRecord, (recordingFlags, tree)); + fRecord = SkNEW_ARGS(SkBBoxHierarchyRecord, (recordingFlags, tree, dev)); tree->unref(); } else { - fRecord = SkNEW_ARGS(SkPictureRecord, (recordingFlags)); + fRecord = SkNEW_ARGS(SkPictureRecord, (recordingFlags, dev)); } + fRecord->beginRecording(); fWidth = width; fHeight = height; - SkBitmap bm; - bm.setConfig(SkBitmap::kNo_Config, width, height); - fRecord->setBitmapDevice(bm); - return fRecord; } diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp index 944fd1898f..60e51d1829 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 @@ SkPictureRecord::SkPictureRecord(uint32_t flags) : #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 @@ SkPictureRecord::~SkPictureRecord() { /////////////////////////////////////////////////////////////////////////////// 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 @@ void SkPictureRecord::fillRestoreOffsetPlaceholdersForCurrentStackLevel( #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); diff --git a/src/core/SkPictureRecord.h b/src/core/SkPictureRecord.h index fec1a829f3..c36c24ab3d 100644 --- a/src/core/SkPictureRecord.h +++ b/src/core/SkPictureRecord.h @@ -21,7 +21,7 @@ class SkBBoxHierarchy; class SkPictureRecord : public SkCanvas { public: - SkPictureRecord(uint32_t recordFlags); + SkPictureRecord(uint32_t recordFlags, SkDevice*); virtual ~SkPictureRecord(); virtual SkDevice* setDevice(SkDevice* device) SK_OVERRIDE; @@ -86,7 +86,9 @@ public: return fWriter; } + void beginRecording(); void endRecording(); + private: void recordRestoreOffsetPlaceholder(SkRegion::Op); void fillRestoreOffsetPlaceholdersForCurrentStackLevel( |