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

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

Issue 26702002: force readbuffer clients to use specialized readFoo for flattenables (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 2 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
« no previous file with comments | « no previous file | src/core/SkBitmap.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 11
12 #include "SkColor.h" 12 #include "SkColor.h"
13 #include "SkData.h" 13 #include "SkData.h"
14 #include "SkPaint.h" 14 #include "SkPaint.h"
15 #include "SkPoint.h" 15 #include "SkPoint.h"
16 16
17 class SkBitmap; 17 class SkBitmap;
18 class SkDrawLooper;
18 class SkFlattenable; 19 class SkFlattenable;
19 struct SkIRect; 20 struct SkIRect;
20 class SkMatrix; 21 class SkMatrix;
21 class SkOrderedReadBuffer; 22 class SkOrderedReadBuffer;
22 class SkOrderedWriteBuffer; 23 class SkOrderedWriteBuffer;
23 class SkPath; 24 class SkPath;
24 class SkPixelRef; 25 class SkPixelRef;
25 struct SkRect; 26 struct SkRect;
26 class SkRefCnt; 27 class SkRefCnt;
27 class SkRegion; 28 class SkRegion;
28 class SkStream; 29 class SkStream;
29 class SkString; 30 class SkString;
30 class SkTypeface; 31 class SkTypeface;
32 class SkUnitMapper;
31 class SkWStream; 33 class SkWStream;
32 34
35 enum SkEffectType {
36 kColorFilter_SkEffectType,
37 kDrawLooper_SkEffectType,
38 kImageFilter_SkEffectType,
39 kMaskFilter_SkEffectType,
40 kPathEffect_SkEffectType,
41 kPixelRef_SkEffectType,
42 kRasterizer_SkEffectType,
43 kShader_SkEffectType,
44 kUnitMapper_SkEffectType,
45 kXfermode_SkEffectType,
46 };
47
33 class SkFlattenableReadBuffer { 48 class SkFlattenableReadBuffer {
34 public: 49 public:
35 SkFlattenableReadBuffer(); 50 SkFlattenableReadBuffer();
36 virtual ~SkFlattenableReadBuffer(); 51 virtual ~SkFlattenableReadBuffer();
37 52
38 bool isOrderedBinaryBuffer() { return NULL != getOrderedBinaryBuffer(); } 53 bool isOrderedBinaryBuffer() { return NULL != getOrderedBinaryBuffer(); }
39 virtual SkOrderedReadBuffer* getOrderedBinaryBuffer() { return NULL; } 54 virtual SkOrderedReadBuffer* getOrderedBinaryBuffer() { return NULL; }
40 55
41 enum Flags { 56 enum Flags {
42 kCrossProcess_Flag = 1 << 0, 57 kCrossProcess_Flag = 1 << 0,
(...skipping 14 matching lines...) Expand all
57 virtual SkFixed readFixed() = 0; 72 virtual SkFixed readFixed() = 0;
58 virtual int32_t readInt() = 0; 73 virtual int32_t readInt() = 0;
59 virtual SkScalar readScalar() = 0; 74 virtual SkScalar readScalar() = 0;
60 virtual uint32_t readUInt() = 0; 75 virtual uint32_t readUInt() = 0;
61 virtual int32_t read32() = 0; 76 virtual int32_t read32() = 0;
62 77
63 // strings -- the caller is responsible for freeing the string contents 78 // strings -- the caller is responsible for freeing the string contents
64 virtual void readString(SkString* string) = 0; 79 virtual void readString(SkString* string) = 0;
65 virtual void* readEncodedString(size_t* length, SkPaint::TextEncoding encodi ng) = 0; 80 virtual void* readEncodedString(size_t* length, SkPaint::TextEncoding encodi ng) = 0;
66 81
82 virtual SkFlattenable* readFlattenable(SkEffectType) = 0;
83
84 SkColorFilter* readColorFilter() {
85 return (SkColorFilter*)this->readFlattenable(kColorFilter_SkEffectType);
86 }
87 SkDrawLooper* readDrawLooper() {
88 return (SkDrawLooper*)this->readFlattenable(kDrawLooper_SkEffectType);
89 }
90 SkImageFilter* readImageFilter() {
91 return (SkImageFilter*)this->readFlattenable(kImageFilter_SkEffectType);
92 }
93 SkMaskFilter* readMaskFilter() {
94 return (SkMaskFilter*)this->readFlattenable(kMaskFilter_SkEffectType);
95 }
96 SkPathEffect* readPathEffect() {
97 return (SkPathEffect*)this->readFlattenable(kPathEffect_SkEffectType);
98 }
99 SkPixelRef* readPixelRef() {
100 return (SkPixelRef*)this->readFlattenable(kPixelRef_SkEffectType);
101 }
102 SkRasterizer* readRasterizer() {
103 return (SkRasterizer*)this->readFlattenable(kRasterizer_SkEffectType);
104 }
105 SkShader* readShader() {
106 return (SkShader*)this->readFlattenable(kShader_SkEffectType);
107 }
108 SkUnitMapper* readUnitMapper() {
109 return (SkUnitMapper*)this->readFlattenable(kUnitMapper_SkEffectType);
110 }
111 SkXfermode* readXfermode() {
112 return (SkXfermode*)this->readFlattenable(kXfermode_SkEffectType);
113 }
114
67 // common data structures 115 // common data structures
68 virtual SkFlattenable* readFlattenable() = 0;
69 virtual void readPoint(SkPoint* point) = 0; 116 virtual void readPoint(SkPoint* point) = 0;
70 virtual void readMatrix(SkMatrix* matrix) = 0; 117 virtual void readMatrix(SkMatrix* matrix) = 0;
71 virtual void readIRect(SkIRect* rect) = 0; 118 virtual void readIRect(SkIRect* rect) = 0;
72 virtual void readRect(SkRect* rect) = 0; 119 virtual void readRect(SkRect* rect) = 0;
73 virtual void readRegion(SkRegion* region) = 0; 120 virtual void readRegion(SkRegion* region) = 0;
74 virtual void readPath(SkPath* path) = 0; 121 virtual void readPath(SkPath* path) = 0;
75 122
76 // binary data and arrays 123 // binary data and arrays
77 virtual uint32_t readByteArray(void* value) = 0; 124 virtual uint32_t readByteArray(void* value) = 0;
78 virtual uint32_t readColorArray(SkColor* colors) = 0; 125 virtual uint32_t readColorArray(SkColor* colors) = 0;
(...skipping 20 matching lines...) Expand all
99 return point; 146 return point;
100 } 147 }
101 148
102 SkData* readByteArrayAsData() { 149 SkData* readByteArrayAsData() {
103 size_t len = this->getArrayCount(); 150 size_t len = this->getArrayCount();
104 void* buffer = sk_malloc_throw(len); 151 void* buffer = sk_malloc_throw(len);
105 (void)this->readByteArray(buffer); 152 (void)this->readByteArray(buffer);
106 return SkData::NewFromMalloc(buffer, len); 153 return SkData::NewFromMalloc(buffer, len);
107 } 154 }
108 155
109 template <typename T> T* readFlattenableT() {
110 return static_cast<T*>(this->readFlattenable());
111 }
112
113 private: 156 private:
114 uint32_t fFlags; 157 uint32_t fFlags;
115 }; 158 };
116 159
117 /////////////////////////////////////////////////////////////////////////////// 160 ///////////////////////////////////////////////////////////////////////////////
118 161
119 class SkFlattenableWriteBuffer { 162 class SkFlattenableWriteBuffer {
120 public: 163 public:
121 SkFlattenableWriteBuffer(); 164 SkFlattenableWriteBuffer();
122 virtual ~SkFlattenableWriteBuffer(); 165 virtual ~SkFlattenableWriteBuffer();
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 } 221 }
179 222
180 protected: 223 protected:
181 // A helper function so that each subclass does not have to be a friend of S kFlattenable 224 // A helper function so that each subclass does not have to be a friend of S kFlattenable
182 void flattenObject(SkFlattenable* obj, SkFlattenableWriteBuffer& buffer); 225 void flattenObject(SkFlattenable* obj, SkFlattenableWriteBuffer& buffer);
183 226
184 uint32_t fFlags; 227 uint32_t fFlags;
185 }; 228 };
186 229
187 #endif 230 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkBitmap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698