Rename SkPicturePlayback to SkPictureData

This is in preparation for splitting the playback portion of the new SkPictureData class into a new SkPicturePlayback class.

R=reed@google.com, mtklein@google.com

Author: robertphillips@google.com

Review URL: https://codereview.chromium.org/362773002
This commit is contained in:
robertphillips 2014-07-01 08:47:04 -07:00 committed by Commit bot
parent bb6a028239
commit db539905bb
14 changed files with 179 additions and 183 deletions

View File

@ -12,7 +12,7 @@
#include <QListWidgetItem>
#include "PictureRenderer.h"
#include "SkPictureRecord.h"
#include "SkPicturePlayback.h"
#include "SkPictureData.h"
__SK_FORCE_IMAGE_DECODER_LINKING;
@ -155,15 +155,15 @@ void SkDebuggerGUI::showDeletes() {
}
}
// The timed picture playback uses the SkPicturePlayback's profiling stubs
// The timed picture playback uses the SkPictureData's profiling stubs
// to time individual commands. The offsets are needed to map SkPicture
// offsets to individual commands.
class SkTimedPicturePlayback : public SkPicturePlayback {
class SkTimedPicturePlayback : public SkPictureData {
public:
static SkTimedPicturePlayback* CreateFromStream(SkStream* stream, const SkPictInfo& info,
SkPicture::InstallPixelRefProc proc,
const SkTDArray<bool>& deletedCommands) {
// Mimics SkPicturePlayback::CreateFromStream
// Mimics SkPictureData::CreateFromStream
SkAutoTDelete<SkTimedPicturePlayback> playback(SkNEW_ARGS(SkTimedPicturePlayback,
(deletedCommands, info)));
if (!playback->parseStream(stream, proc)) {
@ -256,7 +256,7 @@ protected:
#endif
private:
typedef SkPicturePlayback INHERITED;
typedef SkPictureData INHERITED;
};
// Wrap SkPicture to allow installation of an SkTimedPicturePlayback object
@ -286,19 +286,19 @@ public:
return NULL;
}
void resetTimes() { ((SkTimedPicturePlayback*) fPlayback.get())->resetTimes(); }
void resetTimes() { ((SkTimedPicturePlayback*) fData.get())->resetTimes(); }
int count() const { return ((SkTimedPicturePlayback*) fPlayback.get())->count(); }
int count() const { return ((SkTimedPicturePlayback*) fData.get())->count(); }
// return the fraction of the total time this command consumed
double time(int index) const { return ((SkTimedPicturePlayback*) fPlayback.get())->time(index); }
double time(int index) const { return ((SkTimedPicturePlayback*) fData.get())->time(index); }
const SkTDArray<double>* typeTimes() const { return ((SkTimedPicturePlayback*) fPlayback.get())->typeTimes(); }
const SkTDArray<double>* typeTimes() const { return ((SkTimedPicturePlayback*) fData.get())->typeTimes(); }
double totTime() const { return ((SkTimedPicturePlayback*) fPlayback.get())->totTime(); }
double totTime() const { return ((SkTimedPicturePlayback*) fData.get())->totTime(); }
private:
// disallow default ctor b.c. we don't have a good way to setup the fPlayback ptr
// disallow default ctor b.c. we don't have a good way to setup the fData ptr
SkTimedPicture();
// Private ctor only used by CreateTimedPicture, which has created the playback.
SkTimedPicture(SkTimedPicturePlayback* playback, int width, int height)

View File

@ -129,10 +129,10 @@
'<(skia_src_path)/core/SkPathMeasure.cpp',
'<(skia_src_path)/core/SkPathRef.cpp',
'<(skia_src_path)/core/SkPicture.cpp',
'<(skia_src_path)/core/SkPictureData.cpp',
'<(skia_src_path)/core/SkPictureData.h',
'<(skia_src_path)/core/SkPictureFlat.cpp',
'<(skia_src_path)/core/SkPictureFlat.h',
'<(skia_src_path)/core/SkPicturePlayback.cpp',
'<(skia_src_path)/core/SkPicturePlayback.h',
'<(skia_src_path)/core/SkPictureRecord.cpp',
'<(skia_src_path)/core/SkPictureRecord.h',
'<(skia_src_path)/core/SkPictureRecorder.cpp',

View File

@ -23,7 +23,7 @@ class SkBBHFactory;
class SkBBoxHierarchy;
class SkCanvas;
class SkData;
class SkPicturePlayback;
class SkPictureData;
class SkPictureRecord;
class SkStream;
class SkWStream;
@ -249,18 +249,16 @@ protected:
mutable uint32_t fUniqueID;
// fPlayback, fWidth & fHeight are protected to allow derived classes to
// install their own SkPicturePlayback-derived players,SkPictureRecord-derived
// recorders and set the picture size
SkAutoTDelete<SkPicturePlayback> fPlayback;
// TODO: make fData and fWidth/fHeight private
SkAutoTDelete<SkPictureData> fData;
int fWidth, fHeight;
mutable SkAutoTUnref<const AccelData> fAccelData;
void needsNewGenID() { fUniqueID = SK_InvalidGenID; }
// Create a new SkPicture from an existing SkPicturePlayback. Ref count of
// playback is unchanged.
SkPicture(SkPicturePlayback*, int width, int height);
// Create a new SkPicture from an existing SkPictureData. Ref count of
// data is unchanged.
SkPicture(SkPictureData* data, int width, int height);
SkPicture(int width, int height, const SkPictureRecord& record, bool deepCopyOps);
@ -304,7 +302,7 @@ private:
static bool IsValidPictInfo(const SkPictInfo& info);
friend class SkFlatPicture;
friend class SkPicturePlayback;
friend class SkPictureData;
friend class SkPictureRecorder; // just for SkPicture-based constructor
friend class SkGpuDevice;
friend class GrGatherCanvas;

View File

@ -8,7 +8,7 @@
#include "SkPictureFlat.h"
#include "SkPicturePlayback.h"
#include "SkPictureData.h"
#include "SkPictureRecord.h"
#include "SkPictureRecorder.h"
@ -146,7 +146,7 @@ SkPicture::SkPicture(int width, int height,
SkPictInfo info;
this->createHeader(&info);
fPlayback.reset(SkNEW_ARGS(SkPicturePlayback, (record, info, deepCopyOps)));
fData.reset(SkNEW_ARGS(SkPictureData, (record, info, deepCopyOps)));
}
// The simplest / safest way to copy an SkRecord is to replay it into a new one.
@ -157,7 +157,7 @@ static SkRecord* copy(const SkRecord& src, int width, int height) {
return dst;
}
// Create an SkPicturePlayback-backed SkPicture from an SkRecord.
// Create an SkPictureData-backed SkPicture from an SkRecord.
// This for compatibility with serialization code only. This is not cheap.
static SkPicture* backport(const SkRecord& src, int width, int height) {
SkPictureRecorder recorder;
@ -171,8 +171,8 @@ SkPicture::SkPicture(const SkPicture& src) : INHERITED() {
fWidth = src.fWidth;
fHeight = src.fHeight;
if (NULL != src.fPlayback.get()) {
fPlayback.reset(SkNEW_ARGS(SkPicturePlayback, (*src.fPlayback)));
if (NULL != src.fData.get()) {
fData.reset(SkNEW_ARGS(SkPictureData, (*src.fData)));
fUniqueID = src.uniqueID(); // need to call method to ensure != 0
}
@ -203,15 +203,15 @@ void SkPicture::clone(SkPicture* pictures, int count) const {
clone->needsNewGenID();
clone->fWidth = fWidth;
clone->fHeight = fHeight;
clone->fPlayback.reset(NULL);
clone->fData.reset(NULL);
/* We want to copy the src's playback. However, if that hasn't been built
yet, we need to fake a call to endRecording() without actually calling
it (since it is destructive, and we don't want to change src).
*/
if (fPlayback.get()) {
if (fData.get()) {
if (!copyInfo.initialized) {
int paintCount = SafeCount(fPlayback->fPaints);
int paintCount = SafeCount(fData->fPaints);
/* The alternative to doing this is to have a clone method on the paint and have it
* make the deep copy of its internal structures as needed. The holdup to doing
@ -221,38 +221,38 @@ void SkPicture::clone(SkPicture* pictures, int count) const {
copyInfo.paintData.setCount(paintCount);
/* Use an SkBitmapHeap to avoid flattening bitmaps in shaders. If there already is
* one, use it. If this SkPicturePlayback was created from a stream, fBitmapHeap
* one, use it. If this SkPictureData was created from a stream, fBitmapHeap
* will be NULL, so create a new one.
*/
if (fPlayback->fBitmapHeap.get() == NULL) {
if (fData->fBitmapHeap.get() == NULL) {
// FIXME: Put this on the stack inside SkPicture::clone.
SkBitmapHeap* heap = SkNEW(SkBitmapHeap);
copyInfo.controller.setBitmapStorage(heap);
heap->unref();
} else {
copyInfo.controller.setBitmapStorage(fPlayback->fBitmapHeap);
copyInfo.controller.setBitmapStorage(fData->fBitmapHeap);
}
SkDEBUGCODE(int heapSize = SafeCount(fPlayback->fBitmapHeap.get());)
SkDEBUGCODE(int heapSize = SafeCount(fData->fBitmapHeap.get());)
for (int i = 0; i < paintCount; i++) {
if (NeedsDeepCopy(fPlayback->fPaints->at(i))) {
if (NeedsDeepCopy(fData->fPaints->at(i))) {
copyInfo.paintData[i] =
SkFlatData::Create<SkPaint::FlatteningTraits>(&copyInfo.controller,
fPlayback->fPaints->at(i), 0);
fData->fPaints->at(i), 0);
} else {
// this is our sentinel, which we use in the unflatten loop
copyInfo.paintData[i] = NULL;
}
}
SkASSERT(SafeCount(fPlayback->fBitmapHeap.get()) == heapSize);
SkASSERT(SafeCount(fData->fBitmapHeap.get()) == heapSize);
// needed to create typeface playback
copyInfo.controller.setupPlaybacks();
copyInfo.initialized = true;
}
clone->fPlayback.reset(SkNEW_ARGS(SkPicturePlayback, (*fPlayback, &copyInfo)));
clone->fData.reset(SkNEW_ARGS(SkPictureData, (*fData, &copyInfo)));
clone->fUniqueID = this->uniqueID(); // need to call method to ensure != 0
}
}
@ -295,17 +295,17 @@ const SkPicture::OperationList& SkPicture::OperationList::InvalidList() {
// fRecord TODO
const SkPicture::OperationList& SkPicture::EXPERIMENTAL_getActiveOps(const SkIRect& queryRect) const {
SkASSERT(NULL != fPlayback.get());
if (NULL != fPlayback.get()) {
return fPlayback->getActiveOps(queryRect);
SkASSERT(NULL != fData.get());
if (NULL != fData.get()) {
return fData->getActiveOps(queryRect);
}
return OperationList::InvalidList();
}
// fRecord TODO
size_t SkPicture::EXPERIMENTAL_curOpID() const {
if (NULL != fPlayback.get()) {
return fPlayback->curOpID();
if (NULL != fData.get()) {
return fData->curOpID();
}
return 0;
}
@ -313,10 +313,10 @@ size_t SkPicture::EXPERIMENTAL_curOpID() const {
// fRecord OK
void SkPicture::draw(SkCanvas* canvas, SkDrawPictureCallback* callback) const {
SkASSERT(NULL != canvas);
SkASSERT(NULL != fPlayback.get() || NULL != fRecord.get());
SkASSERT(NULL != fData.get() || NULL != fRecord.get());
if (NULL != fPlayback.get()) {
fPlayback->draw(*canvas, callback);
if (NULL != fData.get()) {
fData->draw(*canvas, callback);
}
if (NULL != fRecord.get()) {
SkRecordDraw(*fRecord, canvas, callback);
@ -378,8 +378,8 @@ bool SkPicture::InternalOnly_BufferIsSKP(SkReadBuffer& buffer, SkPictInfo* pInfo
}
// fRecord OK
SkPicture::SkPicture(SkPicturePlayback* playback, int width, int height)
: fPlayback(playback)
SkPicture::SkPicture(SkPictureData* data, int width, int height)
: fData(data)
, fWidth(width)
, fHeight(height) {
this->needsNewGenID();
@ -395,12 +395,12 @@ SkPicture* SkPicture::CreateFromStream(SkStream* stream, InstallPixelRefProc pro
// Check to see if there is a playback to recreate.
if (stream->readBool()) {
SkPicturePlayback* playback = SkPicturePlayback::CreateFromStream(stream, info, proc);
if (NULL == playback) {
SkPictureData* data = SkPictureData::CreateFromStream(stream, info, proc);
if (NULL == data) {
return NULL;
}
return SkNEW_ARGS(SkPicture, (playback, info.fWidth, info.fHeight));
return SkNEW_ARGS(SkPicture, (data, info.fWidth, info.fHeight));
}
return NULL;
@ -416,12 +416,12 @@ SkPicture* SkPicture::CreateFromBuffer(SkReadBuffer& buffer) {
// Check to see if there is a playback to recreate.
if (buffer.readBool()) {
SkPicturePlayback* playback = SkPicturePlayback::CreateFromBuffer(buffer, info);
if (NULL == playback) {
SkPictureData* data = SkPictureData::CreateFromBuffer(buffer, info);
if (NULL == data) {
return NULL;
}
return SkNEW_ARGS(SkPicture, (playback, info.fWidth, info.fHeight));
return SkNEW_ARGS(SkPicture, (data, info.fWidth, info.fHeight));
}
return NULL;
@ -449,23 +449,23 @@ void SkPicture::createHeader(SkPictInfo* info) const {
// fRecord OK
void SkPicture::serialize(SkWStream* stream, EncodeBitmap encoder) const {
const SkPicturePlayback* playback = fPlayback.get();
const SkPictureData* data = fData.get();
// If we're a new-format picture, backport to old format for serialization.
SkAutoTDelete<SkPicture> oldFormat;
if (NULL == playback && NULL != fRecord.get()) {
if (NULL == data && NULL != fRecord.get()) {
oldFormat.reset(backport(*fRecord, fWidth, fHeight));
playback = oldFormat->fPlayback.get();
SkASSERT(NULL != playback);
data = oldFormat->fData.get();
SkASSERT(NULL != data);
}
SkPictInfo info;
this->createHeader(&info);
stream->write(&info, sizeof(info));
if (NULL != playback) {
if (NULL != data) {
stream->writeBool(true);
playback->serialize(stream, encoder);
data->serialize(stream, encoder);
} else {
stream->writeBool(false);
}
@ -485,23 +485,23 @@ void SkPicture::WriteTagSize(SkWStream* stream, uint32_t tag, size_t size) {
// fRecord OK
void SkPicture::flatten(SkWriteBuffer& buffer) const {
const SkPicturePlayback* playback = fPlayback.get();
const SkPictureData* data = fData.get();
// If we're a new-format picture, backport to old format for serialization.
SkAutoTDelete<SkPicture> oldFormat;
if (NULL == playback && NULL != fRecord.get()) {
if (NULL == data && NULL != fRecord.get()) {
oldFormat.reset(backport(*fRecord, fWidth, fHeight));
playback = oldFormat->fPlayback.get();
SkASSERT(NULL != playback);
data = oldFormat->fData.get();
SkASSERT(NULL != data);
}
SkPictInfo info;
this->createHeader(&info);
buffer.writeByteArray(&info, sizeof(info));
if (NULL != playback) {
if (NULL != data) {
buffer.writeBool(true);
playback->flatten(buffer);
data->flatten(buffer);
} else {
buffer.writeBool(false);
}
@ -510,32 +510,32 @@ void SkPicture::flatten(SkWriteBuffer& buffer) const {
#if SK_SUPPORT_GPU
// fRecord TODO
bool SkPicture::suitableForGpuRasterization(GrContext* context, const char **reason) const {
if (NULL == fPlayback.get()) {
if (NULL == fData.get()) {
if (NULL != reason) {
*reason = "Missing playback object.";
*reason = "Missing internal data.";
}
return false;
}
return fPlayback->suitableForGpuRasterization(context, reason);
return fData->suitableForGpuRasterization(context, reason);
}
#endif
// fRecord TODO
bool SkPicture::willPlayBackBitmaps() const {
if (!fPlayback.get()) {
if (!fData.get()) {
return false;
}
return fPlayback->containsBitmaps();
return fData->containsBitmaps();
}
#ifdef SK_BUILD_FOR_ANDROID
// fRecord TODO, fix by switching Android to SkDrawPictureCallback, then deleting this method
void SkPicture::abortPlayback() {
if (NULL == fPlayback.get()) {
if (NULL == fData.get()) {
return;
}
fPlayback->abort();
fData->abort();
}
#endif

View File

@ -7,7 +7,7 @@
#include <new>
#include "SkBBoxHierarchy.h"
#include "SkDrawPictureCallback.h"
#include "SkPicturePlayback.h"
#include "SkPictureData.h"
#include "SkPictureRecord.h"
#include "SkPictureStateTree.h"
#include "SkReadBuffer.h"
@ -28,13 +28,13 @@ template <typename T> int SafeCount(const T* obj) {
*/
#define SPEW_CLIP_SKIPPINGx
SkPicturePlayback::PlaybackReplacements::ReplacementInfo*
SkPicturePlayback::PlaybackReplacements::push() {
SkPictureData::PlaybackReplacements::ReplacementInfo*
SkPictureData::PlaybackReplacements::push() {
SkDEBUGCODE(this->validate());
return fReplacements.push();
}
void SkPicturePlayback::PlaybackReplacements::freeAll() {
void SkPictureData::PlaybackReplacements::freeAll() {
for (int i = 0; i < fReplacements.count(); ++i) {
SkDELETE(fReplacements[i].fBM);
}
@ -42,7 +42,7 @@ void SkPicturePlayback::PlaybackReplacements::freeAll() {
}
#ifdef SK_DEBUG
void SkPicturePlayback::PlaybackReplacements::validate() const {
void SkPictureData::PlaybackReplacements::validate() const {
// Check that the ranges are monotonically increasing and non-overlapping
if (fReplacements.count() > 0) {
SkASSERT(fReplacements[0].fStart < fReplacements[0].fStop);
@ -55,12 +55,12 @@ void SkPicturePlayback::PlaybackReplacements::validate() const {
}
#endif
SkPicturePlayback::SkPicturePlayback(const SkPictInfo& info)
SkPictureData::SkPictureData(const SkPictInfo& info)
: fInfo(info) {
this->init();
}
void SkPicturePlayback::initForPlayback() const {
void SkPictureData::initForPlayback() const {
// ensure that the paths bounds are pre-computed
if (NULL != fPathHeap.get()) {
for (int i = 0; i < fPathHeap->count(); i++) {
@ -69,7 +69,7 @@ void SkPicturePlayback::initForPlayback() const {
}
}
SkPicturePlayback::SkPicturePlayback(const SkPictureRecord& record,
SkPictureData::SkPictureData(const SkPictureRecord& record,
const SkPictInfo& info,
bool deepCopyOps)
: fInfo(info) {
@ -169,7 +169,7 @@ SkPicturePlayback::SkPicturePlayback(const SkPictureRecord& record,
}
#ifdef SK_SUPPORT_LEGACY_PICTURE_CLONE
SkPicturePlayback::SkPicturePlayback(const SkPicturePlayback& src, SkPictCopyInfo* deepCopyInfo)
SkPictureData::SkPictureData(const SkPictureData& src, SkPictCopyInfo* deepCopyInfo)
: fInfo(src.fInfo) {
this->init();
@ -225,7 +225,7 @@ SkPicturePlayback::SkPicturePlayback(const SkPicturePlayback& src, SkPictCopyInf
}
}
#else
SkPicturePlayback::SkPicturePlayback(const SkPicturePlayback& src) : fInfo(src.fInfo) {
SkPictureData::SkPictureData(const SkPictureData& src) : fInfo(src.fInfo) {
this->init();
fBitmapHeap.reset(SkSafeRef(src.fBitmapHeap.get()));
@ -251,7 +251,7 @@ SkPicturePlayback::SkPicturePlayback(const SkPicturePlayback& src) : fInfo(src.f
}
#endif//SK_SUPPORT_LEGACY_PICTURE_CLONE
void SkPicturePlayback::init() {
void SkPictureData::init() {
fBitmaps = NULL;
fPaints = NULL;
fPictureRefs = NULL;
@ -268,7 +268,7 @@ void SkPicturePlayback::init() {
fReplacements = NULL;
}
SkPicturePlayback::~SkPicturePlayback() {
SkPictureData::~SkPictureData() {
SkSafeUnref(fOpData);
SkSafeUnref(fBitmaps);
@ -286,7 +286,7 @@ SkPicturePlayback::~SkPicturePlayback() {
SkDELETE(fFactoryPlayback);
}
void SkPicturePlayback::dumpSize() const {
void SkPictureData::dumpSize() const {
SkDebugf("--- picture size: ops=%d bitmaps=%d [%d] paints=%d [%d]\n",
fOpData->size(),
SafeCount(fBitmaps), SafeCount(fBitmaps) * sizeof(SkBitmap),
@ -295,7 +295,7 @@ void SkPicturePlayback::dumpSize() const {
SafeCount(fPathHeap.get()));
}
bool SkPicturePlayback::containsBitmaps() const {
bool SkPictureData::containsBitmaps() const {
if (fBitmaps && fBitmaps->count() > 0) {
return true;
}
@ -329,7 +329,7 @@ static size_t compute_chunk_size(SkFlattenable::Factory* array, int count) {
return size;
}
void SkPicturePlayback::WriteFactories(SkWStream* stream, const SkFactorySet& rec) {
void SkPictureData::WriteFactories(SkWStream* stream, const SkFactorySet& rec) {
int count = rec.count();
SkAutoSTMalloc<16, SkFlattenable::Factory> storage(count);
@ -358,7 +358,7 @@ void SkPicturePlayback::WriteFactories(SkWStream* stream, const SkFactorySet& re
SkASSERT(size == (stream->bytesWritten() - start));
}
void SkPicturePlayback::WriteTypefaces(SkWStream* stream, const SkRefCntSet& rec) {
void SkPictureData::WriteTypefaces(SkWStream* stream, const SkRefCntSet& rec) {
int count = rec.count();
SkPicture::WriteTagSize(stream, SK_PICT_TYPEFACE_TAG, count);
@ -372,7 +372,7 @@ void SkPicturePlayback::WriteTypefaces(SkWStream* stream, const SkRefCntSet& rec
}
}
void SkPicturePlayback::flattenToBuffer(SkWriteBuffer& buffer) const {
void SkPictureData::flattenToBuffer(SkWriteBuffer& buffer) const {
int i, n;
if ((n = SafeCount(fBitmaps)) > 0) {
@ -395,7 +395,7 @@ void SkPicturePlayback::flattenToBuffer(SkWriteBuffer& buffer) const {
}
}
void SkPicturePlayback::serialize(SkWStream* stream,
void SkPictureData::serialize(SkWStream* stream,
SkPicture::EncodeBitmap encoder) const {
SkPicture::WriteTagSize(stream, SK_PICT_READER_TAG, fOpData->size());
stream->write(fOpData->bytes(), fOpData->size());
@ -433,7 +433,7 @@ void SkPicturePlayback::serialize(SkWStream* stream,
stream->write32(SK_PICT_EOF_TAG);
}
void SkPicturePlayback::flatten(SkWriteBuffer& buffer) const {
void SkPictureData::flatten(SkWriteBuffer& buffer) const {
SkPicture::WriteTagSize(buffer, SK_PICT_READER_TAG, fOpData->size());
buffer.writeByteArray(fOpData->bytes(), fOpData->size());
@ -474,7 +474,7 @@ static uint32_t pictInfoFlagsToReadBufferFlags(uint32_t pictInfoFlags) {
return rbMask;
}
bool SkPicturePlayback::parseStreamTag(SkStream* stream,
bool SkPictureData::parseStreamTag(SkStream* stream,
uint32_t tag,
uint32_t size,
SkPicture::InstallPixelRefProc proc) {
@ -586,7 +586,7 @@ bool SkPicturePlayback::parseStreamTag(SkStream* stream,
return true; // success
}
bool SkPicturePlayback::parseBufferTag(SkReadBuffer& buffer,
bool SkPictureData::parseBufferTag(SkReadBuffer& buffer,
uint32_t tag, uint32_t size) {
switch (tag) {
case SK_PICT_BITMAP_BUFFER_TAG: {
@ -652,30 +652,30 @@ bool SkPicturePlayback::parseBufferTag(SkReadBuffer& buffer,
return true; // success
}
SkPicturePlayback* SkPicturePlayback::CreateFromStream(SkStream* stream,
const SkPictInfo& info,
SkPicture::InstallPixelRefProc proc) {
SkAutoTDelete<SkPicturePlayback> playback(SkNEW_ARGS(SkPicturePlayback, (info)));
SkPictureData* SkPictureData::CreateFromStream(SkStream* stream,
const SkPictInfo& info,
SkPicture::InstallPixelRefProc proc) {
SkAutoTDelete<SkPictureData> data(SkNEW_ARGS(SkPictureData, (info)));
if (!playback->parseStream(stream, proc)) {
if (!data->parseStream(stream, proc)) {
return NULL;
}
return playback.detach();
return data.detach();
}
SkPicturePlayback* SkPicturePlayback::CreateFromBuffer(SkReadBuffer& buffer,
const SkPictInfo& info) {
SkAutoTDelete<SkPicturePlayback> playback(SkNEW_ARGS(SkPicturePlayback, (info)));
SkPictureData* SkPictureData::CreateFromBuffer(SkReadBuffer& buffer,
const SkPictInfo& info) {
SkAutoTDelete<SkPictureData> data(SkNEW_ARGS(SkPictureData, (info)));
buffer.setVersion(info.fVersion);
if (!playback->parseBuffer(buffer)) {
if (!data->parseBuffer(buffer)) {
return NULL;
}
return playback.detach();
return data.detach();
}
bool SkPicturePlayback::parseStream(SkStream* stream,
SkPicture::InstallPixelRefProc proc) {
bool SkPictureData::parseStream(SkStream* stream,
SkPicture::InstallPixelRefProc proc) {
for (;;) {
uint32_t tag = stream->readU32();
if (SK_PICT_EOF_TAG == tag) {
@ -690,7 +690,7 @@ bool SkPicturePlayback::parseStream(SkStream* stream,
return true;
}
bool SkPicturePlayback::parseBuffer(SkReadBuffer& buffer) {
bool SkPictureData::parseBuffer(SkReadBuffer& buffer) {
for (;;) {
uint32_t tag = buffer.readUInt();
if (SK_PICT_EOF_TAG == tag) {
@ -726,11 +726,11 @@ struct SkipClipRec {
#endif
#ifdef SK_DEVELOPER
bool SkPicturePlayback::preDraw(int opIndex, int type) {
bool SkPictureData::preDraw(int opIndex, int type) {
return false;
}
void SkPicturePlayback::postDraw(int opIndex) {
void SkPictureData::postDraw(int opIndex) {
}
#endif
@ -757,17 +757,17 @@ static DrawType read_op_and_size(SkReader32* reader, uint32_t* size) {
return (DrawType) op;
}
uint32_t SkPicturePlayback::CachedOperationList::offset(int index) const {
uint32_t SkPictureData::CachedOperationList::offset(int index) const {
SkASSERT(index < fOps.count());
return ((SkPictureStateTree::Draw*)fOps[index])->fOffset;
}
const SkMatrix& SkPicturePlayback::CachedOperationList::matrix(int index) const {
const SkMatrix& SkPictureData::CachedOperationList::matrix(int index) const {
SkASSERT(index < fOps.count());
return *((SkPictureStateTree::Draw*)fOps[index])->fMatrix;
}
const SkPicture::OperationList& SkPicturePlayback::getActiveOps(const SkIRect& query) {
const SkPicture::OperationList& SkPictureData::getActiveOps(const SkIRect& query) {
if (NULL == fStateTree || NULL == fBoundingHierarchy) {
return SkPicture::OperationList::InvalidList();
}
@ -795,20 +795,20 @@ const SkPicture::OperationList& SkPicturePlayback::getActiveOps(const SkIRect& q
class SkAutoResetOpID {
public:
SkAutoResetOpID(SkPicturePlayback* playback) : fPlayback(playback) { }
SkAutoResetOpID(SkPictureData* data) : fData(data) { }
~SkAutoResetOpID() {
if (NULL != fPlayback) {
fPlayback->resetOpID();
if (NULL != fData) {
fData->resetOpID();
}
}
private:
SkPicturePlayback* fPlayback;
SkPictureData* fData;
};
// TODO: Replace with hash or pass in "lastLookedUp" hint
SkPicturePlayback::PlaybackReplacements::ReplacementInfo*
SkPicturePlayback::PlaybackReplacements::lookupByStart(size_t start) {
SkPictureData::PlaybackReplacements::ReplacementInfo*
SkPictureData::PlaybackReplacements::lookupByStart(size_t start) {
SkDEBUGCODE(this->validate());
for (int i = 0; i < fReplacements.count(); ++i) {
if (start == fReplacements[i].fStart) {
@ -821,7 +821,7 @@ SkPicturePlayback::PlaybackReplacements::lookupByStart(size_t start) {
return NULL;
}
void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback) {
void SkPictureData::draw(SkCanvas& canvas, SkDrawPictureCallback* callback) {
SkAutoResetOpID aroi(this);
SkASSERT(0 == fCurOffset);
@ -922,7 +922,7 @@ void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback)
if (NULL != fReplacements) {
// Potentially replace a block of operations with a single drawBitmap call
SkPicturePlayback::PlaybackReplacements::ReplacementInfo* temp =
SkPictureData::PlaybackReplacements::ReplacementInfo* temp =
fReplacements->lookupByStart(reader.offset());
if (NULL != temp) {
SkASSERT(NULL != temp->fBM);
@ -1376,7 +1376,7 @@ void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback)
#if SK_SUPPORT_GPU
bool SkPicturePlayback::suitableForGpuRasterization(GrContext* context, const char **reason,
bool SkPictureData::suitableForGpuRasterization(GrContext* context, const char **reason,
int sampleCount) const {
// TODO: the heuristic used here needs to be refined
static const int kNumPaintWithPathEffectUsesTol = 1;
@ -1410,8 +1410,8 @@ bool SkPicturePlayback::suitableForGpuRasterization(GrContext* context, const ch
return ret;
}
bool SkPicturePlayback::suitableForGpuRasterization(GrContext* context, const char **reason,
GrPixelConfig config, SkScalar dpi) const {
bool SkPictureData::suitableForGpuRasterization(GrContext* context, const char **reason,
GrPixelConfig config, SkScalar dpi) const {
if (context != NULL) {
return this->suitableForGpuRasterization(context, reason,
@ -1425,7 +1425,7 @@ bool SkPicturePlayback::suitableForGpuRasterization(GrContext* context, const ch
///////////////////////////////////////////////////////////////////////////////
#ifdef SK_DEBUG_SIZE
int SkPicturePlayback::size(size_t* sizePtr) {
int SkPictureData::size(size_t* sizePtr) {
int objects = bitmaps(sizePtr);
objects += paints(sizePtr);
objects += paths(sizePtr);
@ -1435,7 +1435,7 @@ int SkPicturePlayback::size(size_t* sizePtr) {
return objects;
}
int SkPicturePlayback::bitmaps(size_t* size) {
int SkPictureData::bitmaps(size_t* size) {
size_t result = 0;
for (int index = 0; index < fBitmapCount; index++) {
// const SkBitmap& bitmap = fBitmaps[index];
@ -1445,7 +1445,7 @@ int SkPicturePlayback::bitmaps(size_t* size) {
return fBitmapCount;
}
int SkPicturePlayback::paints(size_t* size) {
int SkPictureData::paints(size_t* size) {
size_t result = 0;
for (int index = 0; index < fPaintCount; index++) {
// const SkPaint& paint = fPaints[index];
@ -1455,7 +1455,7 @@ int SkPicturePlayback::paints(size_t* size) {
return fPaintCount;
}
int SkPicturePlayback::paths(size_t* size) {
int SkPictureData::paths(size_t* size) {
size_t result = 0;
for (int index = 0; index < fPathCount; index++) {
const SkPath& path = fPaths[index];
@ -1467,7 +1467,7 @@ int SkPicturePlayback::paths(size_t* size) {
#endif
#ifdef SK_DEBUG_DUMP
void SkPicturePlayback::dumpBitmap(const SkBitmap& bitmap) const {
void SkPictureData::dumpBitmap(const SkBitmap& bitmap) const {
char pBuffer[DUMP_BUFFER_SIZE];
char* bufferPtr = pBuffer;
bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer),
@ -1624,29 +1624,29 @@ void dumpPaint(const SkPaint& paint) const {
&paint, &paint, &paint, &paint);
}
void SkPicturePlayback::dumpPath(const SkPath& path) const {
void SkPictureData::dumpPath(const SkPath& path) const {
SkDebugf("path dump unimplemented\n");
}
void SkPicturePlayback::dumpPicture(const SkPicture& picture) const {
void SkPictureData::dumpPicture(const SkPicture& picture) const {
SkDebugf("picture dump unimplemented\n");
}
void SkPicturePlayback::dumpRegion(const SkRegion& region) const {
void SkPictureData::dumpRegion(const SkRegion& region) const {
SkDebugf("region dump unimplemented\n");
}
int SkPicturePlayback::dumpDrawType(char* bufferPtr, char* buffer, DrawType drawType) {
int SkPictureData::dumpDrawType(char* bufferPtr, char* buffer, DrawType drawType) {
return snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - buffer),
"k%s, ", DrawTypeToString(drawType));
}
int SkPicturePlayback::dumpInt(char* bufferPtr, char* buffer, char* name) {
int SkPictureData::dumpInt(char* bufferPtr, char* buffer, char* name) {
return snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - buffer),
"%s:%d, ", name, getInt());
}
int SkPicturePlayback::dumpRect(char* bufferPtr, char* buffer, char* name) {
int SkPictureData::dumpRect(char* bufferPtr, char* buffer, char* name) {
const SkRect* rect = fReader.skipRect();
return snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - buffer),
"%s:{l:%g t:%g r:%g b:%g}, ", name, SkScalarToFloat(rect.fLeft),
@ -1654,7 +1654,7 @@ int SkPicturePlayback::dumpRect(char* bufferPtr, char* buffer, char* name) {
SkScalarToFloat(rect.fRight), SkScalarToFloat(rect.fBottom));
}
int SkPicturePlayback::dumpPoint(char* bufferPtr, char* buffer, char* name) {
int SkPictureData::dumpPoint(char* bufferPtr, char* buffer, char* name) {
SkPoint pt;
getPoint(&pt);
return snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - buffer),
@ -1662,7 +1662,7 @@ int SkPicturePlayback::dumpPoint(char* bufferPtr, char* buffer, char* name) {
SkScalarToFloat(pt.fY));
}
void SkPicturePlayback::dumpPointArray(char** bufferPtrPtr, char* buffer, int count) {
void SkPictureData::dumpPointArray(char** bufferPtrPtr, char* buffer, int count) {
char* bufferPtr = *bufferPtrPtr;
const SkPoint* pts = (const SkPoint*)fReadStream.getAtPos();
fReadStream.skip(sizeof(SkPoint) * count);
@ -1677,12 +1677,12 @@ void SkPicturePlayback::dumpPointArray(char** bufferPtrPtr, char* buffer, int co
*bufferPtrPtr = bufferPtr;
}
int SkPicturePlayback::dumpPtr(char* bufferPtr, char* buffer, char* name, void* ptr) {
int SkPictureData::dumpPtr(char* bufferPtr, char* buffer, char* name, void* ptr) {
return snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - buffer),
"%s:%p, ", name, ptr);
}
int SkPicturePlayback::dumpRectPtr(char* bufferPtr, char* buffer, char* name) {
int SkPictureData::dumpRectPtr(char* bufferPtr, char* buffer, char* name) {
char result;
fReadStream.read(&result, sizeof(result));
if (result)
@ -1692,12 +1692,12 @@ int SkPicturePlayback::dumpRectPtr(char* bufferPtr, char* buffer, char* name) {
"%s:NULL, ", name);
}
int SkPicturePlayback::dumpScalar(char* bufferPtr, char* buffer, char* name) {
int SkPictureData::dumpScalar(char* bufferPtr, char* buffer, char* name) {
return snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - buffer),
"%s:%d, ", name, getScalar());
}
void SkPicturePlayback::dumpText(char** bufferPtrPtr, char* buffer) {
void SkPictureData::dumpText(char** bufferPtrPtr, char* buffer) {
char* bufferPtr = *bufferPtrPtr;
int length = getInt();
bufferPtr += dumpDrawType(bufferPtr, buffer);
@ -1747,7 +1747,7 @@ void SkPicturePlayback::dumpText(char** bufferPtrPtr, char* buffer) {
#define DUMP_TEXT() \
dumpText(&bufferPtr, buffer)
void SkPicturePlayback::dumpStream() {
void SkPictureData::dumpStream() {
SkDebugf("RecordStream stream = {\n");
DrawType drawType;
TextContainer text;
@ -1866,7 +1866,7 @@ void SkPicturePlayback::dumpStream() {
}
}
void SkPicturePlayback::dump() const {
void SkPictureData::dump() const {
char pBuffer[DUMP_BUFFER_SIZE];
char* bufferPtr = pBuffer;
int index;
@ -1929,7 +1929,7 @@ void SkPicturePlayback::dump() const {
if (fPictureCount > 0)
SkDebugf("%s0};\n", pBuffer);
const_cast<SkPicturePlayback*>(this)->dumpStream();
const_cast<SkPictureData*>(this)->dumpStream();
}
#endif

View File

@ -6,8 +6,8 @@
* found in the LICENSE file.
*/
#ifndef SkPicturePlayback_DEFINED
#define SkPicturePlayback_DEFINED
#ifndef SkPictureData_DEFINED
#define SkPictureData_DEFINED
#include "SkBitmap.h"
#include "SkPathHeap.h"
@ -133,22 +133,22 @@ struct SkPictCopyInfo {
};
#endif
class SkPicturePlayback {
class SkPictureData {
public:
#ifdef SK_SUPPORT_LEGACY_PICTURE_CLONE
SkPicturePlayback(const SkPicturePlayback& src,
SkPictCopyInfo* deepCopyInfo = NULL);
SkPictureData(const SkPictureData& src,
SkPictCopyInfo* deepCopyInfo = NULL);
#else
SkPicturePlayback(const SkPicturePlayback& src);
SkPictureData(const SkPictureData& src);
#endif
SkPicturePlayback(const SkPictureRecord& record, const SkPictInfo&, bool deepCopyOps);
static SkPicturePlayback* CreateFromStream(SkStream*,
SkPictureData(const SkPictureRecord& record, const SkPictInfo&, bool deepCopyOps);
static SkPictureData* CreateFromStream(SkStream*,
const SkPictInfo&,
SkPicture::InstallPixelRefProc);
static SkPicturePlayback* CreateFromBuffer(SkReadBuffer&,
static SkPictureData* CreateFromBuffer(SkReadBuffer&,
const SkPictInfo&);
virtual ~SkPicturePlayback();
virtual ~SkPictureData();
const SkPicture::OperationList& getActiveOps(const SkIRect& queryRect);
@ -173,7 +173,7 @@ public:
void resetOpID() { fCurOffset = 0; }
protected:
explicit SkPicturePlayback(const SkPictInfo& info);
explicit SkPictureData(const SkPictInfo& info);
bool parseStream(SkStream*, SkPicture::InstallPixelRefProc);
bool parseBuffer(SkReadBuffer& buffer);
@ -365,7 +365,7 @@ private:
ReplacementInfo* push();
private:
friend class SkPicturePlayback; // for access to lookupByStart
friend class SkPictureData; // for access to lookupByStart
// look up a replacement range by its start offset
ReplacementInfo* lookupByStart(size_t start);

View File

@ -15,7 +15,7 @@
#endif
#include "SkPathHeap.h"
#include "SkPicture.h"
#include "SkPicturePlayback.h"
#include "SkPictureData.h"
#include "SkPictureFlat.h"
#include "SkTemplates.h"
#include "SkWriter32.h"
@ -325,7 +325,7 @@ private:
bool fOptsEnabled;
int fInitialSaveCount;
friend class SkPicturePlayback;
friend class SkPictureData;
friend class SkPictureTester; // for unit testing
#ifdef SK_COLLAPSE_MATRIX_CLIP_STATE

View File

@ -6,7 +6,6 @@
*/
#include "SkBBoxHierarchyRecord.h"
#include "SkPicturePlayback.h"
#include "SkPictureRecord.h"
#include "SkPictureRecorder.h"
#include "SkRecord.h"

View File

@ -9,7 +9,7 @@
#include "SkDevice.h"
#include "SkDraw.h"
#include "SkPaintPriv.h"
#include "SkPicturePlayback.h"
#include "SkPictureData.h"
SkPicture::AccelData::Key GPUAccelData::ComputeAccelDataKey() {
static const SkPicture::AccelData::Key gGPUID = SkPicture::AccelData::GenerateDomain();
@ -250,12 +250,12 @@ protected:
virtual void onDrawPicture(const SkPicture* picture) SK_OVERRIDE {
// BBH-based rendering doesn't re-issue many of the operations the gather
// process cares about (e.g., saves and restores) so it must be disabled.
if (NULL != picture->fPlayback.get()) {
picture->fPlayback->setUseBBH(false);
if (NULL != picture->fData.get()) {
picture->fData->setUseBBH(false);
}
picture->draw(this);
if (NULL != picture->fPlayback.get()) {
picture->fPlayback->setUseBBH(true);
if (NULL != picture->fData.get()) {
picture->fData->setUseBBH(true);
}
}

View File

@ -29,7 +29,7 @@
#include "SkMaskFilter.h"
#include "SkPathEffect.h"
#include "SkPicture.h"
#include "SkPicturePlayback.h"
#include "SkPictureData.h"
#include "SkRRect.h"
#include "SkStroke.h"
#include "SkSurface.h"
@ -1830,7 +1830,7 @@ void SkGpuDevice::EXPERIMENTAL_purge(const SkPicture* picture) {
bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* canvas, const SkPicture* picture) {
if (NULL == picture->fPlayback.get()) {
if (NULL == picture->fData.get()) {
return false;
}
@ -1928,7 +1928,7 @@ bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* canvas, const SkPicture* pi
}
}
SkPicturePlayback::PlaybackReplacements replacements;
SkPictureData::PlaybackReplacements replacements;
// Generate the layer and/or ensure it is locked
for (int i = 0; i < gpuData->numSaveLayers(); ++i) {
@ -1937,7 +1937,7 @@ bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* canvas, const SkPicture* pi
const GPUAccelData::SaveLayerInfo& info = gpuData->saveLayerInfo(i);
SkPicturePlayback::PlaybackReplacements::ReplacementInfo* layerInfo =
SkPictureData::PlaybackReplacements::ReplacementInfo* layerInfo =
replacements.push();
layerInfo->fStart = info.fSaveLayerOpID;
layerInfo->fStop = info.fRestoreOpID;
@ -2009,9 +2009,9 @@ bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* canvas, const SkPicture* pi
SkIntToScalar(layer->rect().fTop));
}
picture->fPlayback->setDrawLimits(info.fSaveLayerOpID, info.fRestoreOpID);
picture->fPlayback->draw(*canvas, NULL);
picture->fPlayback->setDrawLimits(0, 0);
picture->fData->setDrawLimits(info.fSaveLayerOpID, info.fRestoreOpID);
picture->fData->draw(*canvas, NULL);
picture->fData->setDrawLimits(0, 0);
canvas->flush();
}
@ -2019,9 +2019,9 @@ bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* canvas, const SkPicture* pi
}
// Playback using new layers
picture->fPlayback->setReplacements(&replacements);
picture->fPlayback->draw(*canvas, NULL);
picture->fPlayback->setReplacements(NULL);
picture->fData->setReplacements(&replacements);
picture->fData->draw(*canvas, NULL);
picture->fData->setReplacements(NULL);
// unlock the layers
for (int i = 0; i < gpuData->numSaveLayers(); ++i) {

View File

@ -662,15 +662,15 @@ static void test_gatherpixelrefsandrects(skiatest::Reporter* reporter) {
}
#ifdef SK_DEBUG
// Ensure that deleting SkPicturePlayback does not assert. Asserts only fire in debug mode, so only
// run in debug mode.
static void test_deleting_empty_playback() {
// Ensure that deleting an empty SkPicture does not assert. Asserts only fire
// in debug mode, so only run in debug mode.
static void test_deleting_empty_picture() {
SkPictureRecorder recorder;
// Creates an SkPictureRecord
recorder.beginRecording(0, 0);
// Turns that into an SkPicturePlayback
// Turns that into an SkPicture
SkAutoTUnref<SkPicture> picture(recorder.endRecording());
// Deletes the old SkPicturePlayback, and creates a new SkPictureRecord
// Ceates a new SkPictureRecord
recorder.beginRecording(0, 0);
}
@ -1547,7 +1547,7 @@ static void test_gen_id(skiatest::Reporter* reporter) {
DEF_TEST(Picture, reporter) {
#ifdef SK_DEBUG
test_deleting_empty_playback();
test_deleting_empty_picture();
test_serializing_empty_picture();
#else
test_bad_bitmap();

View File

@ -22,7 +22,7 @@ DEFINE_bool(useVolatileCache, false, "Use a volatile cache for deferred image de
"implementation.");
// Fits SkPicture::InstallPixelRefProc call signature.
// Used in SkPicturePlayback::CreateFromStream
// Used in SkPictureData::CreateFromStream
bool sk_tools::LazyDecodeBitmap(const void* src,
size_t length,
SkBitmap* dst) {

View File

@ -13,7 +13,6 @@
#include "SkImageEncoder.h"
#include "SkOSFile.h"
#include "SkPicture.h"
#include "SkPicturePlayback.h"
#include "SkPictureRecord.h"
#include "SkPictureRecorder.h"
#include "SkStream.h"

View File

@ -7,7 +7,7 @@
#include "SkCommandLineFlags.h"
#include "SkPicture.h"
#include "SkPicturePlayback.h"
#include "SkPictureData.h"
#include "SkStream.h"
DEFINE_string2(input, i, "", "skp on which to report");