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
This commit is contained in:
commit-bot@chromium.org 2014-01-30 18:58:24 +00:00
Родитель 5fbccb35eb
Коммит 8b0e8ac5f5
182 изменённых файлов: 1079 добавлений и 1326 удалений

Просмотреть файл

@ -27,7 +27,7 @@ protected:
return false; return false;
} }
FailImageFilter(SkFlattenableReadBuffer& buffer) FailImageFilter(SkReadBuffer& buffer)
: INHERITED(1, buffer) {} : INHERITED(1, buffer) {}
private: private:
@ -51,7 +51,7 @@ protected:
return true; return true;
} }
IdentityImageFilter(SkFlattenableReadBuffer& buffer) IdentityImageFilter(SkReadBuffer& buffer)
: INHERITED(1, buffer) {} : INHERITED(1, buffer) {}
private: private:

Просмотреть файл

@ -13,7 +13,8 @@
#include "SkColorFilter.h" #include "SkColorFilter.h"
#include "SkColorFilterImageFilter.h" #include "SkColorFilterImageFilter.h"
#include "SkColorMatrixFilter.h" #include "SkColorMatrixFilter.h"
#include "SkFlattenableBuffers.h" #include "SkReadBuffer.h"
#include "SkWriteBuffer.h"
#include "SkMergeImageFilter.h" #include "SkMergeImageFilter.h"
#include "SkMorphologyImageFilter.h" #include "SkMorphologyImageFilter.h"
#include "SkOnce.h" #include "SkOnce.h"
@ -57,13 +58,13 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SimpleOffsetFilter); SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SimpleOffsetFilter);
protected: protected:
explicit SimpleOffsetFilter(SkFlattenableReadBuffer& buffer) explicit SimpleOffsetFilter(SkReadBuffer& buffer)
: SkImageFilter(1, buffer) { : SkImageFilter(1, buffer) {
fDX = buffer.readScalar(); fDX = buffer.readScalar();
fDY = buffer.readScalar(); fDY = buffer.readScalar();
} }
virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE { virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE {
this->SkImageFilter::flatten(buffer); this->SkImageFilter::flatten(buffer);
buffer.writeScalar(fDX); buffer.writeScalar(fDX);
buffer.writeScalar(fDY); buffer.writeScalar(fDY);

Просмотреть файл

@ -8,7 +8,8 @@
#include "gm.h" #include "gm.h"
#include "SkBlurMask.h" #include "SkBlurMask.h"
#include "SkBlurMaskFilter.h" #include "SkBlurMaskFilter.h"
#include "SkFlattenableBuffers.h" #include "SkReadBuffer.h"
#include "SkWriteBuffer.h"
#include "SkLayerRasterizer.h" #include "SkLayerRasterizer.h"
static void r0(SkLayerRasterizer* rast, SkPaint& p) { static void r0(SkLayerRasterizer* rast, SkPaint& p) {

Просмотреть файл

@ -84,7 +84,6 @@
'<(skia_src_path)/core/SkFilterProc.h', '<(skia_src_path)/core/SkFilterProc.h',
'<(skia_src_path)/core/SkFilterShader.cpp', '<(skia_src_path)/core/SkFilterShader.cpp',
'<(skia_src_path)/core/SkFlattenable.cpp', '<(skia_src_path)/core/SkFlattenable.cpp',
'<(skia_src_path)/core/SkFlattenableBuffers.cpp',
'<(skia_src_path)/core/SkFlattenableSerialization.cpp', '<(skia_src_path)/core/SkFlattenableSerialization.cpp',
'<(skia_src_path)/core/SkFloat.cpp', '<(skia_src_path)/core/SkFloat.cpp',
'<(skia_src_path)/core/SkFloat.h', '<(skia_src_path)/core/SkFloat.h',
@ -114,8 +113,8 @@
'<(skia_src_path)/core/SkMessageBus.h', '<(skia_src_path)/core/SkMessageBus.h',
'<(skia_src_path)/core/SkMetaData.cpp', '<(skia_src_path)/core/SkMetaData.cpp',
'<(skia_src_path)/core/SkMipMap.cpp', '<(skia_src_path)/core/SkMipMap.cpp',
'<(skia_src_path)/core/SkOrderedReadBuffer.cpp', '<(skia_src_path)/core/SkReadBuffer.cpp',
'<(skia_src_path)/core/SkOrderedWriteBuffer.cpp', '<(skia_src_path)/core/SkWriteBuffer.cpp',
'<(skia_src_path)/core/SkPackBits.cpp', '<(skia_src_path)/core/SkPackBits.cpp',
'<(skia_src_path)/core/SkPaint.cpp', '<(skia_src_path)/core/SkPaint.cpp',
'<(skia_src_path)/core/SkPaintOptionsAndroid.cpp', '<(skia_src_path)/core/SkPaintOptionsAndroid.cpp',

Просмотреть файл

@ -12,8 +12,8 @@
#include "SkString.h" #include "SkString.h"
class SkData; class SkData;
class SkFlattenableReadBuffer; class SkReadBuffer;
class SkFlattenableWriteBuffer; class SkWriteBuffer;
class SkStream; class SkStream;
class SkWStream; class SkWStream;
struct SkPoint; struct SkPoint;
@ -32,8 +32,8 @@ public:
*/ */
SkData* find(const char key[]) const; SkData* find(const char key[]) const;
SkAnnotation(SkFlattenableReadBuffer&); SkAnnotation(SkReadBuffer&);
void writeToBuffer(SkFlattenableWriteBuffer&) const; void writeToBuffer(SkWriteBuffer&) const;
private: private:
SkString fKey; SkString fKey;

Просмотреть файл

@ -658,8 +658,8 @@ public:
buffers as they can optimize the recording process and avoid recording buffers as they can optimize the recording process and avoid recording
duplicate bitmaps and pixelRefs. duplicate bitmaps and pixelRefs.
*/ */
void flatten(SkFlattenableWriteBuffer&) const; void flatten(SkWriteBuffer&) const;
void unflatten(SkFlattenableReadBuffer&); void unflatten(SkReadBuffer&);
SkDEBUGCODE(void validate() const;) SkDEBUGCODE(void validate() const;)

Просмотреть файл

@ -135,7 +135,7 @@ public:
protected: protected:
SkColorFilter() {} SkColorFilter() {}
SkColorFilter(SkFlattenableReadBuffer& rb) : INHERITED(rb) {} SkColorFilter(SkReadBuffer& rb) : INHERITED(rb) {}
private: private:
typedef SkFlattenable INHERITED; typedef SkFlattenable INHERITED;

Просмотреть файл

@ -52,8 +52,8 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorShader) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorShader)
protected: protected:
SkColorShader(SkFlattenableReadBuffer&); SkColorShader(SkReadBuffer&);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
private: private:

Просмотреть файл

@ -75,8 +75,8 @@ public:
SkDEBUGCODE(f16BitCacheLockCount -= 1); SkDEBUGCODE(f16BitCacheLockCount -= 1);
} }
explicit SkColorTable(SkFlattenableReadBuffer&); explicit SkColorTable(SkReadBuffer&);
void writeToBuffer(SkFlattenableWriteBuffer&) const; void writeToBuffer(SkWriteBuffer&) const;
private: private:
SkPMColor* fColors; SkPMColor* fColors;

Просмотреть файл

@ -43,8 +43,8 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposeShader) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposeShader)
protected: protected:
SkComposeShader(SkFlattenableReadBuffer& ); SkComposeShader(SkReadBuffer& );
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
private: private:

Просмотреть файл

@ -68,7 +68,7 @@ public:
protected: protected:
SkDrawLooper() {} SkDrawLooper() {}
SkDrawLooper(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {} SkDrawLooper(SkReadBuffer& buffer) : INHERITED(buffer) {}
private: private:
typedef SkFlattenable INHERITED; typedef SkFlattenable INHERITED;

Просмотреть файл

@ -34,7 +34,7 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkEmptyShader) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkEmptyShader)
protected: protected:
SkEmptyShader(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {} SkEmptyShader(SkReadBuffer& buffer) : INHERITED(buffer) {}
private: private:
typedef SkShader INHERITED; typedef SkShader INHERITED;

Просмотреть файл

@ -12,8 +12,8 @@
#include "SkRefCnt.h" #include "SkRefCnt.h"
class SkFlattenableReadBuffer; class SkReadBuffer;
class SkFlattenableWriteBuffer; class SkWriteBuffer;
#define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(flattenable) \ #define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(flattenable) \
SkFlattenable::Registrar(#flattenable, flattenable::CreateProc, \ SkFlattenable::Registrar(#flattenable, flattenable::CreateProc, \
@ -32,7 +32,7 @@ class SkFlattenableWriteBuffer;
#define SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(flattenable) \ #define SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(flattenable) \
virtual Factory getFactory() const SK_OVERRIDE { return CreateProc; } \ virtual Factory getFactory() const SK_OVERRIDE { return CreateProc; } \
static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) { \ static SkFlattenable* CreateProc(SkReadBuffer& buffer) { \
return SkNEW_ARGS(flattenable, (buffer)); \ return SkNEW_ARGS(flattenable, (buffer)); \
} }
@ -67,7 +67,7 @@ public:
SK_DECLARE_INST_COUNT(SkFlattenable) SK_DECLARE_INST_COUNT(SkFlattenable)
typedef SkFlattenable* (*Factory)(SkFlattenableReadBuffer&); typedef SkFlattenable* (*Factory)(SkReadBuffer&);
SkFlattenable() {} SkFlattenable() {}
@ -94,19 +94,19 @@ public:
} }
}; };
protected:
SkFlattenable(SkFlattenableReadBuffer&) {}
/** Override this to write data specific to your subclass into the buffer, /** Override this to write data specific to your subclass into the buffer,
being sure to call your super-class' version first. This data will later being sure to call your super-class' version first. This data will later
be passed to your Factory function, returned by getFactory(). be passed to your Factory function, returned by getFactory().
*/ */
virtual void flatten(SkFlattenableWriteBuffer&) const; virtual void flatten(SkWriteBuffer&) const;
protected:
SkFlattenable(SkReadBuffer&) {}
private: private:
static void InitializeFlattenablesIfNeeded(); static void InitializeFlattenablesIfNeeded();
friend class SkGraphics; friend class SkGraphics;
friend class SkFlattenableWriteBuffer;
typedef SkRefCnt INHERITED; typedef SkRefCnt INHERITED;
}; };

Просмотреть файл

