diff options
author | djsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-04-12 13:24:04 +0000 |
---|---|---|
committer | djsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-04-12 13:24:04 +0000 |
commit | 2b2ede3e713065e1bac461787b0aafb03eaf871f (patch) | |
tree | 180a113560b219569ef06556982ec99fcac5ca36 /src/core | |
parent | 7463f190972f45157242d2f1f4368de78e5863d7 (diff) |
Decouple the SkFlattenable from SkReader32/SkWriter32.
The current impl for SkFlattenable read/write buffers is
that they extend from SkReader32 and SkWriter32, but that
dependency must be abstract if we are to add any other
serialization format.
Review URL: https://codereview.appspot.com/5999045
git-svn-id: http://skia.googlecode.com/svn/trunk@3654 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkFlattenable.cpp | 235 | ||||
-rw-r--r-- | src/core/SkOrderedReadBuffer.cpp | 106 | ||||
-rw-r--r-- | src/core/SkOrderedWriteBuffer.cpp | 94 | ||||
-rw-r--r-- | src/core/SkPaint.cpp | 7 | ||||
-rw-r--r-- | src/core/SkPathHeap.cpp | 4 | ||||
-rw-r--r-- | src/core/SkPictureFlat.cpp | 9 | ||||
-rw-r--r-- | src/core/SkPictureFlat.h | 3 | ||||
-rw-r--r-- | src/core/SkPicturePlayback.cpp | 6 | ||||
-rw-r--r-- | src/core/SkPicturePlayback.h | 3 | ||||
-rw-r--r-- | src/core/SkScalerContext.cpp | 3 | ||||
-rw-r--r-- | src/core/SkShader.cpp | 4 |
11 files changed, 230 insertions, 244 deletions
diff --git a/src/core/SkFlattenable.cpp b/src/core/SkFlattenable.cpp index 6a445ea751..b8001f0cdc 100644 --- a/src/core/SkFlattenable.cpp +++ b/src/core/SkFlattenable.cpp @@ -8,33 +8,6 @@ #include "SkFlattenable.h" #include "SkTypeface.h" -#include "SkMatrix.h" -#include "SkRegion.h" - -void SkReadMatrix(SkReader32* reader, SkMatrix* matrix) { - size_t size = matrix->unflatten(reader->peek()); - SkASSERT(SkAlign4(size) == size); - (void)reader->skip(size); -} - -void SkWriteMatrix(SkWriter32* writer, const SkMatrix& matrix) { - size_t size = matrix.flatten(NULL); - SkASSERT(SkAlign4(size) == size); - matrix.flatten(writer->reserve(size)); -} - -void SkReadRegion(SkReader32* reader, SkRegion* rgn) { - size_t size = rgn->unflatten(reader->peek()); - SkASSERT(SkAlign4(size) == size); - (void)reader->skip(size); -} - -void SkWriteRegion(SkWriter32* writer, const SkRegion& rgn) { - size_t size = rgn.flatten(NULL); - SkASSERT(SkAlign4(size) == size); - rgn.flatten(writer->reserve(size)); -} - /////////////////////////////////////////////////////////////////////////////// void SkFlattenable::flatten(SkFlattenableWriteBuffer&) const @@ -46,7 +19,6 @@ void SkFlattenable::flatten(SkFlattenableWriteBuffer&) const } /////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////// SkFlattenableReadBuffer::SkFlattenableReadBuffer() { fRCArray = NULL; @@ -60,126 +32,9 @@ SkFlattenableReadBuffer::SkFlattenableReadBuffer() { fFactoryCount = 0; } -SkFlattenableReadBuffer::SkFlattenableReadBuffer(const void* data) : - INHERITED(data, 1024 * 1024) { - fRCArray = NULL; - fRCCount = 0; - - fTFArray = NULL; - fTFCount = 0; - - fFactoryTDArray = NULL; - fFactoryArray = NULL; - fFactoryCount = 0; -} - -SkFlattenableReadBuffer::SkFlattenableReadBuffer(const void* data, size_t size) - : INHERITED(data, size) { - fRCArray = NULL; - fRCCount = 0; - - fTFArray = NULL; - fTFCount = 0; - - fFactoryTDArray = NULL; - fFactoryArray = NULL; - fFactoryCount = 0; -} - -SkTypeface* SkFlattenableReadBuffer::readTypeface() { - uint32_t index = this->readU32(); - if (0 == index || index > (unsigned)fTFCount) { - if (index) { - SkDebugf("====== typeface index %d\n", index); - } - return NULL; - } else { - SkASSERT(fTFArray); - return fTFArray[index - 1]; - } -} - -SkRefCnt* SkFlattenableReadBuffer::readRefCnt() { - uint32_t index = this->readU32(); - if (0 == index || index > (unsigned)fRCCount) { - return NULL; - } else { - SkASSERT(fRCArray); - return fRCArray[index - 1]; - } -} - -SkFlattenable* SkFlattenableReadBuffer::readFlattenable() { - SkFlattenable::Factory factory = NULL; - - if (fFactoryCount > 0) { - int32_t index = this->readU32(); - if (0 == index) { - return NULL; // writer failed to give us the flattenable - } - index = -index; // we stored the negative of the index - index -= 1; // we stored the index-base-1 - SkASSERT(index < fFactoryCount); - factory = fFactoryArray[index]; - } else if (fFactoryTDArray) { - const int32_t* peek = (const int32_t*)this->peek(); - if (*peek <= 0) { - int32_t index = this->readU32(); - if (0 == index) { - return NULL; // writer failed to give us the flattenable - } - index = -index; // we stored the negative of the index - index -= 1; // we stored the index-base-1 - factory = (*fFactoryTDArray)[index]; - } else { - const char* name = this->readString(); - factory = SkFlattenable::NameToFactory(name); - if (factory) { - SkASSERT(fFactoryTDArray->find(factory) < 0); - *fFactoryTDArray->append() = factory; - } else { -// SkDebugf("can't find factory for [%s]\n", name); - } - // if we didn't find a factory, that's our failure, not the writer's, - // so we fall through, so we can skip the sizeRecorded data. - } - } else { - factory = (SkFlattenable::Factory)readFunctionPtr(); - if (NULL == factory) { - return NULL; // writer failed to give us the flattenable - } - } - - // if we get here, factory may still be null, but if that is the case, the - // failure was ours, not the writer. - SkFlattenable* obj = NULL; - uint32_t sizeRecorded = this->readU32(); - if (factory) { - uint32_t offset = this->offset(); - obj = (*factory)(*this); - // check that we read the amount we expected - uint32_t sizeRead = this->offset() - offset; - if (sizeRecorded != sizeRead) { - // we could try to fix up the offset... - sk_throw(); - } - } else { - // we must skip the remaining data - this->skip(sizeRecorded); - } - return obj; -} - -void* SkFlattenableReadBuffer::readFunctionPtr() { - void* proc; - this->read(&proc, sizeof(proc)); - return proc; -} - /////////////////////////////////////////////////////////////////////////////// -SkFlattenableWriteBuffer::SkFlattenableWriteBuffer(size_t minSize) : - INHERITED(minSize) { +SkFlattenableWriteBuffer::SkFlattenableWriteBuffer() { fFlags = (Flags)0; fRCSet = NULL; fTFSet = NULL; @@ -207,15 +62,8 @@ SkFactorySet* SkFlattenableWriteBuffer::setFactoryRecorder(SkFactorySet* rec) { return rec; } -void SkFlattenableWriteBuffer::writeTypeface(SkTypeface* obj) { - if (NULL == obj || NULL == fTFSet) { - this->write32(0); - } else { - this->write32(fTFSet->add(obj)); - } -} - void SkFlattenableWriteBuffer::writeRefCnt(SkRefCnt* obj) { + SkASSERT(!isCrossProcess()); if (NULL == obj || NULL == fRCSet) { this->write32(0); } else { @@ -223,83 +71,12 @@ void SkFlattenableWriteBuffer::writeRefCnt(SkRefCnt* obj) { } } -void SkFlattenableWriteBuffer::writeFlattenable(SkFlattenable* flattenable) { - /* - * If we have a factoryset, then the first 32bits tell us... - * 0: failure to write the flattenable - * <0: we store the negative of the (1-based) index - * >0: the length of the name - * If we don't have a factoryset, then the first "ptr" is either the - * factory, or null for failure. - * - * The distinction is important, since 0-index is 32bits (always), but a - * 0-functionptr might be 32 or 64 bits. - */ - - SkFlattenable::Factory factory = NULL; - if (flattenable) { - factory = flattenable->getFactory(); - } - if (NULL == factory) { - if (fFactorySet) { - this->write32(0); - } else { - this->writeFunctionPtr(NULL); - } - return; - } - - /* - * We can write 1 of 3 versions of the flattenable: - * 1. function-ptr : this is the fastest for the reader, but assumes that - * the writer and reader are in the same process. - * 2. index into fFactorySet : This is assumes the writer will later - * resolve the function-ptrs into strings for its reader. SkPicture - * does exactly this, by writing a table of names (matching the indices) - * up front in its serialized form. - * 3. names : Reuse fFactorySet to store indices, but only after we've - * written the name the first time. SkGPipe uses this technique, as it - * doesn't require the reader to be told to know the table of names - * up front. - */ - if (fFactorySet) { - if (this->inlineFactoryNames()) { - int index = fFactorySet->find(factory); - if (index) { - // we write the negative of the index, to distinguish it from - // the length of a string - this->write32(-index); - } else { - const char* name = SkFlattenable::FactoryToName(factory); - if (NULL == name) { - this->write32(0); - return; - } - this->writeString(name); - index = fFactorySet->add(factory); - } - } else { - // we write the negative of the index, to distinguish it from - // the length of a string - this->write32(-(int)fFactorySet->add(factory)); - } +void SkFlattenableWriteBuffer::writeTypeface(SkTypeface* obj) { + if (NULL == obj || NULL == fTFSet) { + this->write32(0); } else { - this->writeFunctionPtr((void*)factory); + this->write32(fTFSet->add(obj)); } - - // make room for the size of the flatttened object - (void)this->reserve(sizeof(uint32_t)); - // record the current size, so we can subtract after the object writes. - uint32_t offset = this->size(); - // now flatten the object - flattenable->flatten(*this); - uint32_t objSize = this->size() - offset; - // record the obj's size - *this->peek32(offset - sizeof(uint32_t)) = objSize; -} - -void SkFlattenableWriteBuffer::writeFunctionPtr(void* proc) { - *(void**)this->reserve(sizeof(void*)) = proc; } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/core/SkOrderedReadBuffer.cpp b/src/core/SkOrderedReadBuffer.cpp new file mode 100644 index 0000000000..e3a56dbb07 --- /dev/null +++ b/src/core/SkOrderedReadBuffer.cpp @@ -0,0 +1,106 @@ + +/* + * Copyright 2011 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "SkOrderedReadBuffer.h" +#include "SkTypeface.h" + + +SkOrderedReadBuffer::SkOrderedReadBuffer(const void* data, size_t size) + : INHERITED() { + fReader.setMemory(data, size); +} + +SkTypeface* SkOrderedReadBuffer::readTypeface() { + uint32_t index = fReader.readU32(); + if (0 == index || index > (unsigned)fTFCount) { + if (index) { + SkDebugf("====== typeface index %d\n", index); + } + return NULL; + } else { + SkASSERT(fTFArray); + return fTFArray[index - 1]; + } +} + +SkRefCnt* SkOrderedReadBuffer::readRefCnt() { + uint32_t index = fReader.readU32(); + if (0 == index || index > (unsigned)fRCCount) { + return NULL; + } else { + SkASSERT(fRCArray); + return fRCArray[index - 1]; + } +} + +SkFlattenable* SkOrderedReadBuffer::readFlattenable() { + SkFlattenable::Factory factory = NULL; + + if (fFactoryCount > 0) { + int32_t index = fReader.readU32(); + if (0 == index) { + return NULL; // writer failed to give us the flattenable + } + index = -index; // we stored the negative of the index + index -= 1; // we stored the index-base-1 + SkASSERT(index < fFactoryCount); + factory = fFactoryArray[index]; + } else if (fFactoryTDArray) { + const int32_t* peek = (const int32_t*)fReader.peek(); + if (*peek <= 0) { + int32_t index = fReader.readU32(); + if (0 == index) { + return NULL; // writer failed to give us the flattenable + } + index = -index; // we stored the negative of the index + index -= 1; // we stored the index-base-1 + factory = (*fFactoryTDArray)[index]; + } else { + const char* name = fReader.readString(); + factory = SkFlattenable::NameToFactory(name); + if (factory) { + SkASSERT(fFactoryTDArray->find(factory) < 0); + *fFactoryTDArray->append() = factory; + } else { +// SkDebugf("can't find factory for [%s]\n", name); + } + // if we didn't find a factory, that's our failure, not the writer's, + // so we fall through, so we can skip the sizeRecorded data. + } + } else { + factory = (SkFlattenable::Factory)readFunctionPtr(); + if (NULL == factory) { + return NULL; // writer failed to give us the flattenable + } + } + + // if we get here, factory may still be null, but if that is the case, the + // failure was ours, not the writer. + SkFlattenable* obj = NULL; + uint32_t sizeRecorded = fReader.readU32(); + if (factory) { + uint32_t offset = fReader.offset(); + obj = (*factory)(*this); + // check that we read the amount we expected + uint32_t sizeRead = fReader.offset() - offset; + if (sizeRecorded != sizeRead) { + // we could try to fix up the offset... + sk_throw(); + } + } else { + // we must skip the remaining data + fReader.skip(sizeRecorded); + } + return obj; +} + +void* SkOrderedReadBuffer::readFunctionPtr() { + void* proc; + fReader.read(&proc, sizeof(proc)); + return proc; +} diff --git a/src/core/SkOrderedWriteBuffer.cpp b/src/core/SkOrderedWriteBuffer.cpp new file mode 100644 index 0000000000..bfe2bfc0b4 --- /dev/null +++ b/src/core/SkOrderedWriteBuffer.cpp @@ -0,0 +1,94 @@ + +/* + * Copyright 2011 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "SkOrderedWriteBuffer.h" +#include "SkTypeface.h" + +SkOrderedWriteBuffer::SkOrderedWriteBuffer(size_t minSize) : + INHERITED(), + fWriter(minSize) { +} + +void SkOrderedWriteBuffer::writeFlattenable(SkFlattenable* flattenable) { + /* + * If we have a factoryset, then the first 32bits tell us... + * 0: failure to write the flattenable + * <0: we store the negative of the (1-based) index + * >0: the length of the name + * If we don't have a factoryset, then the first "ptr" is either the + * factory, or null for failure. + * + * The distinction is important, since 0-index is 32bits (always), but a + * 0-functionptr might be 32 or 64 bits. + */ + + SkFlattenable::Factory factory = NULL; + if (flattenable) { + factory = flattenable->getFactory(); + } + if (NULL == factory) { + if (fFactorySet) { + this->write32(0); + } else { + this->writeFunctionPtr(NULL); + } + return; + } + + /* + * We can write 1 of 3 versions of the flattenable: + * 1. function-ptr : this is the fastest for the reader, but assumes that + * the writer and reader are in the same process. + * 2. index into fFactorySet : This is assumes the writer will later + * resolve the function-ptrs into strings for its reader. SkPicture + * does exactly this, by writing a table of names (matching the indices) + * up front in its serialized form. + * 3. names : Reuse fFactorySet to store indices, but only after we've + * written the name the first time. SkGPipe uses this technique, as it + * doesn't require the reader to be told to know the table of names + * up front. + */ + if (fFactorySet) { + if (this->inlineFactoryNames()) { + int index = fFactorySet->find(factory); + if (index) { + // we write the negative of the index, to distinguish it from + // the length of a string + this->write32(-index); + } else { + const char* name = SkFlattenable::FactoryToName(factory); + if (NULL == name) { + this->write32(0); + return; + } + this->writeString(name); + index = fFactorySet->add(factory); + } + } else { + // we write the negative of the index, to distinguish it from + // the length of a string + this->write32(-(int)fFactorySet->add(factory)); + } + } else { + this->writeFunctionPtr((void*)factory); + } + + // make room for the size of the flatttened object + (void)this->reserve(sizeof(uint32_t)); + // record the current size, so we can subtract after the object writes. + uint32_t offset = this->size(); + // now flatten the object + flattenObject(flattenable, *this); + uint32_t objSize = this->size() - offset; + // record the obj's size + *fWriter.peek32(offset - sizeof(uint32_t)) = objSize; +} + +void SkOrderedWriteBuffer::writeFunctionPtr(void* proc) { + *(void**)this->reserve(sizeof(void*)) = proc; +} diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp index 6a16e24ba2..15fdbd196e 100644 --- a/src/core/SkPaint.cpp +++ b/src/core/SkPaint.cpp @@ -24,6 +24,7 @@ #include "SkAutoKern.h" #include "SkGlyphCache.h" #include "SkPaintDefaults.h" +#include "SkOrderedWriteBuffer.h" // define this to get a printf for out-of-range parameter in setters // e.g. setTextSize(-1) @@ -1682,9 +1683,9 @@ void SkPaint::descriptorProc(const SkMatrix* deviceMatrix, SkMaskFilter* mf = this->getMaskFilter(); SkRasterizer* ra = this->getRasterizer(); - SkFlattenableWriteBuffer peBuffer(MIN_SIZE_FOR_EFFECT_BUFFER); - SkFlattenableWriteBuffer mfBuffer(MIN_SIZE_FOR_EFFECT_BUFFER); - SkFlattenableWriteBuffer raBuffer(MIN_SIZE_FOR_EFFECT_BUFFER); + SkOrderedWriteBuffer peBuffer(MIN_SIZE_FOR_EFFECT_BUFFER); + SkOrderedWriteBuffer mfBuffer(MIN_SIZE_FOR_EFFECT_BUFFER); + SkOrderedWriteBuffer raBuffer(MIN_SIZE_FOR_EFFECT_BUFFER); if (pe) { peBuffer.writeFlattenable(pe); diff --git a/src/core/SkPathHeap.cpp b/src/core/SkPathHeap.cpp index 9bf77c1d9c..a9183c3242 100644 --- a/src/core/SkPathHeap.cpp +++ b/src/core/SkPathHeap.cpp @@ -26,7 +26,7 @@ SkPathHeap::SkPathHeap(SkFlattenableReadBuffer& buffer) for (int i = 0; i < count; i++) { new (p) SkPath; - p->unflatten(buffer); + buffer.readPath(p); *ptr++ = p; // record the pointer p++; // move to the next storage location } @@ -55,7 +55,7 @@ void SkPathHeap::flatten(SkFlattenableWriteBuffer& buffer) const { SkPath** iter = fPaths.begin(); SkPath** stop = fPaths.end(); while (iter < stop) { - (*iter)->flatten(buffer); + buffer.writePath(**iter); iter++; } } diff --git a/src/core/SkPictureFlat.cpp b/src/core/SkPictureFlat.cpp index 1058526912..5064ab82e9 100644 --- a/src/core/SkPictureFlat.cpp +++ b/src/core/SkPictureFlat.cpp @@ -14,6 +14,8 @@ #include "SkShader.h" #include "SkTypeface.h" #include "SkXfermode.h" +#include "SkOrderedReadBuffer.h" +#include "SkOrderedWriteBuffer.h" SkFlatData* SkFlatData::Alloc(SkChunkAlloc* heap, int32_t size, int index) { SkFlatData* result = (SkFlatData*) heap->allocThrow(size + sizeof(SkFlatData)); @@ -24,7 +26,7 @@ SkFlatData* SkFlatData::Alloc(SkChunkAlloc* heap, int32_t size, int index) { SkFlatBitmap* SkFlatBitmap::Flatten(SkChunkAlloc* heap, const SkBitmap& bitmap, int index, SkRefCntSet* rec) { - SkFlattenableWriteBuffer buffer(1024); + SkOrderedWriteBuffer buffer(1024); buffer.setRefCntRecorder(rec); bitmap.flatten(buffer); @@ -91,7 +93,8 @@ void SkFlatMatrix::dump() const { SkFlatPaint* SkFlatPaint::Flatten(SkChunkAlloc* heap, const SkPaint& paint, int index, SkRefCntSet* rec, SkRefCntSet* faceRecorder) { - SkFlattenableWriteBuffer buffer(2*sizeof(SkPaint)); + SkOrderedWriteBuffer buffer(2*sizeof(SkPaint)); + buffer.setRefCntRecorder(rec); buffer.setTypefaceRecorder(faceRecorder); @@ -104,7 +107,7 @@ SkFlatPaint* SkFlatPaint::Flatten(SkChunkAlloc* heap, const SkPaint& paint, void SkFlatPaint::Read(const void* storage, SkPaint* paint, SkRefCntPlayback* rcp, SkTypefacePlayback* facePlayback) { - SkFlattenableReadBuffer buffer(storage); + SkOrderedReadBuffer buffer(storage, 1024*1024); if (rcp) { rcp->setupBuffer(buffer); } diff --git a/src/core/SkPictureFlat.h b/src/core/SkPictureFlat.h index 983bfc5f25..60e7f2c895 100644 --- a/src/core/SkPictureFlat.h +++ b/src/core/SkPictureFlat.h @@ -10,6 +10,7 @@ #include "SkChunkAlloc.h" #include "SkBitmap.h" +#include "SkOrderedReadBuffer.h" #include "SkPicture.h" #include "SkMatrix.h" #include "SkPaint.h" @@ -151,7 +152,7 @@ public: SkRefCntSet*); void unflatten(SkBitmap* bitmap, SkRefCntPlayback* rcp) const { - SkFlattenableReadBuffer buffer(fBitmapData); + SkOrderedReadBuffer buffer(fBitmapData, 1024*1024); if (rcp) { rcp->setupBuffer(buffer); } diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp index c51ddcca7f..2ca2fc79bf 100644 --- a/src/core/SkPicturePlayback.cpp +++ b/src/core/SkPicturePlayback.cpp @@ -8,6 +8,8 @@ #include "SkPicturePlayback.h" #include "SkPictureRecord.h" #include "SkTypeface.h" +#include "SkOrderedReadBuffer.h" +#include "SkOrderedWriteBuffer.h" #include <new> /* Define this to spew out a debug statement whenever we skip the remainder of @@ -319,7 +321,7 @@ void SkPicturePlayback::serialize(SkWStream* stream) const { SkRefCntSet typefaceSet; SkFactorySet factSet; - SkFlattenableWriteBuffer buffer(1024); + SkOrderedWriteBuffer buffer(1024); buffer.setFlags(SkFlattenableWriteBuffer::kCrossProcess_Flag); buffer.setTypefaceRecorder(&typefaceSet); @@ -431,7 +433,7 @@ SkPicturePlayback::SkPicturePlayback(SkStream* stream) { SkAutoMalloc storage(tagSize); stream->read(storage.get(), tagSize); - SkFlattenableReadBuffer buffer(storage.get(), tagSize); + SkOrderedReadBuffer buffer(storage.get(), tagSize); fFactoryPlayback->setupBuffer(buffer); fTFPlayback.setupBuffer(buffer); diff --git a/src/core/SkPicturePlayback.h b/src/core/SkPicturePlayback.h index f78f15e4ee..b82e9dbb05 100644 --- a/src/core/SkPicturePlayback.h +++ b/src/core/SkPicturePlayback.h @@ -13,6 +13,7 @@ #include "SkBitmap.h" #include "SkMatrix.h" +#include "SkOrderedReadBuffer.h" #include "SkPaint.h" #include "SkPath.h" #include "SkPathHeap.h" @@ -166,7 +167,7 @@ private: int fPaintCount; SkRegion* fRegions; int fRegionCount; - mutable SkFlattenableReadBuffer fReader; + mutable SkOrderedReadBuffer fReader; SkPicture** fPictureRefs; int fPictureCount; diff --git a/src/core/SkScalerContext.cpp b/src/core/SkScalerContext.cpp index 1799b2c11c..50dbfc52b1 100644 --- a/src/core/SkScalerContext.cpp +++ b/src/core/SkScalerContext.cpp @@ -13,6 +13,7 @@ #include "SkDraw.h" #include "SkFontHost.h" #include "SkMaskFilter.h" +#include "SkOrderedReadBuffer.h" #include "SkPathEffect.h" #include "SkRasterizer.h" #include "SkRasterClip.h" @@ -64,7 +65,7 @@ static SkFlattenable* load_flattenable(const SkDescriptor* desc, uint32_t tag) { const void* data = desc->findEntry(tag, &len); if (data) { - SkFlattenableReadBuffer buffer(data, len); + SkOrderedReadBuffer buffer(data, len); obj = buffer.readFlattenable(); SkASSERT(buffer.offset() == buffer.size()); } diff --git a/src/core/SkShader.cpp b/src/core/SkShader.cpp index bfdebc1b07..695361268a 100644 --- a/src/core/SkShader.cpp +++ b/src/core/SkShader.cpp @@ -20,7 +20,7 @@ SkShader::SkShader(SkFlattenableReadBuffer& buffer) : INHERITED(buffer), fLocalMatrix(NULL) { if (buffer.readBool()) { SkMatrix matrix; - SkReadMatrix(&buffer, &matrix); + buffer.readMatrix(&matrix); setLocalMatrix(matrix); } SkDEBUGCODE(fInSession = false;) @@ -45,7 +45,7 @@ void SkShader::flatten(SkFlattenableWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writeBool(fLocalMatrix != NULL); if (fLocalMatrix) { - SkWriteMatrix(&buffer, *fLocalMatrix); + buffer.writeMatrix(*fLocalMatrix); } } |