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:
parent
7d44059b6c
commit
d86e7ab604
@ -10,8 +10,10 @@
|
|||||||
#include "SkPictureStateTree.h"
|
#include "SkPictureStateTree.h"
|
||||||
#include "SkBBoxHierarchy.h"
|
#include "SkBBoxHierarchy.h"
|
||||||
|
|
||||||
SkBBoxHierarchyRecord::SkBBoxHierarchyRecord(uint32_t recordFlags, SkBBoxHierarchy* h)
|
SkBBoxHierarchyRecord::SkBBoxHierarchyRecord(uint32_t recordFlags,
|
||||||
: INHERITED(recordFlags) {
|
SkBBoxHierarchy* h,
|
||||||
|
SkDevice* device)
|
||||||
|
: INHERITED(recordFlags, device) {
|
||||||
fStateTree = SkNEW(SkPictureStateTree);
|
fStateTree = SkNEW(SkPictureStateTree);
|
||||||
fBoundingHierarchy = h;
|
fBoundingHierarchy = h;
|
||||||
fBoundingHierarchy->ref();
|
fBoundingHierarchy->ref();
|
||||||
|
@ -18,7 +18,8 @@
|
|||||||
class SkBBoxHierarchyRecord : public SkBBoxRecord {
|
class SkBBoxHierarchyRecord : public SkBBoxRecord {
|
||||||
public:
|
public:
|
||||||
/** This will take a ref of h */
|
/** 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;
|
virtual void handleBBox(const SkRect& bounds) SK_OVERRIDE;
|
||||||
|
|
||||||
|
@ -19,7 +19,8 @@
|
|||||||
class SkBBoxRecord : public SkPictureRecord {
|
class SkBBoxRecord : public SkPictureRecord {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
SkBBoxRecord(uint32_t recordFlags) :INHERITED(recordFlags) { }
|
SkBBoxRecord(uint32_t recordFlags, SkDevice* device)
|
||||||
|
: INHERITED(recordFlags, device) { }
|
||||||
virtual ~SkBBoxRecord() { }
|
virtual ~SkBBoxRecord() { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include "SkCanvas.h"
|
#include "SkCanvas.h"
|
||||||
#include "SkChunkAlloc.h"
|
#include "SkChunkAlloc.h"
|
||||||
|
#include "SkDevice.h"
|
||||||
#include "SkPicture.h"
|
#include "SkPicture.h"
|
||||||
#include "SkRegion.h"
|
#include "SkRegion.h"
|
||||||
#include "SkStream.h"
|
#include "SkStream.h"
|
||||||
@ -185,25 +186,26 @@ SkCanvas* SkPicture::beginRecording(int width, int height,
|
|||||||
fRecord = NULL;
|
fRecord = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SkBitmap bm;
|
||||||
|
bm.setConfig(SkBitmap::kNo_Config, width, height);
|
||||||
|
SkAutoTUnref<SkDevice> dev(SkNEW_ARGS(SkDevice, (bm)));
|
||||||
|
|
||||||
if (recordingFlags & kOptimizeForClippedPlayback_RecordingFlag) {
|
if (recordingFlags & kOptimizeForClippedPlayback_RecordingFlag) {
|
||||||
SkScalar aspectRatio = SkScalarDiv(SkIntToScalar(width),
|
SkScalar aspectRatio = SkScalarDiv(SkIntToScalar(width),
|
||||||
SkIntToScalar(height));
|
SkIntToScalar(height));
|
||||||
SkRTree* tree = SkRTree::Create(kRTreeMinChildren, kRTreeMaxChildren,
|
SkRTree* tree = SkRTree::Create(kRTreeMinChildren, kRTreeMaxChildren,
|
||||||
aspectRatio);
|
aspectRatio);
|
||||||
SkASSERT(NULL != tree);
|
SkASSERT(NULL != tree);
|
||||||
fRecord = SkNEW_ARGS(SkBBoxHierarchyRecord, (recordingFlags, tree));
|
fRecord = SkNEW_ARGS(SkBBoxHierarchyRecord, (recordingFlags, tree, dev));
|
||||||
tree->unref();
|
tree->unref();
|
||||||
} else {
|
} else {
|
||||||
fRecord = SkNEW_ARGS(SkPictureRecord, (recordingFlags));
|
fRecord = SkNEW_ARGS(SkPictureRecord, (recordingFlags, dev));
|
||||||
}
|
}
|
||||||
|
fRecord->beginRecording();
|
||||||
|
|
||||||
fWidth = width;
|
fWidth = width;
|
||||||
fHeight = height;
|
fHeight = height;
|
||||||
|
|
||||||
SkBitmap bm;
|
|
||||||
bm.setConfig(SkBitmap::kNo_Config, width, height);
|
|
||||||
fRecord->setBitmapDevice(bm);
|
|
||||||
|
|
||||||
return fRecord;
|
return fRecord;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,10 +15,12 @@
|
|||||||
#define HEAP_BLOCK_SIZE 4096
|
#define HEAP_BLOCK_SIZE 4096
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
// just need a value that save or getSaveCount would never return
|
||||||
kNoInitialSave = -1,
|
kNoInitialSave = -1,
|
||||||
};
|
};
|
||||||
|
|
||||||
SkPictureRecord::SkPictureRecord(uint32_t flags) :
|
SkPictureRecord::SkPictureRecord(uint32_t flags, SkDevice* device) :
|
||||||
|
INHERITED(device),
|
||||||
fBoundingHierarchy(NULL),
|
fBoundingHierarchy(NULL),
|
||||||
fStateTree(NULL),
|
fStateTree(NULL),
|
||||||
fFlattenableHeap(HEAP_BLOCK_SIZE),
|
fFlattenableHeap(HEAP_BLOCK_SIZE),
|
||||||
@ -33,12 +35,13 @@ SkPictureRecord::SkPictureRecord(uint32_t flags) :
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
fRestoreOffsetStack.setReserve(32);
|
fRestoreOffsetStack.setReserve(32);
|
||||||
fInitialSaveCount = kNoInitialSave;
|
|
||||||
|
|
||||||
fBitmapHeap = SkNEW(SkBitmapHeap);
|
fBitmapHeap = SkNEW(SkBitmapHeap);
|
||||||
fFlattenableHeap.setBitmapStorage(fBitmapHeap);
|
fFlattenableHeap.setBitmapStorage(fBitmapHeap);
|
||||||
fPathHeap = NULL; // lazy allocate
|
fPathHeap = NULL; // lazy allocate
|
||||||
fFirstSavedLayerIndex = kNoSavedLayerIndex;
|
fFirstSavedLayerIndex = kNoSavedLayerIndex;
|
||||||
|
|
||||||
|
fInitialSaveCount = kNoInitialSave;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkPictureRecord::~SkPictureRecord() {
|
SkPictureRecord::~SkPictureRecord() {
|
||||||
@ -53,13 +56,8 @@ SkPictureRecord::~SkPictureRecord() {
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
SkDevice* SkPictureRecord::setDevice(SkDevice* device) {
|
SkDevice* SkPictureRecord::setDevice(SkDevice* device) {
|
||||||
SkASSERT(kNoInitialSave == fInitialSaveCount);
|
SkASSERT(!"eeek, don't try to change the device on a recording canvas");
|
||||||
this->INHERITED::setDevice(device);
|
return 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int SkPictureRecord::save(SaveFlags flags) {
|
int SkPictureRecord::save(SaveFlags flags) {
|
||||||
@ -321,6 +319,13 @@ void SkPictureRecord::fillRestoreOffsetPlaceholdersForCurrentStackLevel(
|
|||||||
#endif
|
#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() {
|
void SkPictureRecord::endRecording() {
|
||||||
SkASSERT(kNoInitialSave != fInitialSaveCount);
|
SkASSERT(kNoInitialSave != fInitialSaveCount);
|
||||||
this->restoreToCount(fInitialSaveCount);
|
this->restoreToCount(fInitialSaveCount);
|
||||||
|
@ -21,7 +21,7 @@ class SkBBoxHierarchy;
|
|||||||
|
|
||||||
class SkPictureRecord : public SkCanvas {
|
class SkPictureRecord : public SkCanvas {
|
||||||
public:
|
public:
|
||||||
SkPictureRecord(uint32_t recordFlags);
|
SkPictureRecord(uint32_t recordFlags, SkDevice*);
|
||||||
virtual ~SkPictureRecord();
|
virtual ~SkPictureRecord();
|
||||||
|
|
||||||
virtual SkDevice* setDevice(SkDevice* device) SK_OVERRIDE;
|
virtual SkDevice* setDevice(SkDevice* device) SK_OVERRIDE;
|
||||||
@ -86,7 +86,9 @@ public:
|
|||||||
return fWriter;
|
return fWriter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void beginRecording();
|
||||||
void endRecording();
|
void endRecording();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void recordRestoreOffsetPlaceholder(SkRegion::Op);
|
void recordRestoreOffsetPlaceholder(SkRegion::Op);
|
||||||
void fillRestoreOffsetPlaceholdersForCurrentStackLevel(
|
void fillRestoreOffsetPlaceholdersForCurrentStackLevel(
|
||||||
|
Loading…
Reference in New Issue
Block a user