| 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 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 virtual int32_t readInt() SK_OVERRIDE; | 42 virtual int32_t readInt() SK_OVERRIDE; |
| 43 virtual SkScalar readScalar() SK_OVERRIDE; | 43 virtual SkScalar readScalar() SK_OVERRIDE; |
| 44 virtual uint32_t readUInt() SK_OVERRIDE; | 44 virtual uint32_t readUInt() SK_OVERRIDE; |
| 45 virtual int32_t read32() SK_OVERRIDE; | 45 virtual int32_t read32() SK_OVERRIDE; |
| 46 | 46 |
| 47 // strings -- the caller is responsible for freeing the string contents | 47 // strings -- the caller is responsible for freeing the string contents |
| 48 virtual void readString(SkString* string) SK_OVERRIDE; | 48 virtual void readString(SkString* string) SK_OVERRIDE; |
| 49 virtual void* readEncodedString(size_t* length, SkPaint::TextEncoding encodi
ng) SK_OVERRIDE; | 49 virtual void* readEncodedString(size_t* length, SkPaint::TextEncoding encodi
ng) SK_OVERRIDE; |
| 50 | 50 |
| 51 // common data structures | 51 // common data structures |
| 52 virtual SkFlattenable* readFlattenable() SK_OVERRIDE; | |
| 53 virtual void readPoint(SkPoint* point) SK_OVERRIDE; | 52 virtual void readPoint(SkPoint* point) SK_OVERRIDE; |
| 54 virtual void readMatrix(SkMatrix* matrix) SK_OVERRIDE; | 53 virtual void readMatrix(SkMatrix* matrix) SK_OVERRIDE; |
| 55 virtual void readIRect(SkIRect* rect) SK_OVERRIDE; | 54 virtual void readIRect(SkIRect* rect) SK_OVERRIDE; |
| 56 virtual void readRect(SkRect* rect) SK_OVERRIDE; | 55 virtual void readRect(SkRect* rect) SK_OVERRIDE; |
| 57 virtual void readRegion(SkRegion* region) SK_OVERRIDE; | 56 virtual void readRegion(SkRegion* region) SK_OVERRIDE; |
| 58 virtual void readPath(SkPath* path) SK_OVERRIDE; | 57 virtual void readPath(SkPath* path) SK_OVERRIDE; |
| 59 | 58 |
| 60 // binary data and arrays | 59 // binary data and arrays |
| 61 virtual uint32_t readByteArray(void* value) SK_OVERRIDE; | 60 virtual uint32_t readByteArray(void* value) SK_OVERRIDE; |
| 62 virtual uint32_t readColorArray(SkColor* colors) SK_OVERRIDE; | 61 virtual uint32_t readColorArray(SkColor* colors) SK_OVERRIDE; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 | 101 |
| 103 /** | 102 /** |
| 104 * Provide a function to decode an SkBitmap from encoded data. Only used if
the writer | 103 * Provide a function to decode an SkBitmap from encoded data. Only used if
the writer |
| 105 * encoded the SkBitmap. If the proper decoder cannot be used, a red bitmap
with the | 104 * encoded the SkBitmap. If the proper decoder cannot be used, a red bitmap
with the |
| 106 * appropriate size will be used. | 105 * appropriate size will be used. |
| 107 */ | 106 */ |
| 108 void setBitmapDecoder(SkPicture::InstallPixelRefProc bitmapDecoder) { | 107 void setBitmapDecoder(SkPicture::InstallPixelRefProc bitmapDecoder) { |
| 109 fBitmapDecoder = bitmapDecoder; | 108 fBitmapDecoder = bitmapDecoder; |
| 110 } | 109 } |
| 111 | 110 |
| 111 protected: |
| 112 // Use readFlattenableT to enforce a type check on the flattenable read |
| 113 virtual SkFlattenable* readFlattenable() SK_OVERRIDE; |
| 114 |
| 112 private: | 115 private: |
| 113 void setMemory(const void* data, size_t size); | 116 void setMemory(const void* data, size_t size); |
| 114 | 117 |
| 115 static bool ptr_align_4(const void* ptr) { | 118 static bool ptr_align_4(const void* ptr) { |
| 116 return (((const char*)ptr - (const char*)NULL) & 3) == 0; | 119 return (((const char*)ptr - (const char*)NULL) & 3) == 0; |
| 117 } | 120 } |
| 118 | 121 |
| 119 SkReader32 fReader; | 122 SkReader32 fReader; |
| 120 void* fMemoryPtr; | 123 void* fMemoryPtr; |
| 121 | 124 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 132 #ifdef DEBUG_NON_DETERMINISTIC_ASSERT | 135 #ifdef DEBUG_NON_DETERMINISTIC_ASSERT |
| 133 // Debugging counter to keep track of how many bitmaps we | 136 // Debugging counter to keep track of how many bitmaps we |
| 134 // have decoded. | 137 // have decoded. |
| 135 int fDecodedBitmapIndex; | 138 int fDecodedBitmapIndex; |
| 136 #endif // DEBUG_NON_DETERMINISTIC_ASSERT | 139 #endif // DEBUG_NON_DETERMINISTIC_ASSERT |
| 137 | 140 |
| 138 typedef SkFlattenableReadBuffer INHERITED; | 141 typedef SkFlattenableReadBuffer INHERITED; |
| 139 }; | 142 }; |
| 140 | 143 |
| 141 #endif // SkValidatingReadBuffer_DEFINED | 144 #endif // SkValidatingReadBuffer_DEFINED |
| OLD | NEW |