'../include/utils',
'../include/xml',
'../src/core',
- '../src/opts',
'../src/image',
+ '../src/opts',
+ '../src/utils',
],
'sources': [
'core.gypi', # Makes the gypi appear in IDEs (but does not modify the build).
'<(skia_src_path)/core/SkRasterClip.cpp',
'<(skia_src_path)/core/SkRasterizer.cpp',
'<(skia_src_path)/core/SkReadBuffer.cpp',
+ '<(skia_src_path)/core/SkRecordDraw.cpp',
+ '<(skia_src_path)/core/SkRecordOpts.cpp',
+ '<(skia_src_path)/core/SkRecorder.cpp',
+ '<(skia_src_path)/core/SkRecording.cpp',
'<(skia_src_path)/core/SkRect.cpp',
'<(skia_src_path)/core/SkRefDict.cpp',
'<(skia_src_path)/core/SkRegion.cpp',
'flags.gyp:flags',
'jsoncpp.gyp:jsoncpp',
'gputest.gyp:skgputest',
- 'record.gyp:*',
'etc1.gyp:libetc1',
],
'conditions': [
+++ /dev/null
-# An experimental library for faster recording of SkCanvas commands.
-{
- 'targets': [{
- 'target_name': 'record',
- 'type': 'static_library',
- 'includes': [ 'record.gypi' ],
- 'include_dirs': [
- '../include/config',
- '../include/core',
- '../include/record',
- '../src/utils',
- ],
- 'direct_dependent_settings': {
- 'include_dirs': [
- '../include/record', # Public headers.
- ],
- },
- }]
-}
-# Source list for SkRecord
-# The parent gyp/gypi file must define
-# 'skia_src_path' e.g. skia/trunk/src
-# The Skia build defines this in common_variables.gypi.
+# TODO: cleanup references in Chrome build and remove
{
- 'sources': [
- '<(skia_src_path)/record/SkRecordDraw.cpp',
- '<(skia_src_path)/record/SkRecordOpts.cpp',
- '<(skia_src_path)/record/SkRecorder.cpp',
- '<(skia_src_path)/record/SkRecording.cpp',
- ]
}
'../src/pathops',
'../src/pdf',
'../src/pipe/utils',
- '../src/record',
'../src/utils',
'../src/utils/debugger',
'../tools/',
'flags.gyp:flags',
'pdf.gyp:pdf',
'tools.gyp:picture_utils',
- 'record.gyp:record',
],
'sources': [
'../tests/Test.cpp',
'bench.gyp:bench_timer',
'flags.gyp:flags',
'skia_lib.gyp:skia_lib',
- 'record.gyp:*',
],
},
{
'include_dirs': [
'../src/core/',
'../src/images',
- '../src/record',
],
'dependencies': [
'bench.gyp:bench_timer',
'flags.gyp:flags',
'skia_lib.gyp:skia_lib',
- 'record.gyp:*',
],
},
{
'../src/core/',
'../src/images',
'../src/lazy',
- '../src/record',
],
'dependencies': [
'bench.gyp:bench_timer',
'flags.gyp:flags',
- 'record.gyp:*',
'skia_lib.gyp:skia_lib',
],
},
class SkCanvas;
class SkPictureRecord;
+class SkRecord;
+class SkRecorder;
class SK_API SkPictureRecorder : SkNoncopyable {
public:
- SkPictureRecorder() : fCanvas(NULL) { }
+ SkPictureRecorder() : fPictureRecord(NULL), fRecorder(NULL), fRecord(NULL) { }
~SkPictureRecorder();
/** Returns the canvas that records the drawing commands.
SkBBHFactory* bbhFactory = NULL,
uint32_t recordFlags = 0);
+ /** Same as beginRecording(), using a new faster backend. */
+ SkCanvas* EXPERIMENTAL_beginRecording(int width, int height,
+ SkBBHFactory* bbhFactory = NULL);
+
/** 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).
*/
void internalOnly_EnableOpts(bool enableOpts);
private:
+ void reset();
+
/** Replay the current (partially recorded) operation stream into
canvas. This call doesn't close the current recording.
*/
int fWidth;
int fHeight;
- SkPictureRecord* fCanvas; // ref counted
+
+ // Both ref counted. One of these two will be non-null:
+ SkPictureRecord* fPictureRecord; // beginRecording()
+ SkRecorder* fRecorder; // EXPERIMENTAL_beginRecording()
+
+ // Not refcounted. Used by EXPERIMENTAL_beginRecording().
+ SkRecord* fRecord;
typedef SkNoncopyable INHERITED;
};
#include "SkPicturePlayback.h"
#include "SkPictureRecord.h"
#include "SkPictureRecorder.h"
-#include "SkTypes.h"
+#include "SkRecord.h"
+#include "SkRecordDraw.h"
+#include "SkRecorder.h"
+#include "SkTypes.h"
SkPictureRecorder::~SkPictureRecorder() {
- SkSafeSetNull(fCanvas);
+ this->reset();
+}
+
+void SkPictureRecorder::reset() {
+ SkSafeSetNull(fPictureRecord);
+ SkSafeSetNull(fRecorder);
+ SkDELETE(fRecord);
+ fRecord = NULL;
}
SkCanvas* SkPictureRecorder::beginRecording(int width, int height,
SkBBHFactory* bbhFactory /* = NULL */,
uint32_t recordFlags /* = 0 */) {
- SkSafeSetNull(fCanvas); // terminate any prior recording(s)
-
+ this->reset(); // terminate any prior recording(s)
fWidth = width;
fHeight = height;
if (NULL != bbhFactory) {
SkAutoTUnref<SkBBoxHierarchy> tree((*bbhFactory)(width, height));
SkASSERT(NULL != tree);
- fCanvas = SkNEW_ARGS(SkBBoxHierarchyRecord, (size, recordFlags, tree.get()));
+ fPictureRecord = SkNEW_ARGS(SkBBoxHierarchyRecord, (size, recordFlags, tree.get()));
} else {
- fCanvas = SkNEW_ARGS(SkPictureRecord, (size, recordFlags));
+ fPictureRecord = SkNEW_ARGS(SkPictureRecord, (size, recordFlags));
}
- fCanvas->beginRecording();
+ fPictureRecord->beginRecording();
+ return this->getRecordingCanvas();
+}
+
+SkCanvas* SkPictureRecorder::EXPERIMENTAL_beginRecording(int width, int height,
+ SkBBHFactory* bbhFactory /* = NULL */) {
+ this->reset();
+ fWidth = width;
+ fHeight = height;
- return fCanvas;
+ // TODO: plumb bbhFactory through
+ fRecord = SkNEW(SkRecord);
+ fRecorder = SkNEW_ARGS(SkRecorder, (fRecord, width, height));
+ return this->getRecordingCanvas();
}
SkCanvas* SkPictureRecorder::getRecordingCanvas() {
- return fCanvas;
+ if (NULL != fRecorder) {
+ return fRecorder;
+ }
+ return fPictureRecord;
}
SkPicture* SkPictureRecorder::endRecording() {
- if (NULL == fCanvas) {
- return NULL;
- }
+ SkPicture* picture = NULL;
- fCanvas->endRecording();
+ if (NULL != fRecorder) {
+ // TODO: picture = SkNEW_ARGS(SkPicture, (fWidth, fHeight, fRecord));
+ // fRecord = NULL;
+ }
- const bool deepCopyOps = false;
- SkAutoTUnref<SkPicture> picture(SkNEW_ARGS(SkPicture, (fWidth, fHeight,
- *fCanvas, deepCopyOps)));
- SkSafeSetNull(fCanvas);
+ if (NULL != fPictureRecord) {
+ fPictureRecord->endRecording();
+ const bool deepCopyOps = false;
+ picture = SkNEW_ARGS(SkPicture, (fWidth, fHeight, *fPictureRecord, deepCopyOps));
+ }
- return picture.detach();
+ this->reset();
+ return picture;
}
void SkPictureRecorder::internalOnly_EnableOpts(bool enableOpts) {
- if (NULL != fCanvas) {
- fCanvas->internalOnly_EnableOpts(enableOpts);
+ if (NULL != fPictureRecord) {
+ fPictureRecord->internalOnly_EnableOpts(enableOpts);
}
}
void SkPictureRecorder::partialReplay(SkCanvas* canvas) const {
- if (NULL == fCanvas || NULL == canvas) {
- // Not recording or nothing to replay into
+ if (NULL == canvas) {
return;
}
- const bool deepCopyOps = true;
- SkAutoTUnref<SkPicture> picture(SkNEW_ARGS(SkPicture, (fWidth, fHeight,
- *fCanvas, deepCopyOps)));
- picture->draw(canvas);
+ if (NULL != fRecorder) {
+ SkRecordDraw(*fRecord, canvas);
+ }
+
+ if (NULL != fPictureRecord) {
+ const bool deepCopyOps = true;
+ SkPicture picture(fWidth, fHeight, *fPictureRecord, deepCopyOps);
+ picture.draw(canvas);
+ }
}
* found in the LICENSE file.
*/
-#include "SkRecording.h"
+#include "../../include/record/SkRecording.h"
#include "SkRecord.h"
#include "SkRecordOpts.h"
#include "Test.h"
-#include "SkRecording.h"
+#include "../include/record/SkRecording.h"
// Minimally exercise the public SkRecording API.
#include "SkOSFile.h"
#include "SkPicture.h"
#include "SkPictureRecorder.h"
-#include "SkRecording.h"
#include "SkStream.h"
#include "SkString.h"
+#include "../include/record/SkRecording.h"
+
#include "BenchTimer.h"
#include "Stats.h"
#include "SkOSFile.h"
#include "SkPicture.h"
#include "SkPictureRecorder.h"
-#include "SkRecording.h"
#include "SkStream.h"
#include "SkString.h"
}
static void rerecord(const SkPicture& src, SkBBHFactory* bbhFactory) {
+ SkPictureRecorder recorder;
if (FLAGS_skr) {
- EXPERIMENTAL::SkRecording recording(src.width(), src.height());
- src.draw(recording.canvas());
- // Release and delete the SkPlayback so that recording optimizes its SkRecord.
- SkDELETE(recording.releasePlayback());
+ src.draw(recorder.EXPERIMENTAL_beginRecording(src.width(), src.height(), bbhFactory));
} else {
- SkPictureRecorder recorder;
src.draw(recorder.beginRecording(src.width(), src.height(), bbhFactory));
- SkAutoTUnref<SkPicture> dst(recorder.endRecording());
}
+ SkAutoTUnref<SkPicture> pic(recorder.endRecording());
}
static void bench_record(const SkPicture& src,