@ -1,260 +1,10 @@
// Temporary shim to keep a couple dependencies working in Chromium.
/*
* Copyright 2012 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkFlattenableBuffers_DEFINED #ifndef SkFlattenableBuffers_DEFINED
#define SkFlattenableBuffers_DEFINED #define SkFlattenableBuffers_DEFINED
#include "SkColor.h" #include "SkReadBuffer.h"
#include "SkData.h" #include "SkWriteBuffer.h"
#include "SkPaint.h"
#include "SkPoint.h"
class SkBitmap; typedef SkReadBuffer SkFlattenableReadBuffer;
class SkDrawLooper;
class SkFlattenable;
struct SkIRect;
class SkMatrix;
class SkOrderedReadBuffer;
class SkOrderedWriteBuffer;
class SkPath;
class SkPixelRef;
struct SkRect;
class SkRegion;
class SkStream;
class SkString;
class SkTypeface;
class SkUnitMapper;
class SkWStream;
class SkFlattenableReadBuffer { #endif//SkFlattenableBuffers_DEFINED
public:
SkFlattenableReadBuffer();
virtual ~SkFlattenableReadBuffer();
bool isOrderedBinaryBuffer() { return NULL != getOrderedBinaryBuffer(); }
virtual SkOrderedReadBuffer* getOrderedBinaryBuffer() { return NULL; }
enum Flags {
kCrossProcess_Flag = 1 << 0,
kScalarIsFloat_Flag = 1 << 1,
kPtrIs64Bit_Flag = 1 << 2,
/** The kValidation_Flag is used to force stream validations (by making
* sure that no operation reads past the end of the stream, for example)
* and error handling if any reading operation yields an invalid value.
*/
kValidation_Flag = 1 << 3,
};
void setFlags(uint32_t flags) { fFlags = flags; }
uint32_t getFlags() const { return fFlags; }
bool isCrossProcess() const { return SkToBool(fFlags & (kCrossProcess_Flag | kValidation_Flag)); }
bool isScalarFloat() const { return SkToBool(fFlags & kScalarIsFloat_Flag); }
bool isPtr64Bit() const { return SkToBool(fFlags & kPtrIs64Bit_Flag); }
bool isValidating() const { return SkToBool(fFlags & kValidation_Flag); }
// primitives
virtual bool readBool() = 0;
virtual SkColor readColor() = 0;
virtual SkFixed readFixed() = 0;
virtual int32_t readInt() = 0;
virtual SkScalar readScalar() = 0;
virtual uint32_t readUInt() = 0;
virtual int32_t read32() = 0;
// strings -- the caller is responsible for freeing the string contents
virtual void readString(SkString* string) = 0;
virtual void* readEncodedString(size_t* length, SkPaint::TextEncoding encoding) = 0;
/**
@param type This parameter is only used when using SkValidatingReadBuffer. It will verify
that the object about to be deserialized is of the given type or early return
NULL otherwise. The type provided here is the type of the base class of the
object to deserialize.
*/
virtual SkFlattenable* readFlattenable(SkFlattenable::Type type) = 0;
SkColorFilter* readColorFilter();
SkDrawLooper* readDrawLooper();
SkImageFilter* readImageFilter();
SkMaskFilter* readMaskFilter();
SkPathEffect* readPathEffect();
SkPixelRef* readPixelRef();
SkRasterizer* readRasterizer();
SkShader* readShader();
SkUnitMapper* readUnitMapper();
SkXfermode* readXfermode();
// common data structures
virtual void readPoint(SkPoint* point) = 0;
virtual void readMatrix(SkMatrix* matrix) = 0;
virtual void readIRect(SkIRect* rect) = 0;
virtual void readRect(SkRect* rect) = 0;
virtual void readRegion(SkRegion* region) = 0;
virtual void readPath(SkPath* path) = 0;
// binary data and arrays
/**
* In the following read.*Array(...) functions, the size parameter specifies the allocation
* size in number of elements (or in bytes, for void*) of the pointer parameter. If the
* pointer parameter's size does not match the size to be read, the pointer parameter's memory
* will then stay uninitialized, the cursor will be moved to the end of the stream and, in the
* case where isValidating() is true, an error flag will be set internally (see
* SkValidatingReadBuffer).
* If the sizes match, then "size" amount of memory will be read.
*
* @param size amount of memory expected to be read
* @return true if the size parameter matches the size to be read, false otherwise
*/
virtual bool readByteArray(void* value, size_t size) = 0;
virtual bool readColorArray(SkColor* colors, size_t size) = 0;
virtual bool readIntArray(int32_t* values, size_t size) = 0;
virtual bool readPointArray(SkPoint* points, size_t size) = 0;
virtual bool readScalarArray(SkScalar* values, size_t size) = 0;
/** This helper peeks into the buffer and reports back the length of the next array in
* the buffer but does not change the state of the buffer.
*/
virtual uint32_t getArrayCount() = 0;
// helper functions
virtual void* readFunctionPtr();
virtual void readPaint(SkPaint* paint);
virtual void readBitmap(SkBitmap* bitmap) = 0;
virtual SkTypeface* readTypeface() = 0;
// helper function for classes with const SkPoint members
SkPoint readPoint() {
SkPoint point;
this->readPoint(&point);
return point;
}
SkData* readByteArrayAsData() {
size_t len = this->getArrayCount();
void* buffer = NULL;
if (this->validateAvailable(len)) {
buffer = sk_malloc_throw(len);
(void)this->readByteArray(buffer, len);
} else {
len = 0;
}
return SkData::NewFromMalloc(buffer, len);
}
/** This function validates that the isValid input parameter is true
* If isValidating() is false, then true is always returned
* If isValidating() is true, then true is returned until validate() is called with isValid
* set to false. When isValid is false, an error flag will be set internally and, from that
* point on, validate() will return false. The error flag cannot be unset.
*
* @param isValid result of a test that is expected to be true
*/
virtual bool validate(bool isValid);
/** This function returns true by default
* If isValidating() is true, it will return false if the internal error flag is set.
* Otherwise, it will return true.
*/
virtual bool isValid() const { return true; }
/** This function returns true by default
* If isValidating() is true, it will return whether there's
* at least "size" memory left to read in the stream.
*
* @param size amount of memory that should still be available
*/
virtual bool validateAvailable(size_t size) { return true; }
private:
template <typename T> T* readFlattenableT();
uint32_t fFlags;
};
///////////////////////////////////////////////////////////////////////////////
class SkFlattenableWriteBuffer {
public:
SkFlattenableWriteBuffer();
virtual ~SkFlattenableWriteBuffer();
virtual bool isOrderedBinaryBuffer() { return false; }
virtual SkOrderedWriteBuffer* getOrderedBinaryBuffer() { sk_throw(); return NULL; }
// primitives
virtual void writeByteArray(const void* data, size_t size) = 0;
virtual void writeBool(bool value) = 0;
virtual void writeFixed(SkFixed value) = 0;
virtual void writeScalar(SkScalar value) = 0;
virtual void writeScalarArray(const SkScalar* value, uint32_t count) = 0;
virtual void writeInt(int32_t value) = 0;
virtual void writeIntArray(const int32_t* value, uint32_t count) = 0;
virtual void writeUInt(uint32_t value) = 0;
virtual void write32(int32_t value) = 0; // printf in hex
virtual void writeString(const char* value) = 0;
virtual void writeEncodedString(const void* value, size_t byteLength,
SkPaint::TextEncoding encoding) = 0;
// common data structures
virtual void writeFlattenable(const SkFlattenable* flattenable) = 0;
virtual void writeColor(const SkColor& color) = 0;
virtual void writeColorArray(const SkColor* color, uint32_t count) = 0;
virtual void writePoint(const SkPoint& point) = 0;
virtual void writePointArray(const SkPoint* points, uint32_t count) = 0;
virtual void writeMatrix(const SkMatrix& matrix) = 0;
virtual void writeIRect(const SkIRect& rect) = 0;
virtual void writeRect(const SkRect& rect) = 0;
virtual void writeRegion(const SkRegion& region) = 0;
virtual void writePath(const SkPath& path) = 0;
virtual size_t writeStream(SkStream* stream, size_t length) = 0;
// helper functions
virtual void writeFunctionPtr(void* ptr);
virtual void writePaint(const SkPaint& paint);
virtual void writeBitmap(const SkBitmap& bitmap) = 0;
virtual void writeTypeface(SkTypeface* typeface) = 0;
virtual bool writeToStream(SkWStream*) = 0;
enum Flags {
kCrossProcess_Flag = 0x01,
/** The kValidation_Flag is used here to make sure the write operation
* is symmetric with the read operation using the equivalent flag
* SkFlattenableReadBuffer::kValidation_Flag.
*/
kValidation_Flag = 0x02,
};
uint32_t getFlags() const { return fFlags; }
void setFlags(uint32_t flags) { fFlags = flags; }
bool isCrossProcess() const {
return SkToBool(fFlags & (kCrossProcess_Flag | kValidation_Flag));
}
bool isValidating() const {
return SkToBool(fFlags & kValidation_Flag);
}
bool persistTypeface() const { return (fFlags & kCrossProcess_Flag) != 0; }
void writeDataAsByteArray(SkData* data) {
this->writeByteArray(data->data(), data->size());
}
protected:
// A helper function so that each subclass does not have to be a friend of SkFlattenable
void flattenObject(const SkFlattenable* obj, SkFlattenableWriteBuffer& buffer);
uint32_t fFlags;
};
#endif

Просмотреть файл

@ -160,15 +160,15 @@ protected:
virtual ~SkImageFilter(); virtual ~SkImageFilter();
/** /**
* Constructs a new SkImageFilter read from an SkFlattenableReadBuffer object. * Constructs a new SkImageFilter read from an SkReadBuffer object.
* *
* @param inputCount The exact number of inputs expected for this SkImageFilter object. * @param inputCount The exact number of inputs expected for this SkImageFilter object.
* -1 can be used if the filter accepts any number of inputs. * -1 can be used if the filter accepts any number of inputs.
* @param rb SkFlattenableReadBuffer object from which the SkImageFilter is read. * @param rb SkReadBuffer object from which the SkImageFilter is read.
*/ */
explicit SkImageFilter(int inputCount, SkFlattenableReadBuffer& rb); explicit SkImageFilter(int inputCount, SkReadBuffer& rb);
virtual void flatten(SkFlattenableWriteBuffer& wb) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer& wb) const SK_OVERRIDE;
/** /**
* This is the virtual which should be overridden by the derived class * This is the virtual which should be overridden by the derived class

Просмотреть файл

@ -11,8 +11,8 @@
#include "SkTypes.h" #include "SkTypes.h"
#include "SkSize.h" #include "SkSize.h"
class SkFlattenableWriteBuffer; class SkWriteBuffer;
class SkFlattenableReadBuffer; class SkReadBuffer;
/** /**
* Describes how to interpret the alpha compoent of a pixel. * Describes how to interpret the alpha compoent of a pixel.
@ -178,8 +178,8 @@ struct SkImageInfo {
return 0 != memcmp(this, &other, sizeof(other)); return 0 != memcmp(this, &other, sizeof(other));
} }
void unflatten(SkFlattenableReadBuffer&); void unflatten(SkReadBuffer&);
void flatten(SkFlattenableWriteBuffer&) const; void flatten(SkWriteBuffer&) const;
size_t getSafeSize(size_t rowBytes) const { size_t getSafeSize(size_t rowBytes) const {
if (0 == fHeight) { if (0 == fHeight) {

Просмотреть файл

@ -91,12 +91,12 @@ protected:
// The ownPixels version of this constructor is deprecated. // The ownPixels version of this constructor is deprecated.
SkMallocPixelRef(const SkImageInfo&, void* addr, size_t rb, SkColorTable*, SkMallocPixelRef(const SkImageInfo&, void* addr, size_t rb, SkColorTable*,
bool ownPixels); bool ownPixels);
SkMallocPixelRef(SkFlattenableReadBuffer& buffer); SkMallocPixelRef(SkReadBuffer& buffer);
virtual ~SkMallocPixelRef(); virtual ~SkMallocPixelRef();
virtual bool onNewLockPixels(LockRec*) SK_OVERRIDE; virtual bool onNewLockPixels(LockRec*) SK_OVERRIDE;
virtual void onUnlockPixels() SK_OVERRIDE; virtual void onUnlockPixels() SK_OVERRIDE;
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
virtual size_t getAllocatedSizeInBytes() const SK_OVERRIDE; virtual size_t getAllocatedSizeInBytes() const SK_OVERRIDE;
private: private:

Просмотреть файл

@ -137,7 +137,7 @@ public:
protected: protected:
// empty for now, but lets get our subclass to remember to init us for the future // empty for now, but lets get our subclass to remember to init us for the future
SkMaskFilter(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {} SkMaskFilter(SkReadBuffer& buffer) : INHERITED(buffer) {}
enum FilterReturn { enum FilterReturn {
kFalse_FilterReturn, kFalse_FilterReturn,

Просмотреть файл

@ -24,8 +24,8 @@ class SkAutoGlyphCache;
class SkColorFilter; class SkColorFilter;
class SkDescriptor; class SkDescriptor;
struct SkDeviceProperties; struct SkDeviceProperties;
class SkFlattenableReadBuffer; class SkReadBuffer;
class SkFlattenableWriteBuffer; class SkWriteBuffer;
struct SkGlyph; struct SkGlyph;
struct SkRect; struct SkRect;
class SkGlyphCache; class SkGlyphCache;
@ -72,8 +72,8 @@ public:
return !(a == b); return !(a == b);
} }
void flatten(SkFlattenableWriteBuffer&) const; void flatten(SkWriteBuffer&) const;
void unflatten(SkFlattenableReadBuffer&); void unflatten(SkReadBuffer&);
/** Restores the paint to its initial settings. /** Restores the paint to its initial settings.
*/ */

