Rename SkDrawPictureCallback to SkPicture::AbortCallback
Review URL: https://codereview.chromium.org/829983003
This commit is contained in:
parent
b5d818ab04
commit
7ef197255d
@ -22,6 +22,7 @@
|
||||
'SK_SUPPORT_LEGACY_PORTER_DUFF',
|
||||
'SK_SUPPORT_LEGACY_DRAWDATA',
|
||||
'SK_SUPPORT_LEGACY_CANVAS_VIRTUAL',
|
||||
'SK_LEGACY_DRAWPICTURECALLBACK',
|
||||
],
|
||||
},
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
'skia_for_chromium_defines': [
|
||||
'SK_SUPPORT_LEGACY_DRAWDATA',
|
||||
'SK_SUPPORT_LEGACY_CANVAS_VIRTUAL',
|
||||
'SK_LEGACY_DRAWPICTURECALLBACK',
|
||||
],
|
||||
},
|
||||
}
|
||||
|
@ -10,6 +10,9 @@
|
||||
|
||||
#include "SkTypes.h"
|
||||
|
||||
#ifdef SK_LEGACY_DRAWPICTURECALLBACK
|
||||
#include "SkPicture.h"
|
||||
|
||||
/**
|
||||
* Subclasses of this can be passed to canvas.drawPicture(). During the drawing
|
||||
* of the picture, this callback will periodically be invoked. If its
|
||||
@ -20,12 +23,12 @@
|
||||
* calls to save(), restore will automatically be called to return the state
|
||||
* to the same level it was before the drawPicture call was made.
|
||||
*/
|
||||
class SK_API SkDrawPictureCallback {
|
||||
class SK_API SkDrawPictureCallback : public SkPicture::AbortCallback {
|
||||
public:
|
||||
SkDrawPictureCallback() {}
|
||||
virtual ~SkDrawPictureCallback() {}
|
||||
|
||||
virtual bool abortDrawing() = 0;
|
||||
};
|
||||
|
||||
#endif//SkDrawPictureCallback_DEFINED
|
||||
bool abort() SK_OVERRIDE { return this->abortDrawing(); }
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif // SkDrawPictureCallback_DEFINED
|
||||
|
@ -9,8 +9,6 @@
|
||||
#ifndef SkPicture_DEFINED
|
||||
#define SkPicture_DEFINED
|
||||
|
||||
#include "SkBitmap.h"
|
||||
#include "SkDrawPictureCallback.h"
|
||||
#include "SkImageDecoder.h"
|
||||
#include "SkRefCnt.h"
|
||||
#include "SkTDArray.h"
|
||||
@ -19,6 +17,7 @@
|
||||
class GrContext;
|
||||
#endif
|
||||
|
||||
class SkBitmap;
|
||||
class SkBBoxHierarchy;
|
||||
class SkCanvas;
|
||||
class SkData;
|
||||
@ -102,6 +101,24 @@ public:
|
||||
|
||||
~SkPicture();
|
||||
|
||||
/**
|
||||
* Subclasses of this can be passed to playback(). During the playback
|
||||
* of the picture, this callback will periodically be invoked. If its
|
||||
* abort() returns true, then picture playback will be interrupted.
|
||||
*
|
||||
* The resulting drawing is undefined, as there is no guarantee how often the
|
||||
* callback will be invoked. If the abort happens inside some level of nested
|
||||
* calls to save(), restore will automatically be called to return the state
|
||||
* to the same level it was before the playback call was made.
|
||||
*/
|
||||
class AbortCallback {
|
||||
public:
|
||||
AbortCallback() {}
|
||||
virtual ~AbortCallback() {}
|
||||
|
||||
virtual bool abort() = 0;
|
||||
};
|
||||
|
||||
/** Replays the drawing commands on the specified canvas. Note that
|
||||
this has the effect of unfurling this picture into the destination
|
||||
canvas. Using the SkCanvas::drawPicture entry point gives the destination
|
||||
@ -109,7 +126,7 @@ public:
|
||||
@param canvas the canvas receiving the drawing commands.
|
||||
@param callback a callback that allows interruption of playback
|
||||
*/
|
||||
void playback(SkCanvas* canvas, SkDrawPictureCallback* = NULL) const;
|
||||
void playback(SkCanvas* canvas, AbortCallback* = NULL) const;
|
||||
|
||||
/** Return the cull rect used when creating this picture: { 0, 0, cullWidth, cullHeight }.
|
||||
It does not necessarily reflect the bounds of what has been recorded into the picture.
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include "SkBitmapDevice.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkChunkAlloc.h"
|
||||
#include "SkDrawPictureCallback.h"
|
||||
#include "SkMessageBus.h"
|
||||
#include "SkPaintPriv.h"
|
||||
#include "SkPathEffect.h"
|
||||
@ -310,7 +309,7 @@ SkPicture::AccelData::Domain SkPicture::AccelData::GenerateDomain() {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void SkPicture::playback(SkCanvas* canvas, SkDrawPictureCallback* callback) const {
|
||||
void SkPicture::playback(SkCanvas* canvas, AbortCallback* callback) const {
|
||||
SkASSERT(canvas);
|
||||
|
||||
// If the query contains the whole picture, don't bother with the BBH.
|
||||
|
@ -5,14 +5,11 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#include <new>
|
||||
#include "SkBBoxHierarchy.h"
|
||||
#include "SkDrawPictureCallback.h"
|
||||
#include "SkPictureData.h"
|
||||
#include "SkPictureRecord.h"
|
||||
#include "SkReadBuffer.h"
|
||||
#include "SkTextBlob.h"
|
||||
#include "SkTypeface.h"
|
||||
#include "SkTSort.h"
|
||||
#include "SkWriteBuffer.h"
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
|
@ -65,7 +65,7 @@ static SkBitmap shallow_copy(const SkBitmap& bitmap) {
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
void SkPicturePlayback::draw(SkCanvas* canvas, SkDrawPictureCallback* callback) {
|
||||
void SkPicturePlayback::draw(SkCanvas* canvas, SkPicture::AbortCallback* callback) {
|
||||
AutoResetOpID aroi(this);
|
||||
SkASSERT(0 == fCurOffset);
|
||||
|
||||
@ -77,7 +77,7 @@ void SkPicturePlayback::draw(SkCanvas* canvas, SkDrawPictureCallback* callback)
|
||||
SkAutoCanvasRestore acr(canvas, false);
|
||||
|
||||
while (!reader.eof()) {
|
||||
if (callback && callback->abortDrawing()) {
|
||||
if (callback && callback->abort()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,6 @@
|
||||
|
||||
class SkBitmap;
|
||||
class SkCanvas;
|
||||
class SkDrawPictureCallback;
|
||||
class SkPaint;
|
||||
class SkPictureData;
|
||||
|
||||
@ -25,7 +24,7 @@ public:
|
||||
}
|
||||
virtual ~SkPicturePlayback() { }
|
||||
|
||||
virtual void draw(SkCanvas* canvas, SkDrawPictureCallback*);
|
||||
virtual void draw(SkCanvas* canvas, SkPicture::AbortCallback*);
|
||||
|
||||
// TODO: remove the curOp calls after cleaning up GrGatherDevice
|
||||
// Return the ID of the operation currently being executed when playing
|
||||
|
@ -15,7 +15,7 @@ void SkRecordDraw(const SkRecord& record,
|
||||
SkCanvasDrawable* const drawables[],
|
||||
int drawableCount,
|
||||
const SkBBoxHierarchy* bbh,
|
||||
SkDrawPictureCallback* callback) {
|
||||
SkPicture::AbortCallback* callback) {
|
||||
SkAutoCanvasRestore saveRestore(canvas, true /*save now, restore at exit*/);
|
||||
|
||||
if (bbh) {
|
||||
@ -34,7 +34,7 @@ void SkRecordDraw(const SkRecord& record,
|
||||
|
||||
SkRecords::Draw draw(canvas, drawablePicts, drawables, drawableCount);
|
||||
for (int i = 0; i < ops.count(); i++) {
|
||||
if (callback && callback->abortDrawing()) {
|
||||
if (callback && callback->abort()) {
|
||||
return;
|
||||
}
|
||||
// This visit call uses the SkRecords::Draw::operator() to call
|
||||
@ -46,7 +46,7 @@ void SkRecordDraw(const SkRecord& record,
|
||||
// Draw all ops.
|
||||
SkRecords::Draw draw(canvas, drawablePicts, drawables, drawableCount);
|
||||
for (unsigned i = 0; i < record.count(); i++) {
|
||||
if (callback && callback->abortDrawing()) {
|
||||
if (callback && callback->abort()) {
|
||||
return;
|
||||
}
|
||||
// This visit call uses the SkRecords::Draw::operator() to call
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
#include "SkBBoxHierarchy.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkDrawPictureCallback.h"
|
||||
#include "SkMatrix.h"
|
||||
#include "SkRecord.h"
|
||||
|
||||
@ -27,7 +26,7 @@ void SkRecordComputeLayers(const SkRect& cullRect, const SkRecord& record,
|
||||
// Draw an SkRecord into an SkCanvas. A convenience wrapper around SkRecords::Draw.
|
||||
void SkRecordDraw(const SkRecord&, SkCanvas*, SkPicture const* const drawablePicts[],
|
||||
SkCanvasDrawable* const drawables[], int drawableCount,
|
||||
const SkBBoxHierarchy*, SkDrawPictureCallback*);
|
||||
const SkBBoxHierarchy*, SkPicture::AbortCallback*);
|
||||
|
||||
// Draw a portion of an SkRecord into an SkCanvas.
|
||||
// When drawing a portion of an SkRecord the CTM on the passed in canvas must be
|
||||
|
@ -55,7 +55,7 @@ public:
|
||||
const SkPicture* topLevelPicture,
|
||||
const SkPicture* picture,
|
||||
const SkMatrix& initialMatrix,
|
||||
SkDrawPictureCallback* callback,
|
||||
SkPicture::AbortCallback* callback,
|
||||
const unsigned* opIndices, int numIndices)
|
||||
: INHERITED(canvas, drawablePicts, NULL, drawableCount)
|
||||
, fCanvas(canvas)
|
||||
@ -92,7 +92,7 @@ public:
|
||||
bbh->search(query, &fOps);
|
||||
|
||||
for (fIndex = 0; fIndex < fOps.count(); ++fIndex) {
|
||||
if (fCallback && fCallback->abortDrawing()) {
|
||||
if (fCallback && fCallback->abort()) {
|
||||
return fNumReplaced;
|
||||
}
|
||||
|
||||
@ -101,7 +101,7 @@ public:
|
||||
|
||||
} else {
|
||||
for (fIndex = 0; fIndex < (int) record->count(); ++fIndex) {
|
||||
if (fCallback && fCallback->abortDrawing()) {
|
||||
if (fCallback && fCallback->abort()) {
|
||||
return fNumReplaced;
|
||||
}
|
||||
|
||||
@ -181,19 +181,19 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
SkCanvas* fCanvas;
|
||||
GrLayerCache* fLayerCache;
|
||||
const SkPicture* fTopLevelPicture;
|
||||
const SkPicture* fPicture;
|
||||
const SkMatrix fInitialMatrix;
|
||||
SkDrawPictureCallback* fCallback;
|
||||
SkCanvas* fCanvas;
|
||||
GrLayerCache* fLayerCache;
|
||||
const SkPicture* fTopLevelPicture;
|
||||
const SkPicture* fPicture;
|
||||
const SkMatrix fInitialMatrix;
|
||||
SkPicture::AbortCallback* fCallback;
|
||||
|
||||
SkTDArray<unsigned> fOps;
|
||||
int fIndex;
|
||||
int fNumReplaced;
|
||||
SkTDArray<unsigned> fOps;
|
||||
int fIndex;
|
||||
int fNumReplaced;
|
||||
|
||||
// The op code indices of all the enclosing drawPicture and saveLayer calls
|
||||
SkTDArray<unsigned> fOpIndexStack;
|
||||
SkTDArray<unsigned> fOpIndexStack;
|
||||
|
||||
typedef Draw INHERITED;
|
||||
};
|
||||
@ -202,7 +202,7 @@ int GrRecordReplaceDraw(const SkPicture* picture,
|
||||
SkCanvas* canvas,
|
||||
GrLayerCache* layerCache,
|
||||
const SkMatrix& initialMatrix,
|
||||
SkDrawPictureCallback* callback) {
|
||||
SkPicture::AbortCallback* callback) {
|
||||
SkAutoCanvasRestore saveRestore(canvas, true /*save now, restore at exit*/);
|
||||
|
||||
// TODO: drawablePicts?
|
||||
|
@ -8,12 +8,11 @@
|
||||
#ifndef GrRecordReplaceDraw_DEFINED
|
||||
#define GrRecordReplaceDraw_DEFINED
|
||||
|
||||
#include "SkDrawPictureCallback.h"
|
||||
#include "SkPicture.h"
|
||||
|
||||
class GrLayerCache;
|
||||
class SkCanvas;
|
||||
class SkMatrix;
|
||||
class SkPicture;
|
||||
|
||||
// Draw an SkPicture into an SkCanvas replacing saveLayer/restore blocks with
|
||||
// drawBitmap calls. A convenience wrapper around SkRecords::Draw.
|
||||
@ -22,6 +21,6 @@ int GrRecordReplaceDraw(const SkPicture*,
|
||||
SkCanvas*,
|
||||
GrLayerCache* layerCache,
|
||||
const SkMatrix& initialMatrix,
|
||||
SkDrawPictureCallback*);
|
||||
SkPicture::AbortCallback*);
|
||||
|
||||
#endif // GrRecordReplaceDraw_DEFINED
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "RecordTestUtils.h"
|
||||
|
||||
#include "SkDebugCanvas.h"
|
||||
#include "SkDrawPictureCallback.h"
|
||||
#include "SkDropShadowImageFilter.h"
|
||||
#include "SkImagePriv.h"
|
||||
#include "SkRecord.h"
|
||||
@ -21,11 +20,11 @@
|
||||
|
||||
static const int W = 1920, H = 1080;
|
||||
|
||||
class JustOneDraw : public SkDrawPictureCallback {
|
||||
class JustOneDraw : public SkPicture::AbortCallback {
|
||||
public:
|
||||
JustOneDraw() : fCalls(0) {}
|
||||
|
||||
virtual bool abortDrawing() SK_OVERRIDE { return fCalls++ > 0; }
|
||||
virtual bool abort() SK_OVERRIDE { return fCalls++ > 0; }
|
||||
private:
|
||||
int fCalls;
|
||||
};
|
||||
|
@ -22,11 +22,11 @@
|
||||
static const int kWidth = 100;
|
||||
static const int kHeight = 100;
|
||||
|
||||
class JustOneDraw : public SkDrawPictureCallback {
|
||||
class JustOneDraw : public SkPicture::AbortCallback {
|
||||
public:
|
||||
JustOneDraw() : fCalls(0) {}
|
||||
|
||||
virtual bool abortDrawing() SK_OVERRIDE { return fCalls++ > 0; }
|
||||
virtual bool abort() SK_OVERRIDE { return fCalls++ > 0; }
|
||||
private:
|
||||
int fCalls;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user