kSharedAddressSpace_Flag = 1 << 1
};
- SkCanvas* startRecording(SkGPipeController*, uint32_t flags = 0);
+ SkCanvas* startRecording(SkGPipeController*, uint32_t flags = 0,
+ uint32_t width = kDefaultRecordingCanvasSize,
+ uint32_t height = kDefaultRecordingCanvasSize);
// called in destructor, but can be called sooner once you know there
// should be no more drawing calls made into the recording canvas.
size_t freeMemoryIfPossible(size_t bytesToFree);
private:
+ enum {
+ kDefaultRecordingCanvasSize = 32767,
+ };
+
SkGPipeCanvas* fCanvas;
SkWriter32 fWriter;
};
class SkGPipeCanvas : public SkCanvas {
public:
- SkGPipeCanvas(SkGPipeController*, SkWriter32*, uint32_t flags);
+ SkGPipeCanvas(SkGPipeController*, SkWriter32*, uint32_t flags,
+ uint32_t width, uint32_t height);
virtual ~SkGPipeCanvas();
void finish() {
#define FLATTENABLES_TO_KEEP 10
SkGPipeCanvas::SkGPipeCanvas(SkGPipeController* controller,
- SkWriter32* writer, uint32_t flags)
+ SkWriter32* writer, uint32_t flags,
+ uint32_t width, uint32_t height)
: fFactorySet(isCrossProcess(flags) ? SkNEW(SkNamedFactorySet) : NULL)
, fWriter(*writer)
, fFlags(flags)
sk_bzero(fCurrFlatIndex, sizeof(fCurrFlatIndex));
// we need a device to limit our clip
- // should the caller give us the bounds?
// We don't allocate pixels for the bitmap
SkBitmap bitmap;
- bitmap.setConfig(SkBitmap::kARGB_8888_Config, 32767, 32767);
+ bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
SkDevice* device = SkNEW_ARGS(SkDevice, (bitmap));
this->setDevice(device)->unref();
this->endRecording();
}
-SkCanvas* SkGPipeWriter::startRecording(SkGPipeController* controller, uint32_t flags) {
+SkCanvas* SkGPipeWriter::startRecording(SkGPipeController* controller, uint32_t flags,
+ uint32_t width, uint32_t height) {
if (NULL == fCanvas) {
fWriter.reset(NULL, 0);
- fCanvas = SkNEW_ARGS(SkGPipeCanvas, (controller, &fWriter, flags));
+ fCanvas = SkNEW_ARGS(SkGPipeCanvas, (controller, &fWriter, flags, width, height));
}
controller->setCanvas(fCanvas);
return fCanvas;
SkDevice* immediateDevice, SkDeferredCanvas::NotificationClient* notificationClient) :
SkDevice(SkBitmap::kNo_Config, immediateDevice->width(),
immediateDevice->height(), immediateDevice->isOpaque())
+ , fRecordingCanvas(NULL)
, fFreshFrame(true)
, fPreviousStorageAllocated(0){
}
void DeferredDevice::beginRecording() {
- fRecordingCanvas = fPipeWriter.startRecording(&fPipeController, 0);
+ SkASSERT(NULL == fRecordingCanvas);
+ fRecordingCanvas = fPipeWriter.startRecording(&fPipeController, 0,
+ fImmediateDevice->width(), fImmediateDevice->height());
}
void DeferredDevice::setNotificationClient(
// TODO: find a way to transfer the state stack and layers
// to the new recording canvas. For now, purging only works
- // with an empty stack.
- if (fRecordingCanvas->getSaveCount() == 0) {
+ // with an empty stack. A save count of 1 means an empty stack.
+ SkASSERT(fRecordingCanvas->getSaveCount() >= 1);
+ if (fRecordingCanvas->getSaveCount() == 1) {
// Save state that is trashed by the purge
SkDrawFilter* drawFilter = fRecordingCanvas->getDrawFilter();