Просмотреть файл

@ -13,8 +13,8 @@
#include "SkTypes.h" #include "SkTypes.h"
#include "SkString.h" #include "SkString.h"
class SkFlattenableReadBuffer; class SkReadBuffer;
class SkFlattenableWriteBuffer; class SkWriteBuffer;
/** \class SkLanguage /** \class SkLanguage
@ -80,8 +80,8 @@ public:
fUseFontFallbacks != b.fUseFontFallbacks; fUseFontFallbacks != b.fUseFontFallbacks;
} }
void flatten(SkFlattenableWriteBuffer&) const; void flatten(SkWriteBuffer&) const;
void unflatten(SkFlattenableReadBuffer&); void unflatten(SkReadBuffer&);
/** Return the paint's language value used for drawing text. /** Return the paint's language value used for drawing text.
@return the paint's language value used for drawing text. @return the paint's language value used for drawing text.

Просмотреть файл

@ -109,7 +109,7 @@ public:
SK_DEFINE_FLATTENABLE_TYPE(SkPathEffect) SK_DEFINE_FLATTENABLE_TYPE(SkPathEffect)
protected: protected:
SkPathEffect(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {} SkPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {}
private: private:
// illegal // illegal
@ -131,8 +131,8 @@ public:
virtual ~SkPairPathEffect(); virtual ~SkPairPathEffect();
protected: protected:
SkPairPathEffect(SkFlattenableReadBuffer&); SkPairPathEffect(SkReadBuffer&);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
// these are visible to our subclasses // these are visible to our subclasses
SkPathEffect* fPE0, *fPE1; SkPathEffect* fPE0, *fPE1;
@ -162,7 +162,7 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposePathEffect) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposePathEffect)
protected: protected:
SkComposePathEffect(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {} SkComposePathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {}
private: private:
// illegal // illegal
@ -193,7 +193,7 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSumPathEffect) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSumPathEffect)
protected: protected:
SkSumPathEffect(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {} SkSumPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {}
private: private:
// illegal // illegal

Просмотреть файл

@ -169,8 +169,8 @@ public:
/** /**
* Function to encode an SkBitmap to an SkData. A function with this * Function to encode an SkBitmap to an SkData. A function with this
* signature can be passed to serialize() and SkOrderedWriteBuffer. * signature can be passed to serialize() and SkWriteBuffer.
* Returning NULL will tell the SkOrderedWriteBuffer to use * Returning NULL will tell the SkWriteBuffer to use
* SkBitmap::flatten() to store the bitmap. * SkBitmap::flatten() to store the bitmap.
* *
* @param pixelRefOffset DEPRECATED -- caller assumes it will return 0. * @param pixelRefOffset DEPRECATED -- caller assumes it will return 0.

Просмотреть файл

@ -328,8 +328,8 @@ protected:
SkBaseMutex* mutex() const { return fMutex; } SkBaseMutex* mutex() const { return fMutex; }
// serialization // serialization
SkPixelRef(SkFlattenableReadBuffer&, SkBaseMutex*); SkPixelRef(SkReadBuffer&, SkBaseMutex*);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
// only call from constructor. Flags this to always be locked, removing // only call from constructor. Flags this to always be locked, removing
// the need to grab the mutex and call onLockPixels/onUnlockPixels. // the need to grab the mutex and call onLockPixels/onUnlockPixels.

Просмотреть файл

@ -33,7 +33,7 @@ public:
SK_DEFINE_FLATTENABLE_TYPE(SkRasterizer) SK_DEFINE_FLATTENABLE_TYPE(SkRasterizer)
protected: protected:
SkRasterizer(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {} SkRasterizer(SkReadBuffer& buffer) : INHERITED(buffer) {}
virtual bool onRasterize(const SkPath& path, const SkMatrix& matrix, virtual bool onRasterize(const SkPath& path, const SkMatrix& matrix,
const SkIRect* clipBounds, const SkIRect* clipBounds,

205
include/core/SkReadBuffer.h Normal file
Просмотреть файл

@ -0,0 +1,205 @@
/*
* 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 SkReadBuffer_DEFINED
#define SkReadBuffer_DEFINED
#include "SkBitmapHeap.h"
#include "SkColorFilter.h"
#include "SkData.h"
#include "SkDrawLooper.h"
#include "SkImageFilter.h"
#include "SkMaskFilter.h"
#include "SkPath.h"
#include "SkPathEffect.h"
#include "SkPicture.h"
#include "SkPixelRef.h"
#include "SkRasterizer.h"
#include "SkReadBuffer.h"
#include "SkReader32.h"
#include "SkRefCnt.h"
#include "SkShader.h"
#include "SkUnitMapper.h"
#include "SkWriteBuffer.h"
#include "SkXfermode.h"
class SkBitmap;
#if defined(SK_DEBUG) && defined(SK_BUILD_FOR_MAC)
#define DEBUG_NON_DETERMINISTIC_ASSERT
#endif
class SkReadBuffer {
public:
SkReadBuffer();
SkReadBuffer(const void* data, size_t size);
SkReadBuffer(SkStream* stream);
virtual ~SkReadBuffer();
enum Flags {
kCrossProcess_Flag = 1 << 0,
kScalarIsFloat_Flag = 1 << 1,
kPtrIs64Bit_Flag = 1 << 2,
kValidation_Flag = 1 << 3,
};
void setFlags(uint32_t flags) { fFlags = flags; }
uint32_t getFlags() const { return fFlags; }
bool isCrossProcess() const {
return this->isValidating() || SkToBool(fFlags & kCrossProcess_Flag);
}
bool isScalarFloat() const { return SkToBool(fFlags & kScalarIsFloat_Flag); }
bool isPtr64Bit() const { return SkToBool(fFlags & kPtrIs64Bit_Flag); }
bool isValidating() const { return SkToBool(fFlags & kValidation_Flag); }
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();
virtual SkColor readColor();
virtual SkFixed readFixed();
virtual int32_t readInt();
virtual SkScalar readScalar();
virtual uint32_t readUInt();
virtual int32_t read32();
void* readFunctionPtr() {
void* ptr;
this->readByteArray(&ptr, sizeof(ptr));
return ptr;
}
// strings -- the caller is responsible for freeing the string contents
virtual void readString(SkString* string);
virtual void* readEncodedString(size_t* length, SkPaint::TextEncoding encoding);
// common data structures
virtual void readPoint(SkPoint* point);
SkPoint readPoint() { SkPoint p; this->readPoint(&p); return p; }
virtual void readMatrix(SkMatrix* matrix);
virtual void readIRect(SkIRect* rect);
virtual void readRect(SkRect* rect);
virtual void readRegion(SkRegion* region);
virtual void readPath(SkPath* path);
void readPaint(SkPaint* paint) { paint->unflatten(*this); }
virtual SkFlattenable* readFlattenable(SkFlattenable::Type);
template <typename T> T* readFlattenable() {
return (T*) this->readFlattenable(T::GetFlattenableType());
}
SkColorFilter* readColorFilter() { return this->readFlattenable<SkColorFilter>(); }
SkDrawLooper* readDrawLooper() { return this->readFlattenable<SkDrawLooper>(); }
SkImageFilter* readImageFilter() { return this->readFlattenable<SkImageFilter>(); }
SkMaskFilter* readMaskFilter() { return this->readFlattenable<SkMaskFilter>(); }
SkPathEffect* readPathEffect() { return this->readFlattenable<SkPathEffect>(); }
SkPixelRef* readPixelRef() { return this->readFlattenable<SkPixelRef>(); }
SkRasterizer* readRasterizer() { return this->readFlattenable<SkRasterizer>(); }
SkShader* readShader() { return this->readFlattenable<SkShader>(); }
SkUnitMapper* readUnitMapper() { return this->readFlattenable<SkUnitMapper>(); }
SkXfermode* readXfermode() { return this->readFlattenable<SkXfermode>(); }
// binary data and arrays
virtual bool readByteArray(void* value, size_t size);
virtual bool readColorArray(SkColor* colors, size_t size);
virtual bool readIntArray(int32_t* values, size_t size);
virtual bool readPointArray(SkPoint* points, size_t size);
virtual bool readScalarArray(SkScalar* values, size_t size);
SkData* readByteArrayAsData() {
size_t len = this->getArrayCount();
if (!this->validateAvailable(len)) {
return SkData::NewEmpty();
}
void* buffer = sk_malloc_throw(len);
this->readByteArray(buffer, len);
return SkData::NewFromMalloc(buffer, len);
}
// helpers to get info about arrays and binary data
virtual uint32_t getArrayCount();
virtual void readBitmap(SkBitmap* bitmap);
virtual SkTypeface* readTypeface();
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
* SkWriteBuffer::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;
}
// Default impelementations don't check anything.
virtual bool validate(bool isValid) { return true; }
virtual bool isValid() const { return true; }
virtual bool validateAvailable(size_t size) { return true; }
private:
bool readArray(void* value, size_t size, size_t elementSize);
uint32_t fFlags;
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
};
#endif // SkReadBuffer_DEFINED

Просмотреть файл

@ -363,8 +363,8 @@ protected:
const SkMatrix& getTotalInverse() const { return fTotalInverse; } const SkMatrix& getTotalInverse() const { return fTotalInverse; }
MatrixClass getInverseClass() const { return (MatrixClass)fTotalInverseClass; } MatrixClass getInverseClass() const { return (MatrixClass)fTotalInverseClass; }
SkShader(SkFlattenableReadBuffer& ); SkShader(SkReadBuffer& );
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
private: private:
SkMatrix fLocalMatrix; SkMatrix fLocalMatrix;
SkMatrix fTotalInverse; SkMatrix fTotalInverse;

Просмотреть файл

@ -28,7 +28,7 @@ public:
SK_DEFINE_FLATTENABLE_TYPE(SkUnitMapper) SK_DEFINE_FLATTENABLE_TYPE(SkUnitMapper)
protected: protected:
SkUnitMapper(SkFlattenableReadBuffer& rb) : SkFlattenable(rb) {} SkUnitMapper(SkReadBuffer& rb) : SkFlattenable(rb) {}
private: private:
typedef SkFlattenable INHERITED; typedef SkFlattenable INHERITED;

Просмотреть файл

@ -0,0 +1,121 @@
/*
* 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 SkWriteBuffer_DEFINED
#define SkWriteBuffer_DEFINED
#include "SkBitmapHeap.h"
#include "SkData.h"
#include "SkPath.h"
#include "SkPicture.h"
#include "SkRefCnt.h"
#include "SkWriter32.h"
class SkBitmap;
class SkFactorySet;
class SkFlattenable;
class SkNamedFactorySet;
class SkRefCntSet;
class SkWriteBuffer {
public:
SkWriteBuffer();
SkWriteBuffer(void* initialStorage, size_t storageSize);
~SkWriteBuffer();
enum Flags {
kCrossProcess_Flag = 1 << 0,
kValidation_Flag = 1 << 1,
};
void setFlags(uint32_t flags) { fFlags = flags; }
uint32_t getFlags() const { return fFlags; }
bool isValidating() const { return SkToBool(fFlags & kValidation_Flag); }
bool isCrossProcess() const {
return this->isValidating() || SkToBool(fFlags & kCrossProcess_Flag);
}
SkWriter32* getWriter32() { return &fWriter; }
void reset(void* storage = NULL, size_t storageSize = 0) {
fWriter.reset(storage, storageSize);
}
uint32_t* reserve(size_t size) { return fWriter.reserve(size); }
size_t bytesWritten() const { return fWriter.bytesWritten(); }
void writeByteArray(const void* data, size_t size);
void writeDataAsByteArray(SkData* data) { this->writeByteArray(data->data(), data->size()); }
void writeBool(bool value);
void writeFixed(SkFixed value);
void writeScalar(SkScalar value);
void writeScalarArray(const SkScalar* value, uint32_t count);
void writeInt(int32_t value);
void writeIntArray(const int32_t* value, uint32_t count);
void writeUInt(uint32_t value);
void write32(int32_t value);
void writeString(const char* value);
void writeEncodedString(const void* value, size_t byteLength, SkPaint::TextEncoding encoding);
void writeFunctionPtr(void* ptr) { this->writeByteArray(&ptr, sizeof(ptr)); }
void writeFlattenable(const SkFlattenable* flattenable);
void writeColor(const SkColor& color);
void writeColorArray(const SkColor* color, uint32_t count);
void writePoint(const SkPoint& point);
void writePointArray(const SkPoint* point, uint32_t count);
void writeMatrix(const SkMatrix& matrix);
void writeIRect(const SkIRect& rect);
void writeRect(const SkRect& rect);
void writeRegion(const SkRegion& region);
void writePath(const SkPath& path);
size_t writeStream(SkStream* stream, size_t length);
void writeBitmap(const SkBitmap& bitmap);
void writeTypeface(SkTypeface* typeface);
void writePaint(const SkPaint& paint) { paint.flatten(*this); }
bool writeToStream(SkWStream*);
void writeToMemory(void* dst) { fWriter.flatten(dst); }
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:
uint32_t fFlags;
SkFactorySet* fFactorySet;
SkNamedFactorySet* fNamedFactorySet;
SkWriter32 fWriter;
SkBitmapHeap* fBitmapHeap;
SkRefCntSet* fTFSet;
SkPicture::EncodeBitmap fBitmapEncoder;
};
#endif // SkWriteBuffer_DEFINED

Просмотреть файл

@ -218,7 +218,7 @@ public:
SK_DEFINE_FLATTENABLE_TYPE(SkXfermode) SK_DEFINE_FLATTENABLE_TYPE(SkXfermode)
protected: protected:
SkXfermode(SkFlattenableReadBuffer& rb) : SkFlattenable(rb) {} SkXfermode(SkReadBuffer& rb) : SkFlattenable(rb) {}
/** The default implementation of xfer32/xfer16/xferA8 in turn call this /** The default implementation of xfer32/xfer16/xferA8 in turn call this
method, 1 color at a time (upscaled to a SkPMColor). The default method, 1 color at a time (upscaled to a SkPMColor). The default
@ -264,8 +264,8 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkProcXfermode) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkProcXfermode)
protected: protected:
SkProcXfermode(SkFlattenableReadBuffer&); SkProcXfermode(SkReadBuffer&);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
// allow subclasses to update this after we unflatten // allow subclasses to update this after we unflatten
void setProc(SkXfermodeProc proc) { void setProc(SkXfermodeProc proc) {

Просмотреть файл

@ -60,8 +60,8 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPath1DPathEffect) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPath1DPathEffect)
protected: protected:
SkPath1DPathEffect(SkFlattenableReadBuffer& buffer); SkPath1DPathEffect(SkReadBuffer& buffer);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
// overrides from Sk1DPathEffect // overrides from Sk1DPathEffect
virtual SkScalar begin(SkScalar contourLength) const SK_OVERRIDE; virtual SkScalar begin(SkScalar contourLength) const SK_OVERRIDE;

Просмотреть файл

@ -41,8 +41,8 @@ protected:
const SkMatrix& getMatrix() const { return fMatrix; } const SkMatrix& getMatrix() const { return fMatrix; }
// protected so that subclasses can call this during unflattening // protected so that subclasses can call this during unflattening
Sk2DPathEffect(SkFlattenableReadBuffer&); Sk2DPathEffect(SkReadBuffer&);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
private: private:
SkMatrix fMatrix, fInverse; SkMatrix fMatrix, fInverse;
@ -69,9 +69,9 @@ public:
protected: protected:
virtual void nextSpan(int u, int v, int ucount, SkPath*) const SK_OVERRIDE; virtual void nextSpan(int u, int v, int ucount, SkPath*) const SK_OVERRIDE;
SkLine2DPathEffect(SkFlattenableReadBuffer&); SkLine2DPathEffect(SkReadBuffer&);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
private: private:
SkScalar fWidth; SkScalar fWidth;
@ -90,8 +90,8 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPath2DPathEffect) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPath2DPathEffect)
protected: protected:
SkPath2DPathEffect(SkFlattenableReadBuffer& buffer); SkPath2DPathEffect(SkReadBuffer& buffer);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
virtual void next(const SkPoint&, int u, int v, SkPath*) const SK_OVERRIDE; virtual void next(const SkPoint&, int u, int v, SkPath*) const SK_OVERRIDE;

Просмотреть файл

@ -51,8 +51,8 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkAvoidXfermode) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkAvoidXfermode)
protected: protected:
SkAvoidXfermode(SkFlattenableReadBuffer&); SkAvoidXfermode(SkReadBuffer&);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
private: private:
SkColor fOpColor; SkColor fOpColor;

Просмотреть файл

@ -35,8 +35,8 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBicubicImageFilter) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBicubicImageFilter)
protected: protected:
SkBicubicImageFilter(SkFlattenableReadBuffer& buffer); SkBicubicImageFilter(SkReadBuffer& buffer);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&, virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
SkBitmap* result, SkIPoint* loc) SK_OVERRIDE; SkBitmap* result, SkIPoint* loc) SK_OVERRIDE;

Просмотреть файл

@ -20,8 +20,8 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBitmapSource) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBitmapSource)
protected: protected:
explicit SkBitmapSource(SkFlattenableReadBuffer& buffer); explicit SkBitmapSource(SkReadBuffer& buffer);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&, virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
SkBitmap* result, SkIPoint* offset) SK_OVERRIDE; SkBitmap* result, SkIPoint* offset) SK_OVERRIDE;

Просмотреть файл

@ -51,8 +51,8 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBlurDrawLooper) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBlurDrawLooper)
protected: protected:
SkBlurDrawLooper(SkFlattenableReadBuffer&); SkBlurDrawLooper(SkReadBuffer&);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
private: private:
SkMaskFilter* fBlur; SkMaskFilter* fBlur;

Просмотреть файл

@ -22,8 +22,8 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBlurImageFilter) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBlurImageFilter)
protected: protected:
explicit SkBlurImageFilter(SkFlattenableReadBuffer& buffer); explicit SkBlurImageFilter(SkReadBuffer& buffer);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&, virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
SkBitmap* result, SkIPoint* offset) SK_OVERRIDE; SkBitmap* result, SkIPoint* offset) SK_OVERRIDE;

Просмотреть файл

@ -22,8 +22,8 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorFilterImageFilter) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorFilterImageFilter)
protected: protected:
SkColorFilterImageFilter(SkFlattenableReadBuffer& buffer); SkColorFilterImageFilter(SkReadBuffer& buffer);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&, virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
SkBitmap* result, SkIPoint* loc) SK_OVERRIDE; SkBitmap* result, SkIPoint* loc) SK_OVERRIDE;

Просмотреть файл

@ -35,8 +35,8 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorMatrixFilter) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorMatrixFilter)
protected: protected:
SkColorMatrixFilter(SkFlattenableReadBuffer& buffer); SkColorMatrixFilter(SkReadBuffer& buffer);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
private: private:
SkColorMatrix fMatrix; SkColorMatrix fMatrix;

Просмотреть файл

@ -18,7 +18,7 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposeImageFilter) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposeImageFilter)
protected: protected:
explicit SkComposeImageFilter(SkFlattenableReadBuffer& buffer); explicit SkComposeImageFilter(SkReadBuffer& buffer);
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&, virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
SkBitmap* result, SkIPoint* loc) SK_OVERRIDE; SkBitmap* result, SkIPoint* loc) SK_OVERRIDE;

Просмотреть файл

@ -29,8 +29,8 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkCornerPathEffect) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkCornerPathEffect)
protected: protected:
SkCornerPathEffect(SkFlattenableReadBuffer&); SkCornerPathEffect(SkReadBuffer&);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
private: private:
SkScalar fRadius; SkScalar fRadius;

Просмотреть файл

@ -49,11 +49,11 @@ public:
virtual Factory getFactory() const SK_OVERRIDE; virtual Factory getFactory() const SK_OVERRIDE;
static SkFlattenable* CreateProc(SkFlattenableReadBuffer&); static SkFlattenable* CreateProc(SkReadBuffer&);
protected: protected:
SkDashPathEffect(SkFlattenableReadBuffer&); SkDashPathEffect(SkReadBuffer&);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
private: private:
SkScalar* fIntervals; SkScalar* fIntervals;

Просмотреть файл

@ -28,8 +28,8 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDiscretePathEffect) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDiscretePathEffect)
protected: protected:
SkDiscretePathEffect(SkFlattenableReadBuffer&); SkDiscretePathEffect(SkReadBuffer&);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
private: private:
SkScalar fSegLength, fPerterb; SkScalar fSegLength, fPerterb;

Просмотреть файл

@ -46,8 +46,8 @@ public:
#endif #endif
protected: protected:
explicit SkDisplacementMapEffect(SkFlattenableReadBuffer& buffer); explicit SkDisplacementMapEffect(SkReadBuffer& buffer);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
private: private:
ChannelSelectorType fXChannelSelector; ChannelSelectorType fXChannelSelector;

Просмотреть файл

@ -17,8 +17,8 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDropShadowImageFilter) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDropShadowImageFilter)
protected: protected:
explicit SkDropShadowImageFilter(SkFlattenableReadBuffer&); explicit SkDropShadowImageFilter(SkReadBuffer&);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
virtual bool onFilterImage(Proxy*, const SkBitmap& source, const SkMatrix&, SkBitmap* result, SkIPoint* loc) SK_OVERRIDE; virtual bool onFilterImage(Proxy*, const SkBitmap& source, const SkMatrix&, SkBitmap* result, SkIPoint* loc) SK_OVERRIDE;
private: private:

Просмотреть файл

@ -39,8 +39,8 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkEmbossMaskFilter) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkEmbossMaskFilter)
protected: protected:
SkEmbossMaskFilter(SkFlattenableReadBuffer&); SkEmbossMaskFilter(SkReadBuffer&);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
private: private:
Light fLight; Light fLight;

Просмотреть файл

@ -24,8 +24,8 @@ public:
SkDEVCODE(virtual void toString(SkString* str) const SK_OVERRIDE;) SkDEVCODE(virtual void toString(SkString* str) const SK_OVERRIDE;)
protected: protected:
SkKernel33ProcMaskFilter(SkFlattenableReadBuffer& rb); SkKernel33ProcMaskFilter(SkReadBuffer& rb);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
private: private:
int fPercent256; int fPercent256;
@ -53,8 +53,8 @@ private:
int fKernel[3][3]; int fKernel[3][3];
int fShift; int fShift;
SkKernel33MaskFilter(SkFlattenableReadBuffer& rb); SkKernel33MaskFilter(SkReadBuffer& rb);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
typedef SkKernel33ProcMaskFilter INHERITED; typedef SkKernel33ProcMaskFilter INHERITED;
}; };

Просмотреть файл

@ -110,8 +110,8 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLayerDrawLooper) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLayerDrawLooper)
protected: protected:
SkLayerDrawLooper(SkFlattenableReadBuffer&); SkLayerDrawLooper(SkReadBuffer&);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
private: private:
struct Rec { struct Rec {

Просмотреть файл

@ -35,8 +35,8 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLayerRasterizer) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLayerRasterizer)
protected: protected:
SkLayerRasterizer(SkFlattenableReadBuffer&); SkLayerRasterizer(SkReadBuffer&);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
// override from SkRasterizer // override from SkRasterizer
virtual bool onRasterize(const SkPath& path, const SkMatrix& matrix, virtual bool onRasterize(const SkPath& path, const SkMatrix& matrix,

Просмотреть файл

@ -32,8 +32,8 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLerpXfermode) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLerpXfermode)
protected: protected:
SkLerpXfermode(SkFlattenableReadBuffer&); SkLerpXfermode(SkReadBuffer&);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
private: private:
SkLerpXfermode(unsigned scale256); SkLerpXfermode(unsigned scale256);

Просмотреть файл

@ -74,8 +74,8 @@ protected:
SkScalar surfaceScale, SkScalar surfaceScale,
SkImageFilter* input, SkImageFilter* input,
const CropRect* cropRect = NULL); const CropRect* cropRect = NULL);
explicit SkLightingImageFilter(SkFlattenableReadBuffer& buffer); explicit SkLightingImageFilter(SkReadBuffer& buffer);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
const SkLight* light() const { return fLight; } const SkLight* light() const { return fLight; }
SkScalar surfaceScale() const { return fSurfaceScale; } SkScalar surfaceScale() const { return fSurfaceScale; }

Просмотреть файл

@ -35,8 +35,8 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLumaColorFilter) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLumaColorFilter)
protected: protected:
SkLumaColorFilter(SkFlattenableReadBuffer& buffer); SkLumaColorFilter(SkReadBuffer& buffer);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
private: private:
SkLumaColorFilter(); SkLumaColorFilter();

Просмотреть файл

@ -19,8 +19,8 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMagnifierImageFilter) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMagnifierImageFilter)
protected: protected:
explicit SkMagnifierImageFilter(SkFlattenableReadBuffer& buffer); explicit SkMagnifierImageFilter(SkReadBuffer& buffer);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&, virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
SkBitmap* result, SkIPoint* offset) SK_OVERRIDE; SkBitmap* result, SkIPoint* offset) SK_OVERRIDE;

Просмотреть файл

@ -64,8 +64,8 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMatrixConvolutionImageFilter) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMatrixConvolutionImageFilter)
protected: protected:
SkMatrixConvolutionImageFilter(SkFlattenableReadBuffer& buffer); SkMatrixConvolutionImageFilter(SkReadBuffer& buffer);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&, virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
SkBitmap* result, SkIPoint* loc) SK_OVERRIDE; SkBitmap* result, SkIPoint* loc) SK_OVERRIDE;

Просмотреть файл

@ -25,8 +25,8 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMergeImageFilter) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMergeImageFilter)
protected: protected:
SkMergeImageFilter(SkFlattenableReadBuffer& buffer); SkMergeImageFilter(SkReadBuffer& buffer);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&, virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
SkBitmap* result, SkIPoint* loc) SK_OVERRIDE; SkBitmap* result, SkIPoint* loc) SK_OVERRIDE;

Просмотреть файл

@ -32,8 +32,8 @@ protected:
bool filterImageGeneric(Proc procX, Proc procY, bool filterImageGeneric(Proc procX, Proc procY,
Proxy*, const SkBitmap& src, const SkMatrix&, Proxy*, const SkBitmap& src, const SkMatrix&,
SkBitmap* result, SkIPoint* offset); SkBitmap* result, SkIPoint* offset);
SkMorphologyImageFilter(SkFlattenableReadBuffer& buffer); SkMorphologyImageFilter(SkReadBuffer& buffer);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
virtual bool canFilterImageGPU() const SK_OVERRIDE { return true; } virtual bool canFilterImageGPU() const SK_OVERRIDE { return true; }
bool filterImageGPUGeneric(bool dilate, Proxy* proxy, const SkBitmap& src, bool filterImageGPUGeneric(bool dilate, Proxy* proxy, const SkBitmap& src,
@ -65,7 +65,7 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDilateImageFilter) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDilateImageFilter)
protected: protected:
SkDilateImageFilter(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {} SkDilateImageFilter(SkReadBuffer& buffer) : INHERITED(buffer) {}
private: private:
typedef SkMorphologyImageFilter INHERITED; typedef SkMorphologyImageFilter INHERITED;
@ -88,7 +88,7 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkErodeImageFilter) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkErodeImageFilter)
protected: protected:
SkErodeImageFilter(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {} SkErodeImageFilter(SkReadBuffer& buffer) : INHERITED(buffer) {}
private: private:
typedef SkMorphologyImageFilter INHERITED; typedef SkMorphologyImageFilter INHERITED;

Просмотреть файл

@ -21,8 +21,8 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkOffsetImageFilter) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkOffsetImageFilter)
protected: protected:
SkOffsetImageFilter(SkFlattenableReadBuffer& buffer); SkOffsetImageFilter(SkReadBuffer& buffer);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&, virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
SkBitmap* result, SkIPoint* loc) SK_OVERRIDE; SkBitmap* result, SkIPoint* loc) SK_OVERRIDE;

Просмотреть файл

@ -73,8 +73,8 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPerlinNoiseShader) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPerlinNoiseShader)
protected: protected:
SkPerlinNoiseShader(SkFlattenableReadBuffer&); SkPerlinNoiseShader(SkReadBuffer&);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
private: private:
SkPerlinNoiseShader(SkPerlinNoiseShader::Type type, SkScalar baseFrequencyX, SkPerlinNoiseShader(SkPerlinNoiseShader::Type type, SkScalar baseFrequencyX,

Просмотреть файл

@ -28,8 +28,8 @@ public:
protected: protected:
virtual ~SkPictureImageFilter(); virtual ~SkPictureImageFilter();
explicit SkPictureImageFilter(SkFlattenableReadBuffer& buffer); explicit SkPictureImageFilter(SkReadBuffer& buffer);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&, virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
SkBitmap* result, SkIPoint* offset) SK_OVERRIDE; SkBitmap* result, SkIPoint* offset) SK_OVERRIDE;

Просмотреть файл

@ -23,8 +23,8 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPixelXorXfermode) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPixelXorXfermode)
protected: protected:
SkPixelXorXfermode(SkFlattenableReadBuffer& rb); SkPixelXorXfermode(SkReadBuffer& rb);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
// override from SkXfermode // override from SkXfermode
virtual SkPMColor xferColor(SkPMColor src, SkPMColor dst) const; virtual SkPMColor xferColor(SkPMColor src, SkPMColor dst) const;

Просмотреть файл

@ -34,8 +34,8 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkRectShaderImageFilter) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkRectShaderImageFilter)
protected: protected:
SkRectShaderImageFilter(SkFlattenableReadBuffer& buffer); SkRectShaderImageFilter(SkReadBuffer& buffer);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&, virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
SkBitmap* result, SkIPoint* loc) SK_OVERRIDE; SkBitmap* result, SkIPoint* loc) SK_OVERRIDE;

Просмотреть файл

@ -36,8 +36,8 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkResizeImageFilter) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkResizeImageFilter)
protected: protected:
SkResizeImageFilter(SkFlattenableReadBuffer& buffer); SkResizeImageFilter(SkReadBuffer& buffer);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&, virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
SkBitmap* result, SkIPoint* loc) SK_OVERRIDE; SkBitmap* result, SkIPoint* loc) SK_OVERRIDE;

Просмотреть файл

@ -31,7 +31,7 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkStippleMaskFilter); SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkStippleMaskFilter);
protected: protected:
SkStippleMaskFilter(SkFlattenableReadBuffer& buffer) SkStippleMaskFilter(SkReadBuffer& buffer)
: SkMaskFilter(buffer) { : SkMaskFilter(buffer) {
} }

Просмотреть файл

@ -51,8 +51,8 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTableMaskFilter) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTableMaskFilter)
protected: protected:
SkTableMaskFilter(SkFlattenableReadBuffer& rb); SkTableMaskFilter(SkReadBuffer& rb);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
private: private:
uint8_t fTable[256]; uint8_t fTable[256];

Просмотреть файл

@ -12,8 +12,8 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDownSampleImageFilter) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDownSampleImageFilter)
protected: protected:
SkDownSampleImageFilter(SkFlattenableReadBuffer& buffer); SkDownSampleImageFilter(SkReadBuffer& buffer);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&, virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
SkBitmap* result, SkIPoint* loc) SK_OVERRIDE; SkBitmap* result, SkIPoint* loc) SK_OVERRIDE;

Просмотреть файл

@ -28,9 +28,9 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTileImageFilter) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTileImageFilter)
protected: protected:
explicit SkTileImageFilter(SkFlattenableReadBuffer& buffer); explicit SkTileImageFilter(SkReadBuffer& buffer);
virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE;
private: private:
SkRect fSrcRect; SkRect fSrcRect;

Просмотреть файл

@ -29,7 +29,7 @@ private:
const SkBitmap* fDevice; const SkBitmap* fDevice;
uint8_t fAlpha; uint8_t fAlpha;
SkTransparentShader(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {} SkTransparentShader(SkReadBuffer& buffer) : INHERITED(buffer) {}
typedef SkShader INHERITED; typedef SkShader INHERITED;
}; };

Просмотреть файл

@ -40,8 +40,8 @@ public:
#endif #endif
protected: protected:
explicit SkXfermodeImageFilter(SkFlattenableReadBuffer& buffer); explicit SkXfermodeImageFilter(SkReadBuffer& buffer);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
private: private:
SkXfermode* fMode; SkXfermode* fMode;

Просмотреть файл

@ -76,8 +76,8 @@ protected:
// override this in your subclass to clean up when we're unlocking pixels // override this in your subclass to clean up when we're unlocking pixels
virtual void onUnlockPixels() SK_OVERRIDE {} virtual void onUnlockPixels() SK_OVERRIDE {}
SkImageRef(SkFlattenableReadBuffer&, SkBaseMutex* mutex = NULL); SkImageRef(SkReadBuffer&, SkBaseMutex* mutex = NULL);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
SkBitmap fBitmap; SkBitmap fBitmap;

Просмотреть файл

@ -53,7 +53,7 @@ protected:
virtual void onUnlockPixels(); virtual void onUnlockPixels();
SkImageRef_GlobalPool(SkFlattenableReadBuffer&); SkImageRef_GlobalPool(SkReadBuffer&);
private: private:
typedef SkImageRef INHERITED; typedef SkImageRef INHERITED;

Просмотреть файл

@ -23,8 +23,8 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDiscreteMapper) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDiscreteMapper)
protected: protected:
SkDiscreteMapper(SkFlattenableReadBuffer& ); SkDiscreteMapper(SkReadBuffer& );
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
private: private:
int fSegments; int fSegments;
@ -45,7 +45,7 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkCosineMapper) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkCosineMapper)
protected: protected:
SkCosineMapper(SkFlattenableReadBuffer&); SkCosineMapper(SkReadBuffer&);
private: private:

Просмотреть файл

@ -8,7 +8,8 @@
#include "SampleCode.h" #include "SampleCode.h"
#include "SkView.h" #include "SkView.h"
#include "SkCanvas.h" #include "SkCanvas.h"
#include "SkFlattenableBuffers.h" #include "SkReadBuffer.h"
#include "SkWriteBuffer.h"
#include "SkGradientShader.h" #include "SkGradientShader.h"
#include "SkPath.h" #include "SkPath.h"
#include "SkRegion.h" #include "SkRegion.h"
@ -89,12 +90,12 @@ protected:
dst->addCircle(loc.fX, loc.fY, fRadius); dst->addCircle(loc.fX, loc.fY, fRadius);
} }
Dot2DPathEffect(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) { Dot2DPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {
fRadius = buffer.readScalar(); fRadius = buffer.readScalar();
fPts = NULL; fPts = NULL;
} }
virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE { virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE {
this->INHERITED::flatten(buffer); this->INHERITED::flatten(buffer);
buffer.writeScalar(fRadius); buffer.writeScalar(fRadius);
} }
@ -118,7 +119,7 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(InverseFillPE) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(InverseFillPE)
protected: protected:
InverseFillPE(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {} InverseFillPE(SkReadBuffer& buffer) : INHERITED(buffer) {}
private: private:
typedef SkPathEffect INHERITED; typedef SkPathEffect INHERITED;

Просмотреть файл

@ -19,7 +19,8 @@
#include "SkDashPathEffect.h" #include "SkDashPathEffect.h"
#include "SkDiscretePathEffect.h" #include "SkDiscretePathEffect.h"
#include "SkEmbossMaskFilter.h" #include "SkEmbossMaskFilter.h"
#include "SkFlattenableBuffers.h" #include "SkReadBuffer.h"
#include "SkWriteBuffer.h"
#include "SkGradientShader.h" #include "SkGradientShader.h"
#include "SkImageDecoder.h" #include "SkImageDecoder.h"
#include "SkLayerRasterizer.h" #include "SkLayerRasterizer.h"
@ -171,10 +172,10 @@ protected:
dst->addCircle(loc.fX, loc.fY, fRadius); dst->addCircle(loc.fX, loc.fY, fRadius);
} }
Dot2DPathEffect(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) { Dot2DPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {
fRadius = buffer.readScalar(); fRadius = buffer.readScalar();
} }
virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE { virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE {
this->INHERITED::flatten(buffer); this->INHERITED::flatten(buffer);
buffer.writeScalar(fRadius); buffer.writeScalar(fRadius);
} }

Просмотреть файл

@ -10,7 +10,8 @@
#include "SkBlurMaskFilter.h" #include "SkBlurMaskFilter.h"
#include "SkCanvas.h" #include "SkCanvas.h"
#include "SkDevice.h" #include "SkDevice.h"
#include "SkFlattenableBuffers.h" #include "SkReadBuffer.h"
#include "SkWriteBuffer.h"
#include "SkGradientShader.h" #include "SkGradientShader.h"
#include "SkLayerRasterizer.h" #include "SkLayerRasterizer.h"
#include "SkPaint.h" #include "SkPaint.h"

Просмотреть файл

@ -8,7 +8,8 @@
#include "SampleCode.h" #include "SampleCode.h"
#include "SkView.h" #include "SkView.h"
#include "SkCanvas.h" #include "SkCanvas.h"
#include "SkFlattenableBuffers.h" #include "SkReadBuffer.h"
#include "SkWriteBuffer.h"
#include "SkGradientShader.h" #include "SkGradientShader.h"
#include "SkGraphics.h" #include "SkGraphics.h"
#include "SkImageDecoder.h" #include "SkImageDecoder.h"
@ -59,7 +60,7 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(ReduceNoise) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(ReduceNoise)
private: private:
ReduceNoise(SkFlattenableReadBuffer& rb) : SkKernel33ProcMaskFilter(rb) {} ReduceNoise(SkReadBuffer& rb) : SkKernel33ProcMaskFilter(rb) {}
typedef SkKernel33ProcMaskFilter INHERITED; typedef SkKernel33ProcMaskFilter INHERITED;
}; };
@ -91,7 +92,7 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Darken) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Darken)
private: private:
Darken(SkFlattenableReadBuffer& rb) : SkKernel33ProcMaskFilter(rb) {} Darken(SkReadBuffer& rb) : SkKernel33ProcMaskFilter(rb) {}
typedef SkKernel33ProcMaskFilter INHERITED; typedef SkKernel33ProcMaskFilter INHERITED;
}; };
@ -143,7 +144,7 @@ public:
virtual void xfer16(uint16_t dst[], const SkPMColor src[], int count, virtual void xfer16(uint16_t dst[], const SkPMColor src[], int count,
const SkAlpha aa[]) const SK_OVERRIDE; const SkAlpha aa[]) const SK_OVERRIDE;
typedef SkFlattenable* (*Factory)(SkFlattenableReadBuffer&); typedef SkFlattenable* (*Factory)(SkReadBuffer&);
SK_DEVELOPER_TO_STRING() SK_DEVELOPER_TO_STRING()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPowerMode) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPowerMode)
@ -153,11 +154,11 @@ private:
uint8_t fTable[256]; // cache uint8_t fTable[256]; // cache
void init(SkScalar exponent); void init(SkScalar exponent);
SkPowerMode(SkFlattenableReadBuffer& b) : INHERITED(b) { SkPowerMode(SkReadBuffer& b) : INHERITED(b) {
// read the exponent // read the exponent
this->init(SkFixedToScalar(b.readFixed())); this->init(SkFixedToScalar(b.readFixed()));
} }
virtual void flatten(SkFlattenableWriteBuffer& b) const SK_OVERRIDE { virtual void flatten(SkWriteBuffer& b) const SK_OVERRIDE {
this->INHERITED::flatten(b); this->INHERITED::flatten(b);
b.writeFixed(SkScalarToFixed(fExp)); b.writeFixed(SkScalarToFixed(fExp));
} }

Просмотреть файл

@ -7,7 +7,8 @@
#include "SkAnnotation.h" #include "SkAnnotation.h"
#include "SkData.h" #include "SkData.h"
#include "SkFlattenableBuffers.h" #include "SkReadBuffer.h"
#include "SkWriteBuffer.h"
#include "SkPoint.h" #include "SkPoint.h"
#include "SkStream.h" #include "SkStream.h"
@ -28,12 +29,12 @@ SkData* SkAnnotation::find(const char key[]) const {
return fKey.equals(key) ? fData : NULL; return fKey.equals(key) ? fData : NULL;
} }
SkAnnotation::SkAnnotation(SkFlattenableReadBuffer& buffer) { SkAnnotation::SkAnnotation(SkReadBuffer& buffer) {
buffer.readString(&fKey); buffer.readString(&fKey);
fData = buffer.readByteArrayAsData(); fData = buffer.readByteArrayAsData();
} }
void SkAnnotation::writeToBuffer(SkFlattenableWriteBuffer& buffer) const { void SkAnnotation::writeToBuffer(SkWriteBuffer& buffer) const {
buffer.writeString(fKey.c_str()); buffer.writeString(fKey.c_str());
buffer.writeDataAsByteArray(fData); buffer.writeDataAsByteArray(fData);
} }

Просмотреть файл

@ -14,8 +14,8 @@
#include "SkImagePriv.h" #include "SkImagePriv.h"
#include "SkMallocPixelRef.h" #include "SkMallocPixelRef.h"
#include "SkMask.h" #include "SkMask.h"
#include "SkOrderedReadBuffer.h" #include "SkReadBuffer.h"
#include "SkOrderedWriteBuffer.h" #include "SkWriteBuffer.h"
#include "SkPixelRef.h" #include "SkPixelRef.h"
#include "SkThread.h" #include "SkThread.h"
#include "SkUnPreMultiply.h" #include "SkUnPreMultiply.h"
@ -1583,7 +1583,7 @@ enum {
SERIALIZE_PIXELTYPE_REF_DATA SERIALIZE_PIXELTYPE_REF_DATA
}; };
void SkBitmap::flatten(SkFlattenableWriteBuffer& buffer) const { void SkBitmap::flatten(SkWriteBuffer& buffer) const {
buffer.writeInt(fWidth); buffer.writeInt(fWidth);
buffer.writeInt(fHeight); buffer.writeInt(fHeight);
buffer.writeInt(fRowBytes); 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(); this->reset();
int width = buffer.readInt(); int width = buffer.readInt();

Просмотреть файл

@ -9,7 +9,8 @@
#include "SkBitmapHeap.h" #include "SkBitmapHeap.h"
#include "SkBitmap.h" #include "SkBitmap.h"
#include "SkFlattenableBuffers.h" #include "SkReadBuffer.h"
#include "SkWriteBuffer.h"
#include "SkTSearch.h" #include "SkTSearch.h"
SkBitmapHeapEntry::SkBitmapHeapEntry() SkBitmapHeapEntry::SkBitmapHeapEntry()

Просмотреть файл

@ -6,7 +6,8 @@
* found in the LICENSE file. * found in the LICENSE file.
*/ */
#include "SkColorPriv.h" #include "SkColorPriv.h"
#include "SkFlattenableBuffers.h" #include "SkReadBuffer.h"
#include "SkWriteBuffer.h"
#include "SkPixelRef.h" #include "SkPixelRef.h"
#include "SkErrorInternals.h" #include "SkErrorInternals.h"
#include "SkBitmapProcShader.h" #include "SkBitmapProcShader.h"
@ -38,7 +39,7 @@ SkBitmapProcShader::SkBitmapProcShader(const SkBitmap& src,
fFlags = 0; // computed in setContext fFlags = 0; // computed in setContext
} }
SkBitmapProcShader::SkBitmapProcShader(SkFlattenableReadBuffer& buffer) SkBitmapProcShader::SkBitmapProcShader(SkReadBuffer& buffer)
: INHERITED(buffer) { : INHERITED(buffer) {
buffer.readBitmap(&fRawBitmap); buffer.readBitmap(&fRawBitmap);
fRawBitmap.setImmutable(); fRawBitmap.setImmutable();
@ -63,7 +64,7 @@ SkShader::BitmapType SkBitmapProcShader::asABitmap(SkBitmap* texture,
return kDefault_BitmapType; return kDefault_BitmapType;
} }
void SkBitmapProcShader::flatten(SkFlattenableWriteBuffer& buffer) const { void SkBitmapProcShader::flatten(SkWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer); this->INHERITED::flatten(buffer);
buffer.writeBitmap(fRawBitmap); buffer.writeBitmap(fRawBitmap);

Просмотреть файл

@ -37,8 +37,8 @@ public:
#endif #endif
protected: protected:
SkBitmapProcShader(SkFlattenableReadBuffer& ); SkBitmapProcShader(SkReadBuffer& );
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
SkBitmap fRawBitmap; // experimental for RLE encoding SkBitmap fRawBitmap; // experimental for RLE encoding
SkBitmapProcState fState; SkBitmapProcState fState;

Просмотреть файл

@ -12,7 +12,8 @@
#include "SkColor.h" #include "SkColor.h"
#include "SkColorFilter.h" #include "SkColorFilter.h"
#include "SkFilterShader.h" #include "SkFilterShader.h"
#include "SkFlattenableBuffers.h" #include "SkReadBuffer.h"
#include "SkWriteBuffer.h"
#include "SkMask.h" #include "SkMask.h"
#include "SkMaskFilter.h" #include "SkMaskFilter.h"
#include "SkTemplatesPriv.h" #include "SkTemplatesPriv.h"
@ -682,13 +683,13 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Sk3DShader) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Sk3DShader)
protected: protected:
Sk3DShader(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) { Sk3DShader(SkReadBuffer& buffer) : INHERITED(buffer) {
fProxy = buffer.readShader(); fProxy = buffer.readShader();
fPMColor = buffer.readColor(); fPMColor = buffer.readColor();
fMask = NULL; fMask = NULL;
} }
virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE { virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE {
this->INHERITED::flatten(buffer); this->INHERITED::flatten(buffer);
buffer.writeFlattenable(fProxy); buffer.writeFlattenable(fProxy);
buffer.writeColor(fPMColor); buffer.writeColor(fPMColor);

Просмотреть файл

@ -7,7 +7,8 @@
#include "SkColorFilter.h" #include "SkColorFilter.h"
#include "SkFlattenableBuffers.h" #include "SkReadBuffer.h"
#include "SkWriteBuffer.h"
#include "SkShader.h" #include "SkShader.h"
#include "SkUnPreMultiply.h" #include "SkUnPreMultiply.h"
#include "SkString.h" #include "SkString.h"

Просмотреть файл

@ -8,7 +8,8 @@
#include "SkColorTable.h" #include "SkColorTable.h"
#include "SkFlattenableBuffers.h" #include "SkReadBuffer.h"
#include "SkWriteBuffer.h"
#include "SkStream.h" #include "SkStream.h"
#include "SkTemplates.h" #include "SkTemplates.h"
@ -83,7 +84,7 @@ const uint16_t* SkColorTable::lock16BitCache() {
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
SkColorTable::SkColorTable(SkFlattenableReadBuffer& buffer) { SkColorTable::SkColorTable(SkReadBuffer& buffer) {
f16BitCache = NULL; f16BitCache = NULL;
SkDEBUGCODE(fColorLockCount = 0;) SkDEBUGCODE(fColorLockCount = 0;)
SkDEBUGCODE(f16BitCacheLockCount = 0;) SkDEBUGCODE(f16BitCacheLockCount = 0;)
@ -105,7 +106,7 @@ SkColorTable::SkColorTable(SkFlattenableReadBuffer& buffer) {
#endif #endif
} }
void SkColorTable::writeToBuffer(SkFlattenableWriteBuffer& buffer) const { void SkColorTable::writeToBuffer(SkWriteBuffer& buffer) const {
buffer.writeUInt(fAlphaType); buffer.writeUInt(fAlphaType);
buffer.writeColorArray(fColors, fCount); buffer.writeColorArray(fColors, fCount);
} }

Просмотреть файл

@ -11,7 +11,8 @@
#include "SkColorFilter.h" #include "SkColorFilter.h"
#include "SkColorPriv.h" #include "SkColorPriv.h"
#include "SkColorShader.h" #include "SkColorShader.h"
#include "SkFlattenableBuffers.h" #include "SkReadBuffer.h"
#include "SkWriteBuffer.h"
#include "SkXfermode.h" #include "SkXfermode.h"
#include "SkString.h" #include "SkString.h"
@ -25,7 +26,7 @@ SkComposeShader::SkComposeShader(SkShader* sA, SkShader* sB, SkXfermode* mode) {
SkSafeRef(mode); SkSafeRef(mode);
} }
SkComposeShader::SkComposeShader(SkFlattenableReadBuffer& buffer) : SkComposeShader::SkComposeShader(SkReadBuffer& buffer) :
INHERITED(buffer) { INHERITED(buffer) {
fShaderA = buffer.readShader(); fShaderA = buffer.readShader();
if (NULL == fShaderA) { if (NULL == fShaderA) {
@ -61,7 +62,7 @@ private:
}; };
#define SkAutoAlphaRestore(...) SK_REQUIRE_LOCAL_VAR(SkAutoAlphaRestore) #define SkAutoAlphaRestore(...) SK_REQUIRE_LOCAL_VAR(SkAutoAlphaRestore)
void SkComposeShader::flatten(SkFlattenableWriteBuffer& buffer) const { void SkComposeShader::flatten(SkWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer); this->INHERITED::flatten(buffer);
buffer.writeFlattenable(fShaderA); buffer.writeFlattenable(fShaderA);
buffer.writeFlattenable(fShaderB); buffer.writeFlattenable(fShaderB);

Просмотреть файл

@ -6,7 +6,8 @@
*/ */
#include "SkData.h" #include "SkData.h"
#include "SkFlattenableBuffers.h" #include "SkReadBuffer.h"
#include "SkWriteBuffer.h"
#include "SkOSFile.h" #include "SkOSFile.h"
#include "SkOnce.h" #include "SkOnce.h"

Просмотреть файл

@ -2382,7 +2382,7 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTriColorShader) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTriColorShader)
protected: protected:
SkTriColorShader(SkFlattenableReadBuffer& buffer) : SkShader(buffer) {} SkTriColorShader(SkReadBuffer& buffer) : SkShader(buffer) {}
private: private:
SkMatrix fDstToUnit; SkMatrix fDstToUnit;

Просмотреть файл

@ -8,7 +8,8 @@
#include "SkFilterShader.h" #include "SkFilterShader.h"
#include "SkColorFilter.h" #include "SkColorFilter.h"
#include "SkFlattenableBuffers.h" #include "SkReadBuffer.h"
#include "SkWriteBuffer.h"
#include "SkShader.h" #include "SkShader.h"
#include "SkString.h" #include "SkString.h"
@ -20,7 +21,7 @@ SkFilterShader::SkFilterShader(SkShader* shader, SkColorFilter* filter) {
filter->ref(); filter->ref();
} }
SkFilterShader::SkFilterShader(SkFlattenableReadBuffer& buffer) SkFilterShader::SkFilterShader(SkReadBuffer& buffer)
: INHERITED(buffer) { : INHERITED(buffer) {
fShader = buffer.readShader(); fShader = buffer.readShader();
fFilter = buffer.readColorFilter(); fFilter = buffer.readColorFilter();
@ -31,7 +32,7 @@ SkFilterShader::~SkFilterShader() {
fShader->unref(); fShader->unref();
} }
void SkFilterShader::flatten(SkFlattenableWriteBuffer& buffer) const { void SkFilterShader::flatten(SkWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer); this->INHERITED::flatten(buffer);
buffer.writeFlattenable(fShader); buffer.writeFlattenable(fShader);
buffer.writeFlattenable(fFilter); buffer.writeFlattenable(fFilter);

Просмотреть файл

@ -28,8 +28,8 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkFilterShader) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkFilterShader)
protected: protected:
SkFilterShader(SkFlattenableReadBuffer& ); SkFilterShader(SkReadBuffer& );
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
private: private:
SkShader* fShader; SkShader* fShader;

Просмотреть файл

@ -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 /* 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() to not know that, since we want them to always call INHERITED::flatten()

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -9,11 +9,11 @@
#include "SkData.h" #include "SkData.h"
#include "SkValidatingReadBuffer.h" #include "SkValidatingReadBuffer.h"
#include "SkOrderedWriteBuffer.h" #include "SkWriteBuffer.h"
SkData* SkValidatingSerializeFlattenable(SkFlattenable* flattenable) { SkData* SkValidatingSerializeFlattenable(SkFlattenable* flattenable) {
SkOrderedWriteBuffer writer; SkWriteBuffer writer;
writer.setFlags(SkOrderedWriteBuffer::kValidation_Flag); writer.setFlags(SkWriteBuffer::kValidation_Flag);
writer.writeFlattenable(flattenable); writer.writeFlattenable(flattenable);
uint32_t size = writer.bytesWritten(); uint32_t size = writer.bytesWritten();
void* data = sk_malloc_throw(size); void* data = sk_malloc_throw(size);

Просмотреть файл

@ -8,7 +8,8 @@
#include "SkImageFilter.h" #include "SkImageFilter.h"
#include "SkBitmap.h" #include "SkBitmap.h"
#include "SkFlattenableBuffers.h" #include "SkReadBuffer.h"
#include "SkWriteBuffer.h"
#include "SkRect.h" #include "SkRect.h"
#include "SkValidationUtils.h" #include "SkValidationUtils.h"
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
@ -51,7 +52,7 @@ SkImageFilter::~SkImageFilter() {
delete[] fInputs; delete[] fInputs;
} }
SkImageFilter::SkImageFilter(int inputCount, SkFlattenableReadBuffer& buffer) { SkImageFilter::SkImageFilter(int inputCount, SkReadBuffer& buffer) {
fInputCount = buffer.readInt(); fInputCount = buffer.readInt();
if (buffer.validate((fInputCount >= 0) && ((inputCount < 0) || (fInputCount == inputCount)))) { if (buffer.validate((fInputCount >= 0) && ((inputCount < 0) || (fInputCount == inputCount)))) {
fInputs = new SkImageFilter*[fInputCount]; 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); buffer.writeInt(fInputCount);
for (int i = 0; i < fInputCount; i++) { for (int i = 0; i < fInputCount; i++) {
SkImageFilter* input = getInput(i); SkImageFilter* input = getInput(i);

Просмотреть файл

@ -6,7 +6,8 @@
*/ */
#include "SkImageInfo.h" #include "SkImageInfo.h"
#include "SkFlattenableBuffers.h" #include "SkReadBuffer.h"
#include "SkWriteBuffer.h"
static bool alpha_type_is_valid(SkAlphaType alphaType) { static bool alpha_type_is_valid(SkAlphaType alphaType) {
return (alphaType >= 0) && (alphaType <= kLastEnum_SkAlphaType); return (alphaType >= 0) && (alphaType <= kLastEnum_SkAlphaType);
@ -16,7 +17,7 @@ static bool color_type_is_valid(SkColorType colorType) {
return (colorType >= 0) && (colorType <= kLastEnum_SkColorType); return (colorType >= 0) && (colorType <= kLastEnum_SkColorType);
} }
void SkImageInfo::unflatten(SkFlattenableReadBuffer& buffer) { void SkImageInfo::unflatten(SkReadBuffer& buffer) {
fWidth = buffer.read32(); fWidth = buffer.read32();
fHeight = buffer.read32(); fHeight = buffer.read32();
@ -28,7 +29,7 @@ void SkImageInfo::unflatten(SkFlattenableReadBuffer& buffer) {
color_type_is_valid(fColorType)); color_type_is_valid(fColorType));
} }
void SkImageInfo::flatten(SkFlattenableWriteBuffer& buffer) const { void SkImageInfo::flatten(SkWriteBuffer& buffer) const {
buffer.write32(fWidth); buffer.write32(fWidth);
buffer.write32(fHeight); buffer.write32(fHeight);

Просмотреть файл

@ -7,7 +7,8 @@
#include "SkMallocPixelRef.h" #include "SkMallocPixelRef.h"
#include "SkBitmap.h" #include "SkBitmap.h"
#include "SkFlattenableBuffers.h" #include "SkReadBuffer.h"
#include "SkWriteBuffer.h"
// assumes ptr was allocated via sk_malloc // assumes ptr was allocated via sk_malloc
static void sk_free_releaseproc(void* ptr, void*) { static void sk_free_releaseproc(void* ptr, void*) {
@ -201,7 +202,7 @@ size_t SkMallocPixelRef::getAllocatedSizeInBytes() const {
return this->info().getSafeSize(fRB); return this->info().getSafeSize(fRB);
} }
void SkMallocPixelRef::flatten(SkFlattenableWriteBuffer& buffer) const { void SkMallocPixelRef::flatten(SkWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer); this->INHERITED::flatten(buffer);
buffer.write32(SkToU32(fRB)); 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) : INHERITED(buffer, NULL)
, fReleaseProc(sk_free_releaseproc) , fReleaseProc(sk_free_releaseproc)
, fReleaseProcContext(NULL) , fReleaseProcContext(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

Просмотреть файл

@ -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

Просмотреть файл

@ -18,8 +18,8 @@
#include "SkImageFilter.h" #include "SkImageFilter.h"
#include "SkMaskFilter.h" #include "SkMaskFilter.h"
#include "SkMaskGamma.h" #include "SkMaskGamma.h"
#include "SkOrderedReadBuffer.h" #include "SkReadBuffer.h"
#include "SkOrderedWriteBuffer.h" #include "SkWriteBuffer.h"
#include "SkPaintDefaults.h" #include "SkPaintDefaults.h"
#include "SkPaintOptionsAndroid.h" #include "SkPaintOptionsAndroid.h"
#include "SkPathEffect.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, static void add_flattenable(SkDescriptor* desc, uint32_t tag,
SkOrderedWriteBuffer* buffer) { SkWriteBuffer* buffer) {
buffer->writeToMemory(desc->addEntry(tag, buffer->size(), NULL)); buffer->writeToMemory(desc->addEntry(tag, buffer->bytesWritten(), NULL));
} }
// SkFontHost can override this choice in FilterRec() // SkFontHost can override this choice in FilterRec()
@ -1815,18 +1815,18 @@ void SkPaint::descriptorProc(const SkDeviceProperties* deviceProperties,
SkMaskFilter* mf = this->getMaskFilter(); SkMaskFilter* mf = this->getMaskFilter();
SkRasterizer* ra = this->getRasterizer(); SkRasterizer* ra = this->getRasterizer();
SkOrderedWriteBuffer peBuffer, mfBuffer, raBuffer; SkWriteBuffer peBuffer, mfBuffer, raBuffer;
if (pe) { if (pe) {
peBuffer.writeFlattenable(pe); peBuffer.writeFlattenable(pe);
descSize += peBuffer.size(); descSize += peBuffer.bytesWritten();
entryCount += 1; entryCount += 1;
rec.fMaskFormat = SkMask::kA8_Format; // force antialiasing when we do the scan conversion rec.fMaskFormat = SkMask::kA8_Format; // force antialiasing when we do the scan conversion
// seems like we could support kLCD as well at this point... // seems like we could support kLCD as well at this point...
} }
if (mf) { if (mf) {
mfBuffer.writeFlattenable(mf); mfBuffer.writeFlattenable(mf);
descSize += mfBuffer.size(); descSize += mfBuffer.bytesWritten();
entryCount += 1; entryCount += 1;
rec.fMaskFormat = SkMask::kA8_Format; // force antialiasing with maskfilters rec.fMaskFormat = SkMask::kA8_Format; // force antialiasing with maskfilters
/* Pre-blend is not currently applied to filtered text. /* Pre-blend is not currently applied to filtered text.
@ -1837,15 +1837,15 @@ void SkPaint::descriptorProc(const SkDeviceProperties* deviceProperties,
} }
if (ra) { if (ra) {
raBuffer.writeFlattenable(ra); raBuffer.writeFlattenable(ra);
descSize += raBuffer.size(); descSize += raBuffer.bytesWritten();
entryCount += 1; entryCount += 1;
rec.fMaskFormat = SkMask::kA8_Format; // force antialiasing when we do the scan conversion rec.fMaskFormat = SkMask::kA8_Format; // force antialiasing when we do the scan conversion
} }
#ifdef SK_BUILD_FOR_ANDROID #ifdef SK_BUILD_FOR_ANDROID
SkOrderedWriteBuffer androidBuffer; SkWriteBuffer androidBuffer;
fPaintOptionsAndroid.flatten(androidBuffer); fPaintOptionsAndroid.flatten(androidBuffer);
descSize += androidBuffer.size(); descSize += androidBuffer.bytesWritten();
entryCount += 1; entryCount += 1;
#endif #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 /* To save space/time, we analyze the paint, and write a truncated version of
it if there are not tricky elements like shaders, etc. 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; uint8_t flatFlags = 0;
if (this->getTypeface()) { if (this->getTypeface()) {
flatFlags |= kHasTypeface_FlatFlag; flatFlags |= kHasTypeface_FlatFlag;
@ -2021,42 +2021,24 @@ void SkPaint::flatten(SkFlattenableWriteBuffer& buffer) const {
} }
#endif #endif
if (buffer.isOrderedBinaryBuffer()) { SkASSERT(SkAlign4(kPODPaintSize) == kPODPaintSize);
SkASSERT(SkAlign4(kPODPaintSize) == kPODPaintSize); uint32_t* ptr = buffer.reserve(kPODPaintSize);
uint32_t* ptr = buffer.getOrderedBinaryBuffer()->reserve(kPODPaintSize);
ptr = write_scalar(ptr, this->getTextSize()); ptr = write_scalar(ptr, this->getTextSize());
ptr = write_scalar(ptr, this->getTextScaleX()); ptr = write_scalar(ptr, this->getTextScaleX());
ptr = write_scalar(ptr, this->getTextSkewX()); ptr = write_scalar(ptr, this->getTextSkewX());
ptr = write_scalar(ptr, this->getStrokeWidth()); ptr = write_scalar(ptr, this->getStrokeWidth());
ptr = write_scalar(ptr, this->getStrokeMiter()); ptr = write_scalar(ptr, this->getStrokeMiter());
*ptr++ = this->getColor(); *ptr++ = this->getColor();
// previously flags:16, textAlign:8, flatFlags:8 // previously flags:16, textAlign:8, flatFlags:8
// now flags:16, hinting:4, textAlign:4, flatFlags:8 // now flags:16, hinting:4, textAlign:4, flatFlags:8
*ptr++ = (this->getFlags() << 16) | *ptr++ = (this->getFlags() << 16) |
// hinting added later. 0 in this nibble means use the default. // hinting added later. 0 in this nibble means use the default.
((this->getHinting()+1) << 12) | ((this->getHinting()+1) << 12) |
(this->getTextAlign() << 8) | (this->getTextAlign() << 8) |
flatFlags; flatFlags;
*ptr++ = pack_4(this->getStrokeCap(), this->getStrokeJoin(), *ptr++ = pack_4(this->getStrokeCap(), this->getStrokeJoin(),
this->getStyle(), this->getTextEncoding()); 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);
}
// now we're done with ptr and the (pre)reserved space. If we need to write // now we're done with ptr and the (pre)reserved space. If we need to write
// additional fields, use the buffer directly // additional fields, use the buffer directly
@ -2087,58 +2069,38 @@ void SkPaint::flatten(SkFlattenableWriteBuffer& buffer) const {
#endif #endif
} }
void SkPaint::unflatten(SkFlattenableReadBuffer& buffer) { void SkPaint::unflatten(SkReadBuffer& buffer) {
uint8_t flatFlags = 0; uint8_t flatFlags = 0;
if (buffer.isOrderedBinaryBuffer()) { SkASSERT(SkAlign4(kPODPaintSize) == kPODPaintSize);
SkASSERT(SkAlign4(kPODPaintSize) == kPODPaintSize); const void* podData = buffer.skip(kPODPaintSize);
const void* podData = buffer.getOrderedBinaryBuffer()->skip(kPODPaintSize); const uint32_t* pod = reinterpret_cast<const uint32_t*>(podData);
const uint32_t* pod = reinterpret_cast<const uint32_t*>(podData);
// the order we read must match the order we wrote in flatten() // the order we read must match the order we wrote in flatten()
this->setTextSize(read_scalar(pod)); this->setTextSize(read_scalar(pod));
this->setTextScaleX(read_scalar(pod)); this->setTextScaleX(read_scalar(pod));
this->setTextSkewX(read_scalar(pod)); this->setTextSkewX(read_scalar(pod));
this->setStrokeWidth(read_scalar(pod)); this->setStrokeWidth(read_scalar(pod));
this->setStrokeMiter(read_scalar(pod)); this->setStrokeMiter(read_scalar(pod));
this->setColor(*pod++); this->setColor(*pod++);
// previously flags:16, textAlign:8, flatFlags:8 // previously flags:16, textAlign:8, flatFlags:8
// now flags:16, hinting:4, textAlign:4, flatFlags:8 // now flags:16, hinting:4, textAlign:4, flatFlags:8
uint32_t tmp = *pod++; uint32_t tmp = *pod++;
this->setFlags(tmp >> 16); this->setFlags(tmp >> 16);
// hinting added later. 0 in this nibble means use the default. // hinting added later. 0 in this nibble means use the default.
uint32_t hinting = (tmp >> 12) & 0xF; uint32_t hinting = (tmp >> 12) & 0xF;
this->setHinting(0 == hinting ? kNormal_Hinting : static_cast<Hinting>(hinting-1)); this->setHinting(0 == hinting ? kNormal_Hinting : static_cast<Hinting>(hinting-1));
this->setTextAlign(static_cast<Align>((tmp >> 8) & 0xF)); this->setTextAlign(static_cast<Align>((tmp >> 8) & 0xF));
flatFlags = tmp & 0xFF; flatFlags = tmp & 0xFF;
tmp = *pod++; tmp = *pod++;
this->setStrokeCap(static_cast<Cap>((tmp >> 24) & 0xFF)); this->setStrokeCap(static_cast<Cap>((tmp >> 24) & 0xFF));
this->setStrokeJoin(static_cast<Join>((tmp >> 16) & 0xFF)); this->setStrokeJoin(static_cast<Join>((tmp >> 16) & 0xFF));
this->setStyle(static_cast<Style>((tmp >> 8) & 0xFF)); this->setStyle(static_cast<Style>((tmp >> 8) & 0xFF));
this->setTextEncoding(static_cast<TextEncoding>((tmp >> 0) & 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()));
}
if (flatFlags & kHasTypeface_FlatFlag) { if (flatFlags & kHasTypeface_FlatFlag) {
this->setTypeface(buffer.readTypeface()); this->setTypeface(buffer.readTypeface());

Просмотреть файл

@ -7,7 +7,8 @@
*/ */
#include "SkPaintOptionsAndroid.h" #include "SkPaintOptionsAndroid.h"
#include "SkFlattenableBuffers.h" #include "SkReadBuffer.h"
#include "SkWriteBuffer.h"
#include "SkTDict.h" #include "SkTDict.h"
#include "SkThread.h" #include "SkThread.h"
#include <cstring> #include <cstring>
@ -25,13 +26,13 @@ SkLanguage SkLanguage::getParent() const {
return SkLanguage(tag, parentTagLen); return SkLanguage(tag, parentTagLen);
} }
void SkPaintOptionsAndroid::flatten(SkFlattenableWriteBuffer& buffer) const { void SkPaintOptionsAndroid::flatten(SkWriteBuffer& buffer) const {
buffer.writeUInt(fFontVariant); buffer.writeUInt(fFontVariant);
buffer.writeString(fLanguage.getTag().c_str()); buffer.writeString(fLanguage.getTag().c_str());
buffer.writeBool(fUseFontFallbacks); buffer.writeBool(fUseFontFallbacks);
} }
void SkPaintOptionsAndroid::unflatten(SkFlattenableReadBuffer& buffer) { void SkPaintOptionsAndroid::unflatten(SkReadBuffer& buffer) {
fFontVariant = (FontVariant)buffer.readUInt(); fFontVariant = (FontVariant)buffer.readUInt();
SkString tag; SkString tag;
buffer.readString(&tag); buffer.readString(&tag);

Просмотреть файл

@ -8,7 +8,8 @@
#include "SkPathEffect.h" #include "SkPathEffect.h"
#include "SkPath.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] 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); this->INHERITED::flatten(buffer);
buffer.writeFlattenable(fPE0); buffer.writeFlattenable(fPE0);
buffer.writeFlattenable(fPE1); buffer.writeFlattenable(fPE1);
} }
SkPairPathEffect::SkPairPathEffect(SkFlattenableReadBuffer& buffer) { SkPairPathEffect::SkPairPathEffect(SkReadBuffer& buffer) {
fPE0 = buffer.readPathEffect(); fPE0 = buffer.readPathEffect();
fPE1 = buffer.readPathEffect(); fPE1 = buffer.readPathEffect();
// either of these may fail, so we have to check for nulls later on // either of these may fail, so we have to check for nulls later on

Просмотреть файл

@ -8,7 +8,8 @@
#include "SkPathHeap.h" #include "SkPathHeap.h"
#include "SkPath.h" #include "SkPath.h"
#include "SkStream.h" #include "SkStream.h"
#include "SkFlattenableBuffers.h" #include "SkReadBuffer.h"
#include "SkWriteBuffer.h"
#include <new> #include <new>
#define kPathCount 64 #define kPathCount 64
@ -16,7 +17,7 @@
SkPathHeap::SkPathHeap() : fHeap(kPathCount * sizeof(SkPath)) { SkPathHeap::SkPathHeap() : fHeap(kPathCount * sizeof(SkPath)) {
} }
SkPathHeap::SkPathHeap(SkFlattenableReadBuffer& buffer) SkPathHeap::SkPathHeap(SkReadBuffer& buffer)
: fHeap(kPathCount * sizeof(SkPath)) { : fHeap(kPathCount * sizeof(SkPath)) {
const int count = buffer.readInt(); const int count = buffer.readInt();
@ -48,7 +49,7 @@ int SkPathHeap::append(const SkPath& path) {
return fPaths.count(); return fPaths.count();
} }
void SkPathHeap::flatten(SkFlattenableWriteBuffer& buffer) const { void SkPathHeap::flatten(SkWriteBuffer& buffer) const {
int count = fPaths.count(); int count = fPaths.count();
buffer.writeInt(count); buffer.writeInt(count);

Просмотреть файл

@ -13,15 +13,15 @@
#include "SkTDArray.h" #include "SkTDArray.h"
class SkPath; class SkPath;
class SkFlattenableReadBuffer; class SkReadBuffer;
class SkFlattenableWriteBuffer; class SkWriteBuffer;
class SkPathHeap : public SkRefCnt { class SkPathHeap : public SkRefCnt {
public: public:
SK_DECLARE_INST_COUNT(SkPathHeap) SK_DECLARE_INST_COUNT(SkPathHeap)
SkPathHeap(); SkPathHeap();
SkPathHeap(SkFlattenableReadBuffer&); SkPathHeap(SkReadBuffer&);
virtual ~SkPathHeap(); virtual ~SkPathHeap();
/** Copy the path into the heap, and return the new total number of paths. /** Copy the path into the heap, and return the new total number of paths.
@ -36,7 +36,7 @@ public:
return *fPaths[index]; return *fPaths[index];
} }
void flatten(SkFlattenableWriteBuffer&) const; void flatten(SkWriteBuffer&) const;
private: private:
// we store the paths in the heap (placement new) // we store the paths in the heap (placement new)

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше