diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-01-30 18:58:24 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-01-30 18:58:24 +0000 |
commit | 8b0e8ac5f582de80356019406e2975079bf0829d (patch) | |
tree | 9f43589895207dfcf422d41318b371c9540f1ada /src | |
parent | 5fbccb35eb9e7e8cfa3c6b02026206db77990324 (diff) |
Refactor read and write buffers.
Eliminates SkFlattenable{Read,Write}Buffer, promoting SkOrdered{Read,Write}Buffer
a step each in the hierarchy.
What used to be this:
SkFlattenableWriteBuffer -> SkOrderedWriteBuffer
SkFlattenableReadBuffer -> SkOrderedReadBuffer
SkFlattenableReadBuffer -> SkValidatingReadBuffer
is now
SkWriteBuffer
SkReadBuffer -> SkValidatingReadBuffer
Benefits:
- code is simpler, names are less wordy
- the generic SkFlattenableFooBuffer code in SkPaint was incorrect; removed
- write buffers are completely devirtualized, important for record speed
This refactoring was mostly mechanical. You aren't going to find anything
interesting in files with less than 10 lines changed.
BUG=skia:
R=reed@google.com, scroggo@google.com, djsollen@google.com, mtklein@google.com
Author: mtklein@chromium.org
Review URL: https://codereview.chromium.org/134163010
git-svn-id: http://skia.googlecode.com/svn/trunk@13245 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
102 files changed, 550 insertions, 878 deletions
diff --git a/src/core/SkAnnotation.cpp b/src/core/SkAnnotation.cpp index 837cb62ad4..6ba645ffed 100644 --- a/src/core/SkAnnotation.cpp +++ b/src/core/SkAnnotation.cpp @@ -7,7 +7,8 @@ #include "SkAnnotation.h" #include "SkData.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkPoint.h" #include "SkStream.h" @@ -28,12 +29,12 @@ SkData* SkAnnotation::find(const char key[]) const { return fKey.equals(key) ? fData : NULL; } -SkAnnotation::SkAnnotation(SkFlattenableReadBuffer& buffer) { +SkAnnotation::SkAnnotation(SkReadBuffer& buffer) { buffer.readString(&fKey); fData = buffer.readByteArrayAsData(); } -void SkAnnotation::writeToBuffer(SkFlattenableWriteBuffer& buffer) const { +void SkAnnotation::writeToBuffer(SkWriteBuffer& buffer) const { buffer.writeString(fKey.c_str()); buffer.writeDataAsByteArray(fData); } diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp index e12840adab..3b33820558 100644 --- a/src/core/SkBitmap.cpp +++ b/src/core/SkBitmap.cpp @@ -14,8 +14,8 @@ #include "SkImagePriv.h" #include "SkMallocPixelRef.h" #include "SkMask.h" -#include "SkOrderedReadBuffer.h" -#include "SkOrderedWriteBuffer.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkPixelRef.h" #include "SkThread.h" #include "SkUnPreMultiply.h" @@ -1583,7 +1583,7 @@ enum { SERIALIZE_PIXELTYPE_REF_DATA }; -void SkBitmap::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkBitmap::flatten(SkWriteBuffer& buffer) const { buffer.writeInt(fWidth); buffer.writeInt(fHeight); buffer.writeInt(fRowBytes); @@ -1605,7 +1605,7 @@ void SkBitmap::flatten(SkFlattenableWriteBuffer& buffer) const { } } -void SkBitmap::unflatten(SkFlattenableReadBuffer& buffer) { +void SkBitmap::unflatten(SkReadBuffer& buffer) { this->reset(); int width = buffer.readInt(); diff --git a/src/core/SkBitmapHeap.cpp b/src/core/SkBitmapHeap.cpp index 7904492f46..da628937e9 100644 --- a/src/core/SkBitmapHeap.cpp +++ b/src/core/SkBitmapHeap.cpp @@ -9,7 +9,8 @@ #include "SkBitmapHeap.h" #include "SkBitmap.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkTSearch.h" SkBitmapHeapEntry::SkBitmapHeapEntry() diff --git a/src/core/SkBitmapProcShader.cpp b/src/core/SkBitmapProcShader.cpp index 9a94676d6e..d7c7269c89 100644 --- a/src/core/SkBitmapProcShader.cpp +++ b/src/core/SkBitmapProcShader.cpp @@ -6,7 +6,8 @@ * found in the LICENSE file. */ #include "SkColorPriv.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkPixelRef.h" #include "SkErrorInternals.h" #include "SkBitmapProcShader.h" @@ -38,7 +39,7 @@ SkBitmapProcShader::SkBitmapProcShader(const SkBitmap& src, fFlags = 0; // computed in setContext } -SkBitmapProcShader::SkBitmapProcShader(SkFlattenableReadBuffer& buffer) +SkBitmapProcShader::SkBitmapProcShader(SkReadBuffer& buffer) : INHERITED(buffer) { buffer.readBitmap(&fRawBitmap); fRawBitmap.setImmutable(); @@ -63,7 +64,7 @@ SkShader::BitmapType SkBitmapProcShader::asABitmap(SkBitmap* texture, return kDefault_BitmapType; } -void SkBitmapProcShader::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkBitmapProcShader::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writeBitmap(fRawBitmap); diff --git a/src/core/SkBitmapProcShader.h b/src/core/SkBitmapProcShader.h index 5a599c3b92..b7e60f1ca1 100644 --- a/src/core/SkBitmapProcShader.h +++ b/src/core/SkBitmapProcShader.h @@ -37,8 +37,8 @@ public: #endif protected: - SkBitmapProcShader(SkFlattenableReadBuffer& ); - virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; + SkBitmapProcShader(SkReadBuffer& ); + virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; SkBitmap fRawBitmap; // experimental for RLE encoding SkBitmapProcState fState; diff --git a/src/core/SkBlitter.cpp b/src/core/SkBlitter.cpp index 9682d5572a..31a3edea76 100644 --- a/src/core/SkBlitter.cpp +++ b/src/core/SkBlitter.cpp @@ -12,7 +12,8 @@ #include "SkColor.h" #include "SkColorFilter.h" #include "SkFilterShader.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkMask.h" #include "SkMaskFilter.h" #include "SkTemplatesPriv.h" @@ -682,13 +683,13 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Sk3DShader) protected: - Sk3DShader(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) { + Sk3DShader(SkReadBuffer& buffer) : INHERITED(buffer) { fProxy = buffer.readShader(); fPMColor = buffer.readColor(); fMask = NULL; } - virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE { + virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE { this->INHERITED::flatten(buffer); buffer.writeFlattenable(fProxy); buffer.writeColor(fPMColor); diff --git a/src/core/SkColorFilter.cpp b/src/core/SkColorFilter.cpp index ef0bda74ee..8cf9fc010a 100644 --- a/src/core/SkColorFilter.cpp +++ b/src/core/SkColorFilter.cpp @@ -7,7 +7,8 @@ #include "SkColorFilter.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkShader.h" #include "SkUnPreMultiply.h" #include "SkString.h" diff --git a/src/core/SkColorTable.cpp b/src/core/SkColorTable.cpp index 12ec43ec98..b8e7b059e8 100644 --- a/src/core/SkColorTable.cpp +++ b/src/core/SkColorTable.cpp @@ -8,7 +8,8 @@ #include "SkColorTable.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkStream.h" #include "SkTemplates.h" @@ -83,7 +84,7 @@ const uint16_t* SkColorTable::lock16BitCache() { /////////////////////////////////////////////////////////////////////////////// -SkColorTable::SkColorTable(SkFlattenableReadBuffer& buffer) { +SkColorTable::SkColorTable(SkReadBuffer& buffer) { f16BitCache = NULL; SkDEBUGCODE(fColorLockCount = 0;) SkDEBUGCODE(f16BitCacheLockCount = 0;) @@ -105,7 +106,7 @@ SkColorTable::SkColorTable(SkFlattenableReadBuffer& buffer) { #endif } -void SkColorTable::writeToBuffer(SkFlattenableWriteBuffer& buffer) const { +void SkColorTable::writeToBuffer(SkWriteBuffer& buffer) const { buffer.writeUInt(fAlphaType); buffer.writeColorArray(fColors, fCount); } diff --git a/src/core/SkComposeShader.cpp b/src/core/SkComposeShader.cpp index 0d2d68717f..b5ea63c24c 100644 --- a/src/core/SkComposeShader.cpp +++ b/src/core/SkComposeShader.cpp @@ -11,7 +11,8 @@ #include "SkColorFilter.h" #include "SkColorPriv.h" #include "SkColorShader.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkXfermode.h" #include "SkString.h" @@ -25,7 +26,7 @@ SkComposeShader::SkComposeShader(SkShader* sA, SkShader* sB, SkXfermode* mode) { SkSafeRef(mode); } -SkComposeShader::SkComposeShader(SkFlattenableReadBuffer& buffer) : +SkComposeShader::SkComposeShader(SkReadBuffer& buffer) : INHERITED(buffer) { fShaderA = buffer.readShader(); if (NULL == fShaderA) { @@ -61,7 +62,7 @@ private: }; #define SkAutoAlphaRestore(...) SK_REQUIRE_LOCAL_VAR(SkAutoAlphaRestore) -void SkComposeShader::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkComposeShader::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writeFlattenable(fShaderA); buffer.writeFlattenable(fShaderB); diff --git a/src/core/SkData.cpp b/src/core/SkData.cpp index 176e93c47b..2f07914067 100644 --- a/src/core/SkData.cpp +++ b/src/core/SkData.cpp @@ -6,7 +6,8 @@ */ #include "SkData.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkOSFile.h" #include "SkOnce.h" diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp index 013b73d23a..5f81073068 100644 --- a/src/core/SkDraw.cpp +++ b/src/core/SkDraw.cpp @@ -2382,7 +2382,7 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTriColorShader) protected: - SkTriColorShader(SkFlattenableReadBuffer& buffer) : SkShader(buffer) {} + SkTriColorShader(SkReadBuffer& buffer) : SkShader(buffer) {} private: SkMatrix fDstToUnit; diff --git a/src/core/SkFilterShader.cpp b/src/core/SkFilterShader.cpp index 1e590cb66f..feea75b48b 100644 --- a/src/core/SkFilterShader.cpp +++ b/src/core/SkFilterShader.cpp @@ -8,7 +8,8 @@ #include "SkFilterShader.h" #include "SkColorFilter.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkShader.h" #include "SkString.h" @@ -20,7 +21,7 @@ SkFilterShader::SkFilterShader(SkShader* shader, SkColorFilter* filter) { filter->ref(); } -SkFilterShader::SkFilterShader(SkFlattenableReadBuffer& buffer) +SkFilterShader::SkFilterShader(SkReadBuffer& buffer) : INHERITED(buffer) { fShader = buffer.readShader(); fFilter = buffer.readColorFilter(); @@ -31,7 +32,7 @@ SkFilterShader::~SkFilterShader() { fShader->unref(); } -void SkFilterShader::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkFilterShader::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writeFlattenable(fShader); buffer.writeFlattenable(fFilter); diff --git a/src/core/SkFilterShader.h b/src/core/SkFilterShader.h index be19640d0e..abb5165578 100644 --- a/src/core/SkFilterShader.h +++ b/src/core/SkFilterShader.h @@ -28,8 +28,8 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkFilterShader) protected: - SkFilterShader(SkFlattenableReadBuffer& ); - virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; + SkFilterShader(SkReadBuffer& ); + virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; private: SkShader* fShader; diff --git a/src/core/SkFlattenable.cpp b/src/core/SkFlattenable.cpp index 877fa0a85f..410fe0d974 100644 --- a/src/core/SkFlattenable.cpp +++ b/src/core/SkFlattenable.cpp @@ -10,7 +10,7 @@ /////////////////////////////////////////////////////////////////////////////// -void SkFlattenable::flatten(SkFlattenableWriteBuffer&) const +void SkFlattenable::flatten(SkWriteBuffer&) const { /* we don't write anything at the moment, but this allows our subclasses to not know that, since we want them to always call INHERITED::flatten() diff --git a/src/core/SkFlattenableBuffers.cpp b/src/core/SkFlattenableBuffers.cpp deleted file mode 100644 index fc38529ef7..0000000000 --- a/src/core/SkFlattenableBuffers.cpp +++ /dev/null @@ -1,115 +0,0 @@ - -/* - * Copyright 2012 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -#include "SkFlattenableBuffers.h" -#include "SkPaint.h" -#include "SkTypeface.h" - -#include "SkColorFilter.h" -#include "SkDrawLooper.h" -#include "SkImageFilter.h" -#include "SkMaskFilter.h" -#include "SkPathEffect.h" -#include "SkPixelRef.h" -#include "SkRasterizer.h" -#include "SkShader.h" -#include "SkUnitMapper.h" -#include "SkXfermode.h" - -SkFlattenableReadBuffer::SkFlattenableReadBuffer() { - // Set default values. These should be explicitly set by our client - // via setFlags() if the buffer came from serialization. - fFlags = 0; - // TODO: remove this flag, since we're always floats (now) - fFlags |= kScalarIsFloat_Flag; - if (8 == sizeof(void*)) { - fFlags |= kPtrIs64Bit_Flag; - } -} - -SkFlattenableReadBuffer::~SkFlattenableReadBuffer() { } - -void* SkFlattenableReadBuffer::readFunctionPtr() { - void* proc; - SkASSERT(sizeof(void*) == this->getArrayCount()); - this->readByteArray(&proc, sizeof(void*)); - return proc; -} - -void SkFlattenableReadBuffer::readPaint(SkPaint* paint) { - paint->unflatten(*this); -} - -template <typename T> T* SkFlattenableReadBuffer::readFlattenableT() { - return static_cast<T*>(this->readFlattenable(T::GetFlattenableType())); -} - -SkColorFilter* SkFlattenableReadBuffer::readColorFilter() { - return this->readFlattenableT<SkColorFilter>(); -} - -SkDrawLooper* SkFlattenableReadBuffer::readDrawLooper() { - return this->readFlattenableT<SkDrawLooper>(); -} - -SkImageFilter* SkFlattenableReadBuffer::readImageFilter() { - return this->readFlattenableT<SkImageFilter>(); -} - -SkMaskFilter* SkFlattenableReadBuffer::readMaskFilter() { - return this->readFlattenableT<SkMaskFilter>(); -} - -SkPathEffect* SkFlattenableReadBuffer::readPathEffect() { - return this->readFlattenableT<SkPathEffect>(); -} - -SkPixelRef* SkFlattenableReadBuffer::readPixelRef() { - return this->readFlattenableT<SkPixelRef>(); -} - -SkRasterizer* SkFlattenableReadBuffer::readRasterizer() { - return this->readFlattenableT<SkRasterizer>(); -} - -SkShader* SkFlattenableReadBuffer::readShader() { - return this->readFlattenableT<SkShader>(); -} - -SkUnitMapper* SkFlattenableReadBuffer::readUnitMapper() { - return this->readFlattenableT<SkUnitMapper>(); -} - -SkXfermode* SkFlattenableReadBuffer::readXfermode() { - return this->readFlattenableT<SkXfermode>(); -} - -bool SkFlattenableReadBuffer::validate(bool isValid) { - return true; -} - -/////////////////////////////////////////////////////////////////////////////// - -SkFlattenableWriteBuffer::SkFlattenableWriteBuffer() { - fFlags = (Flags)0; -} - -SkFlattenableWriteBuffer::~SkFlattenableWriteBuffer() { } - -void SkFlattenableWriteBuffer::writeFunctionPtr(void* ptr) { - void* ptrStorage[] = { ptr }; - this->writeByteArray(ptrStorage, sizeof(void*)); -} - -void SkFlattenableWriteBuffer::writePaint(const SkPaint& paint) { - paint.flatten(*this); -} - -void SkFlattenableWriteBuffer::flattenObject(const SkFlattenable* obj, - SkFlattenableWriteBuffer& buffer) { - obj->flatten(buffer); -} diff --git a/src/core/SkFlattenableSerialization.cpp b/src/core/SkFlattenableSerialization.cpp index 5c83101eaf..13fbe6edbf 100644 --- a/src/core/SkFlattenableSerialization.cpp +++ b/src/core/SkFlattenableSerialization.cpp @@ -9,11 +9,11 @@ #include "SkData.h" #include "SkValidatingReadBuffer.h" -#include "SkOrderedWriteBuffer.h" +#include "SkWriteBuffer.h" SkData* SkValidatingSerializeFlattenable(SkFlattenable* flattenable) { - SkOrderedWriteBuffer writer; - writer.setFlags(SkOrderedWriteBuffer::kValidation_Flag); + SkWriteBuffer writer; + writer.setFlags(SkWriteBuffer::kValidation_Flag); writer.writeFlattenable(flattenable); uint32_t size = writer.bytesWritten(); void* data = sk_malloc_throw(size); diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp index cb1d9fb571..43e96bbb5f 100644 --- a/src/core/SkImageFilter.cpp +++ b/src/core/SkImageFilter.cpp @@ -8,7 +8,8 @@ #include "SkImageFilter.h" #include "SkBitmap.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkRect.h" #include "SkValidationUtils.h" #if SK_SUPPORT_GPU @@ -51,7 +52,7 @@ SkImageFilter::~SkImageFilter() { delete[] fInputs; } -SkImageFilter::SkImageFilter(int inputCount, SkFlattenableReadBuffer& buffer) { +SkImageFilter::SkImageFilter(int inputCount, SkReadBuffer& buffer) { fInputCount = buffer.readInt(); if (buffer.validate((fInputCount >= 0) && ((inputCount < 0) || (fInputCount == inputCount)))) { fInputs = new SkImageFilter*[fInputCount]; @@ -78,7 +79,7 @@ SkImageFilter::SkImageFilter(int inputCount, SkFlattenableReadBuffer& buffer) { } } -void SkImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkImageFilter::flatten(SkWriteBuffer& buffer) const { buffer.writeInt(fInputCount); for (int i = 0; i < fInputCount; i++) { SkImageFilter* input = getInput(i); diff --git a/src/core/SkImageInfo.cpp b/src/core/SkImageInfo.cpp index 967b4f6f08..27c457391f 100644 --- a/src/core/SkImageInfo.cpp +++ b/src/core/SkImageInfo.cpp @@ -6,7 +6,8 @@ */ #include "SkImageInfo.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" static bool alpha_type_is_valid(SkAlphaType alphaType) { return (alphaType >= 0) && (alphaType <= kLastEnum_SkAlphaType); @@ -16,7 +17,7 @@ static bool color_type_is_valid(SkColorType colorType) { return (colorType >= 0) && (colorType <= kLastEnum_SkColorType); } -void SkImageInfo::unflatten(SkFlattenableReadBuffer& buffer) { +void SkImageInfo::unflatten(SkReadBuffer& buffer) { fWidth = buffer.read32(); fHeight = buffer.read32(); @@ -28,7 +29,7 @@ void SkImageInfo::unflatten(SkFlattenableReadBuffer& buffer) { color_type_is_valid(fColorType)); } -void SkImageInfo::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkImageInfo::flatten(SkWriteBuffer& buffer) const { buffer.write32(fWidth); buffer.write32(fHeight); diff --git a/src/core/SkMallocPixelRef.cpp b/src/core/SkMallocPixelRef.cpp index 9adcd34ba6..aa7c4f745c 100644 --- a/src/core/SkMallocPixelRef.cpp +++ b/src/core/SkMallocPixelRef.cpp @@ -7,7 +7,8 @@ #include "SkMallocPixelRef.h" #include "SkBitmap.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" // assumes ptr was allocated via sk_malloc static void sk_free_releaseproc(void* ptr, void*) { @@ -201,7 +202,7 @@ size_t SkMallocPixelRef::getAllocatedSizeInBytes() const { return this->info().getSafeSize(fRB); } -void SkMallocPixelRef::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkMallocPixelRef::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.write32(SkToU32(fRB)); @@ -216,7 +217,7 @@ void SkMallocPixelRef::flatten(SkFlattenableWriteBuffer& buffer) const { } } -SkMallocPixelRef::SkMallocPixelRef(SkFlattenableReadBuffer& buffer) +SkMallocPixelRef::SkMallocPixelRef(SkReadBuffer& buffer) : INHERITED(buffer, NULL) , fReleaseProc(sk_free_releaseproc) , fReleaseProcContext(NULL) diff --git a/src/core/SkOrderedReadBuffer.h b/src/core/SkOrderedReadBuffer.h deleted file mode 100644 index 2c4f480e73..0000000000 --- a/src/core/SkOrderedReadBuffer.h +++ /dev/null @@ -1,140 +0,0 @@ - -/* - * Copyright 2011 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef SkOrderedReadBuffer_DEFINED -#define SkOrderedReadBuffer_DEFINED - -#include "SkRefCnt.h" -#include "SkBitmapHeap.h" -#include "SkFlattenableBuffers.h" -#include "SkPath.h" -#include "SkPicture.h" -#include "SkReader32.h" - -class SkBitmap; - -#if defined(SK_DEBUG) && defined(SK_BUILD_FOR_MAC) - #define DEBUG_NON_DETERMINISTIC_ASSERT -#endif - -class SkOrderedReadBuffer : public SkFlattenableReadBuffer { -public: - SkOrderedReadBuffer(); - SkOrderedReadBuffer(const void* data, size_t size); - SkOrderedReadBuffer(SkStream* stream); - virtual ~SkOrderedReadBuffer(); - - virtual SkOrderedReadBuffer* getOrderedBinaryBuffer() SK_OVERRIDE { return this; } - - SkReader32* getReader32() { return &fReader; } - - uint32_t size() { return fReader.size(); } - uint32_t offset() { return fReader.offset(); } - bool eof() { return fReader.eof(); } - const void* skip(size_t size) { return fReader.skip(size); } - - // primitives - virtual bool readBool() SK_OVERRIDE; - virtual SkColor readColor() SK_OVERRIDE; - virtual SkFixed readFixed() SK_OVERRIDE; - virtual int32_t readInt() SK_OVERRIDE; - virtual SkScalar readScalar() SK_OVERRIDE; - virtual uint32_t readUInt() SK_OVERRIDE; - virtual int32_t read32() SK_OVERRIDE; - - // strings -- the caller is responsible for freeing the string contents - virtual void readString(SkString* string) SK_OVERRIDE; - virtual void* readEncodedString(size_t* length, SkPaint::TextEncoding encoding) SK_OVERRIDE; - - // common data structures - virtual SkFlattenable* readFlattenable(SkFlattenable::Type) SK_OVERRIDE; - virtual void readPoint(SkPoint* point) SK_OVERRIDE; - virtual void readMatrix(SkMatrix* matrix) SK_OVERRIDE; - virtual void readIRect(SkIRect* rect) SK_OVERRIDE; - virtual void readRect(SkRect* rect) SK_OVERRIDE; - virtual void readRegion(SkRegion* region) SK_OVERRIDE; - virtual void readPath(SkPath* path) SK_OVERRIDE; - - // binary data and arrays - virtual bool readByteArray(void* value, size_t size) SK_OVERRIDE; - virtual bool readColorArray(SkColor* colors, size_t size) SK_OVERRIDE; - virtual bool readIntArray(int32_t* values, size_t size) SK_OVERRIDE; - virtual bool readPointArray(SkPoint* points, size_t size) SK_OVERRIDE; - virtual bool readScalarArray(SkScalar* values, size_t size) SK_OVERRIDE; - - // helpers to get info about arrays and binary data - virtual uint32_t getArrayCount() SK_OVERRIDE; - - virtual void readBitmap(SkBitmap* bitmap) SK_OVERRIDE; - virtual SkTypeface* readTypeface() SK_OVERRIDE; - - void setBitmapStorage(SkBitmapHeapReader* bitmapStorage) { - SkRefCnt_SafeAssign(fBitmapStorage, bitmapStorage); - } - - void setTypefaceArray(SkTypeface* array[], int count) { - fTFArray = array; - fTFCount = count; - } - - /** - * Call this with a pre-loaded array of Factories, in the same order as - * were created/written by the writer. SkPicture uses this. - */ - void setFactoryPlayback(SkFlattenable::Factory array[], int count) { - fFactoryTDArray = NULL; - fFactoryArray = array; - fFactoryCount = count; - } - - /** - * Call this with an initially empty array, so the reader can cache each - * factory it sees by name. Used by the pipe code in conjunction with - * SkOrderedWriteBuffer::setNamedFactoryRecorder. - */ - void setFactoryArray(SkTDArray<SkFlattenable::Factory>* array) { - fFactoryTDArray = array; - fFactoryArray = NULL; - fFactoryCount = 0; - } - - /** - * Provide a function to decode an SkBitmap from encoded data. Only used if the writer - * encoded the SkBitmap. If the proper decoder cannot be used, a red bitmap with the - * appropriate size will be used. - */ - void setBitmapDecoder(SkPicture::InstallPixelRefProc bitmapDecoder) { - fBitmapDecoder = bitmapDecoder; - } - -private: - bool readArray(void* value, size_t size, size_t elementSize); - - SkReader32 fReader; - void* fMemoryPtr; - - SkBitmapHeapReader* fBitmapStorage; - SkTypeface** fTFArray; - int fTFCount; - - SkTDArray<SkFlattenable::Factory>* fFactoryTDArray; - SkFlattenable::Factory* fFactoryArray; - int fFactoryCount; - - SkPicture::InstallPixelRefProc fBitmapDecoder; - -#ifdef DEBUG_NON_DETERMINISTIC_ASSERT - // Debugging counter to keep track of how many bitmaps we - // have decoded. - int fDecodedBitmapIndex; -#endif // DEBUG_NON_DETERMINISTIC_ASSERT - - typedef SkFlattenableReadBuffer INHERITED; -}; - -#endif // SkOrderedReadBuffer_DEFINED diff --git a/src/core/SkOrderedWriteBuffer.h b/src/core/SkOrderedWriteBuffer.h deleted file mode 100644 index 1f10152293..0000000000 --- a/src/core/SkOrderedWriteBuffer.h +++ /dev/null @@ -1,115 +0,0 @@ - -/* - * Copyright 2011 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef SkOrderedWriteBuffer_DEFINED -#define SkOrderedWriteBuffer_DEFINED - -#include "SkFlattenableBuffers.h" - -#include "SkRefCnt.h" -#include "SkBitmapHeap.h" -#include "SkPath.h" -#include "SkPicture.h" -#include "SkWriter32.h" - -class SkBitmap; -class SkFlattenable; -class SkFactorySet; -class SkNamedFactorySet; -class SkRefCntSet; - -class SkOrderedWriteBuffer : public SkFlattenableWriteBuffer { -public: - SkOrderedWriteBuffer(); - SkOrderedWriteBuffer(void* initialStorage, size_t storageSize); - virtual ~SkOrderedWriteBuffer(); - - virtual bool isOrderedBinaryBuffer() SK_OVERRIDE { return true; } - virtual SkOrderedWriteBuffer* getOrderedBinaryBuffer() SK_OVERRIDE { return this; } - - SkWriter32* getWriter32() { return &fWriter; } - void reset(void* storage = NULL, size_t storageSize = 0) { - fWriter.reset(storage, storageSize); - } - - void writeToMemory(void* dst) { fWriter.flatten(dst); } - uint32_t* reserve(size_t size) { return fWriter.reserve(size); } - - size_t bytesWritten() const { return fWriter.bytesWritten(); } - // Deprecated. Please call bytesWritten instead. TODO(mtklein): clean up - size_t size() const { return this->bytesWritten(); } - - virtual void writeByteArray(const void* data, size_t size) SK_OVERRIDE; - virtual void writeBool(bool value) SK_OVERRIDE; - virtual void writeFixed(SkFixed value) SK_OVERRIDE; - virtual void writeScalar(SkScalar value) SK_OVERRIDE; - virtual void writeScalarArray(const SkScalar* value, uint32_t count) SK_OVERRIDE; - virtual void writeInt(int32_t value) SK_OVERRIDE; - virtual void writeIntArray(const int32_t* value, uint32_t count) SK_OVERRIDE; - virtual void writeUInt(uint32_t value) SK_OVERRIDE; - virtual void write32(int32_t value) SK_OVERRIDE; - virtual void writeString(const char* value) SK_OVERRIDE; - virtual void writeEncodedString(const void* value, size_t byteLength, - SkPaint::TextEncoding encoding) SK_OVERRIDE; - - virtual void writeFlattenable(const SkFlattenable* flattenable) SK_OVERRIDE; - virtual void writeColor(const SkColor& color) SK_OVERRIDE; - virtual void writeColorArray(const SkColor* color, uint32_t count) SK_OVERRIDE; - virtual void writePoint(const SkPoint& point) SK_OVERRIDE; - virtual void writePointArray(const SkPoint* point, uint32_t count) SK_OVERRIDE; - virtual void writeMatrix(const SkMatrix& matrix) SK_OVERRIDE; - virtual void writeIRect(const SkIRect& rect)SK_OVERRIDE; - virtual void writeRect(const SkRect& rect) SK_OVERRIDE; - virtual void writeRegion(const SkRegion& region) SK_OVERRIDE; - virtual void writePath(const SkPath& path) SK_OVERRIDE; - virtual size_t writeStream(SkStream* stream, size_t length) SK_OVERRIDE; - - virtual void writeBitmap(const SkBitmap& bitmap) SK_OVERRIDE; - virtual void writeTypeface(SkTypeface* typeface) SK_OVERRIDE; - - virtual bool writeToStream(SkWStream*) SK_OVERRIDE; - - SkFactorySet* setFactoryRecorder(SkFactorySet*); - SkNamedFactorySet* setNamedFactoryRecorder(SkNamedFactorySet*); - - SkRefCntSet* getTypefaceRecorder() const { return fTFSet; } - SkRefCntSet* setTypefaceRecorder(SkRefCntSet*); - - /** - * Set an SkBitmapHeap to store bitmaps rather than flattening. - * - * Incompatible with an EncodeBitmap function. If an EncodeBitmap function is set, setting an - * SkBitmapHeap will set the function to NULL in release mode and crash in debug. - */ - void setBitmapHeap(SkBitmapHeap*); - - /** - * Provide a function to encode an SkBitmap to an SkData. writeBitmap will attempt to use - * bitmapEncoder to store the SkBitmap. If the reader does not provide a function to decode, it - * will not be able to restore SkBitmaps, but will still be able to read the rest of the stream. - * bitmapEncoder will never be called with a NULL pixelRefOffset. - * - * Incompatible with the SkBitmapHeap. If an encoder is set fBitmapHeap will be set to NULL in - * release and crash in debug. - */ - void setBitmapEncoder(SkPicture::EncodeBitmap bitmapEncoder); - -private: - SkFactorySet* fFactorySet; - SkNamedFactorySet* fNamedFactorySet; - SkWriter32 fWriter; - - SkBitmapHeap* fBitmapHeap; - SkRefCntSet* fTFSet; - - SkPicture::EncodeBitmap fBitmapEncoder; - - typedef SkFlattenableWriteBuffer INHERITED; -}; - -#endif // SkOrderedWriteBuffer_DEFINED diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp index cc6d7ba1b3..c3f217cefc 100644 --- a/src/core/SkPaint.cpp +++ b/src/core/SkPaint.cpp @@ -18,8 +18,8 @@ #include "SkImageFilter.h" #include "SkMaskFilter.h" #include "SkMaskGamma.h" -#include "SkOrderedReadBuffer.h" -#include "SkOrderedWriteBuffer.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkPaintDefaults.h" #include "SkPaintOptionsAndroid.h" #include "SkPathEffect.h" @@ -1474,8 +1474,8 @@ void SkPaint::getPosTextPath(const void* textData, size_t length, } static void add_flattenable(SkDescriptor* desc, uint32_t tag, - SkOrderedWriteBuffer* buffer) { - buffer->writeToMemory(desc->addEntry(tag, buffer->size(), NULL)); + SkWriteBuffer* buffer) { + buffer->writeToMemory(desc->addEntry(tag, buffer->bytesWritten(), NULL)); } // SkFontHost can override this choice in FilterRec() @@ -1815,18 +1815,18 @@ void SkPaint::descriptorProc(const SkDeviceProperties* deviceProperties, SkMaskFilter* mf = this->getMaskFilter(); SkRasterizer* ra = this->getRasterizer(); - SkOrderedWriteBuffer peBuffer, mfBuffer, raBuffer; + SkWriteBuffer peBuffer, mfBuffer, raBuffer; if (pe) { peBuffer.writeFlattenable(pe); - descSize += peBuffer.size(); + descSize += peBuffer.bytesWritten(); entryCount += 1; rec.fMaskFormat = SkMask::kA8_Format; // force antialiasing when we do the scan conversion // seems like we could support kLCD as well at this point... } if (mf) { mfBuffer.writeFlattenable(mf); - descSize += mfBuffer.size(); + descSize += mfBuffer.bytesWritten(); entryCount += 1; rec.fMaskFormat = SkMask::kA8_Format; // force antialiasing with maskfilters /* Pre-blend is not currently applied to filtered text. @@ -1837,15 +1837,15 @@ void SkPaint::descriptorProc(const SkDeviceProperties* deviceProperties, } if (ra) { raBuffer.writeFlattenable(ra); - descSize += raBuffer.size(); + descSize += raBuffer.bytesWritten(); entryCount += 1; rec.fMaskFormat = SkMask::kA8_Format; // force antialiasing when we do the scan conversion } #ifdef SK_BUILD_FOR_ANDROID - SkOrderedWriteBuffer androidBuffer; + SkWriteBuffer androidBuffer; fPaintOptionsAndroid.flatten(androidBuffer); - descSize += androidBuffer.size(); + descSize += androidBuffer.bytesWritten(); entryCount += 1; #endif @@ -1999,7 +1999,7 @@ static const uint32_t kPODPaintSize = 5 * sizeof(SkScalar) + /* To save space/time, we analyze the paint, and write a truncated version of it if there are not tricky elements like shaders, etc. */ -void SkPaint::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkPaint::flatten(SkWriteBuffer& buffer) const { uint8_t flatFlags = 0; if (this->getTypeface()) { flatFlags |= kHasTypeface_FlatFlag; @@ -2021,42 +2021,24 @@ void SkPaint::flatten(SkFlattenableWriteBuffer& buffer) const { } #endif - if (buffer.isOrderedBinaryBuffer()) { - SkASSERT(SkAlign4(kPODPaintSize) == kPODPaintSize); - uint32_t* ptr = buffer.getOrderedBinaryBuffer()->reserve(kPODPaintSize); - - ptr = write_scalar(ptr, this->getTextSize()); - ptr = write_scalar(ptr, this->getTextScaleX()); - ptr = write_scalar(ptr, this->getTextSkewX()); - ptr = write_scalar(ptr, this->getStrokeWidth()); - ptr = write_scalar(ptr, this->getStrokeMiter()); - *ptr++ = this->getColor(); - // previously flags:16, textAlign:8, flatFlags:8 - // now flags:16, hinting:4, textAlign:4, flatFlags:8 - *ptr++ = (this->getFlags() << 16) | - // hinting added later. 0 in this nibble means use the default. - ((this->getHinting()+1) << 12) | - (this->getTextAlign() << 8) | - flatFlags; - *ptr++ = pack_4(this->getStrokeCap(), this->getStrokeJoin(), - this->getStyle(), this->getTextEncoding()); - } else { - buffer.writeScalar(fTextSize); - buffer.writeScalar(fTextScaleX); - buffer.writeScalar(fTextSkewX); - buffer.writeScalar(fWidth); - buffer.writeScalar(fMiterLimit); - buffer.writeColor(fColor); - buffer.writeUInt(fFlags); - buffer.writeUInt(fHinting); - buffer.writeUInt(fTextAlign); - buffer.writeUInt(flatFlags); - - buffer.writeUInt(fCapType); - buffer.writeUInt(fJoinType); - buffer.writeUInt(fStyle); - buffer.writeUInt(fTextEncoding); - } + SkASSERT(SkAlign4(kPODPaintSize) == kPODPaintSize); + uint32_t* ptr = buffer.reserve(kPODPaintSize); + + ptr = write_scalar(ptr, this->getTextSize()); + ptr = write_scalar(ptr, this->getTextScaleX()); + ptr = write_scalar(ptr, this->getTextSkewX()); + ptr = write_scalar(ptr, this->getStrokeWidth()); + ptr = write_scalar(ptr, this->getStrokeMiter()); + *ptr++ = this->getColor(); + // previously flags:16, textAlign:8, flatFlags:8 + // now flags:16, hinting:4, textAlign:4, flatFlags:8 + *ptr++ = (this->getFlags() << 16) | + // hinting added later. 0 in this nibble means use the default. + ((this->getHinting()+1) << 12) | + (this->getTextAlign() << 8) | + flatFlags; + *ptr++ = pack_4(this->getStrokeCap(), this->getStrokeJoin(), + this->getStyle(), this->getTextEncoding()); // now we're done with ptr and the (pre)reserved space. If we need to write // additional fields, use the buffer directly @@ -2087,58 +2069,38 @@ void SkPaint::flatten(SkFlattenableWriteBuffer& buffer) const { #endif } -void SkPaint::unflatten(SkFlattenableReadBuffer& buffer) { +void SkPaint::unflatten(SkReadBuffer& buffer) { uint8_t flatFlags = 0; - if (buffer.isOrderedBinaryBuffer()) { - SkASSERT(SkAlign4(kPODPaintSize) == kPODPaintSize); - const void* podData = buffer.getOrderedBinaryBuffer()->skip(kPODPaintSize); - const uint32_t* pod = reinterpret_cast<const uint32_t*>(podData); - - // the order we read must match the order we wrote in flatten() - this->setTextSize(read_scalar(pod)); - this->setTextScaleX(read_scalar(pod)); - this->setTextSkewX(read_scalar(pod)); - this->setStrokeWidth(read_scalar(pod)); - this->setStrokeMiter(read_scalar(pod)); - this->setColor(*pod++); - - // previously flags:16, textAlign:8, flatFlags:8 - // now flags:16, hinting:4, textAlign:4, flatFlags:8 - uint32_t tmp = *pod++; - this->setFlags(tmp >> 16); - - // hinting added later. 0 in this nibble means use the default. - uint32_t hinting = (tmp >> 12) & 0xF; - this->setHinting(0 == hinting ? kNormal_Hinting : static_cast<Hinting>(hinting-1)); - - this->setTextAlign(static_cast<Align>((tmp >> 8) & 0xF)); - - flatFlags = tmp & 0xFF; - - tmp = *pod++; - this->setStrokeCap(static_cast<Cap>((tmp >> 24) & 0xFF)); - this->setStrokeJoin(static_cast<Join>((tmp >> 16) & 0xFF)); - this->setStyle(static_cast<Style>((tmp >> 8) & 0xFF)); - this->setTextEncoding(static_cast<TextEncoding>((tmp >> 0) & 0xFF)); - } else { - this->setTextSize(buffer.readScalar()); - this->setTextScaleX(buffer.readScalar()); - this->setTextSkewX(buffer.readScalar()); - // Skip the hinting scalar factor, which is not supported. - buffer.readScalar(); - this->setStrokeWidth(buffer.readScalar()); - this->setStrokeMiter(buffer.readScalar()); - this->setColor(buffer.readColor()); - this->setFlags(buffer.readUInt()); - this->setHinting(static_cast<SkPaint::Hinting>(buffer.readUInt())); - this->setTextAlign(static_cast<SkPaint::Align>(buffer.readUInt())); - flatFlags = buffer.readUInt(); - - this->setStrokeCap(static_cast<SkPaint::Cap>(buffer.readUInt())); - this->setStrokeJoin(static_cast<SkPaint::Join>(buffer.readUInt())); - this->setStyle(static_cast<SkPaint::Style>(buffer.readUInt())); - this->setTextEncoding(static_cast<SkPaint::TextEncoding>(buffer.readUInt())); - } + SkASSERT(SkAlign4(kPODPaintSize) == kPODPaintSize); + const void* podData = buffer.skip(kPODPaintSize); + const uint32_t* pod = reinterpret_cast<const uint32_t*>(podData); + + // the order we read must match the order we wrote in flatten() + this->setTextSize(read_scalar(pod)); + this->setTextScaleX(read_scalar(pod)); + this->setTextSkewX(read_scalar(pod)); + this->setStrokeWidth(read_scalar(pod)); + this->setStrokeMiter(read_scalar(pod)); + this->setColor(*pod++); + + // previously flags:16, textAlign:8, flatFlags:8 + // now flags:16, hinting:4, textAlign:4, flatFlags:8 + uint32_t tmp = *pod++; + this->setFlags(tmp >> 16); + + // hinting added later. 0 in this nibble means use the default. + uint32_t hinting = (tmp >> 12) & 0xF; + this->setHinting(0 == hinting ? kNormal_Hinting : static_cast<Hinting>(hinting-1)); + + this->setTextAlign(static_cast<Align>((tmp >> 8) & 0xF)); + + flatFlags = tmp & 0xFF; + + tmp = *pod++; + this->setStrokeCap(static_cast<Cap>((tmp >> 24) & 0xFF)); + this->setStrokeJoin(static_cast<Join>((tmp >> 16) & 0xFF)); + this->setStyle(static_cast<Style>((tmp >> 8) & 0xFF)); + this->setTextEncoding(static_cast<TextEncoding>((tmp >> 0) & 0xFF)); if (flatFlags & kHasTypeface_FlatFlag) { this->setTypeface(buffer.readTypeface()); diff --git a/src/core/SkPaintOptionsAndroid.cpp b/src/core/SkPaintOptionsAndroid.cpp index f8a65e9d90..56f1bd1654 100644 --- a/src/core/SkPaintOptionsAndroid.cpp +++ b/src/core/SkPaintOptionsAndroid.cpp @@ -7,7 +7,8 @@ */ #include "SkPaintOptionsAndroid.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkTDict.h" #include "SkThread.h" #include <cstring> @@ -25,13 +26,13 @@ SkLanguage SkLanguage::getParent() const { return SkLanguage(tag, parentTagLen); } -void SkPaintOptionsAndroid::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkPaintOptionsAndroid::flatten(SkWriteBuffer& buffer) const { buffer.writeUInt(fFontVariant); buffer.writeString(fLanguage.getTag().c_str()); buffer.writeBool(fUseFontFallbacks); } -void SkPaintOptionsAndroid::unflatten(SkFlattenableReadBuffer& buffer) { +void SkPaintOptionsAndroid::unflatten(SkReadBuffer& buffer) { fFontVariant = (FontVariant)buffer.readUInt(); SkString tag; buffer.readString(&tag); diff --git a/src/core/SkPathEffect.cpp b/src/core/SkPathEffect.cpp index 59ba3ec31f..e181320356 100644 --- a/src/core/SkPathEffect.cpp +++ b/src/core/SkPathEffect.cpp @@ -8,7 +8,8 @@ #include "SkPathEffect.h" #include "SkPath.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" /////////////////////////////////////////////////////////////////////////////// @@ -39,13 +40,13 @@ SkPairPathEffect::~SkPairPathEffect() { /* Format: [oe0-factory][pe1-factory][pe0-size][pe0-data][pe1-data] */ -void SkPairPathEffect::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkPairPathEffect::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writeFlattenable(fPE0); buffer.writeFlattenable(fPE1); } -SkPairPathEffect::SkPairPathEffect(SkFlattenableReadBuffer& buffer) { +SkPairPathEffect::SkPairPathEffect(SkReadBuffer& buffer) { fPE0 = buffer.readPathEffect(); fPE1 = buffer.readPathEffect(); // either of these may fail, so we have to check for nulls later on diff --git a/src/core/SkPathHeap.cpp b/src/core/SkPathHeap.cpp index c6e2129e9e..a8271e1fa2 100644 --- a/src/core/SkPathHeap.cpp +++ b/src/core/SkPathHeap.cpp @@ -8,7 +8,8 @@ #include "SkPathHeap.h" #include "SkPath.h" #include "SkStream.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include <new> #define kPathCount 64 @@ -16,7 +17,7 @@ SkPathHeap::SkPathHeap() : fHeap(kPathCount * sizeof(SkPath)) { } -SkPathHeap::SkPathHeap(SkFlattenableReadBuffer& buffer) +SkPathHeap::SkPathHeap(SkReadBuffer& buffer) : fHeap(kPathCount * sizeof(SkPath)) { const int count = buffer.readInt(); @@ -48,7 +49,7 @@ int SkPathHeap::append(const SkPath& path) { return fPaths.count(); } -void SkPathHeap::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkPathHeap::flatten(SkWriteBuffer& buffer) const { int count = fPaths.count(); buffer.writeInt(count); diff --git a/src/core/SkPathHeap.h b/src/core/SkPathHeap.h index 095e84a202..e3b0f7a84f 100644 --- a/src/core/SkPathHeap.h +++ b/src/core/SkPathHeap.h @@ -13,15 +13,15 @@ #include "SkTDArray.h" class SkPath; -class SkFlattenableReadBuffer; -class SkFlattenableWriteBuffer; +class SkReadBuffer; +class SkWriteBuffer; class SkPathHeap : public SkRefCnt { public: SK_DECLARE_INST_COUNT(SkPathHeap) SkPathHeap(); - SkPathHeap(SkFlattenableReadBuffer&); + SkPathHeap(SkReadBuffer&); virtual ~SkPathHeap(); /** Copy the path into the heap, and return the new total number of paths. @@ -36,7 +36,7 @@ public: return *fPaths[index]; } - void flatten(SkFlattenableWriteBuffer&) const; + void flatten(SkWriteBuffer&) const; private: // we store the paths in the heap (placement new) diff --git a/src/core/SkPictureFlat.h b/src/core/SkPictureFlat.h index d92e4c45df..431fa96037 100644 --- a/src/core/SkPictureFlat.h +++ b/src/core/SkPictureFlat.h @@ -13,8 +13,8 @@ #include "SkBitmapHeap.h" #include "SkChecksum.h" #include "SkChunkAlloc.h" -#include "SkOrderedReadBuffer.h" -#include "SkOrderedWriteBuffer.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkPaint.h" #include "SkPicture.h" #include "SkPtrRecorder.h" @@ -107,7 +107,7 @@ public: void setCount(int count); SkRefCnt* set(int index, SkRefCnt*); - void setupBuffer(SkOrderedReadBuffer& buffer) const { + void setupBuffer(SkReadBuffer& buffer) const { buffer.setTypefaceArray((SkTypeface**)fArray, fCount); } @@ -128,7 +128,7 @@ public: SkFlattenable::Factory* base() const { return fArray; } - void setupBuffer(SkOrderedReadBuffer& buffer) const { + void setupBuffer(SkReadBuffer& buffer) const { buffer.setFactoryPlayback(fArray, fCount); } @@ -264,7 +264,7 @@ public: static SkFlatData* Create(SkFlatController* controller, const T& obj, int index) { // A buffer of 256 bytes should fit most paints, regions, and matrices. uint32_t storage[64]; - SkOrderedWriteBuffer buffer(storage, sizeof(storage)); + SkWriteBuffer buffer(storage, sizeof(storage)); buffer.setBitmapHeap(controller->getBitmapHeap()); buffer.setTypefaceRecorder(controller->getTypefaceSet()); @@ -272,7 +272,7 @@ public: buffer.setFlags(controller->getWriteBufferFlags()); Traits::flatten(buffer, obj); - size_t size = buffer.size(); + size_t size = buffer.bytesWritten(); SkASSERT(SkIsAlign4(size)); // Allocate enough memory to hold SkFlatData struct and the flat data itself. @@ -291,7 +291,7 @@ public: void unflatten(T* result, SkBitmapHeap* bitmapHeap = NULL, SkTypefacePlayback* facePlayback = NULL) const { - SkOrderedReadBuffer buffer(this->data(), fFlatSize); + SkReadBuffer buffer(this->data(), fFlatSize); if (bitmapHeap) { buffer.setBitmapStorage(bitmapHeap); @@ -556,7 +556,7 @@ private: // All SkFlatData* stored in fIndexedData and fHash are owned by the controller. SkAutoTUnref<SkFlatController> fController; - SkOrderedWriteBuffer fScratch; + SkWriteBuffer fScratch; bool fReady; // For index -> SkFlatData. 0-based, while all indices in the API are 1-based. Careful! @@ -568,10 +568,10 @@ private: }; struct SkPaintTraits { - static void flatten(SkOrderedWriteBuffer& buffer, const SkPaint& paint) { + static void flatten(SkWriteBuffer& buffer, const SkPaint& paint) { paint.flatten(buffer); } - static void unflatten(SkOrderedReadBuffer& buffer, SkPaint* paint) { + static void unflatten(SkReadBuffer& buffer, SkPaint* paint) { paint->unflatten(buffer); } }; diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp index 38f7deb111..02d8828977 100644 --- a/src/core/SkPicturePlayback.cpp +++ b/src/core/SkPicturePlayback.cpp @@ -8,8 +8,8 @@ #include "SkPicturePlayback.h" #include "SkPictureRecord.h" #include "SkTypeface.h" -#include "SkOrderedReadBuffer.h" -#include "SkOrderedWriteBuffer.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include <new> #include "SkBBoxHierarchy.h" #include "SkPictureStateTree.h" @@ -322,7 +322,7 @@ bool SkPicturePlayback::containsBitmaps() const { #include "SkStream.h" -static void writeTagSize(SkOrderedWriteBuffer& buffer, uint32_t tag, +static void writeTagSize(SkWriteBuffer& buffer, uint32_t tag, uint32_t size) { buffer.writeUInt(tag); buffer.writeUInt(size); @@ -370,7 +370,7 @@ static void writeTypefaces(SkWStream* stream, const SkRefCntSet& rec) { } } -void SkPicturePlayback::flattenToBuffer(SkOrderedWriteBuffer& buffer) const { +void SkPicturePlayback::flattenToBuffer(SkWriteBuffer& buffer) const { int i, n; if ((n = SafeCount(fBitmaps)) > 0) { @@ -411,8 +411,8 @@ void SkPicturePlayback::serialize(SkWStream* stream, SkRefCntSet typefaceSet; SkFactorySet factSet; - SkOrderedWriteBuffer buffer; - buffer.setFlags(SkFlattenableWriteBuffer::kCrossProcess_Flag); + SkWriteBuffer buffer; + buffer.setFlags(SkWriteBuffer::kCrossProcess_Flag); buffer.setTypefaceRecorder(&typefaceSet); buffer.setFactoryRecorder(&factSet); buffer.setBitmapEncoder(encoder); @@ -425,7 +425,7 @@ void SkPicturePlayback::serialize(SkWStream* stream, writeFactories(stream, factSet); writeTypefaces(stream, typefaceSet); - writeTagSize(stream, PICT_BUFFER_SIZE_TAG, buffer.size()); + writeTagSize(stream, PICT_BUFFER_SIZE_TAG, buffer.bytesWritten()); buffer.writeToStream(stream); } @@ -435,7 +435,7 @@ void SkPicturePlayback::serialize(SkWStream* stream, /////////////////////////////////////////////////////////////////////////////// /** - * Return the corresponding SkFlattenableReadBuffer flags, given a set of + * Return the corresponding SkReadBuffer flags, given a set of * SkPictInfo flags. */ static uint32_t pictInfoFlagsToReadBufferFlags(uint32_t pictInfoFlags) { @@ -443,9 +443,9 @@ static uint32_t pictInfoFlagsToReadBufferFlags(uint32_t pictInfoFlags) { uint32_t fSrc; uint32_t fDst; } gSD[] = { - { SkPictInfo::kCrossProcess_Flag, SkFlattenableReadBuffer::kCrossProcess_Flag }, - { SkPictInfo::kScalarIsFloat_Flag, SkFlattenableReadBuffer::kScalarIsFloat_Flag }, - { SkPictInfo::kPtrIs64Bit_Flag, SkFlattenableReadBuffer::kPtrIs64Bit_Flag }, + { SkPictInfo::kCrossProcess_Flag, SkReadBuffer::kCrossProcess_Flag }, + { SkPictInfo::kScalarIsFloat_Flag, SkReadBuffer::kScalarIsFloat_Flag }, + { SkPictInfo::kPtrIs64Bit_Flag, SkReadBuffer::kPtrIs64Bit_Flag }, }; uint32_t rbMask = 0; @@ -534,7 +534,7 @@ bool SkPicturePlayback::parseStreamTag(SkStream* stream, const SkPictInfo& info, return false; } - SkOrderedReadBuffer buffer(storage.get(), size); + SkReadBuffer buffer(storage.get(), size); buffer.setFlags(pictInfoFlagsToReadBufferFlags(info.fFlags)); fFactoryPlayback->setupBuffer(buffer); @@ -554,7 +554,7 @@ bool SkPicturePlayback::parseStreamTag(SkStream* stream, const SkPictInfo& info, return true; // success } -bool SkPicturePlayback::parseBufferTag(SkOrderedReadBuffer& buffer, +bool SkPicturePlayback::parseBufferTag(SkReadBuffer& buffer, uint32_t tag, size_t size) { switch (tag) { case PICT_BITMAP_BUFFER_TAG: { diff --git a/src/core/SkPicturePlayback.h b/src/core/SkPicturePlayback.h index 1cff0f9e0e..efa67225b5 100644 --- a/src/core/SkPicturePlayback.h +++ b/src/core/SkPicturePlayback.h @@ -14,7 +14,7 @@ #include "SkBitmap.h" #include "SkData.h" #include "SkMatrix.h" -#include "SkOrderedReadBuffer.h" +#include "SkReadBuffer.h" #include "SkPaint.h" #include "SkPath.h" #include "SkPathHeap.h" @@ -192,8 +192,8 @@ public: private: // these help us with reading/writing bool parseStreamTag(SkStream*, const SkPictInfo&, uint32_t tag, size_t size, SkPicture::InstallPixelRefProc); - bool parseBufferTag(SkOrderedReadBuffer&, uint32_t tag, size_t size); - void flattenToBuffer(SkOrderedWriteBuffer&) const; + bool parseBufferTag(SkReadBuffer&, uint32_t tag, size_t size); + void flattenToBuffer(SkWriteBuffer&) const; private: // Only used by getBitmap() if the passed in index is SkBitmapHeap::INVALID_SLOT. This empty diff --git a/src/core/SkPixelRef.cpp b/src/core/SkPixelRef.cpp index d08796b18c..30b405f7e9 100644 --- a/src/core/SkPixelRef.cpp +++ b/src/core/SkPixelRef.cpp @@ -6,7 +6,8 @@ * found in the LICENSE file. */ #include "SkPixelRef.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkThread.h" #ifdef SK_USE_POSIX_THREADS @@ -101,13 +102,13 @@ SkPixelRef::SkPixelRef(const SkImageInfo& info, SkBaseMutex* mutex) : fInfo(info fPreLocked = false; } -static SkImageInfo read_info(SkFlattenableReadBuffer& buffer) { +static SkImageInfo read_info(SkReadBuffer& buffer) { SkImageInfo info; info.unflatten(buffer); return info; } -SkPixelRef::SkPixelRef(SkFlattenableReadBuffer& buffer, SkBaseMutex* mutex) +SkPixelRef::SkPixelRef(SkReadBuffer& buffer, SkBaseMutex* mutex) : INHERITED(buffer) , fInfo(read_info(buffer)) { @@ -148,7 +149,7 @@ void SkPixelRef::setPreLocked(void* pixels, size_t rowBytes, SkColorTable* ctabl #endif } -void SkPixelRef::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkPixelRef::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); fInfo.flatten(buffer); buffer.writeBool(fIsImmutable); diff --git a/src/core/SkOrderedReadBuffer.cpp b/src/core/SkReadBuffer.cpp index 1ebaac4da8..6a590ed694 100644 --- a/src/core/SkOrderedReadBuffer.cpp +++ b/src/core/SkReadBuffer.cpp @@ -8,11 +8,23 @@ #include "SkBitmap.h" #include "SkErrorInternals.h" -#include "SkOrderedReadBuffer.h" +#include "SkReadBuffer.h" #include "SkStream.h" #include "SkTypeface.h" -SkOrderedReadBuffer::SkOrderedReadBuffer() : INHERITED() { +static uint32_t default_flags() { + uint32_t flags = 0; +#ifdef SK_SCALAR_IS_FLOAT + flags |= SkReadBuffer::kScalarIsFloat_Flag; +#endif + if (8 == sizeof(void*)) { + flags |= SkReadBuffer::kPtrIs64Bit_Flag; + } + return flags; +} + +SkReadBuffer::SkReadBuffer() { + fFlags = default_flags(); fMemoryPtr = NULL; fBitmapStorage = NULL; @@ -28,7 +40,8 @@ SkOrderedReadBuffer::SkOrderedReadBuffer() : INHERITED() { #endif // DEBUG_NON_DETERMINISTIC_ASSERT } -SkOrderedReadBuffer::SkOrderedReadBuffer(const void* data, size_t size) : INHERITED() { +SkReadBuffer::SkReadBuffer(const void* data, size_t size) { + fFlags = default_flags(); fReader.setMemory(data, size); fMemoryPtr = NULL; @@ -45,7 +58,8 @@ SkOrderedReadBuffer::SkOrderedReadBuffer(const void* data, size_t size) : INHERI #endif // DEBUG_NON_DETERMINISTIC_ASSERT } -SkOrderedReadBuffer::SkOrderedReadBuffer(SkStream* stream) { +SkReadBuffer::SkReadBuffer(SkStream* stream) { + fFlags = default_flags(); const size_t length = stream->getLength(); fMemoryPtr = sk_malloc_throw(length); stream->read(fMemoryPtr, length); @@ -64,46 +78,46 @@ SkOrderedReadBuffer::SkOrderedReadBuffer(SkStream* stream) { #endif // DEBUG_NON_DETERMINISTIC_ASSERT } -SkOrderedReadBuffer::~SkOrderedReadBuffer() { +SkReadBuffer::~SkReadBuffer() { sk_free(fMemoryPtr); SkSafeUnref(fBitmapStorage); } -bool SkOrderedReadBuffer::readBool() { +bool SkReadBuffer::readBool() { return fReader.readBool(); } -SkColor SkOrderedReadBuffer::readColor() { +SkColor SkReadBuffer::readColor() { return fReader.readInt(); } -SkFixed SkOrderedReadBuffer::readFixed() { +SkFixed SkReadBuffer::readFixed() { return fReader.readS32(); } -int32_t SkOrderedReadBuffer::readInt() { +int32_t SkReadBuffer::readInt() { return fReader.readInt(); } -SkScalar SkOrderedReadBuffer::readScalar() { +SkScalar SkReadBuffer::readScalar() { return fReader.readScalar(); } -uint32_t SkOrderedReadBuffer::readUInt() { +uint32_t SkReadBuffer::readUInt() { return fReader.readU32(); } -int32_t SkOrderedReadBuffer::read32() { +int32_t SkReadBuffer::read32() { return fReader.readInt(); } -void SkOrderedReadBuffer::readString(SkString* string) { +void SkReadBuffer::readString(SkString* string) { size_t len; const char* strContents = fReader.readString(&len); string->set(strContents, len); } -void* SkOrderedReadBuffer::readEncodedString(size_t* length, SkPaint::TextEncoding encoding) { +void* SkReadBuffer::readEncodedString(size_t* length, SkPaint::TextEncoding encoding) { SkDEBUGCODE(int32_t encodingType = ) fReader.readInt(); SkASSERT(encodingType == encoding); *length = fReader.readInt(); @@ -112,32 +126,32 @@ void* SkOrderedReadBuffer::readEncodedString(size_t* length, SkPaint::TextEncodi return data; } -void SkOrderedReadBuffer::readPoint(SkPoint* point) { +void SkReadBuffer::readPoint(SkPoint* point) { point->fX = fReader.readScalar(); point->fY = fReader.readScalar(); } -void SkOrderedReadBuffer::readMatrix(SkMatrix* matrix) { +void SkReadBuffer::readMatrix(SkMatrix* matrix) { fReader.readMatrix(matrix); } -void SkOrderedReadBuffer::readIRect(SkIRect* rect) { +void SkReadBuffer::readIRect(SkIRect* rect) { memcpy(rect, fReader.skip(sizeof(SkIRect)), sizeof(SkIRect)); } -void SkOrderedReadBuffer::readRect(SkRect* rect) { +void SkReadBuffer::readRect(SkRect* rect) { memcpy(rect, fReader.skip(sizeof(SkRect)), sizeof(SkRect)); } -void SkOrderedReadBuffer::readRegion(SkRegion* region) { +void SkReadBuffer::readRegion(SkRegion* region) { fReader.readRegion(region); } -void SkOrderedReadBuffer::readPath(SkPath* path) { +void SkReadBuffer::readPath(SkPath* path) { fReader.readPath(path); } -bool SkOrderedReadBuffer::readArray(void* value, size_t size, size_t elementSize) { +bool SkReadBuffer::readArray(void* value, size_t size, size_t elementSize) { const size_t count = this->getArrayCount(); if (count == size) { (void)fReader.skip(sizeof(uint32_t)); // Skip array count @@ -150,31 +164,31 @@ bool SkOrderedReadBuffer::readArray(void* value, size_t size, size_t elementSize return false; } -bool SkOrderedReadBuffer::readByteArray(void* value, size_t size) { +bool SkReadBuffer::readByteArray(void* value, size_t size) { return readArray(static_cast<unsigned char*>(value), size, sizeof(unsigned char)); } -bool SkOrderedReadBuffer::readColorArray(SkColor* colors, size_t size) { +bool SkReadBuffer::readColorArray(SkColor* colors, size_t size) { return readArray(colors, size, sizeof(SkColor)); } -bool SkOrderedReadBuffer::readIntArray(int32_t* values, size_t size) { +bool SkReadBuffer::readIntArray(int32_t* values, size_t size) { return readArray(values, size, sizeof(int32_t)); } -bool SkOrderedReadBuffer::readPointArray(SkPoint* points, size_t size) { +bool SkReadBuffer::readPointArray(SkPoint* points, size_t size) { return readArray(points, size, sizeof(SkPoint)); } -bool SkOrderedReadBuffer::readScalarArray(SkScalar* values, size_t size) { +bool SkReadBuffer::readScalarArray(SkScalar* values, size_t size) { return readArray(values, size, sizeof(SkScalar)); } -uint32_t SkOrderedReadBuffer::getArrayCount() { +uint32_t SkReadBuffer::getArrayCount() { return *(uint32_t*)fReader.peek(); } -void SkOrderedReadBuffer::readBitmap(SkBitmap* bitmap) { +void SkReadBuffer::readBitmap(SkBitmap* bitmap) { const int width = this->readInt(); const int height = this->readInt(); // The writer stored a boolean value to determine whether an SkBitmapHeap was used during @@ -183,7 +197,7 @@ void SkOrderedReadBuffer::readBitmap(SkBitmap* bitmap) { // An SkBitmapHeap was used for writing. Read the index from the stream and find the // corresponding SkBitmap in fBitmapStorage. const uint32_t index = fReader.readU32(); - fReader.readU32(); // bitmap generation ID (see SkOrderedWriteBuffer::writeBitmap) + fReader.readU32(); // bitmap generation ID (see SkWriteBuffer::writeBitmap) if (fBitmapStorage) { *bitmap = *fBitmapStorage->getBitmap(index); fBitmapStorage->releaseRef(index); @@ -191,9 +205,9 @@ void SkOrderedReadBuffer::readBitmap(SkBitmap* bitmap) { } else { // The bitmap was stored in a heap, but there is no way to access it. Set an error and // fall through to use a place holder bitmap. - SkErrorInternals::SetError(kParseError_SkError, "SkOrderedWriteBuffer::writeBitmap " + SkErrorInternals::SetError(kParseError_SkError, "SkWriteBuffer::writeBitmap " "stored the SkBitmap in an SkBitmapHeap, but " - "SkOrderedReadBuffer has no SkBitmapHeapReader to " + "SkReadBuffer has no SkBitmapHeapReader to " "retrieve the SkBitmap."); } } else { @@ -212,7 +226,7 @@ void SkOrderedReadBuffer::readBitmap(SkBitmap* bitmap) { if (bitmap->width() == width && bitmap->height() == height) { #ifdef DEBUG_NON_DETERMINISTIC_ASSERT if (0 != xOffset || 0 != yOffset) { - SkDebugf("SkOrderedReadBuffer::readBitmap: heights match," + SkDebugf("SkReadBuffer::readBitmap: heights match," " but offset is not zero. \nInfo about the bitmap:" "\n\tIndex: %d\n\tDimensions: [%d %d]\n\tEncoded" " data size: %d\n\tOffset: (%d, %d)\n", @@ -256,7 +270,7 @@ void SkOrderedReadBuffer::readBitmap(SkBitmap* bitmap) { bitmap->eraseColor(SK_ColorRED); } -SkTypeface* SkOrderedReadBuffer::readTypeface() { +SkTypeface* SkReadBuffer::readTypeface() { uint32_t index = fReader.readU32(); if (0 == index || index > (unsigned)fTFCount) { @@ -270,7 +284,7 @@ SkTypeface* SkOrderedReadBuffer::readTypeface() { } } -SkFlattenable* SkOrderedReadBuffer::readFlattenable(SkFlattenable::Type ft) { +SkFlattenable* SkReadBuffer::readFlattenable(SkFlattenable::Type ft) { // // TODO: confirm that ft matches the factory we decide to use // diff --git a/src/core/SkScalerContext.cpp b/src/core/SkScalerContext.cpp index 2a4e9d3d58..8a333481c5 100644 --- a/src/core/SkScalerContext.cpp +++ b/src/core/SkScalerContext.cpp @@ -15,8 +15,8 @@ #include "SkGlyph.h" #include "SkMaskFilter.h" #include "SkMaskGamma.h" -#include "SkOrderedReadBuffer.h" -#include "SkOrderedWriteBuffer.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkPathEffect.h" #include "SkRasterizer.h" #include "SkRasterClip.h" @@ -73,7 +73,7 @@ static SkFlattenable* load_flattenable(const SkDescriptor* desc, uint32_t tag, const void* data = desc->findEntry(tag, &len); if (data) { - SkOrderedReadBuffer buffer(data, len); + SkReadBuffer buffer(data, len); obj = buffer.readFlattenable(ft); SkASSERT(buffer.offset() == buffer.size()); } @@ -118,7 +118,7 @@ SkScalerContext::SkScalerContext(SkTypeface* typeface, const SkDescriptor* desc) uint32_t len; const void* data = desc->findEntry(kAndroidOpts_SkDescriptorTag, &len); if (data) { - SkOrderedReadBuffer buffer(data, len); + SkReadBuffer buffer(data, len); fPaintOptionsAndroid.unflatten(buffer); SkASSERT(buffer.offset() == buffer.size()); } @@ -147,10 +147,11 @@ SkScalerContext* SkScalerContext::allocNextContext() const { SkAutoTUnref<SkTypeface> aur(newFace); uint32_t newFontID = newFace->uniqueID(); - SkOrderedWriteBuffer androidBuffer; + SkWriteBuffer androidBuffer; fPaintOptionsAndroid.flatten(androidBuffer); - SkAutoDescriptor ad(sizeof(fRec) + androidBuffer.size() + SkDescriptor::ComputeOverhead(2)); + SkAutoDescriptor ad(sizeof(fRec) + androidBuffer.bytesWritten() + + SkDescriptor::ComputeOverhead(2)); SkDescriptor* desc = ad.getDesc(); desc->init(); @@ -158,7 +159,7 @@ SkScalerContext* SkScalerContext::allocNextContext() const { (SkScalerContext::Rec*)desc->addEntry(kRec_SkDescriptorTag, sizeof(fRec), &fRec); androidBuffer.writeToMemory(desc->addEntry(kAndroidOpts_SkDescriptorTag, - androidBuffer.size(), NULL)); + androidBuffer.bytesWritten(), NULL)); newRec->fFontID = newFontID; desc->computeChecksum(); diff --git a/src/core/SkShader.cpp b/src/core/SkShader.cpp index 33fddb1183..bebfc59912 100644 --- a/src/core/SkShader.cpp +++ b/src/core/SkShader.cpp @@ -8,7 +8,8 @@ #include "SkScalar.h" #include "SkShader.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkPaint.h" #include "SkMallocPixelRef.h" @@ -17,7 +18,7 @@ SkShader::SkShader() { SkDEBUGCODE(fInSetContext = false;) } -SkShader::SkShader(SkFlattenableReadBuffer& buffer) +SkShader::SkShader(SkReadBuffer& buffer) : INHERITED(buffer) { if (buffer.readBool()) { buffer.readMatrix(&fLocalMatrix); @@ -32,7 +33,7 @@ SkShader::~SkShader() { SkASSERT(!fInSetContext); } -void SkShader::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkShader::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); bool hasLocalM = this->hasLocalMatrix(); buffer.writeBool(hasLocalM); @@ -213,7 +214,7 @@ bool SkColorShader::isOpaque() const { return SkColorGetA(fColor) == 255; } -SkColorShader::SkColorShader(SkFlattenableReadBuffer& b) : INHERITED(b) { +SkColorShader::SkColorShader(SkReadBuffer& b) : INHERITED(b) { fFlags = 0; // computed in setContext fInheritColor = b.readBool(); @@ -223,7 +224,7 @@ SkColorShader::SkColorShader(SkFlattenableReadBuffer& b) : INHERITED(b) { fColor = b.readColor(); } -void SkColorShader::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkColorShader::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writeBool(fInheritColor); if (fInheritColor) { diff --git a/src/core/SkValidatingReadBuffer.cpp b/src/core/SkValidatingReadBuffer.cpp index ab6a04a1cf..ae7a83684b 100644 --- a/src/core/SkValidatingReadBuffer.cpp +++ b/src/core/SkValidatingReadBuffer.cpp @@ -14,7 +14,7 @@ SkValidatingReadBuffer::SkValidatingReadBuffer(const void* data, size_t size) : fError(false) { this->setMemory(data, size); - this->setFlags(SkFlattenableReadBuffer::kValidation_Flag); + this->setFlags(SkReadBuffer::kValidation_Flag); } SkValidatingReadBuffer::~SkValidatingReadBuffer() { diff --git a/src/core/SkValidatingReadBuffer.h b/src/core/SkValidatingReadBuffer.h index 627c2c42db..59b5c1acc3 100644 --- a/src/core/SkValidatingReadBuffer.h +++ b/src/core/SkValidatingReadBuffer.h @@ -10,14 +10,15 @@ #include "SkRefCnt.h" #include "SkBitmapHeap.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkPath.h" #include "SkPicture.h" #include "SkReader32.h" class SkBitmap; -class SkValidatingReadBuffer : public SkFlattenableReadBuffer { +class SkValidatingReadBuffer : public SkReadBuffer { public: SkValidatingReadBuffer(const void* data, size_t size); virtual ~SkValidatingReadBuffer(); @@ -77,7 +78,7 @@ private: SkReader32 fReader; bool fError; - typedef SkFlattenableReadBuffer INHERITED; + typedef SkReadBuffer INHERITED; }; #endif // SkValidatingReadBuffer_DEFINED diff --git a/src/core/SkOrderedWriteBuffer.cpp b/src/core/SkWriteBuffer.cpp index 9107ecd828..cbbb4c94fc 100644 --- a/src/core/SkOrderedWriteBuffer.cpp +++ b/src/core/SkWriteBuffer.cpp @@ -6,7 +6,7 @@ * found in the LICENSE file. */ -#include "SkOrderedWriteBuffer.h" +#include "SkWriteBuffer.h" #include "SkBitmap.h" #include "SkData.h" #include "SkPixelRef.h" @@ -14,8 +14,8 @@ #include "SkStream.h" #include "SkTypeface.h" -SkOrderedWriteBuffer::SkOrderedWriteBuffer() - : INHERITED() +SkWriteBuffer::SkWriteBuffer() + : fFlags(0) , fFactorySet(NULL) , fNamedFactorySet(NULL) , fBitmapHeap(NULL) @@ -23,8 +23,8 @@ SkOrderedWriteBuffer::SkOrderedWriteBuffer() , fBitmapEncoder(NULL) { } -SkOrderedWriteBuffer::SkOrderedWriteBuffer(void* storage, size_t storageSize) - : INHERITED() +SkWriteBuffer::SkWriteBuffer(void* storage, size_t storageSize) + : fFlags(0) , fFactorySet(NULL) , fNamedFactorySet(NULL) , fWriter(storage, storageSize) @@ -33,57 +33,57 @@ SkOrderedWriteBuffer::SkOrderedWriteBuffer(void* storage, size_t storageSize) , fBitmapEncoder(NULL) { } -SkOrderedWriteBuffer::~SkOrderedWriteBuffer() { +SkWriteBuffer::~SkWriteBuffer() { SkSafeUnref(fFactorySet); SkSafeUnref(fNamedFactorySet); SkSafeUnref(fBitmapHeap); SkSafeUnref(fTFSet); } -void SkOrderedWriteBuffer::writeByteArray(const void* data, size_t size) { +void SkWriteBuffer::writeByteArray(const void* data, size_t size) { fWriter.write32(size); fWriter.writePad(data, size); } -void SkOrderedWriteBuffer::writeBool(bool value) { +void SkWriteBuffer::writeBool(bool value) { fWriter.writeBool(value); } -void SkOrderedWriteBuffer::writeFixed(SkFixed value) { +void SkWriteBuffer::writeFixed(SkFixed value) { fWriter.write32(value); } -void SkOrderedWriteBuffer::writeScalar(SkScalar value) { +void SkWriteBuffer::writeScalar(SkScalar value) { fWriter.writeScalar(value); } -void SkOrderedWriteBuffer::writeScalarArray(const SkScalar* value, uint32_t count) { +void SkWriteBuffer::writeScalarArray(const SkScalar* value, uint32_t count) { fWriter.write32(count); fWriter.write(value, count * sizeof(SkScalar)); } -void SkOrderedWriteBuffer::writeInt(int32_t value) { +void SkWriteBuffer::writeInt(int32_t value) { fWriter.write32(value); } -void SkOrderedWriteBuffer::writeIntArray(const int32_t* value, uint32_t count) { +void SkWriteBuffer::writeIntArray(const int32_t* value, uint32_t count) { fWriter.write32(count); fWriter.write(value, count * sizeof(int32_t)); } -void SkOrderedWriteBuffer::writeUInt(uint32_t value) { +void SkWriteBuffer::writeUInt(uint32_t value) { fWriter.write32(value); } -void SkOrderedWriteBuffer::write32(int32_t value) { +void SkWriteBuffer::write32(int32_t value) { fWriter.write32(value); } -void SkOrderedWriteBuffer::writeString(const char* value) { +void SkWriteBuffer::writeString(const char* value) { fWriter.writeString(value); } -void SkOrderedWriteBuffer::writeEncodedString(const void* value, size_t byteLength, +void SkWriteBuffer::writeEncodedString(const void* value, size_t byteLength, SkPaint::TextEncoding encoding) { fWriter.writeInt(encoding); fWriter.writeInt(byteLength); @@ -91,46 +91,46 @@ void SkOrderedWriteBuffer::writeEncodedString(const void* value, size_t byteLeng } -void SkOrderedWriteBuffer::writeColor(const SkColor& color) { +void SkWriteBuffer::writeColor(const SkColor& color) { fWriter.write32(color); } -void SkOrderedWriteBuffer::writeColorArray(const SkColor* color, uint32_t count) { +void SkWriteBuffer::writeColorArray(const SkColor* color, uint32_t count) { fWriter.write32(count); fWriter.write(color, count * sizeof(SkColor)); } -void SkOrderedWriteBuffer::writePoint(const SkPoint& point) { +void SkWriteBuffer::writePoint(const SkPoint& point) { fWriter.writeScalar(point.fX); fWriter.writeScalar(point.fY); } -void SkOrderedWriteBuffer::writePointArray(const SkPoint* point, uint32_t count) { +void SkWriteBuffer::writePointArray(const SkPoint* point, uint32_t count) { fWriter.write32(count); fWriter.write(point, count * sizeof(SkPoint)); } -void SkOrderedWriteBuffer::writeMatrix(const SkMatrix& matrix) { +void SkWriteBuffer::writeMatrix(const SkMatrix& matrix) { fWriter.writeMatrix(matrix); } -void SkOrderedWriteBuffer::writeIRect(const SkIRect& rect) { +void SkWriteBuffer::writeIRect(const SkIRect& rect) { fWriter.write(&rect, sizeof(SkIRect)); } -void SkOrderedWriteBuffer::writeRect(const SkRect& rect) { +void SkWriteBuffer::writeRect(const SkRect& rect) { fWriter.writeRect(rect); } -void SkOrderedWriteBuffer::writeRegion(const SkRegion& region) { +void SkWriteBuffer::writeRegion(const SkRegion& region) { fWriter.writeRegion(region); } -void SkOrderedWriteBuffer::writePath(const SkPath& path) { +void SkWriteBuffer::writePath(const SkPath& path) { fWriter.writePath(path); } -size_t SkOrderedWriteBuffer::writeStream(SkStream* stream, size_t length) { +size_t SkWriteBuffer::writeStream(SkStream* stream, size_t length) { fWriter.write32(length); size_t bytesWritten = fWriter.readFromStream(stream, length); if (bytesWritten < length) { @@ -139,11 +139,11 @@ size_t SkOrderedWriteBuffer::writeStream(SkStream* stream, size_t length) { return bytesWritten; } -bool SkOrderedWriteBuffer::writeToStream(SkWStream* stream) { +bool SkWriteBuffer::writeToStream(SkWStream* stream) { return fWriter.writeToStream(stream); } -static void write_encoded_bitmap(SkOrderedWriteBuffer* buffer, SkData* data, +static void write_encoded_bitmap(SkWriteBuffer* buffer, SkData* data, const SkIPoint& origin) { buffer->writeUInt(SkToU32(data->size())); buffer->getWriter32()->writePad(data->data(), data->size()); @@ -151,7 +151,7 @@ static void write_encoded_bitmap(SkOrderedWriteBuffer* buffer, SkData* data, buffer->write32(origin.fY); } -void SkOrderedWriteBuffer::writeBitmap(const SkBitmap& bitmap) { +void SkWriteBuffer::writeBitmap(const SkBitmap& bitmap) { // Record the width and height. This way if readBitmap fails a dummy bitmap can be drawn at the // right size. this->writeInt(bitmap.width()); @@ -211,7 +211,7 @@ void SkOrderedWriteBuffer::writeBitmap(const SkBitmap& bitmap) { bitmap.flatten(*this); } -void SkOrderedWriteBuffer::writeTypeface(SkTypeface* obj) { +void SkWriteBuffer::writeTypeface(SkTypeface* obj) { if (NULL == obj || NULL == fTFSet) { fWriter.write32(0); } else { @@ -219,7 +219,7 @@ void SkOrderedWriteBuffer::writeTypeface(SkTypeface* obj) { } } -SkFactorySet* SkOrderedWriteBuffer::setFactoryRecorder(SkFactorySet* rec) { +SkFactorySet* SkWriteBuffer::setFactoryRecorder(SkFactorySet* rec) { SkRefCnt_SafeAssign(fFactorySet, rec); if (fNamedFactorySet != NULL) { fNamedFactorySet->unref(); @@ -228,7 +228,7 @@ SkFactorySet* SkOrderedWriteBuffer::setFactoryRecorder(SkFactorySet* rec) { return rec; } -SkNamedFactorySet* SkOrderedWriteBuffer::setNamedFactoryRecorder(SkNamedFactorySet* rec) { +SkNamedFactorySet* SkWriteBuffer::setNamedFactoryRecorder(SkNamedFactorySet* rec) { SkRefCnt_SafeAssign(fNamedFactorySet, rec); if (fFactorySet != NULL) { fFactorySet->unref(); @@ -237,12 +237,12 @@ SkNamedFactorySet* SkOrderedWriteBuffer::setNamedFactoryRecorder(SkNamedFactoryS return rec; } -SkRefCntSet* SkOrderedWriteBuffer::setTypefaceRecorder(SkRefCntSet* rec) { +SkRefCntSet* SkWriteBuffer::setTypefaceRecorder(SkRefCntSet* rec) { SkRefCnt_SafeAssign(fTFSet, rec); return rec; } -void SkOrderedWriteBuffer::setBitmapHeap(SkBitmapHeap* bitmapHeap) { +void SkWriteBuffer::setBitmapHeap(SkBitmapHeap* bitmapHeap) { SkRefCnt_SafeAssign(fBitmapHeap, bitmapHeap); if (bitmapHeap != NULL) { SkASSERT(NULL == fBitmapEncoder); @@ -250,7 +250,7 @@ void SkOrderedWriteBuffer::setBitmapHeap(SkBitmapHeap* bitmapHeap) { } } -void SkOrderedWriteBuffer::setBitmapEncoder(SkPicture::EncodeBitmap bitmapEncoder) { +void SkWriteBuffer::setBitmapEncoder(SkPicture::EncodeBitmap bitmapEncoder) { fBitmapEncoder = bitmapEncoder; if (bitmapEncoder != NULL) { SkASSERT(NULL == fBitmapHeap); @@ -259,7 +259,7 @@ void SkOrderedWriteBuffer::setBitmapEncoder(SkPicture::EncodeBitmap bitmapEncode } } -void SkOrderedWriteBuffer::writeFlattenable(const SkFlattenable* flattenable) { +void SkWriteBuffer::writeFlattenable(const SkFlattenable* flattenable) { /* * If we have a factoryset, then the first 32bits tell us... * 0: failure to write the flattenable @@ -318,7 +318,7 @@ void SkOrderedWriteBuffer::writeFlattenable(const SkFlattenable* flattenable) { // record the current size, so we can subtract after the object writes. uint32_t offset = fWriter.bytesWritten(); // now flatten the object - flattenObject(flattenable, *this); + flattenable->flatten(*this); uint32_t objSize = fWriter.bytesWritten() - offset; // record the obj's size *fWriter.peek32(offset - sizeof(uint32_t)) = objSize; diff --git a/src/core/SkXfermode.cpp b/src/core/SkXfermode.cpp index 176bcb50ea..66e0dea2f5 100644 --- a/src/core/SkXfermode.cpp +++ b/src/core/SkXfermode.cpp @@ -10,7 +10,8 @@ #include "SkXfermode.h" #include "SkXfermode_proccoeff.h" #include "SkColorPriv.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkMathPriv.h" #include "SkString.h" #include "SkUtilsArm.h" @@ -860,7 +861,7 @@ void SkProcXfermode::xferA8(SkAlpha* SK_RESTRICT dst, } } -SkProcXfermode::SkProcXfermode(SkFlattenableReadBuffer& buffer) +SkProcXfermode::SkProcXfermode(SkReadBuffer& buffer) : SkXfermode(buffer) { fProc = NULL; if (!buffer.isCrossProcess()) { @@ -868,7 +869,7 @@ SkProcXfermode::SkProcXfermode(SkFlattenableReadBuffer& buffer) } } -void SkProcXfermode::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkProcXfermode::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); if (!buffer.isCrossProcess()) { buffer.writeFunctionPtr((void*)fProc); @@ -1343,7 +1344,7 @@ GrEffectRef* XferEffect::TestCreate(SkRandom* rand, /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// -SkProcCoeffXfermode::SkProcCoeffXfermode(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) { +SkProcCoeffXfermode::SkProcCoeffXfermode(SkReadBuffer& buffer) : INHERITED(buffer) { uint32_t mode32 = buffer.read32() % SK_ARRAY_COUNT(gProcCoeffs); if (mode32 >= SK_ARRAY_COUNT(gProcCoeffs)) { // out of range, just set to something harmless @@ -1394,7 +1395,7 @@ bool SkProcCoeffXfermode::asNewEffect(GrEffectRef** effect, } #endif -void SkProcCoeffXfermode::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkProcCoeffXfermode::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.write32(fMode); } @@ -1452,7 +1453,7 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkClearXfermode) private: - SkClearXfermode(SkFlattenableReadBuffer& buffer) + SkClearXfermode(SkReadBuffer& buffer) : SkProcCoeffXfermode(buffer) {} typedef SkProcCoeffXfermode INHERITED; @@ -1514,7 +1515,7 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSrcXfermode) private: - SkSrcXfermode(SkFlattenableReadBuffer& buffer) + SkSrcXfermode(SkReadBuffer& buffer) : SkProcCoeffXfermode(buffer) {} typedef SkProcCoeffXfermode INHERITED; @@ -1580,7 +1581,7 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDstInXfermode) private: - SkDstInXfermode(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {} + SkDstInXfermode(SkReadBuffer& buffer) : INHERITED(buffer) {} typedef SkProcCoeffXfermode INHERITED; }; @@ -1623,7 +1624,7 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDstOutXfermode) private: - SkDstOutXfermode(SkFlattenableReadBuffer& buffer) + SkDstOutXfermode(SkReadBuffer& buffer) : INHERITED(buffer) {} typedef SkProcCoeffXfermode INHERITED; diff --git a/src/core/SkXfermode_proccoeff.h b/src/core/SkXfermode_proccoeff.h index 205edf2fa0..1a2f7fcc7f 100644 --- a/src/core/SkXfermode_proccoeff.h +++ b/src/core/SkXfermode_proccoeff.h @@ -2,7 +2,8 @@ #define SkXfermode_proccoeff_DEFINED #include "SkXfermode.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" struct ProcCoeff { SkXfermodeProc fProc; @@ -35,9 +36,9 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkProcCoeffXfermode) protected: - SkProcCoeffXfermode(SkFlattenableReadBuffer& buffer); + SkProcCoeffXfermode(SkReadBuffer& buffer); - virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE; + virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE; Mode getMode() const { return fMode; diff --git a/src/effects/Sk1DPathEffect.cpp b/src/effects/Sk1DPathEffect.cpp index 10a68b9f84..7354cdacb4 100644 --- a/src/effects/Sk1DPathEffect.cpp +++ b/src/effects/Sk1DPathEffect.cpp @@ -8,7 +8,8 @@ #include "Sk1DPathEffect.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkPathMeasure.h" bool Sk1DPathEffect::filterPath(SkPath* dst, const SkPath& src, @@ -146,7 +147,7 @@ static void morphpath(SkPath* dst, const SkPath& src, SkPathMeasure& meas, } } -SkPath1DPathEffect::SkPath1DPathEffect(SkFlattenableReadBuffer& buffer) { +SkPath1DPathEffect::SkPath1DPathEffect(SkReadBuffer& buffer) { fAdvance = buffer.readScalar(); if (fAdvance > 0) { buffer.readPath(&fPath); @@ -164,7 +165,7 @@ SkScalar SkPath1DPathEffect::begin(SkScalar contourLength) const { return fInitialOffset; } -void SkPath1DPathEffect::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkPath1DPathEffect::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writeScalar(fAdvance); if (fAdvance > 0) { diff --git a/src/effects/Sk2DPathEffect.cpp b/src/effects/Sk2DPathEffect.cpp index dc15f076d6..252866c054 100644 --- a/src/effects/Sk2DPathEffect.cpp +++ b/src/effects/Sk2DPathEffect.cpp @@ -8,7 +8,8 @@ #include "Sk2DPathEffect.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkPath.h" #include "SkRegion.h" @@ -67,12 +68,12 @@ void Sk2DPathEffect::end(SkPath* dst) const {} /////////////////////////////////////////////////////////////////////////////// -void Sk2DPathEffect::flatten(SkFlattenableWriteBuffer& buffer) const { +void Sk2DPathEffect::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writeMatrix(fMatrix); } -Sk2DPathEffect::Sk2DPathEffect(SkFlattenableReadBuffer& buffer) { +Sk2DPathEffect::Sk2DPathEffect(SkReadBuffer& buffer) { buffer.readMatrix(&fMatrix); fMatrixIsInvertible = fMatrix.invert(&fInverse); } @@ -101,11 +102,11 @@ void SkLine2DPathEffect::nextSpan(int u, int v, int ucount, SkPath* dst) const { } } -SkLine2DPathEffect::SkLine2DPathEffect(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) { +SkLine2DPathEffect::SkLine2DPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) { fWidth = buffer.readScalar(); } -void SkLine2DPathEffect::flatten(SkFlattenableWriteBuffer &buffer) const { +void SkLine2DPathEffect::flatten(SkWriteBuffer &buffer) const { this->INHERITED::flatten(buffer); buffer.writeScalar(fWidth); } @@ -116,12 +117,12 @@ SkPath2DPathEffect::SkPath2DPathEffect(const SkMatrix& m, const SkPath& p) : INHERITED(m), fPath(p) { } -SkPath2DPathEffect::SkPath2DPathEffect(SkFlattenableReadBuffer& buffer) +SkPath2DPathEffect::SkPath2DPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) { buffer.readPath(&fPath); } -void SkPath2DPathEffect::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkPath2DPathEffect::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writePath(fPath); } diff --git a/src/effects/SkAlphaThresholdFilter.cpp b/src/effects/SkAlphaThresholdFilter.cpp index 4bcb32031b..d3d9093050 100644 --- a/src/effects/SkAlphaThresholdFilter.cpp +++ b/src/effects/SkAlphaThresholdFilter.cpp @@ -7,7 +7,8 @@ #include "SkAlphaThresholdFilter.h" #include "SkBitmap.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkRegion.h" class SK_API SkAlphaThresholdFilterImpl : public SkImageFilter { @@ -17,8 +18,8 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkAlphaThresholdFilterImpl) protected: - explicit SkAlphaThresholdFilterImpl(SkFlattenableReadBuffer& buffer); - virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; + explicit SkAlphaThresholdFilterImpl(SkReadBuffer& buffer); + virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&, SkBitmap* result, SkIPoint* offset) SK_OVERRIDE; @@ -230,7 +231,7 @@ void AlphaThresholdEffect::getConstantColorComponents(GrColor* color, uint32_t* #endif -SkAlphaThresholdFilterImpl::SkAlphaThresholdFilterImpl(SkFlattenableReadBuffer& buffer) +SkAlphaThresholdFilterImpl::SkAlphaThresholdFilterImpl(SkReadBuffer& buffer) : INHERITED(1, buffer) { fInnerThreshold = buffer.readScalar(); fOuterThreshold = buffer.readScalar(); @@ -295,7 +296,7 @@ bool SkAlphaThresholdFilterImpl::asNewEffect(GrEffectRef** effect, GrTexture* te } #endif -void SkAlphaThresholdFilterImpl::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkAlphaThresholdFilterImpl::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writeScalar(fInnerThreshold); buffer.writeScalar(fOuterThreshold); diff --git a/src/effects/SkArithmeticMode.cpp b/src/effects/SkArithmeticMode.cpp index 93d708a98b..052b06507c 100644 --- a/src/effects/SkArithmeticMode.cpp +++ b/src/effects/SkArithmeticMode.cpp @@ -7,7 +7,8 @@ #include "SkArithmeticMode.h" #include "SkColorPriv.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkString.h" #include "SkUnPreMultiply.h" #if SK_SUPPORT_GPU @@ -40,14 +41,14 @@ public: #endif private: - SkArithmeticMode_scalar(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) { + SkArithmeticMode_scalar(SkReadBuffer& buffer) : INHERITED(buffer) { fK[0] = buffer.readScalar(); fK[1] = buffer.readScalar(); fK[2] = buffer.readScalar(); fK[3] = buffer.readScalar(); } - virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE { + virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE { INHERITED::flatten(buffer); buffer.writeScalar(fK[0]); buffer.writeScalar(fK[1]); diff --git a/src/effects/SkAvoidXfermode.cpp b/src/effects/SkAvoidXfermode.cpp index d76efb839e..a3334926f5 100644 --- a/src/effects/SkAvoidXfermode.cpp +++ b/src/effects/SkAvoidXfermode.cpp @@ -7,7 +7,8 @@ #include "SkAvoidXfermode.h" #include "SkColorPriv.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkString.h" SkAvoidXfermode::SkAvoidXfermode(SkColor opColor, U8CPU tolerance, Mode mode) { @@ -20,14 +21,14 @@ SkAvoidXfermode::SkAvoidXfermode(SkColor opColor, U8CPU tolerance, Mode mode) { fMode = mode; } -SkAvoidXfermode::SkAvoidXfermode(SkFlattenableReadBuffer& buffer) +SkAvoidXfermode::SkAvoidXfermode(SkReadBuffer& buffer) : INHERITED(buffer) { fOpColor = buffer.readColor(); fDistMul = buffer.readUInt(); fMode = (Mode)buffer.readUInt(); } -void SkAvoidXfermode::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkAvoidXfermode::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writeColor(fOpColor); diff --git a/src/effects/SkBicubicImageFilter.cpp b/src/effects/SkBicubicImageFilter.cpp index 8b89a343d0..e44b717003 100644 --- a/src/effects/SkBicubicImageFilter.cpp +++ b/src/effects/SkBicubicImageFilter.cpp @@ -8,7 +8,8 @@ #include "SkBicubicImageFilter.h" #include "SkBitmap.h" #include "SkColorPriv.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkMatrix.h" #include "SkRect.h" #include "SkUnPreMultiply.h" @@ -40,7 +41,7 @@ SkBicubicImageFilter* SkBicubicImageFilter::CreateMitchell(const SkSize& scale, return SkNEW_ARGS(SkBicubicImageFilter, (scale, gMitchellCoefficients, input)); } -SkBicubicImageFilter::SkBicubicImageFilter(SkFlattenableReadBuffer& buffer) +SkBicubicImageFilter::SkBicubicImageFilter(SkReadBuffer& buffer) : INHERITED(1, buffer) { SkDEBUGCODE(bool success =) buffer.readScalarArray(fCoefficients, 16); SkASSERT(success); @@ -52,7 +53,7 @@ SkBicubicImageFilter::SkBicubicImageFilter(SkFlattenableReadBuffer& buffer) (fScale.fHeight >= 0)); } -void SkBicubicImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkBicubicImageFilter::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writeScalarArray(fCoefficients, 16); buffer.writeScalar(fScale.fWidth); diff --git a/src/effects/SkBitmapSource.cpp b/src/effects/SkBitmapSource.cpp index 4aab92fc66..67567c5039 100644 --- a/src/effects/SkBitmapSource.cpp +++ b/src/effects/SkBitmapSource.cpp @@ -8,7 +8,8 @@ #include "SkBitmapSource.h" #include "SkDevice.h" #include "SkCanvas.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkValidationUtils.h" SkBitmapSource::SkBitmapSource(const SkBitmap& bitmap) @@ -26,7 +27,7 @@ SkBitmapSource::SkBitmapSource(const SkBitmap& bitmap, const SkRect& srcRect, co fDstRect(dstRect) { } -SkBitmapSource::SkBitmapSource(SkFlattenableReadBuffer& buffer) +SkBitmapSource::SkBitmapSource(SkReadBuffer& buffer) : INHERITED(0, buffer) { fBitmap.unflatten(buffer); buffer.readRect(&fSrcRect); @@ -34,7 +35,7 @@ SkBitmapSource::SkBitmapSource(SkFlattenableReadBuffer& buffer) buffer.validate(buffer.isValid() && SkIsValidRect(fSrcRect) && SkIsValidRect(fDstRect)); } -void SkBitmapSource::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkBitmapSource::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); fBitmap.flatten(buffer); buffer.writeRect(fSrcRect); diff --git a/src/effects/SkBlurDrawLooper.cpp b/src/effects/SkBlurDrawLooper.cpp index 51e6ec98e0..3a5c697371 100644 --- a/src/effects/SkBlurDrawLooper.cpp +++ b/src/effects/SkBlurDrawLooper.cpp @@ -10,7 +10,8 @@ #include "SkBlurMaskFilter.h" #include "SkCanvas.h" #include "SkColorFilter.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkMaskFilter.h" #include "SkPaint.h" #include "SkString.h" @@ -63,7 +64,7 @@ void SkBlurDrawLooper::init(SkScalar sigma, SkScalar dx, SkScalar dy, } } -SkBlurDrawLooper::SkBlurDrawLooper(SkFlattenableReadBuffer& buffer) +SkBlurDrawLooper::SkBlurDrawLooper(SkReadBuffer& buffer) : INHERITED(buffer) { fDx = buffer.readScalar(); @@ -79,7 +80,7 @@ SkBlurDrawLooper::~SkBlurDrawLooper() { SkSafeUnref(fColorFilter); } -void SkBlurDrawLooper::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkBlurDrawLooper::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writeScalar(fDx); buffer.writeScalar(fDy); diff --git a/src/effects/SkBlurImageFilter.cpp b/src/effects/SkBlurImageFilter.cpp index 5d9a077d43..196baf4804 100644 --- a/src/effects/SkBlurImageFilter.cpp +++ b/src/effects/SkBlurImageFilter.cpp @@ -8,7 +8,8 @@ #include "SkBitmap.h" #include "SkBlurImageFilter.h" #include "SkColorPriv.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkGpuBlurUtils.h" #include "SkBlurImage_opts.h" #if SK_SUPPORT_GPU @@ -16,7 +17,7 @@ #include "SkImageFilterUtils.h" #endif -SkBlurImageFilter::SkBlurImageFilter(SkFlattenableReadBuffer& buffer) +SkBlurImageFilter::SkBlurImageFilter(SkReadBuffer& buffer) : INHERITED(1, buffer) { fSigma.fWidth = buffer.readScalar(); fSigma.fHeight = buffer.readScalar(); @@ -34,7 +35,7 @@ SkBlurImageFilter::SkBlurImageFilter(SkScalar sigmaX, SkASSERT(sigmaX >= 0 && sigmaY >= 0); } -void SkBlurImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkBlurImageFilter::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writeScalar(fSigma.fWidth); buffer.writeScalar(fSigma.fHeight); diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp index 3325232f8b..2fffd05076 100644 --- a/src/effects/SkBlurMaskFilter.cpp +++ b/src/effects/SkBlurMaskFilter.cpp @@ -9,7 +9,8 @@ #include "SkBlurMaskFilter.h" #include "SkBlurMask.h" #include "SkGpuBlurUtils.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkMaskFilter.h" #include "SkRRect.h" #include "SkRTConf.h" @@ -79,8 +80,8 @@ private: SkBlurMaskFilter::BlurStyle fBlurStyle; uint32_t fBlurFlags; - SkBlurMaskFilterImpl(SkFlattenableReadBuffer&); - virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; + SkBlurMaskFilterImpl(SkReadBuffer&); + virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; SkScalar computeXformedSigma(const SkMatrix& ctm) const { bool ignoreTransform = SkToBool(fBlurFlags & SkBlurMaskFilter::kIgnoreTransform_BlurFlag); @@ -490,7 +491,7 @@ void SkBlurMaskFilterImpl::computeFastBounds(const SkRect& src, src.fRight + pad, src.fBottom + pad); } -SkBlurMaskFilterImpl::SkBlurMaskFilterImpl(SkFlattenableReadBuffer& buffer) +SkBlurMaskFilterImpl::SkBlurMaskFilterImpl(SkReadBuffer& buffer) : SkMaskFilter(buffer) { fSigma = buffer.readScalar(); fBlurStyle = (SkBlurMaskFilter::BlurStyle)buffer.readInt(); @@ -499,7 +500,7 @@ SkBlurMaskFilterImpl::SkBlurMaskFilterImpl(SkFlattenableReadBuffer& buffer) SkASSERT((unsigned)fBlurStyle < SkBlurMaskFilter::kBlurStyleCount); } -void SkBlurMaskFilterImpl::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkBlurMaskFilterImpl::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writeScalar(fSigma); buffer.writeInt(fBlurStyle); diff --git a/src/effects/SkColorFilterImageFilter.cpp b/src/effects/SkColorFilterImageFilter.cpp index d648b6c4a7..da494bb294 100755 --- a/src/effects/SkColorFilterImageFilter.cpp +++ b/src/effects/SkColorFilterImageFilter.cpp @@ -11,7 +11,8 @@ #include "SkColorMatrixFilter.h" #include "SkDevice.h" #include "SkColorFilter.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" namespace { @@ -82,12 +83,12 @@ SkColorFilterImageFilter::SkColorFilterImageFilter(SkColorFilter* cf, SkSafeRef(cf); } -SkColorFilterImageFilter::SkColorFilterImageFilter(SkFlattenableReadBuffer& buffer) +SkColorFilterImageFilter::SkColorFilterImageFilter(SkReadBuffer& buffer) : INHERITED(1, buffer) { fColorFilter = buffer.readColorFilter(); } -void SkColorFilterImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkColorFilterImageFilter::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writeFlattenable(fColorFilter); diff --git a/src/effects/SkColorFilters.cpp b/src/effects/SkColorFilters.cpp index d482a09d1f..f9fa1fd82b 100644 --- a/src/effects/SkColorFilters.cpp +++ b/src/effects/SkColorFilters.cpp @@ -10,7 +10,8 @@ #include "SkBlitRow.h" #include "SkColorFilter.h" #include "SkColorPriv.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkUtils.h" #include "SkString.h" #include "SkValidationUtils.h" @@ -92,13 +93,13 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkModeColorFilter) protected: - virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE { + virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE { this->INHERITED::flatten(buffer); buffer.writeColor(fColor); buffer.writeUInt(fMode); } - SkModeColorFilter(SkFlattenableReadBuffer& buffer) { + SkModeColorFilter(SkReadBuffer& buffer) { fColor = buffer.readColor(); fMode = (SkXfermode::Mode)buffer.readUInt(); if (buffer.isValid()) { @@ -446,7 +447,7 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Src_SkModeColorFilter) protected: - Src_SkModeColorFilter(SkFlattenableReadBuffer& buffer) + Src_SkModeColorFilter(SkReadBuffer& buffer) : INHERITED(buffer) {} private: @@ -482,7 +483,7 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SrcOver_SkModeColorFilter) protected: - SrcOver_SkModeColorFilter(SkFlattenableReadBuffer& buffer) + SrcOver_SkModeColorFilter(SkReadBuffer& buffer) : INHERITED(buffer) { fColor32Proc = SkBlitRow::ColorProcFactory(); } @@ -585,13 +586,13 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLightingColorFilter) protected: - virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE { + virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE { this->INHERITED::flatten(buffer); buffer.writeColor(fMul); buffer.writeColor(fAdd); } - SkLightingColorFilter(SkFlattenableReadBuffer& buffer) { + SkLightingColorFilter(SkReadBuffer& buffer) { fMul = buffer.readColor(); fAdd = buffer.readColor(); } @@ -637,7 +638,7 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLightingColorFilter_JustAdd) protected: - SkLightingColorFilter_JustAdd(SkFlattenableReadBuffer& buffer) + SkLightingColorFilter_JustAdd(SkReadBuffer& buffer) : INHERITED(buffer) {} private: @@ -678,7 +679,7 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLightingColorFilter_JustMul) protected: - SkLightingColorFilter_JustMul(SkFlattenableReadBuffer& buffer) + SkLightingColorFilter_JustMul(SkReadBuffer& buffer) : INHERITED(buffer) {} private: @@ -722,7 +723,7 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLightingColorFilter_SingleMul) protected: - SkLightingColorFilter_SingleMul(SkFlattenableReadBuffer& buffer) + SkLightingColorFilter_SingleMul(SkReadBuffer& buffer) : INHERITED(buffer) {} private: @@ -770,7 +771,7 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLightingColorFilter_NoPin) protected: - SkLightingColorFilter_NoPin(SkFlattenableReadBuffer& buffer) + SkLightingColorFilter_NoPin(SkReadBuffer& buffer) : INHERITED(buffer) {} private: @@ -781,7 +782,7 @@ private: class SkSimpleColorFilter : public SkColorFilter { public: - static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) { + static SkFlattenable* CreateProc(SkReadBuffer& buffer) { return SkNEW(SkSimpleColorFilter); } @@ -799,7 +800,7 @@ protected: } } - virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE {} + virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE {} virtual Factory getFactory() const { return CreateProc; diff --git a/src/effects/SkColorMatrix.cpp b/src/effects/SkColorMatrix.cpp index 535d6cc247..0e2ede2ce0 100644 --- a/src/effects/SkColorMatrix.cpp +++ b/src/effects/SkColorMatrix.cpp @@ -6,7 +6,8 @@ * found in the LICENSE file. */ #include "SkColorMatrix.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #define kRScale 0 #define kGScale 6 diff --git a/src/effects/SkColorMatrixFilter.cpp b/src/effects/SkColorMatrixFilter.cpp index fc1b77b7d5..6b925710c9 100644 --- a/src/effects/SkColorMatrixFilter.cpp +++ b/src/effects/SkColorMatrixFilter.cpp @@ -8,7 +8,8 @@ #include "SkColorMatrixFilter.h" #include "SkColorMatrix.h" #include "SkColorPriv.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkUnPreMultiply.h" #include "SkString.h" @@ -299,13 +300,13 @@ void SkColorMatrixFilter::filterSpan16(const uint16_t src[], int count, /////////////////////////////////////////////////////////////////////////////// -void SkColorMatrixFilter::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkColorMatrixFilter::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); SkASSERT(sizeof(fMatrix.fMat)/sizeof(SkScalar) == 20); buffer.writeScalarArray(fMatrix.fMat, 20); } -SkColorMatrixFilter::SkColorMatrixFilter(SkFlattenableReadBuffer& buffer) +SkColorMatrixFilter::SkColorMatrixFilter(SkReadBuffer& buffer) : INHERITED(buffer) { SkASSERT(buffer.getArrayCount() == 20); if (buffer.readScalarArray(fMatrix.fMat, 20)) { diff --git a/src/effects/SkComposeImageFilter.cpp b/src/effects/SkComposeImageFilter.cpp index 7445bdfe91..c794b0daf0 100644 --- a/src/effects/SkComposeImageFilter.cpp +++ b/src/effects/SkComposeImageFilter.cpp @@ -7,7 +7,8 @@ #include "SkBitmap.h" #include "SkComposeImageFilter.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" SkComposeImageFilter::~SkComposeImageFilter() { } @@ -52,6 +53,6 @@ bool SkComposeImageFilter::onFilterBounds(const SkIRect& src, outer->filterBounds(tmp, ctm, dst); } -SkComposeImageFilter::SkComposeImageFilter(SkFlattenableReadBuffer& buffer) +SkComposeImageFilter::SkComposeImageFilter(SkReadBuffer& buffer) : INHERITED(2, buffer) { } diff --git a/src/effects/SkCornerPathEffect.cpp b/src/effects/SkCornerPathEffect.cpp index f4c3147301..5b61e06df8 100644 --- a/src/effects/SkCornerPathEffect.cpp +++ b/src/effects/SkCornerPathEffect.cpp @@ -10,7 +10,8 @@ #include "SkCornerPathEffect.h" #include "SkPath.h" #include "SkPoint.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" SkCornerPathEffect::SkCornerPathEffect(SkScalar radius) : fRadius(radius) {} SkCornerPathEffect::~SkCornerPathEffect() {} @@ -127,11 +128,11 @@ DONE: return true; } -void SkCornerPathEffect::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkCornerPathEffect::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writeScalar(fRadius); } -SkCornerPathEffect::SkCornerPathEffect(SkFlattenableReadBuffer& buffer) { +SkCornerPathEffect::SkCornerPathEffect(SkReadBuffer& buffer) { fRadius = buffer.readScalar(); } diff --git a/src/effects/SkDashPathEffect.cpp b/src/effects/SkDashPathEffect.cpp index 52875bc87d..8be5f1d086 100644 --- a/src/effects/SkDashPathEffect.cpp +++ b/src/effects/SkDashPathEffect.cpp @@ -8,7 +8,8 @@ #include "SkDashPathEffect.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkPathMeasure.h" static inline int is_even(int x) { @@ -532,7 +533,7 @@ SkFlattenable::Factory SkDashPathEffect::getFactory() const { return fInitialDashLength < 0 ? NULL : CreateProc; } -void SkDashPathEffect::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkDashPathEffect::flatten(SkWriteBuffer& buffer) const { SkASSERT(fInitialDashLength >= 0); this->INHERITED::flatten(buffer); @@ -543,11 +544,11 @@ void SkDashPathEffect::flatten(SkFlattenableWriteBuffer& buffer) const { buffer.writeScalarArray(fIntervals, fCount); } -SkFlattenable* SkDashPathEffect::CreateProc(SkFlattenableReadBuffer& buffer) { +SkFlattenable* SkDashPathEffect::CreateProc(SkReadBuffer& buffer) { return SkNEW_ARGS(SkDashPathEffect, (buffer)); } -SkDashPathEffect::SkDashPathEffect(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) { +SkDashPathEffect::SkDashPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) { fInitialDashIndex = buffer.readInt(); fInitialDashLength = buffer.readScalar(); fIntervalLength = buffer.readScalar(); diff --git a/src/effects/SkDiscretePathEffect.cpp b/src/effects/SkDiscretePathEffect.cpp index b7ec1de3e0..de834424df 100644 --- a/src/effects/SkDiscretePathEffect.cpp +++ b/src/effects/SkDiscretePathEffect.cpp @@ -8,7 +8,8 @@ #include "SkDiscretePathEffect.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkPathMeasure.h" #include "SkRandom.h" @@ -70,13 +71,13 @@ bool SkDiscretePathEffect::filterPath(SkPath* dst, const SkPath& src, return true; } -void SkDiscretePathEffect::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkDiscretePathEffect::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writeScalar(fSegLength); buffer.writeScalar(fPerterb); } -SkDiscretePathEffect::SkDiscretePathEffect(SkFlattenableReadBuffer& buffer) { +SkDiscretePathEffect::SkDiscretePathEffect(SkReadBuffer& buffer) { fSegLength = buffer.readScalar(); fPerterb = buffer.readScalar(); } diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp index fc8d3dda72..e56cba1b4b 100644 --- a/src/effects/SkDisplacementMapEffect.cpp +++ b/src/effects/SkDisplacementMapEffect.cpp @@ -6,7 +6,8 @@ */ #include "SkDisplacementMapEffect.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkUnPreMultiply.h" #include "SkColorPriv.h" #if SK_SUPPORT_GPU @@ -172,7 +173,7 @@ SkDisplacementMapEffect::SkDisplacementMapEffect(ChannelSelectorType xChannelSel SkDisplacementMapEffect::~SkDisplacementMapEffect() { } -SkDisplacementMapEffect::SkDisplacementMapEffect(SkFlattenableReadBuffer& buffer) +SkDisplacementMapEffect::SkDisplacementMapEffect(SkReadBuffer& buffer) : INHERITED(2, buffer) { fXChannelSelector = (SkDisplacementMapEffect::ChannelSelectorType) buffer.readInt(); @@ -183,7 +184,7 @@ SkDisplacementMapEffect::SkDisplacementMapEffect(SkFlattenableReadBuffer& buffer SkScalarIsFinite(fScale)); } -void SkDisplacementMapEffect::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkDisplacementMapEffect::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writeInt((int) fXChannelSelector); buffer.writeInt((int) fYChannelSelector); diff --git a/src/effects/SkDropShadowImageFilter.cpp b/src/effects/SkDropShadowImageFilter.cpp index be99c673b4..0bc7e1211f 100644 --- a/src/effects/SkDropShadowImageFilter.cpp +++ b/src/effects/SkDropShadowImageFilter.cpp @@ -12,7 +12,8 @@ #include "SkCanvas.h" #include "SkColorMatrixFilter.h" #include "SkDevice.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" SkDropShadowImageFilter::SkDropShadowImageFilter(SkScalar dx, SkScalar dy, SkScalar sigma, SkColor color, SkImageFilter* input) : INHERITED(input) @@ -34,7 +35,7 @@ SkDropShadowImageFilter::SkDropShadowImageFilter(SkScalar dx, SkScalar dy, SkSca { } -SkDropShadowImageFilter::SkDropShadowImageFilter(SkFlattenableReadBuffer& buffer) +SkDropShadowImageFilter::SkDropShadowImageFilter(SkReadBuffer& buffer) : INHERITED(1, buffer) { fDx = buffer.readScalar(); fDy = buffer.readScalar(); @@ -47,7 +48,7 @@ SkDropShadowImageFilter::SkDropShadowImageFilter(SkFlattenableReadBuffer& buffer SkScalarIsFinite(fSigmaY)); } -void SkDropShadowImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const +void SkDropShadowImageFilter::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writeScalar(fDx); diff --git a/src/effects/SkEmbossMaskFilter.cpp b/src/effects/SkEmbossMaskFilter.cpp index 5c95eebe30..6747bf5b38 100644 --- a/src/effects/SkEmbossMaskFilter.cpp +++ b/src/effects/SkEmbossMaskFilter.cpp @@ -11,7 +11,8 @@ #include "SkBlurMaskFilter.h" #include "SkBlurMask.h" #include "SkEmbossMask.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkString.h" static inline int pin2byte(int n) { @@ -129,7 +130,7 @@ bool SkEmbossMaskFilter::filterMask(SkMask* dst, const SkMask& src, return true; } -SkEmbossMaskFilter::SkEmbossMaskFilter(SkFlattenableReadBuffer& buffer) +SkEmbossMaskFilter::SkEmbossMaskFilter(SkReadBuffer& buffer) : SkMaskFilter(buffer) { SkASSERT(buffer.getArrayCount() == sizeof(Light)); buffer.readByteArray(&fLight, sizeof(Light)); @@ -137,7 +138,7 @@ SkEmbossMaskFilter::SkEmbossMaskFilter(SkFlattenableReadBuffer& buffer) fBlurSigma = buffer.readScalar(); } -void SkEmbossMaskFilter::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkEmbossMaskFilter::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); Light tmpLight = fLight; diff --git a/src/effects/SkKernel33MaskFilter.cpp b/src/effects/SkKernel33MaskFilter.cpp index 821eebd785..353661de25 100644 --- a/src/effects/SkKernel33MaskFilter.cpp +++ b/src/effects/SkKernel33MaskFilter.cpp @@ -7,7 +7,8 @@ */ #include "SkKernel33MaskFilter.h" #include "SkColorPriv.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkString.h" SkMask::Format SkKernel33ProcMaskFilter::getFormat() const { @@ -75,12 +76,12 @@ bool SkKernel33ProcMaskFilter::filterMask(SkMask* dst, const SkMask& src, return true; } -void SkKernel33ProcMaskFilter::flatten(SkFlattenableWriteBuffer& wb) const { +void SkKernel33ProcMaskFilter::flatten(SkWriteBuffer& wb) const { this->INHERITED::flatten(wb); wb.writeInt(fPercent256); } -SkKernel33ProcMaskFilter::SkKernel33ProcMaskFilter(SkFlattenableReadBuffer& rb) +SkKernel33ProcMaskFilter::SkKernel33ProcMaskFilter(SkReadBuffer& rb) : SkMaskFilter(rb) { fPercent256 = rb.readInt(); } @@ -112,13 +113,13 @@ uint8_t SkKernel33MaskFilter::computeValue(uint8_t* const* srcRows) const { return (uint8_t)value; } -void SkKernel33MaskFilter::flatten(SkFlattenableWriteBuffer& wb) const { +void SkKernel33MaskFilter::flatten(SkWriteBuffer& wb) const { this->INHERITED::flatten(wb); wb.writeIntArray(&fKernel[0][0], 9); wb.writeInt(fShift); } -SkKernel33MaskFilter::SkKernel33MaskFilter(SkFlattenableReadBuffer& rb) +SkKernel33MaskFilter::SkKernel33MaskFilter(SkReadBuffer& rb) : SkKernel33ProcMaskFilter(rb) { SkDEBUGCODE(bool success = )rb.readIntArray(&fKernel[0][0], 9); SkASSERT(success); diff --git a/src/effects/SkLayerDrawLooper.cpp b/src/effects/SkLayerDrawLooper.cpp index 65f058b9d4..6c7c3cef0c 100644 --- a/src/effects/SkLayerDrawLooper.cpp +++ b/src/effects/SkLayerDrawLooper.cpp @@ -7,7 +7,8 @@ */ #include "SkCanvas.h" #include "SkColor.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkLayerDrawLooper.h" #include "SkString.h" #include "SkStringUtils.h" @@ -191,7 +192,7 @@ bool SkLayerDrawLooper::next(SkCanvas* canvas, SkPaint* paint) { /////////////////////////////////////////////////////////////////////////////// -void SkLayerDrawLooper::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkLayerDrawLooper::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); #ifdef SK_DEBUG @@ -220,7 +221,7 @@ void SkLayerDrawLooper::flatten(SkFlattenableWriteBuffer& buffer) const { } } -SkLayerDrawLooper::SkLayerDrawLooper(SkFlattenableReadBuffer& buffer) +SkLayerDrawLooper::SkLayerDrawLooper(SkReadBuffer& buffer) : INHERITED(buffer), fRecs(NULL), fTopRec(NULL), diff --git a/src/effects/SkLayerRasterizer.cpp b/src/effects/SkLayerRasterizer.cpp index ea5808c2b4..6381c4d694 100644 --- a/src/effects/SkLayerRasterizer.cpp +++ b/src/effects/SkLayerRasterizer.cpp @@ -9,7 +9,8 @@ #include "SkLayerRasterizer.h" #include "SkDraw.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkMask.h" #include "SkMaskFilter.h" #include "SkPaint.h" @@ -143,7 +144,7 @@ bool SkLayerRasterizer::onRasterize(const SkPath& path, const SkMatrix& matrix, return true; } -SkLayerRasterizer::SkLayerRasterizer(SkFlattenableReadBuffer& buffer) +SkLayerRasterizer::SkLayerRasterizer(SkReadBuffer& buffer) : SkRasterizer(buffer), fLayers(sizeof(SkLayerRasterizer_Rec)) { int count = buffer.readInt(); @@ -156,7 +157,7 @@ SkLayerRasterizer::SkLayerRasterizer(SkFlattenableReadBuffer& buffer) } } -void SkLayerRasterizer::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkLayerRasterizer::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writeInt(fLayers.count()); diff --git a/src/effects/SkLerpXfermode.cpp b/src/effects/SkLerpXfermode.cpp index d73ecf4c57..505ada0b9a 100644 --- a/src/effects/SkLerpXfermode.cpp +++ b/src/effects/SkLerpXfermode.cpp @@ -7,7 +7,8 @@ #include "SkLerpXfermode.h" #include "SkColorPriv.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkString.h" SkXfermode* SkLerpXfermode::Create(SkScalar scale) { @@ -22,12 +23,12 @@ SkXfermode* SkLerpXfermode::Create(SkScalar scale) { SkLerpXfermode::SkLerpXfermode(unsigned scale256) : fScale256(scale256) {} -SkLerpXfermode::SkLerpXfermode(SkFlattenableReadBuffer& buffer) +SkLerpXfermode::SkLerpXfermode(SkReadBuffer& buffer) : INHERITED(buffer) { fScale256 = buffer.readUInt(); } -void SkLerpXfermode::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkLerpXfermode::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writeUInt(fScale256); } diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp index 81c62fe6dc..d16ecb1bb3 100644 --- a/src/effects/SkLightingImageFilter.cpp +++ b/src/effects/SkLightingImageFilter.cpp @@ -8,9 +8,10 @@ #include "SkLightingImageFilter.h" #include "SkBitmap.h" #include "SkColorPriv.h" -#include "SkFlattenableBuffers.h" -#include "SkOrderedReadBuffer.h" -#include "SkOrderedWriteBuffer.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkTypes.h" #if SK_SUPPORT_GPU @@ -243,7 +244,7 @@ template <class LightingType, class LightType> void lightBitmap(const LightingTy } } -SkPoint3 readPoint3(SkFlattenableReadBuffer& buffer) { +SkPoint3 readPoint3(SkReadBuffer& buffer) { SkPoint3 point; point.fX = buffer.readScalar(); point.fY = buffer.readScalar(); @@ -254,7 +255,7 @@ SkPoint3 readPoint3(SkFlattenableReadBuffer& buffer) { return point; }; -void writePoint3(const SkPoint3& point, SkFlattenableWriteBuffer& buffer) { +void writePoint3(const SkPoint3& point, SkWriteBuffer& buffer) { buffer.writeScalar(point.fX); buffer.writeScalar(point.fY); buffer.writeScalar(point.fZ); @@ -268,8 +269,8 @@ public: SkScalar kd() const { return fKD; } protected: - explicit SkDiffuseLightingImageFilter(SkFlattenableReadBuffer& buffer); - virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE; + explicit SkDiffuseLightingImageFilter(SkReadBuffer& buffer); + virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE; virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&, SkBitmap* result, SkIPoint* offset) SK_OVERRIDE; #if SK_SUPPORT_GPU @@ -290,8 +291,8 @@ public: SkScalar shininess() const { return fShininess; } protected: - explicit SkSpecularLightingImageFilter(SkFlattenableReadBuffer& buffer); - virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE; + explicit SkSpecularLightingImageFilter(SkReadBuffer& buffer); + virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE; virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&, SkBitmap* result, SkIPoint* offset) SK_OVERRIDE; #if SK_SUPPORT_GPU @@ -527,8 +528,8 @@ public: virtual SkLight* transform(const SkMatrix& matrix) const = 0; // Defined below SkLight's subclasses. - void flattenLight(SkFlattenableWriteBuffer& buffer) const; - static SkLight* UnflattenLight(SkFlattenableReadBuffer& buffer); + void flattenLight(SkWriteBuffer& buffer) const; + static SkLight* UnflattenLight(SkReadBuffer& buffer); protected: SkLight(SkColor color) @@ -537,11 +538,11 @@ protected: SkIntToScalar(SkColorGetB(color))) {} SkLight(const SkPoint3& color) : fColor(color) {} - SkLight(SkFlattenableReadBuffer& buffer) { + SkLight(SkReadBuffer& buffer) { fColor = readPoint3(buffer); } - virtual void onFlattenLight(SkFlattenableWriteBuffer& buffer) const = 0; + virtual void onFlattenLight(SkWriteBuffer& buffer) const = 0; private: @@ -583,7 +584,7 @@ public: fDirection == o.fDirection; } - SkDistantLight(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) { + SkDistantLight(SkReadBuffer& buffer) : INHERITED(buffer) { fDirection = readPoint3(buffer); } @@ -594,7 +595,7 @@ protected: virtual SkLight* transform(const SkMatrix& matrix) const { return new SkDistantLight(direction(), color()); } - virtual void onFlattenLight(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE { + virtual void onFlattenLight(SkWriteBuffer& buffer) const SK_OVERRIDE { writePoint3(fDirection, buffer); } @@ -644,14 +645,14 @@ public: return new SkPointLight(location, color()); } - SkPointLight(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) { + SkPointLight(SkReadBuffer& buffer) : INHERITED(buffer) { fLocation = readPoint3(buffer); } protected: SkPointLight(const SkPoint3& location, const SkPoint3& color) : INHERITED(color), fLocation(location) {} - virtual void onFlattenLight(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE { + virtual void onFlattenLight(SkWriteBuffer& buffer) const SK_OVERRIDE { writePoint3(fLocation, buffer); } @@ -725,7 +726,7 @@ public: SkScalar coneScale() const { return fConeScale; } const SkPoint3& s() const { return fS; } - SkSpotLight(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) { + SkSpotLight(SkReadBuffer& buffer) : INHERITED(buffer) { fLocation = readPoint3(buffer); fTarget = readPoint3(buffer); fSpecularExponent = buffer.readScalar(); @@ -750,7 +751,7 @@ protected: fS(s) { } - virtual void onFlattenLight(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE { + virtual void onFlattenLight(SkWriteBuffer& buffer) const SK_OVERRIDE { writePoint3(fLocation, buffer); writePoint3(fTarget, buffer); buffer.writeScalar(fSpecularExponent); @@ -794,14 +795,14 @@ const SkScalar SkSpotLight::kSpecularExponentMax = 128.0f; /////////////////////////////////////////////////////////////////////////////// -void SkLight::flattenLight(SkFlattenableWriteBuffer& buffer) const { +void SkLight::flattenLight(SkWriteBuffer& buffer) const { // Write type first, then baseclass, then subclass. buffer.writeInt(this->type()); writePoint3(fColor, buffer); this->onFlattenLight(buffer); } -/*static*/ SkLight* SkLight::UnflattenLight(SkFlattenableReadBuffer& buffer) { +/*static*/ SkLight* SkLight::UnflattenLight(SkReadBuffer& buffer) { // Read type first. const SkLight::LightType type = (SkLight::LightType)buffer.readInt(); switch (type) { @@ -885,14 +886,14 @@ SkLightingImageFilter::~SkLightingImageFilter() { SkSafeUnref(fLight); } -SkLightingImageFilter::SkLightingImageFilter(SkFlattenableReadBuffer& buffer) +SkLightingImageFilter::SkLightingImageFilter(SkReadBuffer& buffer) : INHERITED(1, buffer) { fLight = SkLight::UnflattenLight(buffer); fSurfaceScale = buffer.readScalar(); buffer.validate(SkScalarIsFinite(fSurfaceScale)); } -void SkLightingImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkLightingImageFilter::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); fLight->flattenLight(buffer); buffer.writeScalar(fSurfaceScale); @@ -908,14 +909,14 @@ SkDiffuseLightingImageFilter::SkDiffuseLightingImageFilter(SkLight* light, SkSca { } -SkDiffuseLightingImageFilter::SkDiffuseLightingImageFilter(SkFlattenableReadBuffer& buffer) +SkDiffuseLightingImageFilter::SkDiffuseLightingImageFilter(SkReadBuffer& buffer) : INHERITED(buffer) { fKD = buffer.readScalar(); buffer.validate(SkScalarIsFinite(fKD) && (fKD >= 0)); } -void SkDiffuseLightingImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkDiffuseLightingImageFilter::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writeScalar(fKD); } @@ -998,7 +999,7 @@ SkSpecularLightingImageFilter::SkSpecularLightingImageFilter(SkLight* light, SkS { } -SkSpecularLightingImageFilter::SkSpecularLightingImageFilter(SkFlattenableReadBuffer& buffer) +SkSpecularLightingImageFilter::SkSpecularLightingImageFilter(SkReadBuffer& buffer) : INHERITED(buffer) { fKS = buffer.readScalar(); @@ -1007,7 +1008,7 @@ SkSpecularLightingImageFilter::SkSpecularLightingImageFilter(SkFlattenableReadBu SkScalarIsFinite(fShininess)); } -void SkSpecularLightingImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkSpecularLightingImageFilter::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writeScalar(fKS); buffer.writeScalar(fShininess); diff --git a/src/effects/SkLumaColorFilter.cpp b/src/effects/SkLumaColorFilter.cpp index fd4826b5a9..669af67026 100644 --- a/src/effects/SkLumaColorFilter.cpp +++ b/src/effects/SkLumaColorFilter.cpp @@ -44,11 +44,11 @@ SkLumaColorFilter::SkLumaColorFilter() : INHERITED() { } -SkLumaColorFilter::SkLumaColorFilter(SkFlattenableReadBuffer& buffer) +SkLumaColorFilter::SkLumaColorFilter(SkReadBuffer& buffer) : INHERITED(buffer) { } -void SkLumaColorFilter::flatten(SkFlattenableWriteBuffer&) const { +void SkLumaColorFilter::flatten(SkWriteBuffer&) const { } #ifdef SK_DEVELOPER diff --git a/src/effects/SkMagnifierImageFilter.cpp b/src/effects/SkMagnifierImageFilter.cpp index e6f3984bdd..a1c62b7720 100644 --- a/src/effects/SkMagnifierImageFilter.cpp +++ b/src/effects/SkMagnifierImageFilter.cpp @@ -8,7 +8,8 @@ #include "SkBitmap.h" #include "SkMagnifierImageFilter.h" #include "SkColorPriv.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkValidationUtils.h" //////////////////////////////////////////////////////////////////////////////// @@ -231,7 +232,7 @@ void GrMagnifierEffect::getConstantColorComponents(GrColor* color, uint32_t* val #endif //////////////////////////////////////////////////////////////////////////////// -SkMagnifierImageFilter::SkMagnifierImageFilter(SkFlattenableReadBuffer& buffer) +SkMagnifierImageFilter::SkMagnifierImageFilter(SkReadBuffer& buffer) : INHERITED(1, buffer) { float x = buffer.readScalar(); float y = buffer.readScalar(); @@ -269,7 +270,7 @@ bool SkMagnifierImageFilter::asNewEffect(GrEffectRef** effect, GrTexture* textur } #endif -void SkMagnifierImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkMagnifierImageFilter::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writeScalar(fSrcRect.x()); buffer.writeScalar(fSrcRect.y()); diff --git a/src/effects/SkMatrixConvolutionImageFilter.cpp b/src/effects/SkMatrixConvolutionImageFilter.cpp index a450040000..b73f623aec 100644 --- a/src/effects/SkMatrixConvolutionImageFilter.cpp +++ b/src/effects/SkMatrixConvolutionImageFilter.cpp @@ -8,7 +8,8 @@ #include "SkMatrixConvolutionImageFilter.h" #include "SkBitmap.h" #include "SkColorPriv.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkRect.h" #include "SkUnPreMultiply.h" @@ -57,7 +58,7 @@ SkMatrixConvolutionImageFilter::SkMatrixConvolutionImageFilter( SkASSERT(target.fY >= 0 && target.fY < kernelSize.fHeight); } -SkMatrixConvolutionImageFilter::SkMatrixConvolutionImageFilter(SkFlattenableReadBuffer& buffer) +SkMatrixConvolutionImageFilter::SkMatrixConvolutionImageFilter(SkReadBuffer& buffer) : INHERITED(1, buffer) { // We need to be able to read at most SK_MaxS32 bytes, so divide that // by the size of a scalar to know how many scalars we can read. @@ -88,7 +89,7 @@ SkMatrixConvolutionImageFilter::SkMatrixConvolutionImageFilter(SkFlattenableRead tile_mode_is_valid(fTileMode)); } -void SkMatrixConvolutionImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkMatrixConvolutionImageFilter::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writeInt(fKernelSize.fWidth); buffer.writeInt(fKernelSize.fHeight); diff --git a/src/effects/SkMergeImageFilter.cpp b/src/effects/SkMergeImageFilter.cpp index 9c0fa92a2b..086d8e68a1 100755 --- a/src/effects/SkMergeImageFilter.cpp +++ b/src/effects/SkMergeImageFilter.cpp @@ -8,7 +8,8 @@ #include "SkMergeImageFilter.h" #include "SkCanvas.h" #include "SkDevice.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkValidationUtils.h" /////////////////////////////////////////////////////////////////////////////// @@ -148,7 +149,7 @@ bool SkMergeImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src, return true; } -void SkMergeImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkMergeImageFilter::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writeBool(fModes != NULL); @@ -157,7 +158,7 @@ void SkMergeImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { } } -SkMergeImageFilter::SkMergeImageFilter(SkFlattenableReadBuffer& buffer) +SkMergeImageFilter::SkMergeImageFilter(SkReadBuffer& buffer) : INHERITED(-1, buffer) { bool hasModes = buffer.readBool(); if (hasModes) { diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp index 5008ad1814..7321eb25e2 100644 --- a/src/effects/SkMorphologyImageFilter.cpp +++ b/src/effects/SkMorphologyImageFilter.cpp @@ -8,7 +8,8 @@ #include "SkMorphologyImageFilter.h" #include "SkBitmap.h" #include "SkColorPriv.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkRect.h" #include "SkMorphology_opts.h" #if SK_SUPPORT_GPU @@ -20,7 +21,7 @@ #include "SkImageFilterUtils.h" #endif -SkMorphologyImageFilter::SkMorphologyImageFilter(SkFlattenableReadBuffer& buffer) +SkMorphologyImageFilter::SkMorphologyImageFilter(SkReadBuffer& buffer) : INHERITED(1, buffer) { fRadius.fWidth = buffer.readInt(); fRadius.fHeight = buffer.readInt(); @@ -36,7 +37,7 @@ SkMorphologyImageFilter::SkMorphologyImageFilter(int radiusX, } -void SkMorphologyImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkMorphologyImageFilter::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writeInt(fRadius.fWidth); buffer.writeInt(fRadius.fHeight); diff --git a/src/effects/SkOffsetImageFilter.cpp b/src/effects/SkOffsetImageFilter.cpp index e69cf411e3..16ce36f13c 100644 --- a/src/effects/SkOffsetImageFilter.cpp +++ b/src/effects/SkOffsetImageFilter.cpp @@ -9,7 +9,8 @@ #include "SkBitmap.h" #include "SkCanvas.h" #include "SkDevice.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkMatrix.h" #include "SkPaint.h" @@ -84,7 +85,7 @@ bool SkOffsetImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm return true; } -void SkOffsetImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkOffsetImageFilter::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writePoint(fOffset); } @@ -94,7 +95,7 @@ SkOffsetImageFilter::SkOffsetImageFilter(SkScalar dx, SkScalar dy, SkImageFilter fOffset.set(dx, dy); } -SkOffsetImageFilter::SkOffsetImageFilter(SkFlattenableReadBuffer& buffer) +SkOffsetImageFilter::SkOffsetImageFilter(SkReadBuffer& buffer) : INHERITED(1, buffer) { buffer.readPoint(&fOffset); buffer.validate(SkScalarIsFinite(fOffset.fX) && diff --git a/src/effects/SkPerlinNoiseShader.cpp b/src/effects/SkPerlinNoiseShader.cpp index cdf8baf682..48a25f9a5b 100644 --- a/src/effects/SkPerlinNoiseShader.cpp +++ b/src/effects/SkPerlinNoiseShader.cpp @@ -8,7 +8,8 @@ #include "SkDither.h" #include "SkPerlinNoiseShader.h" #include "SkColorFilter.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkShader.h" #include "SkUnPreMultiply.h" #include "SkString.h" @@ -293,7 +294,7 @@ SkPerlinNoiseShader::SkPerlinNoiseShader(SkPerlinNoiseShader::Type type, fMatrix.reset(); } -SkPerlinNoiseShader::SkPerlinNoiseShader(SkFlattenableReadBuffer& buffer) : +SkPerlinNoiseShader::SkPerlinNoiseShader(SkReadBuffer& buffer) : INHERITED(buffer), fPaintingData(NULL) { fType = (SkPerlinNoiseShader::Type) buffer.readInt(); fBaseFrequencyX = buffer.readScalar(); @@ -314,7 +315,7 @@ SkPerlinNoiseShader::~SkPerlinNoiseShader() { SkDELETE(fPaintingData); } -void SkPerlinNoiseShader::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkPerlinNoiseShader::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writeInt((int) fType); buffer.writeScalar(fBaseFrequencyX); diff --git a/src/effects/SkPictureImageFilter.cpp b/src/effects/SkPictureImageFilter.cpp index b054ee21a8..ae9576043f 100644 --- a/src/effects/SkPictureImageFilter.cpp +++ b/src/effects/SkPictureImageFilter.cpp @@ -8,7 +8,8 @@ #include "SkPictureImageFilter.h" #include "SkDevice.h" #include "SkCanvas.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkValidationUtils.h" SkPictureImageFilter::SkPictureImageFilter(SkPicture* picture) @@ -30,14 +31,14 @@ SkPictureImageFilter::~SkPictureImageFilter() { SkSafeUnref(fPicture); } -SkPictureImageFilter::SkPictureImageFilter(SkFlattenableReadBuffer& buffer) +SkPictureImageFilter::SkPictureImageFilter(SkReadBuffer& buffer) : INHERITED(0, buffer), fPicture(NULL) { // FIXME: unflatten picture here. buffer.readRect(&fRect); } -void SkPictureImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkPictureImageFilter::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); // FIXME: flatten picture here. buffer.writeRect(fRect); diff --git a/src/effects/SkPixelXorXfermode.cpp b/src/effects/SkPixelXorXfermode.cpp index b9c96dc382..eaf7757453 100644 --- a/src/effects/SkPixelXorXfermode.cpp +++ b/src/effects/SkPixelXorXfermode.cpp @@ -9,7 +9,8 @@ #include "SkPixelXorXfermode.h" #include "SkColorPriv.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkString.h" // we always return an opaque color, 'cause I don't know what to do with @@ -20,12 +21,12 @@ SkPMColor SkPixelXorXfermode::xferColor(SkPMColor src, SkPMColor dst) const { return res; } -void SkPixelXorXfermode::flatten(SkFlattenableWriteBuffer& wb) const { +void SkPixelXorXfermode::flatten(SkWriteBuffer& wb) const { this->INHERITED::flatten(wb); wb.writeColor(fOpColor); } -SkPixelXorXfermode::SkPixelXorXfermode(SkFlattenableReadBuffer& rb) +SkPixelXorXfermode::SkPixelXorXfermode(SkReadBuffer& rb) : INHERITED(rb) { fOpColor = rb.readColor(); } diff --git a/src/effects/SkRectShaderImageFilter.cpp b/src/effects/SkRectShaderImageFilter.cpp index f55df2c577..272a4af2b9 100644 --- a/src/effects/SkRectShaderImageFilter.cpp +++ b/src/effects/SkRectShaderImageFilter.cpp @@ -9,7 +9,8 @@ #include "SkBitmap.h" #include "SkCanvas.h" #include "SkDevice.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkShader.h" SkRectShaderImageFilter* SkRectShaderImageFilter::Create(SkShader* s, const SkRect& rect) { @@ -34,12 +35,12 @@ SkRectShaderImageFilter::SkRectShaderImageFilter(SkShader* s, const CropRect* cr s->ref(); } -SkRectShaderImageFilter::SkRectShaderImageFilter(SkFlattenableReadBuffer& buffer) +SkRectShaderImageFilter::SkRectShaderImageFilter(SkReadBuffer& buffer) : INHERITED(1, buffer) { fShader = buffer.readShader(); } -void SkRectShaderImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkRectShaderImageFilter::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writeFlattenable(fShader); diff --git a/src/effects/SkResizeImageFilter.cpp b/src/effects/SkResizeImageFilter.cpp index 4d700901ef..983dd157cc 100644 --- a/src/effects/SkResizeImageFilter.cpp +++ b/src/effects/SkResizeImageFilter.cpp @@ -10,7 +10,8 @@ #include "SkCanvas.h" #include "SkDevice.h" #include "SkColorPriv.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkMatrix.h" #include "SkRect.h" @@ -22,14 +23,14 @@ SkResizeImageFilter::SkResizeImageFilter(SkScalar sx, SkScalar sy, SkPaint::Filt fFilterLevel(filterLevel) { } -SkResizeImageFilter::SkResizeImageFilter(SkFlattenableReadBuffer& buffer) +SkResizeImageFilter::SkResizeImageFilter(SkReadBuffer& buffer) : INHERITED(1, buffer) { fSx = buffer.readScalar(); fSy = buffer.readScalar(); fFilterLevel = static_cast<SkPaint::FilterLevel>(buffer.readInt()); } -void SkResizeImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkResizeImageFilter::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writeScalar(fSx); buffer.writeScalar(fSy); diff --git a/src/effects/SkTableColorFilter.cpp b/src/effects/SkTableColorFilter.cpp index 2872ed14b0..eb3dbc3587 100644 --- a/src/effects/SkTableColorFilter.cpp +++ b/src/effects/SkTableColorFilter.cpp @@ -2,7 +2,8 @@ #include "SkBitmap.h" #include "SkTableColorFilter.h" #include "SkColorPriv.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkUnPreMultiply.h" #include "SkString.h" @@ -60,8 +61,8 @@ public: }; protected: - SkTable_ColorFilter(SkFlattenableReadBuffer& buffer); - virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; + SkTable_ColorFilter(SkReadBuffer& buffer); + virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; private: mutable const SkBitmap* fBitmap; // lazily allocated @@ -166,7 +167,7 @@ static const uint8_t gCountNibBits[] = { #include "SkPackBits.h" -void SkTable_ColorFilter::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkTable_ColorFilter::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); uint8_t storage[5*256]; @@ -180,7 +181,7 @@ void SkTable_ColorFilter::flatten(SkFlattenableWriteBuffer& buffer) const { buffer.writeByteArray(storage, size); } -SkTable_ColorFilter::SkTable_ColorFilter(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) { +SkTable_ColorFilter::SkTable_ColorFilter(SkReadBuffer& buffer) : INHERITED(buffer) { fBitmap = NULL; uint8_t storage[5*256]; diff --git a/src/effects/SkTableMaskFilter.cpp b/src/effects/SkTableMaskFilter.cpp index eb80abb059..27280d3364 100644 --- a/src/effects/SkTableMaskFilter.cpp +++ b/src/effects/SkTableMaskFilter.cpp @@ -8,7 +8,8 @@ #include "SkTableMaskFilter.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkString.h" SkTableMaskFilter::SkTableMaskFilter() { @@ -69,12 +70,12 @@ SkMask::Format SkTableMaskFilter::getFormat() const { return SkMask::kA8_Format; } -void SkTableMaskFilter::flatten(SkFlattenableWriteBuffer& wb) const { +void SkTableMaskFilter::flatten(SkWriteBuffer& wb) const { this->INHERITED::flatten(wb); wb.writeByteArray(fTable, 256); } -SkTableMaskFilter::SkTableMaskFilter(SkFlattenableReadBuffer& rb) +SkTableMaskFilter::SkTableMaskFilter(SkReadBuffer& rb) : INHERITED(rb) { SkASSERT(256 == rb.getArrayCount()); rb.readByteArray(fTable, 256); diff --git a/src/effects/SkTestImageFilters.cpp b/src/effects/SkTestImageFilters.cpp index cc6d1adc43..96226f5d25 100755 --- a/src/effects/SkTestImageFilters.cpp +++ b/src/effects/SkTestImageFilters.cpp @@ -2,7 +2,8 @@ #include "SkTestImageFilters.h" #include "SkCanvas.h" #include "SkDevice.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" // Simple helper canvas that "takes ownership" of the provided device, so that // when this canvas goes out of scope, so will its device. Could be replaced @@ -70,13 +71,13 @@ bool SkDownSampleImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src, return true; } -void SkDownSampleImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkDownSampleImageFilter::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writeScalar(fScale); } -SkDownSampleImageFilter::SkDownSampleImageFilter(SkFlattenableReadBuffer& buffer) +SkDownSampleImageFilter::SkDownSampleImageFilter(SkReadBuffer& buffer) : INHERITED(1, buffer) { fScale = buffer.readScalar(); buffer.validate(SkScalarIsFinite(fScale)); diff --git a/src/effects/SkTileImageFilter.cpp b/src/effects/SkTileImageFilter.cpp index 08dfec4493..f0b7fda869 100644 --- a/src/effects/SkTileImageFilter.cpp +++ b/src/effects/SkTileImageFilter.cpp @@ -9,7 +9,8 @@ #include "SkBitmap.h" #include "SkCanvas.h" #include "SkDevice.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkMatrix.h" #include "SkPaint.h" #include "SkShader.h" @@ -73,14 +74,14 @@ bool SkTileImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src, const S return true; } -SkTileImageFilter::SkTileImageFilter(SkFlattenableReadBuffer& buffer) +SkTileImageFilter::SkTileImageFilter(SkReadBuffer& buffer) : INHERITED(1, buffer) { buffer.readRect(&fSrcRect); buffer.readRect(&fDstRect); buffer.validate(buffer.isValid() && SkIsValidRect(fSrcRect) && SkIsValidRect(fDstRect)); } -void SkTileImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkTileImageFilter::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writeRect(fSrcRect); buffer.writeRect(fDstRect); diff --git a/src/effects/SkXfermodeImageFilter.cpp b/src/effects/SkXfermodeImageFilter.cpp index beb1de211c..b3ab9ffa93 100644 --- a/src/effects/SkXfermodeImageFilter.cpp +++ b/src/effects/SkXfermodeImageFilter.cpp @@ -9,7 +9,8 @@ #include "SkCanvas.h" #include "SkDevice.h" #include "SkColorPriv.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkXfermode.h" #if SK_SUPPORT_GPU #include "GrContext.h" @@ -32,12 +33,12 @@ SkXfermodeImageFilter::~SkXfermodeImageFilter() { SkSafeUnref(fMode); } -SkXfermodeImageFilter::SkXfermodeImageFilter(SkFlattenableReadBuffer& buffer) +SkXfermodeImageFilter::SkXfermodeImageFilter(SkReadBuffer& buffer) : INHERITED(2, buffer) { fMode = buffer.readXfermode(); } -void SkXfermodeImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkXfermodeImageFilter::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writeFlattenable(fMode); } diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp index 6925ad2e4b..1da259afe1 100644 --- a/src/effects/gradients/SkGradientShader.cpp +++ b/src/effects/gradients/SkGradientShader.cpp @@ -143,7 +143,7 @@ static uint32_t unpack_flags(uint32_t packed) { return packed >> 4; } -SkGradientShaderBase::SkGradientShaderBase(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) { +SkGradientShaderBase::SkGradientShaderBase(SkReadBuffer& buffer) : INHERITED(buffer) { fCacheAlpha = 256; fMapper = buffer.readUnitMapper(); @@ -205,7 +205,7 @@ void SkGradientShaderBase::initCommon() { fColorsAreOpaque = colorAlpha == 0xFF; } -void SkGradientShaderBase::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkGradientShaderBase::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writeFlattenable(fMapper); buffer.writeColorArray(fOrigColors, fColorCount); diff --git a/src/effects/gradients/SkGradientShaderPriv.h b/src/effects/gradients/SkGradientShaderPriv.h index f45b7773ea..184ef8e883 100644 --- a/src/effects/gradients/SkGradientShaderPriv.h +++ b/src/effects/gradients/SkGradientShaderPriv.h @@ -11,7 +11,8 @@ #include "SkGradientShader.h" #include "SkClampRange.h" #include "SkColorPriv.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkMallocPixelRef.h" #include "SkUnitMapper.h" #include "SkUtils.h" @@ -129,8 +130,8 @@ public: protected: - SkGradientShaderBase(SkFlattenableReadBuffer& ); - virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; + SkGradientShaderBase(SkReadBuffer& ); + virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; SK_DEVELOPER_TO_STRING() SkUnitMapper* fMapper; diff --git a/src/effects/gradients/SkLinearGradient.cpp b/src/effects/gradients/SkLinearGradient.cpp index 70452962ac..bd66f7ca84 100644 --- a/src/effects/gradients/SkLinearGradient.cpp +++ b/src/effects/gradients/SkLinearGradient.cpp @@ -59,13 +59,13 @@ SkLinearGradient::SkLinearGradient(const SkPoint pts[2], const Descriptor& desc) pts_to_unit_matrix(pts, &fPtsToUnit); } -SkLinearGradient::SkLinearGradient(SkFlattenableReadBuffer& buffer) +SkLinearGradient::SkLinearGradient(SkReadBuffer& buffer) : INHERITED(buffer) , fStart(buffer.readPoint()) , fEnd(buffer.readPoint()) { } -void SkLinearGradient::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkLinearGradient::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writePoint(fStart); buffer.writePoint(fEnd); diff --git a/src/effects/gradients/SkLinearGradient.h b/src/effects/gradients/SkLinearGradient.h index 24c6caba7b..ed0c70b755 100644 --- a/src/effects/gradients/SkLinearGradient.h +++ b/src/effects/gradients/SkLinearGradient.h @@ -26,8 +26,8 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLinearGradient) protected: - SkLinearGradient(SkFlattenableReadBuffer& buffer); - virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE; + SkLinearGradient(SkReadBuffer& buffer); + virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE; private: typedef SkGradientShaderBase INHERITED; diff --git a/src/effects/gradients/SkRadialGradient.cpp b/src/effects/gradients/SkRadialGradient.cpp index 50e58bc2dc..efa82f49bf 100644 --- a/src/effects/gradients/SkRadialGradient.cpp +++ b/src/effects/gradients/SkRadialGradient.cpp @@ -239,13 +239,13 @@ SkShader::GradientType SkRadialGradient::asAGradient(GradientInfo* info) const { return kRadial_GradientType; } -SkRadialGradient::SkRadialGradient(SkFlattenableReadBuffer& buffer) +SkRadialGradient::SkRadialGradient(SkReadBuffer& buffer) : INHERITED(buffer), fCenter(buffer.readPoint()), fRadius(buffer.readScalar()) { } -void SkRadialGradient::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkRadialGradient::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writePoint(fCenter); buffer.writeScalar(fRadius); diff --git a/src/effects/gradients/SkRadialGradient.h b/src/effects/gradients/SkRadialGradient.h index fa0a969cf2..4ff3951b90 100644 --- a/src/effects/gradients/SkRadialGradient.h +++ b/src/effects/gradients/SkRadialGradient.h @@ -28,8 +28,8 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkRadialGradient) protected: - SkRadialGradient(SkFlattenableReadBuffer& buffer); - virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE; + SkRadialGradient(SkReadBuffer& buffer); + virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE; private: typedef SkGradientShaderBase INHERITED; diff --git a/src/effects/gradients/SkSweepGradient.cpp b/src/effects/gradients/SkSweepGradient.cpp index d60d8b6050..494569df5d 100644 --- a/src/effects/gradients/SkSweepGradient.cpp +++ b/src/effects/gradients/SkSweepGradient.cpp @@ -42,12 +42,12 @@ SkShader::GradientType SkSweepGradient::asAGradient(GradientInfo* info) const { return kSweep_GradientType; } -SkSweepGradient::SkSweepGradient(SkFlattenableReadBuffer& buffer) +SkSweepGradient::SkSweepGradient(SkReadBuffer& buffer) : INHERITED(buffer), fCenter(buffer.readPoint()) { } -void SkSweepGradient::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkSweepGradient::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writePoint(fCenter); } diff --git a/src/effects/gradients/SkSweepGradient.h b/src/effects/gradients/SkSweepGradient.h index 8b685bc209..18d5ddc0ef 100644 --- a/src/effects/gradients/SkSweepGradient.h +++ b/src/effects/gradients/SkSweepGradient.h @@ -29,8 +29,8 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSweepGradient) protected: - SkSweepGradient(SkFlattenableReadBuffer& buffer); - virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE; + SkSweepGradient(SkReadBuffer& buffer); + virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE; private: typedef SkGradientShaderBase INHERITED; diff --git a/src/effects/gradients/SkTwoPointConicalGradient.cpp b/src/effects/gradients/SkTwoPointConicalGradient.cpp index a9bd1c2762..6a503d2fb7 100644 --- a/src/effects/gradients/SkTwoPointConicalGradient.cpp +++ b/src/effects/gradients/SkTwoPointConicalGradient.cpp @@ -310,7 +310,7 @@ SkShader::GradientType SkTwoPointConicalGradient::asAGradient( } SkTwoPointConicalGradient::SkTwoPointConicalGradient( - SkFlattenableReadBuffer& buffer) + SkReadBuffer& buffer) : INHERITED(buffer), fCenter1(buffer.readPoint()), fCenter2(buffer.readPoint()), @@ -320,7 +320,7 @@ SkTwoPointConicalGradient::SkTwoPointConicalGradient( }; void SkTwoPointConicalGradient::flatten( - SkFlattenableWriteBuffer& buffer) const { + SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writePoint(fCenter1); buffer.writePoint(fCenter2); diff --git a/src/effects/gradients/SkTwoPointConicalGradient.h b/src/effects/gradients/SkTwoPointConicalGradient.h index 1358f0b2ac..20a3da8b2e 100644 --- a/src/effects/gradients/SkTwoPointConicalGradient.h +++ b/src/effects/gradients/SkTwoPointConicalGradient.h @@ -70,8 +70,8 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTwoPointConicalGradient) protected: - SkTwoPointConicalGradient(SkFlattenableReadBuffer& buffer); - virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE; + SkTwoPointConicalGradient(SkReadBuffer& buffer); + virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE; private: typedef SkGradientShaderBase INHERITED; diff --git a/src/effects/gradients/SkTwoPointRadialGradient.cpp b/src/effects/gradients/SkTwoPointRadialGradient.cpp index 207f3db653..103e7d41c9 100644 --- a/src/effects/gradients/SkTwoPointRadialGradient.cpp +++ b/src/effects/gradients/SkTwoPointRadialGradient.cpp @@ -334,7 +334,7 @@ void SkTwoPointRadialGradient::toString(SkString* str) const { #endif SkTwoPointRadialGradient::SkTwoPointRadialGradient( - SkFlattenableReadBuffer& buffer) + SkReadBuffer& buffer) : INHERITED(buffer), fCenter1(buffer.readPoint()), fCenter2(buffer.readPoint()), @@ -344,7 +344,7 @@ SkTwoPointRadialGradient::SkTwoPointRadialGradient( }; void SkTwoPointRadialGradient::flatten( - SkFlattenableWriteBuffer& buffer) const { + SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writePoint(fCenter1); buffer.writePoint(fCenter2); diff --git a/src/effects/gradients/SkTwoPointRadialGradient.h b/src/effects/gradients/SkTwoPointRadialGradient.h index 444c23dd70..e050804b46 100644 --- a/src/effects/gradients/SkTwoPointRadialGradient.h +++ b/src/effects/gradients/SkTwoPointRadialGradient.h @@ -37,8 +37,8 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTwoPointRadialGradient) protected: - SkTwoPointRadialGradient(SkFlattenableReadBuffer& buffer); - virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE; + SkTwoPointRadialGradient(SkReadBuffer& buffer); + virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE; private: typedef SkGradientShaderBase INHERITED; diff --git a/src/images/SkImageRef.cpp b/src/images/SkImageRef.cpp index 2c1ec38116..ea129642db 100644 --- a/src/images/SkImageRef.cpp +++ b/src/images/SkImageRef.cpp @@ -7,7 +7,8 @@ */ #include "SkImageRef.h" #include "SkBitmap.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkImageDecoder.h" #include "SkStream.h" #include "SkTemplates.h" @@ -162,7 +163,7 @@ size_t SkImageRef::ramUsed() const { /////////////////////////////////////////////////////////////////////////////// -SkImageRef::SkImageRef(SkFlattenableReadBuffer& buffer, SkBaseMutex* mutex) +SkImageRef::SkImageRef(SkReadBuffer& buffer, SkBaseMutex* mutex) : INHERITED(buffer, mutex), fErrorInDecoding(false) { fSampleSize = buffer.readInt(); fDoDither = buffer.readBool(); @@ -179,7 +180,7 @@ SkImageRef::SkImageRef(SkFlattenableReadBuffer& buffer, SkBaseMutex* mutex) fFactory = NULL; } -void SkImageRef::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkImageRef::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writeInt(fSampleSize); diff --git a/src/images/SkImageRef_GlobalPool.cpp b/src/images/SkImageRef_GlobalPool.cpp index f91cebabbf..2659e8b471 100644 --- a/src/images/SkImageRef_GlobalPool.cpp +++ b/src/images/SkImageRef_GlobalPool.cpp @@ -64,7 +64,7 @@ void SkImageRef_GlobalPool::onUnlockPixels() { GetGlobalPool()->canLosePixels(this); } -SkImageRef_GlobalPool::SkImageRef_GlobalPool(SkFlattenableReadBuffer& buffer) +SkImageRef_GlobalPool::SkImageRef_GlobalPool(SkReadBuffer& buffer) : INHERITED(buffer, &gGlobalPoolMutex) { SkASSERT(&gGlobalPoolMutex == this->mutex()); SkAutoMutexAcquire ac(gGlobalPoolMutex); diff --git a/src/images/SkImageRef_ashmem.cpp b/src/images/SkImageRef_ashmem.cpp index 14dedf8bd3..3c7d5c1bbf 100644 --- a/src/images/SkImageRef_ashmem.cpp +++ b/src/images/SkImageRef_ashmem.cpp @@ -7,7 +7,8 @@ #include "SkImageRef_ashmem.h" #include "SkImageDecoder.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" #include "SkThread.h" #include "android/ashmem.h" @@ -210,12 +211,12 @@ void SkImageRef_ashmem::onUnlockPixels() { fBitmap.setPixels(NULL, NULL); } -void SkImageRef_ashmem::flatten(SkFlattenableWriteBuffer& buffer) const { +void SkImageRef_ashmem::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); buffer.writeString(getURI()); } -SkImageRef_ashmem::SkImageRef_ashmem(SkFlattenableReadBuffer& buffer) +SkImageRef_ashmem::SkImageRef_ashmem(SkReadBuffer& buffer) : INHERITED(buffer) { fRec.fFD = -1; fRec.fAddr = NULL; diff --git a/src/images/SkImageRef_ashmem.h b/src/images/SkImageRef_ashmem.h index fa30baf99c..cf6e903837 100644 --- a/src/images/SkImageRef_ashmem.h +++ b/src/images/SkImageRef_ashmem.h @@ -25,8 +25,8 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkImageRef_ashmem) protected: - SkImageRef_ashmem(SkFlattenableReadBuffer&); - virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; + SkImageRef_ashmem(SkReadBuffer&); + virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; virtual bool onDecode(SkImageDecoder* codec, SkStreamRewindable* stream, SkBitmap* bitmap, SkBitmap::Config config, diff --git a/src/lazy/SkCachingPixelRef.h b/src/lazy/SkCachingPixelRef.h index b73a2ca443..9fc71c3616 100644 --- a/src/lazy/SkCachingPixelRef.h +++ b/src/lazy/SkCachingPixelRef.h @@ -49,9 +49,9 @@ protected: return fImageGenerator->refEncodedData(); } // No need to flatten this object. When flattening an SkBitmap, - // SkOrderedWriteBuffer will check the encoded data and write that + // SkWriteBuffer will check the encoded data and write that // instead. - // Future implementations of SkFlattenableWriteBuffer will need to + // Future implementations of SkWriteBuffer will need to // special case for onRefEncodedData as well. SK_DECLARE_UNFLATTENABLE_OBJECT() diff --git a/src/opts/SkXfermode_opts_arm_neon.cpp b/src/opts/SkXfermode_opts_arm_neon.cpp index 6a79b73726..da14e6631d 100644 --- a/src/opts/SkXfermode_opts_arm_neon.cpp +++ b/src/opts/SkXfermode_opts_arm_neon.cpp @@ -690,7 +690,7 @@ typedef uint8x8x4_t (*SkXfermodeProcSIMD)(uint8x8x4_t src, uint8x8x4_t dst); extern SkXfermodeProcSIMD gNEONXfermodeProcs[]; -SkNEONProcCoeffXfermode::SkNEONProcCoeffXfermode(SkFlattenableReadBuffer& buffer) +SkNEONProcCoeffXfermode::SkNEONProcCoeffXfermode(SkReadBuffer& buffer) : INHERITED(buffer) { fProcSIMD = reinterpret_cast<void*>(gNEONXfermodeProcs[this->getMode()]); } diff --git a/src/opts/SkXfermode_opts_arm_neon.h b/src/opts/SkXfermode_opts_arm_neon.h index a8d438195e..d87748464d 100644 --- a/src/opts/SkXfermode_opts_arm_neon.h +++ b/src/opts/SkXfermode_opts_arm_neon.h @@ -18,7 +18,7 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkNEONProcCoeffXfermode) private: - SkNEONProcCoeffXfermode(SkFlattenableReadBuffer& buffer); + SkNEONProcCoeffXfermode(SkReadBuffer& buffer); // void* is used to avoid pulling arm_neon.h in the core and having to build // it with -mfpu=neon. diff --git a/src/pipe/SkGPipeRead.cpp b/src/pipe/SkGPipeRead.cpp index fc5ab5a2aa..513a34d639 100644 --- a/src/pipe/SkGPipeRead.cpp +++ b/src/pipe/SkGPipeRead.cpp @@ -20,7 +20,7 @@ #include "SkDrawLooper.h" #include "SkImageFilter.h" #include "SkMaskFilter.h" -#include "SkOrderedReadBuffer.h" +#include "SkReadBuffer.h" #include "SkPathEffect.h" #include "SkRasterizer.h" #include "SkRRect.h" @@ -105,7 +105,7 @@ public: return fFlags; } - void setReader(SkOrderedReadBuffer* reader) { + void setReader(SkReadBuffer* reader) { fReader = reader; this->updateReader(); } @@ -156,7 +156,7 @@ public: } /** - * Override of SkBitmapHeapReader, so that SkOrderedReadBuffer can use + * Override of SkBitmapHeapReader, so that SkReadBuffer can use * these SkBitmaps for bitmap shaders. Used only in cross process mode * without a shared heap. */ @@ -203,7 +203,7 @@ private: } bool crossProcess = SkToBool(fFlags & SkGPipeWriter::kCrossProcess_Flag); fReader->setFlags(SkSetClearMask(fReader->getFlags(), crossProcess, - SkFlattenableReadBuffer::kCrossProcess_Flag)); + SkReadBuffer::kCrossProcess_Flag)); if (crossProcess) { fReader->setFactoryArray(&fFactoryArray); } else { @@ -216,7 +216,7 @@ private: fReader->setBitmapStorage(fSharedHeap); } } - SkOrderedReadBuffer* fReader; + SkReadBuffer* fReader; SkPaint fPaint; SkTDArray<SkFlattenable*> fFlatArray; SkTDArray<SkTypeface*> fTypefaces; @@ -696,7 +696,7 @@ static void annotation_rp(SkCanvas*, SkReader32* reader, uint32_t op32, const size_t size = DrawOp_unpackData(op32); if (size > 0) { - SkOrderedReadBuffer buffer(reader->skip(size), size); + SkReadBuffer buffer(reader->skip(size), size); p->setAnnotation(SkNEW_ARGS(SkAnnotation, (buffer)))->unref(); SkASSERT(buffer.offset() == size); } else { @@ -857,7 +857,7 @@ SkGPipeReader::Status SkGPipeReader::playback(const void* data, size_t length, SkASSERT(SK_ARRAY_COUNT(gReadTable) == (kDone_DrawOp + 1)); const ReadProc* table = gReadTable; - SkOrderedReadBuffer reader(data, length); + SkReadBuffer reader(data, length); reader.setBitmapDecoder(fProc); SkCanvas* canvas = fCanvas; Status status = kEOF_Status; diff --git a/src/pipe/SkGPipeWrite.cpp b/src/pipe/SkGPipeWrite.cpp index 2948f25d27..ce58ca6122 100644 --- a/src/pipe/SkGPipeWrite.cpp +++ b/src/pipe/SkGPipeWrite.cpp @@ -17,7 +17,7 @@ #include "SkGPipePriv.h" #include "SkImageFilter.h" #include "SkMaskFilter.h" -#include "SkOrderedWriteBuffer.h" +#include "SkWriteBuffer.h" #include "SkPaint.h" #include "SkPathEffect.h" #include "SkPictureFlat.h" @@ -75,7 +75,7 @@ public: SkASSERT((isCrossProcess && fset != NULL) || (!isCrossProcess && NULL == fset)); if (isCrossProcess) { this->setNamedFactorySet(fset); - this->setWriteBufferFlags(SkFlattenableWriteBuffer::kCrossProcess_Flag); + this->setWriteBufferFlags(SkWriteBuffer::kCrossProcess_Flag); } } @@ -151,7 +151,7 @@ const SkFlatData* FlattenableHeap::flatToReplace() const { /////////////////////////////////////////////////////////////////////////////// struct SkFlattenableTraits { - static void flatten(SkOrderedWriteBuffer& buffer, const SkFlattenable& flattenable) { + static void flatten(SkWriteBuffer& buffer, const SkFlattenable& flattenable) { buffer.writeFlattenable(&flattenable); } // No need to define unflatten if we never call it. @@ -370,11 +370,11 @@ void SkGPipeCanvas::flattenFactoryNames() { bool SkGPipeCanvas::shuttleBitmap(const SkBitmap& bm, int32_t slot) { SkASSERT(shouldFlattenBitmaps(fFlags)); - SkOrderedWriteBuffer buffer; + SkWriteBuffer buffer; buffer.setNamedFactoryRecorder(fFactorySet); buffer.writeBitmap(bm); this->flattenFactoryNames(); - uint32_t size = buffer.size(); + uint32_t size = buffer.bytesWritten(); if (this->needOpBytes(size)) { this->writeOp(kDef_Bitmap_DrawOp, 0, slot); void* dst = static_cast<void*>(fWriter.reserve(size)); @@ -1146,7 +1146,7 @@ void SkGPipeCanvas::writePaint(const SkPaint& paint) { this->writeOp(kSetAnnotation_DrawOp, 0, 0); } } else { - SkOrderedWriteBuffer buffer; + SkWriteBuffer buffer; paint.getAnnotation()->writeToBuffer(buffer); const size_t size = buffer.bytesWritten(); if (this->needOpBytes(size)) { diff --git a/src/utils/SkUnitMappers.cpp b/src/utils/SkUnitMappers.cpp index f86a4542db..336a26e164 100644 --- a/src/utils/SkUnitMappers.cpp +++ b/src/utils/SkUnitMappers.cpp @@ -6,7 +6,8 @@ * found in the LICENSE file. */ #include "SkUnitMappers.h" -#include "SkFlattenableBuffers.h" +#include "SkReadBuffer.h" +#include "SkWriteBuffer.h" SkDiscreteMapper::SkDiscreteMapper(int segments) { @@ -29,13 +30,13 @@ uint16_t SkDiscreteMapper::mapUnit16(uint16_t input) { return SkToU16(x); } -SkDiscreteMapper::SkDiscreteMapper(SkFlattenableReadBuffer& rb) +SkDiscreteMapper::SkDiscreteMapper(SkReadBuffer& rb) : SkUnitMapper(rb) { fSegments = rb.readInt(); fScale = rb.read32(); } -void SkDiscreteMapper::flatten(SkFlattenableWriteBuffer& wb) const { +void SkDiscreteMapper::flatten(SkWriteBuffer& wb) const { this->INHERITED::flatten(wb); wb.writeInt(fSegments); @@ -56,5 +57,5 @@ uint16_t SkCosineMapper::mapUnit16(uint16_t input) return SkToU16(x); } -SkCosineMapper::SkCosineMapper(SkFlattenableReadBuffer& rb) +SkCosineMapper::SkCosineMapper(SkReadBuffer& rb) : SkUnitMapper(rb) {} |