Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: src/core/SkValidatingReadBuffer.h

Issue 37803002: Adding size parameter to read array functions (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Cleanup Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 29 matching lines...) Expand all
40 // common data structures 40 // common data structures
41 virtual SkFlattenable* readFlattenable(SkFlattenable::Type type) SK_OVERRIDE ; 41 virtual SkFlattenable* readFlattenable(SkFlattenable::Type type) SK_OVERRIDE ;
42 virtual void readPoint(SkPoint* point) SK_OVERRIDE; 42 virtual void readPoint(SkPoint* point) SK_OVERRIDE;
43 virtual void readMatrix(SkMatrix* matrix) SK_OVERRIDE; 43 virtual void readMatrix(SkMatrix* matrix) SK_OVERRIDE;
44 virtual void readIRect(SkIRect* rect) SK_OVERRIDE; 44 virtual void readIRect(SkIRect* rect) SK_OVERRIDE;
45 virtual void readRect(SkRect* rect) SK_OVERRIDE; 45 virtual void readRect(SkRect* rect) SK_OVERRIDE;
46 virtual void readRegion(SkRegion* region) SK_OVERRIDE; 46 virtual void readRegion(SkRegion* region) SK_OVERRIDE;
47 virtual void readPath(SkPath* path) SK_OVERRIDE; 47 virtual void readPath(SkPath* path) SK_OVERRIDE;
48 48
49 // binary data and arrays 49 // binary data and arrays
50 virtual uint32_t readByteArray(void* value) SK_OVERRIDE; 50 virtual bool readByteArray(void* value, size_t size) SK_OVERRIDE;
51 virtual uint32_t readColorArray(SkColor* colors) SK_OVERRIDE; 51 virtual bool readColorArray(SkColor* colors, size_t size) SK_OVERRIDE;
52 virtual uint32_t readIntArray(int32_t* values) SK_OVERRIDE; 52 virtual bool readIntArray(int32_t* values, size_t size) SK_OVERRIDE;
53 virtual uint32_t readPointArray(SkPoint* points) SK_OVERRIDE; 53 virtual bool readPointArray(SkPoint* points, size_t size) SK_OVERRIDE;
54 virtual uint32_t readScalarArray(SkScalar* values) SK_OVERRIDE; 54 virtual bool readScalarArray(SkScalar* values, size_t size) SK_OVERRIDE;
55 55
56 // helpers to get info about arrays and binary data 56 // helpers to get info about arrays and binary data
57 virtual uint32_t getArrayCount() SK_OVERRIDE; 57 virtual uint32_t getArrayCount() SK_OVERRIDE;
58 58
59 virtual void readBitmap(SkBitmap* bitmap) SK_OVERRIDE; 59 virtual void readBitmap(SkBitmap* bitmap) SK_OVERRIDE;
60 // TODO: Implement this (securely) when needed 60 // TODO: Implement this (securely) when needed
61 virtual SkTypeface* readTypeface() SK_OVERRIDE { return NULL; } 61 virtual SkTypeface* readTypeface() SK_OVERRIDE { return NULL; }
62 62
63 virtual void validate(bool isValid) SK_OVERRIDE { 63 virtual void validate(bool isValid) SK_OVERRIDE {
reed1 2013/10/30 20:22:32 at some point, we should move all of these virtual
sugoi1 2013/10/31 14:16:24 Done.
64 fError = fError || !isValid; 64 if (!fError && !isValid) {
65 // When an error is found, send the read cursor to the end of the st ream
66 fReader.skip(fReader.available());
67 fError = true;
68 }
65 } 69 }
66 70
67 private: 71 private:
72 template <typename T> bool readArray(T* value, size_t size);
73
68 void setMemory(const void* data, size_t size); 74 void setMemory(const void* data, size_t size);
69 75
70 static bool IsPtrAlign4(const void* ptr) { 76 static bool IsPtrAlign4(const void* ptr) {
71 return SkIsAlign4((uintptr_t)ptr); 77 return SkIsAlign4((uintptr_t)ptr);
72 } 78 }
73 79
74 SkReader32 fReader; 80 SkReader32 fReader;
75 bool fError; 81 bool fError;
76 82
77 typedef SkFlattenableReadBuffer INHERITED; 83 typedef SkFlattenableReadBuffer INHERITED;
78 }; 84 };
79 85
80 #endif // SkValidatingReadBuffer_DEFINED 86 #endif // SkValidatingReadBuffer_DEFINED
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698