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
This commit is contained in:
reed@google.com 2012-09-27 20:31:31 +00:00
parent 7d44059b6c
commit d86e7ab604
6 changed files with 33 additions and 20 deletions

View File

@ -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();

View File

@ -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;

View File

@ -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() { }
/**

View File

@ -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;
}

View File

@ -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);

View File

@ -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(