aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2014-06-08 05:55:05 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-06-08 05:55:05 -0700
commit643b8bd6617e333f7a970a57ad9166f3d6675d1a (patch)
tree39adc8ef73017ed29d0cfeda574e31d6479b29f4 /include/core
parent52e4f413ffe2d281f9e90ff2147db08083ffcba7 (diff)
First pass at splitting out SkPictureRecord from SkPicture
This patch begins the process of splitting apart SkPicture, SkPicturePlayback and SkPictureRecord. This is still a bit messy. In a follow up CL I hope to delay the creation of SkPictureRecorder's SkPicture until endRecording time. R=reed@google.com, mtklein@google.com Author: robertphillips@google.com Review URL: https://codereview.chromium.org/318763004
Diffstat (limited to 'include/core')
-rw-r--r--include/core/SkPicture.h37
-rw-r--r--include/core/SkPictureRecorder.h28
2 files changed, 10 insertions, 55 deletions
diff --git a/include/core/SkPicture.h b/include/core/SkPicture.h
index a908ab577f..fb5e7ffd03 100644
--- a/include/core/SkPicture.h
+++ b/include/core/SkPicture.h
@@ -147,8 +147,7 @@ public:
kUsePathBoundsForClip_RecordingFlag = 0x01
};
- /** Replays the drawing commands on the specified canvas. This internally
- calls endRecording() if that has not already been called.
+ /** Replays the drawing commands on the specified canvas.
@param canvas the canvas receiving the drawing commands.
*/
void draw(SkCanvas* canvas, SkDrawPictureCallback* = NULL) const;
@@ -225,14 +224,6 @@ public:
static bool InternalOnly_StreamIsSKP(SkStream*, SkPictInfo*);
static bool InternalOnly_BufferIsSKP(SkReadBuffer&, SkPictInfo*);
- /** Enable/disable all the picture recording optimizations (i.e.,
- those in SkPictureRecord). It is mainly intended for testing the
- existing optimizations (i.e., to actually have the pattern
- appear in an .skp we have to disable the optimization). Call right
- after 'beginRecording'.
- */
- void internalOnly_EnableOpts(bool enableOpts);
-
/** Return true if the picture is suitable for rendering on the GPU.
*/
@@ -284,7 +275,6 @@ protected:
// install their own SkPicturePlayback-derived players,SkPictureRecord-derived
// recorders and set the picture size
SkPicturePlayback* fPlayback;
- SkPictureRecord* fRecord;
int fWidth, fHeight;
mutable const AccelData* fAccelData;
@@ -419,31 +409,6 @@ private:
friend class GrGatherDevice;
friend class SkDebugCanvas;
- // TODO: beginRecording, getRecordingCanvas & endRecording can now be
- // be moved out of SkPicture (and, presumably, be directly implemented
- // in SkPictureRecorder)
-
- /** Returns the canvas that records the drawing commands.
- @param width the base width for the picture, as if the recording
- canvas' bitmap had this width.
- @param height the base width for the picture, as if the recording
- canvas' bitmap had this height.
- @param factory if non-NULL, the factory used to the BBH for the recorded picture
- @param recordFlags optional flags that control recording.
- @return the picture canvas.
- */
- SkCanvas* beginRecording(int width, int height, SkBBHFactory* factory, uint32_t recordFlags);
- /** Returns the recording canvas if one is active, or NULL if recording is
- not active. This does not alter the refcnt on the canvas (if present).
- */
- SkCanvas* getRecordingCanvas() const;
- /** Signal that the caller is done recording. This invalidates the canvas
- returned by beginRecording/getRecordingCanvas, and prepares the picture
- for drawing. Note: this happens implicitly the first time the picture
- is drawn.
- */
- void endRecording();
-
typedef SkRefCnt INHERITED;
};
diff --git a/include/core/SkPictureRecorder.h b/include/core/SkPictureRecorder.h
index b496aee28e..545dc31bb6 100644
--- a/include/core/SkPictureRecorder.h
+++ b/include/core/SkPictureRecorder.h
@@ -13,9 +13,13 @@
#include "SkRefCnt.h"
class SkCanvas;
+class SkPictureRecord;
class SK_API SkPictureRecorder : SkNoncopyable {
public:
+ SkPictureRecorder() : fCanvas(NULL) { }
+ ~SkPictureRecorder();
+
/** Returns the canvas that records the drawing commands.
@param width the base width for the picture, as if the recording
canvas' bitmap had this width.
@@ -33,25 +37,14 @@ public:
/** Returns the recording canvas if one is active, or NULL if recording is
not active. This does not alter the refcnt on the canvas (if present).
*/
- SkCanvas* getRecordingCanvas() {
- if (NULL != fPicture.get()) {
- return fPicture->getRecordingCanvas();
- }
- return NULL;
- }
+ SkCanvas* getRecordingCanvas();
/** Signal that the caller is done recording. This invalidates the canvas
returned by beginRecording/getRecordingCanvas, and returns the
created SkPicture. Note that the returned picture has its creation
ref which the caller must take ownership of.
*/
- SkPicture* endRecording() {
- if (NULL != fPicture.get()) {
- fPicture->endRecording();
- return fPicture.detach();
- }
- return NULL;
- }
+ SkPicture* endRecording();
/** Enable/disable all the picture recording optimizations (i.e.,
those in SkPictureRecord). It is mainly intended for testing the
@@ -59,11 +52,7 @@ public:
appear in an .skp we have to disable the optimization). Call right
after 'beginRecording'.
*/
- void internalOnly_EnableOpts(bool enableOpts) {
- if (NULL != fPicture.get()) {
- fPicture->internalOnly_EnableOpts(enableOpts);
- }
- }
+ void internalOnly_EnableOpts(bool enableOpts);
private:
#ifdef SK_BUILD_FOR_ANDROID
@@ -75,7 +64,8 @@ private:
void partialReplay(SkCanvas* canvas) const;
#endif
- SkAutoTUnref<SkPicture> fPicture;
+ SkAutoTUnref<SkPicture> fPicture;
+ SkPictureRecord* fCanvas; // ref counted
typedef SkNoncopyable INHERITED;
};