2014-04-18 18:04:41 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2014 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkPictureRecorder_DEFINED
|
|
|
|
#define SkPictureRecorder_DEFINED
|
|
|
|
|
|
|
|
#include "SkBBHFactory.h"
|
|
|
|
#include "SkPicture.h"
|
|
|
|
#include "SkRefCnt.h"
|
|
|
|
|
|
|
|
class SkCanvas;
|
2014-06-08 12:55:05 +00:00
|
|
|
class SkPictureRecord;
|
2014-04-18 18:04:41 +00:00
|
|
|
|
|
|
|
class SK_API SkPictureRecorder : SkNoncopyable {
|
|
|
|
public:
|
2014-06-08 12:55:05 +00:00
|
|
|
SkPictureRecorder() : fCanvas(NULL) { }
|
|
|
|
~SkPictureRecorder();
|
|
|
|
|
2014-04-18 18:04:41 +00:00
|
|
|
/** 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 bbhFactory factory to create desired acceleration structure
|
|
|
|
@param recordFlags optional flags that control recording.
|
|
|
|
@return the canvas.
|
|
|
|
*/
|
|
|
|
SkCanvas* beginRecording(int width, int height,
|
2014-06-09 13:25:34 +00:00
|
|
|
SkBBHFactory* bbhFactory = NULL,
|
|
|
|
uint32_t recordFlags = 0);
|
2014-04-18 18:04:41 +00:00
|
|
|
|
|
|
|
/** 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).
|
|
|
|
*/
|
2014-06-08 12:55:05 +00:00
|
|
|
SkCanvas* getRecordingCanvas();
|
2014-04-18 18:04:41 +00:00
|
|
|
|
|
|
|
/** 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.
|
|
|
|
*/
|
2014-06-08 12:55:05 +00:00
|
|
|
SkPicture* endRecording();
|
2014-04-18 18:04:41 +00:00
|
|
|
|
|
|
|
/** 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'.
|
|
|
|
*/
|
2014-06-08 12:55:05 +00:00
|
|
|
void internalOnly_EnableOpts(bool enableOpts);
|
2014-04-18 18:04:41 +00:00
|
|
|
|
|
|
|
private:
|
2014-05-27 23:41:45 +00:00
|
|
|
/** Replay the current (partially recorded) operation stream into
|
|
|
|
canvas. This call doesn't close the current recording.
|
|
|
|
*/
|
|
|
|
friend class AndroidPicture;
|
|
|
|
friend class SkPictureRecorderReplayTester; // for unit testing
|
2014-05-29 15:57:11 +00:00
|
|
|
void partialReplay(SkCanvas* canvas) const;
|
2014-05-27 23:41:45 +00:00
|
|
|
|
2014-06-11 18:37:55 +00:00
|
|
|
int fWidth;
|
|
|
|
int fHeight;
|
2014-06-08 12:55:05 +00:00
|
|
|
SkPictureRecord* fCanvas; // ref counted
|
2014-04-18 18:04:41 +00:00
|
|
|
|
|
|
|
typedef SkNoncopyable INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|