| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkValidatingReadBuffer_DEFINED | 8 #ifndef SkValidatingReadBuffer_DEFINED |
| 9 #define SkValidatingReadBuffer_DEFINED | 9 #define SkValidatingReadBuffer_DEFINED |
| 10 | 10 |
| 11 #include "SkRefCnt.h" | 11 #include "SkRefCnt.h" |
| 12 #include "SkBitmapHeap.h" | 12 #include "SkBitmapHeap.h" |
| 13 #include "SkReadBuffer.h" | 13 #include "SkReadBuffer.h" |
| 14 #include "SkWriteBuffer.h" | 14 #include "SkWriteBuffer.h" |
| 15 #include "SkPath.h" | 15 #include "SkPath.h" |
| 16 #include "SkPicture.h" | 16 #include "SkPicture.h" |
| 17 #include "SkReader32.h" | 17 #include "SkReader32.h" |
| 18 | 18 |
| 19 class SkBitmap; | 19 class SkBitmap; |
| 20 | 20 |
| 21 class SkValidatingReadBuffer : public SkReadBuffer { | 21 class SkValidatingReadBuffer : public SkReadBuffer { |
| 22 public: | 22 public: |
| 23 SkValidatingReadBuffer(const void* data, size_t size); | 23 SkValidatingReadBuffer(const void* data, size_t size); |
| 24 virtual ~SkValidatingReadBuffer(); | 24 virtual ~SkValidatingReadBuffer(); |
| 25 | 25 |
| 26 const void* skip(size_t size) SK_OVERRIDE; | 26 const void* skip(size_t size) override; |
| 27 | 27 |
| 28 // primitives | 28 // primitives |
| 29 bool readBool() SK_OVERRIDE; | 29 bool readBool() override; |
| 30 SkColor readColor() SK_OVERRIDE; | 30 SkColor readColor() override; |
| 31 SkFixed readFixed() SK_OVERRIDE; | 31 SkFixed readFixed() override; |
| 32 int32_t readInt() SK_OVERRIDE; | 32 int32_t readInt() override; |
| 33 SkScalar readScalar() SK_OVERRIDE; | 33 SkScalar readScalar() override; |
| 34 uint32_t readUInt() SK_OVERRIDE; | 34 uint32_t readUInt() override; |
| 35 int32_t read32() SK_OVERRIDE; | 35 int32_t read32() override; |
| 36 | 36 |
| 37 // strings -- the caller is responsible for freeing the string contents | 37 // strings -- the caller is responsible for freeing the string contents |
| 38 void readString(SkString* string) SK_OVERRIDE; | 38 void readString(SkString* string) override; |
| 39 void* readEncodedString(size_t* length, SkPaint::TextEncoding encoding) SK_O
VERRIDE; | 39 void* readEncodedString(size_t* length, SkPaint::TextEncoding encoding) over
ride; |
| 40 | 40 |
| 41 // common data structures | 41 // common data structures |
| 42 SkFlattenable* readFlattenable(SkFlattenable::Type type) SK_OVERRIDE; | 42 SkFlattenable* readFlattenable(SkFlattenable::Type type) override; |
| 43 void skipFlattenable() SK_OVERRIDE; | 43 void skipFlattenable() override; |
| 44 void readPoint(SkPoint* point) SK_OVERRIDE; | 44 void readPoint(SkPoint* point) override; |
| 45 void readMatrix(SkMatrix* matrix) SK_OVERRIDE; | 45 void readMatrix(SkMatrix* matrix) override; |
| 46 void readIRect(SkIRect* rect) SK_OVERRIDE; | 46 void readIRect(SkIRect* rect) override; |
| 47 void readRect(SkRect* rect) SK_OVERRIDE; | 47 void readRect(SkRect* rect) override; |
| 48 void readRegion(SkRegion* region) SK_OVERRIDE; | 48 void readRegion(SkRegion* region) override; |
| 49 void readPath(SkPath* path) SK_OVERRIDE; | 49 void readPath(SkPath* path) override; |
| 50 | 50 |
| 51 // binary data and arrays | 51 // binary data and arrays |
| 52 bool readByteArray(void* value, size_t size) SK_OVERRIDE; | 52 bool readByteArray(void* value, size_t size) override; |
| 53 bool readColorArray(SkColor* colors, size_t size) SK_OVERRIDE; | 53 bool readColorArray(SkColor* colors, size_t size) override; |
| 54 bool readIntArray(int32_t* values, size_t size) SK_OVERRIDE; | 54 bool readIntArray(int32_t* values, size_t size) override; |
| 55 bool readPointArray(SkPoint* points, size_t size) SK_OVERRIDE; | 55 bool readPointArray(SkPoint* points, size_t size) override; |
| 56 bool readScalarArray(SkScalar* values, size_t size) SK_OVERRIDE; | 56 bool readScalarArray(SkScalar* values, size_t size) override; |
| 57 | 57 |
| 58 // helpers to get info about arrays and binary data | 58 // helpers to get info about arrays and binary data |
| 59 uint32_t getArrayCount() SK_OVERRIDE; | 59 uint32_t getArrayCount() override; |
| 60 | 60 |
| 61 // TODO: Implement this (securely) when needed | 61 // TODO: Implement this (securely) when needed |
| 62 SkTypeface* readTypeface() SK_OVERRIDE; | 62 SkTypeface* readTypeface() override; |
| 63 | 63 |
| 64 bool validate(bool isValid) SK_OVERRIDE; | 64 bool validate(bool isValid) override; |
| 65 bool isValid() const SK_OVERRIDE; | 65 bool isValid() const override; |
| 66 | 66 |
| 67 bool validateAvailable(size_t size) SK_OVERRIDE; | 67 bool validateAvailable(size_t size) override; |
| 68 | 68 |
| 69 private: | 69 private: |
| 70 bool readArray(void* value, size_t size, size_t elementSize); | 70 bool readArray(void* value, size_t size, size_t elementSize); |
| 71 | 71 |
| 72 void setMemory(const void* data, size_t size); | 72 void setMemory(const void* data, size_t size); |
| 73 | 73 |
| 74 static bool IsPtrAlign4(const void* ptr) { | 74 static bool IsPtrAlign4(const void* ptr) { |
| 75 return SkIsAlign4((uintptr_t)ptr); | 75 return SkIsAlign4((uintptr_t)ptr); |
| 76 } | 76 } |
| 77 | 77 |
| 78 bool fError; | 78 bool fError; |
| 79 | 79 |
| 80 typedef SkReadBuffer INHERITED; | 80 typedef SkReadBuffer INHERITED; |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 #endif // SkValidatingReadBuffer_DEFINED | 83 #endif // SkValidatingReadBuffer_DEFINED |
| OLD | NEW |