aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2015-01-06 12:26:08 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-01-06 12:26:08 -0800
commit7ef197255deb4e2fa64c03c7130d56ddf164e83c (patch)
treea6a936f30912c91e182560cfe6babd9b8feb92f5
parentb5d818ab04860a9b558ae0d6edef6386c4a09061 (diff)
Rename SkDrawPictureCallback to SkPicture::AbortCallback
-rw-r--r--gyp/skia_for_android_framework_defines.gypi1
-rw-r--r--gyp/skia_for_chromium_defines.gypi1
-rw-r--r--include/core/SkDrawPictureCallback.h13
-rw-r--r--include/core/SkPicture.h23
-rw-r--r--src/core/SkPicture.cpp3
-rw-r--r--src/core/SkPictureData.cpp3
-rw-r--r--src/core/SkPicturePlayback.cpp4
-rw-r--r--src/core/SkPicturePlayback.h3
-rw-r--r--src/core/SkRecordDraw.cpp6
-rw-r--r--src/core/SkRecordDraw.h3
-rw-r--r--src/gpu/GrRecordReplaceDraw.cpp28
-rw-r--r--src/gpu/GrRecordReplaceDraw.h5
-rw-r--r--tests/RecordDrawTest.cpp5
-rw-r--r--tests/RecordReplaceDrawTest.cpp4
14 files changed, 58 insertions, 44 deletions
diff --git a/gyp/skia_for_android_framework_defines.gypi b/gyp/skia_for_android_framework_defines.gypi
index 779af88b4e..04b4338c43 100644
--- a/gyp/skia_for_android_framework_defines.gypi
+++ b/gyp/skia_for_android_framework_defines.gypi
@@ -22,6 +22,7 @@
'SK_SUPPORT_LEGACY_PORTER_DUFF',
'SK_SUPPORT_LEGACY_DRAWDATA',
'SK_SUPPORT_LEGACY_CANVAS_VIRTUAL',
+ 'SK_LEGACY_DRAWPICTURECALLBACK',
],
},
}
diff --git a/gyp/skia_for_chromium_defines.gypi b/gyp/skia_for_chromium_defines.gypi
index afc17c527b..d4566ee335 100644
--- a/gyp/skia_for_chromium_defines.gypi
+++ b/gyp/skia_for_chromium_defines.gypi
@@ -15,6 +15,7 @@
'skia_for_chromium_defines': [
'SK_SUPPORT_LEGACY_DRAWDATA',
'SK_SUPPORT_LEGACY_CANVAS_VIRTUAL',
+ 'SK_LEGACY_DRAWPICTURECALLBACK',
],
},
}
diff --git a/include/core/SkDrawPictureCallback.h b/include/core/SkDrawPictureCallback.h
index d5a360ee8e..ea30f59a24 100644
--- a/include/core/SkDrawPictureCallback.h
+++ b/include/core/SkDrawPictureCallback.h
@@ -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;
+
+ bool abort() SK_OVERRIDE { return this->abortDrawing(); }
};
+#endif
-#endif//SkDrawPictureCallback_DEFINED
+#endif // SkDrawPictureCallback_DEFINED
diff --git a/include/core/SkPicture.h b/include/core/SkPicture.h
index 35b4d056a5..a1493eb9a1 100644
--- a/include/core/SkPicture.h
+++ b/include/core/SkPicture.h
@@ -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.
diff --git a/src/core/SkPicture.cpp b/src/core/SkPicture.cpp
index 63f32e650b..871a62e8f3 100644
--- a/src/core/SkPicture.cpp
+++ b/src/core/SkPicture.cpp
@@ -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.
diff --git a/src/core/SkPictureData.cpp b/src/core/SkPictureData.cpp
index 7fc165d219..73cf2bf215 100644
--- a/src/core/SkPictureData.cpp
+++ b/src/core/SkPictureData.cpp
@@ -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
diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp
index 94d5190c5e..4f775cf9fd 100644
--- a/src/core/SkPicturePlayback.cpp
+++ b/src/core/SkPicturePlayback.cpp
@@ -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;
}
diff --git a/src/core/SkPicturePlayback.h b/src/core/SkPicturePlayback.h
index 32d8c162a7..ca6ad1ade4 100644
--- a/src/core/SkPicturePlayback.h
+++ b/src/core/SkPicturePlayback.h
@@ -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
diff --git a/src/core/SkRecordDraw.cpp b/src/core/SkRecordDraw.cpp
index 6b1de4c613..a59d325eef 100644
--- a/src/core/SkRecordDraw.cpp
+++ b/src/core/SkRecordDraw.cpp
@@ -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
diff --git a/src/core/SkRecordDraw.h b/src/core/SkRecordDraw.h
index 509f5a6c72..593674eddd 100644
--- a/src/core/SkRecordDraw.h
+++ b/src/core/SkRecordDraw.h
@@ -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
diff --git a/src/gpu/GrRecordReplaceDraw.cpp b/src/gpu/GrRecordReplaceDraw.cpp
index 0ceea3721f..234f92f24f 100644
--- a/src/gpu/GrRecordReplaceDraw.cpp
+++ b/src/gpu/GrRecordReplaceDraw.cpp
@@ -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?
diff --git a/src/gpu/GrRecordReplaceDraw.h b/src/gpu/GrRecordReplaceDraw.h
index c0dd0b6a32..0dadcfa0cb 100644
--- a/src/gpu/GrRecordReplaceDraw.h
+++ b/src/gpu/GrRecordReplaceDraw.h
@@ -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
diff --git a/tests/RecordDrawTest.cpp b/tests/RecordDrawTest.cpp
index ec3680c3a9..5f0195d0c2 100644
--- a/tests/RecordDrawTest.cpp
+++ b/tests/RecordDrawTest.cpp
@@ -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;
};
diff --git a/tests/RecordReplaceDrawTest.cpp b/tests/RecordReplaceDrawTest.cpp
index b9c2f44e0f..9136ffce7b 100644
--- a/tests/RecordReplaceDrawTest.cpp
+++ b/tests/RecordReplaceDrawTest.cpp
@@ -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;
};