Removing the SkPicture backend from SkDeferredCanvas code

Review URL: https://codereview.appspot.com/6446095

git-svn-id: http://skia.googlecode.com/svn/trunk@4974 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
junov@chromium.org 2012-08-07 14:53:59 +00:00
parent 24e8999b4b
commit 3de7acc180
4 changed files with 0 additions and 61 deletions

View File

@ -8,20 +8,12 @@
#ifndef SkDeferredCanvas_DEFINED
#define SkDeferredCanvas_DEFINED
#ifndef SK_DEFERRED_CANVAS_USES_GPIPE
#define SK_DEFERRED_CANVAS_USES_GPIPE 1
#endif
#include "SkCanvas.h"
#include "SkDevice.h"
#include "SkPixelRef.h"
#if SK_DEFERRED_CANVAS_USES_GPIPE
#include "SkGPipe.h"
#include "SkChunkAlloc.h"
#else
#include "SkPicture.h"
#endif
/** \class SkDeferredCanvas
Subclass of SkCanvas that encapsulates an SkPicture or SkGPipe for deferred
@ -184,7 +176,6 @@ public:
typedef SkRefCnt INHERITED;
};
#if SK_DEFERRED_CANVAS_USES_GPIPE
protected:
class DeferredPipeController : public SkGPipeController {
public:
@ -212,7 +203,6 @@ protected:
SkTDArray<PipeBlock> fBlockList;
SkGPipeReader fReader;
};
#endif
public:
class DeferredDevice : public SkDevice {
@ -347,12 +337,8 @@ public:
void endRecording();
void beginRecording();
#if SK_DEFERRED_CANVAS_USES_GPIPE
DeferredPipeController fPipeController;
SkGPipeWriter fPipeWriter;
#else
SkPicture fPicture;
#endif
SkDevice* fImmediateDevice;
SkCanvas* fImmediateCanvas;
SkCanvas* fRecordingCanvas;

View File

@ -169,11 +169,7 @@ size_t SkDeferredCanvas::storageAllocatedForRecording() const {
}
size_t SkDeferredCanvas::freeMemoryIfPossible(size_t bytesToFree) {
#if SK_DEFERRED_CANVAS_USES_GPIPE
return this->getDeferredDevice()->freeMemoryIfPossible(bytesToFree);
#else
return 0;
#endif
}
void SkDeferredCanvas::validate() const {
@ -518,8 +514,6 @@ SkCanvas* SkDeferredCanvas::canvasForDrawIter() {
return drawingCanvas();
}
#if SK_DEFERRED_CANVAS_USES_GPIPE
// SkDeferredCanvas::DeferredPipeController
//-------------------------------------------
@ -576,8 +570,6 @@ void SkDeferredCanvas::DeferredPipeController::reset() {
fAllocator.reset();
}
#endif // SK_DEFERRED_CANVAS_USES_GPIPE
// SkDeferredCanvas::DeferredDevice
//------------------------------------
@ -592,9 +584,7 @@ SkDeferredCanvas::DeferredDevice::DeferredDevice(
SkSafeRef(fDeviceContext);
fImmediateDevice = immediateDevice; // ref counted via fImmediateCanvas
fImmediateCanvas = SkNEW_ARGS(SkCanvas, (fImmediateDevice));
#if SK_DEFERRED_CANVAS_USES_GPIPE
fPipeController.setPlaybackCanvas(fImmediateCanvas);
#endif
beginRecording();
}
@ -610,22 +600,13 @@ void SkDeferredCanvas::DeferredDevice::setMaxRecordingStorage(size_t maxStorage)
}
void SkDeferredCanvas::DeferredDevice::endRecording() {
#if SK_DEFERRED_CANVAS_USES_GPIPE
fPipeWriter.endRecording();
fPipeController.reset();
#else
fPicture.endRecording();
#endif
fRecordingCanvas = NULL;
}
void SkDeferredCanvas::DeferredDevice::beginRecording() {
#if SK_DEFERRED_CANVAS_USES_GPIPE
fRecordingCanvas = fPipeWriter.startRecording(&fPipeController, 0);
#else
fRecordingCanvas = fPicture.beginRecording(fImmediateDevice->width(),
fImmediateDevice->height());
#endif
}
void SkDeferredCanvas::DeferredDevice::setDeviceContext(
@ -675,26 +656,15 @@ bool SkDeferredCanvas::DeferredDevice::isFreshFrame() {
}
void SkDeferredCanvas::DeferredDevice::flushPending() {
#if SK_DEFERRED_CANVAS_USES_GPIPE
if (!fPipeController.hasRecorded()) {
return;
}
#else
if (!fPicture.hasRecorded()) {
return;
}
#endif
if (fDeviceContext) {
fDeviceContext->prepareForDraw();
}
#if SK_DEFERRED_CANVAS_USES_GPIPE
fPipeWriter.flushRecording(true);
fPipeController.playback();
#else
fPicture.draw(fImmediateCanvas);
this->beginRecording();
#endif
}
void SkDeferredCanvas::DeferredDevice::flush() {
@ -702,23 +672,16 @@ void SkDeferredCanvas::DeferredDevice::flush() {
fImmediateCanvas->flush();
}
#if SK_DEFERRED_CANVAS_USES_GPIPE
size_t SkDeferredCanvas::DeferredDevice::freeMemoryIfPossible(size_t bytesToFree) {
return fPipeWriter.freeMemoryIfPossible(bytesToFree);
}
#endif
size_t SkDeferredCanvas::DeferredDevice::storageAllocatedForRecording() const {
#if SK_DEFERRED_CANVAS_USES_GPIPE
return (fPipeController.storageAllocatedForRecording()
+ fPipeWriter.storageAllocatedForRecording());
#else
return 0;
#endif
}
SkCanvas* SkDeferredCanvas::DeferredDevice::recordingCanvas() {
#if SK_DEFERRED_CANVAS_USES_GPIPE
size_t storageAllocated = this->storageAllocatedForRecording();
if (storageAllocated > fMaxRecordingStorageBytes) {
// First, attempt to reduce cache without flushing
@ -731,7 +694,6 @@ SkCanvas* SkDeferredCanvas::DeferredDevice::recordingCanvas() {
this->freeMemoryIfPossible(~0);
}
}
#endif
return fRecordingCanvas;
}

View File

@ -756,14 +756,12 @@ static void TestDeferredCanvasStateConsistency(
AssertCanvasStatesEqual(reporter, &deferredCanvas, &referenceCanvas,
testStep);
#if SK_DEFERRED_CANVAS_USES_GPIPE
deferredCanvas.flush();
testStep->setAssertMessageFormat(
kDeferredPostFlushPlaybackAssertMessageFormat);
AssertCanvasStatesEqual(reporter,
deferredCanvas.getDeferredDevice()->immediateCanvas(),
&referenceCanvas, testStep);
#endif
// Verified that deferred canvas state is not affected by flushing
// pending draw operations

View File

@ -210,13 +210,9 @@ static void TestDeferredCanvasMemoryLimit(skiatest::Reporter* reporter) {
canvas.drawBitmap(sourceImage, 0, 0, NULL);
}
// SkPicture path is not fixed
#if SK_DEFERRED_CANVAS_USES_GPIPE
REPORTER_ASSERT(reporter, mockDevice.fDrawBitmapCallCount == 4);
#endif
}
#if SK_DEFERRED_CANVAS_USES_GPIPE
static void TestDeferredCanvasBitmapCaching(skiatest::Reporter* reporter) {
SkBitmap store;
store.setConfig(SkBitmap::kARGB_8888_Config, 100, 100);
@ -282,16 +278,13 @@ static void TestDeferredCanvasBitmapCaching(skiatest::Reporter* reporter) {
canvas.drawBitmap(sourceImages[1], 0, 0, NULL);
REPORTER_ASSERT(reporter, canvas.storageAllocatedForRecording() > 2*bitmapSize);
}
#endif
static void TestDeferredCanvas(skiatest::Reporter* reporter) {
TestDeferredCanvasBitmapAccess(reporter);
TestDeferredCanvasFlush(reporter);
TestDeferredCanvasFreshFrame(reporter);
TestDeferredCanvasMemoryLimit(reporter);
#if SK_DEFERRED_CANVAS_USES_GPIPE
TestDeferredCanvasBitmapCaching(reporter);
#endif
}
#include "TestClassDef.h"