Chromium Code Reviews| Index: src/core/SkValidatingReadBuffer.h |
| diff --git a/src/core/SkValidatingReadBuffer.h b/src/core/SkValidatingReadBuffer.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6dcff874bcdcd67f9c907589d9aaf20250214e57 |
| --- /dev/null |
| +++ b/src/core/SkValidatingReadBuffer.h |
| @@ -0,0 +1,83 @@ |
| +/* |
| + * Copyright 2013 Google Inc. |
| + * |
| + * Use of this source code is governed by a BSD-style license that can be |
| + * found in the LICENSE file. |
| + */ |
| + |
| +#ifndef SkValidatingReadBuffer_DEFINED |
| +#define SkValidatingReadBuffer_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) |
|
mtklein
2013/10/07 19:29:56
Is this left over from an old version? Any idea w
sugoi1
2013/10/08 20:23:10
Yeah, that's from SkOrderedReadBuffer.h. I removed
|
| + #define DEBUG_NON_DETERMINISTIC_ASSERT |
| +#endif |
| + |
| +class SkValidatingReadBuffer : public SkFlattenableReadBuffer { |
| +public: |
| + SkValidatingReadBuffer(); |
| + SkValidatingReadBuffer(const void* data, size_t size); |
| + SkValidatingReadBuffer(SkStream* stream); |
| + virtual ~SkValidatingReadBuffer(); |
| + |
| + const void* skip(size_t 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( |
| + const char* name = SkFlattenable::GetName()) 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; |
| + // TODO: Implement this (with securely) when needed |
|
mtklein
2013/10/07 19:29:56
with securely?
sugoi1
2013/10/08 20:23:10
That's what happens when I'm thinking of 2 sentenc
|
| + virtual SkTypeface* readTypeface() SK_OVERRIDE { return NULL; } |
| + |
| +private: |
| + void setMemory(const void* data, size_t size); |
| + |
| + static bool IsPtrAlign4(const void* ptr) { |
| + return SkIsAlign4((uintptr_t)ptr); |
| + } |
| + |
| + SkReader32 fReader; |
| + void* fMemoryPtr; |
| + |
| + typedef SkFlattenableReadBuffer INHERITED; |
| +}; |
| + |
| +#endif // SkValidatingReadBuffer_DEFINED |