diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkPicture.cpp | 102 | ||||
-rw-r--r-- | src/core/SkPictureData.cpp (renamed from src/core/SkPicturePlayback.cpp) | 142 | ||||
-rw-r--r-- | src/core/SkPictureData.h (renamed from src/core/SkPicturePlayback.h) | 24 | ||||
-rw-r--r-- | src/core/SkPictureRecord.h | 4 | ||||
-rw-r--r-- | src/core/SkPictureRecorder.cpp | 1 | ||||
-rw-r--r-- | src/gpu/GrPictureUtils.cpp | 10 | ||||
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 20 |
7 files changed, 151 insertions, 152 deletions
diff --git a/src/core/SkPicture.cpp b/src/core/SkPicture.cpp index 45a0d2c38c..8d196a130b 100644 --- a/src/core/SkPicture.cpp +++ b/src/core/SkPicture.cpp @@ -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>(©Info.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, ©Info))); + clone->fData.reset(SkNEW_ARGS(SkPictureData, (*fData, ©Info))); 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 diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPictureData.cpp index 92b1b01e02..d121a302ba 100644 --- a/src/core/SkPicturePlayback.cpp +++ b/src/core/SkPictureData.cpp @@ -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 diff --git a/src/core/SkPicturePlayback.h b/src/core/SkPictureData.h index f5260f8d0f..f798e7c923 100644 --- a/src/core/SkPicturePlayback.h +++ b/src/core/SkPictureData.h @@ -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); diff --git a/src/core/SkPictureRecord.h b/src/core/SkPictureRecord.h index 417dde6e82..0fdfaa7108 100644 --- a/src/core/SkPictureRecord.h +++ b/src/core/SkPictureRecord.h @@ -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 diff --git a/src/core/SkPictureRecorder.cpp b/src/core/SkPictureRecorder.cpp index 1da9653436..7985145001 100644 --- a/src/core/SkPictureRecorder.cpp +++ b/src/core/SkPictureRecorder.cpp @@ -6,7 +6,6 @@ */ #include "SkBBoxHierarchyRecord.h" -#include "SkPicturePlayback.h" #include "SkPictureRecord.h" #include "SkPictureRecorder.h" #include "SkRecord.h" diff --git a/src/gpu/GrPictureUtils.cpp b/src/gpu/GrPictureUtils.cpp index c677c64bd1..4da9e3ceab 100644 --- a/src/gpu/GrPictureUtils.cpp +++ b/src/gpu/GrPictureUtils.cpp @@ -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); } } diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index 318de8db3d..9041bdfba2 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -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) { |