aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar mike@reedtribe.org <mike@reedtribe.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-08-09 00:49:00 +0000
committerGravatar mike@reedtribe.org <mike@reedtribe.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-08-09 00:49:00 +0000
commitefb65de8ab9f62244659a0e7792db98bef9a01b0 (patch)
tree7112b5982bcf12be1a0f18c7d184a20c959e4fd1 /src
parent1407a4861a0d3951fc45783b1573607049fac037 (diff)
privatization -- moving headers out of include into src
git-svn-id: http://skia.googlecode.com/svn/trunk@5024 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r--src/core/SkOrderedReadBuffer.h115
-rw-r--r--src/core/SkOrderedWriteBuffer.h89
2 files changed, 204 insertions, 0 deletions
diff --git a/src/core/SkOrderedReadBuffer.h b/src/core/SkOrderedReadBuffer.h
new file mode 100644
index 0000000000..8462b7f89d
--- /dev/null
+++ b/src/core/SkOrderedReadBuffer.h
@@ -0,0 +1,115 @@
+
+/*
+ * 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 "SkBitmap.h"
+#include "SkBitmapHeap.h"
+#include "SkFlattenableBuffers.h"
+#include "SkReader32.h"
+#include "SkPath.h"
+
+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 char* readString() SK_OVERRIDE;
+ virtual void* readEncodedString(size_t* length, SkPaint::TextEncoding encoding) SK_OVERRIDE;
+
+ // common data structures
+ virtual SkFlattenable* readFlattenable() 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 uint32_t readByteArray(void* value) SK_OVERRIDE;
+ virtual uint32_t readColorArray(SkColor* colors) SK_OVERRIDE;
+ virtual uint32_t readIntArray(int32_t* values) SK_OVERRIDE;
+ virtual uint32_t readPointArray(SkPoint* points) SK_OVERRIDE;
+ virtual uint32_t readScalarArray(SkScalar* values) 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
+ * the writer's kInlineFactoryNames_Flag.
+ */
+ void setFactoryArray(SkTDArray<SkFlattenable::Factory>* array) {
+ fFactoryTDArray = array;
+ fFactoryArray = NULL;
+ fFactoryCount = 0;
+ }
+
+private:
+ SkReader32 fReader;
+ void* fMemoryPtr;
+
+ SkBitmapHeapReader* fBitmapStorage;
+ SkTypeface** fTFArray;
+ int fTFCount;
+
+ SkTDArray<SkFlattenable::Factory>* fFactoryTDArray;
+ SkFlattenable::Factory* fFactoryArray;
+ int fFactoryCount;
+
+ typedef SkFlattenableReadBuffer INHERITED;
+};
+
+#endif // SkOrderedReadBuffer_DEFINED
diff --git a/src/core/SkOrderedWriteBuffer.h b/src/core/SkOrderedWriteBuffer.h
new file mode 100644
index 0000000000..7be2a90bc3
--- /dev/null
+++ b/src/core/SkOrderedWriteBuffer.h
@@ -0,0 +1,89 @@
+
+/*
+ * 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 "SkBitmap.h"
+#include "SkBitmapHeap.h"
+#include "SkPath.h"
+#include "SkWriter32.h"
+
+class SkFlattenable;
+
+class SkOrderedWriteBuffer : public SkFlattenableWriteBuffer {
+public:
+ SkOrderedWriteBuffer(size_t minSize);
+ SkOrderedWriteBuffer(size_t minSize, 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 writeToMemory(void* dst) { fWriter.flatten(dst); }
+ uint32_t* reserve(size_t size) { return fWriter.reserve(size); }
+ uint32_t size() { return fWriter.size(); }
+
+ 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(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*);
+
+ void setBitmapHeap(SkBitmapHeap* bitmapHeap) {
+ SkRefCnt_SafeAssign(fBitmapHeap, bitmapHeap);
+ }
+
+private:
+ SkFactorySet* fFactorySet;
+ SkNamedFactorySet* fNamedFactorySet;
+ SkWriter32 fWriter;
+
+ SkBitmapHeap* fBitmapHeap;
+ SkRefCntSet* fTFSet;
+
+ typedef SkFlattenableWriteBuffer INHERITED;
+};
+
+#endif // SkOrderedWriteBuffer_DEFINED