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

Side by Side Diff: include/core/SkFlattenableBuffers.h

Issue 23548034: Follow up to serialization validation code (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 3 months 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 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #ifndef SkFlattenableBuffers_DEFINED 9 #ifndef SkFlattenableBuffers_DEFINED
10 #define SkFlattenableBuffers_DEFINED 10 #define SkFlattenableBuffers_DEFINED
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 virtual int32_t readInt() = 0; 63 virtual int32_t readInt() = 0;
64 virtual SkScalar readScalar() = 0; 64 virtual SkScalar readScalar() = 0;
65 virtual uint32_t readUInt() = 0; 65 virtual uint32_t readUInt() = 0;
66 virtual int32_t read32() = 0; 66 virtual int32_t read32() = 0;
67 67
68 // strings -- the caller is responsible for freeing the string contents 68 // strings -- the caller is responsible for freeing the string contents
69 virtual void readString(SkString* string) = 0; 69 virtual void readString(SkString* string) = 0;
70 virtual void* readEncodedString(size_t* length, SkPaint::TextEncoding encodi ng) = 0; 70 virtual void* readEncodedString(size_t* length, SkPaint::TextEncoding encodi ng) = 0;
71 71
72 // common data structures 72 // common data structures
73 virtual SkFlattenable* readFlattenable() = 0;
74 virtual void readPoint(SkPoint* point) = 0; 73 virtual void readPoint(SkPoint* point) = 0;
75 virtual void readMatrix(SkMatrix* matrix) = 0; 74 virtual void readMatrix(SkMatrix* matrix) = 0;
76 virtual void readIRect(SkIRect* rect) = 0; 75 virtual void readIRect(SkIRect* rect) = 0;
77 virtual void readRect(SkRect* rect) = 0; 76 virtual void readRect(SkRect* rect) = 0;
78 virtual void readRegion(SkRegion* region) = 0; 77 virtual void readRegion(SkRegion* region) = 0;
79 virtual void readPath(SkPath* path) = 0; 78 virtual void readPath(SkPath* path) = 0;
80 79
81 // binary data and arrays 80 // binary data and arrays
82 virtual uint32_t readByteArray(void* value) = 0; 81 virtual uint32_t readByteArray(void* value) = 0;
83 virtual uint32_t readColorArray(SkColor* colors) = 0; 82 virtual uint32_t readColorArray(SkColor* colors) = 0;
(...skipping 22 matching lines...) Expand all
106 105
107 template <typename T> T* readFlattenableT() { 106 template <typename T> T* readFlattenableT() {
108 return static_cast<T*>(this->readFlattenable()); 107 return static_cast<T*>(this->readFlattenable());
109 } 108 }
110 109
111 void validate(bool isValid) { 110 void validate(bool isValid) {
112 fError |= !isValid; 111 fError |= !isValid;
113 } 112 }
114 113
115 protected: 114 protected:
115 // Use readFlattenableT to enforce a type check on the flattenable read
reed1 2013/09/13 15:18:41 How does this enforce a type-check?
116 virtual SkFlattenable* readFlattenable() = 0;
117
116 bool fError; 118 bool fError;
117 119
118 private: 120 private:
119 uint32_t fFlags; 121 uint32_t fFlags;
120 }; 122 };
121 123
122 /////////////////////////////////////////////////////////////////////////////// 124 ///////////////////////////////////////////////////////////////////////////////
123 125
124 class SkFlattenableWriteBuffer { 126 class SkFlattenableWriteBuffer {
125 public: 127 public:
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 bool persistTypeface() const { return (fFlags & kCrossProcess_Flag) != 0; } 190 bool persistTypeface() const { return (fFlags & kCrossProcess_Flag) != 0; }
189 191
190 protected: 192 protected:
191 // A helper function so that each subclass does not have to be a friend of S kFlattenable 193 // A helper function so that each subclass does not have to be a friend of S kFlattenable
192 void flattenObject(SkFlattenable* obj, SkFlattenableWriteBuffer& buffer); 194 void flattenObject(SkFlattenable* obj, SkFlattenableWriteBuffer& buffer);
193 195
194 uint32_t fFlags; 196 uint32_t fFlags;
195 }; 197 };
196 198
197 #endif 199 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkFlattenableSerialization.cpp » ('j') | src/core/SkFlattenableSerialization.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698