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

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

Issue 2187613002: Deserialize pictures with custom image-deserializer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix build Created 4 years, 4 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
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 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 SkReadBuffer_DEFINED 8 #ifndef SkReadBuffer_DEFINED
9 #define SkReadBuffer_DEFINED 9 #define SkReadBuffer_DEFINED
10 10
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 } 159 }
160 void* buffer = sk_malloc_throw(len); 160 void* buffer = sk_malloc_throw(len);
161 this->readByteArray(buffer, len); 161 this->readByteArray(buffer, len);
162 return SkData::MakeFromMalloc(buffer, len); 162 return SkData::MakeFromMalloc(buffer, len);
163 } 163 }
164 164
165 // helpers to get info about arrays and binary data 165 // helpers to get info about arrays and binary data
166 virtual uint32_t getArrayCount(); 166 virtual uint32_t getArrayCount();
167 167
168 /** 168 /**
169 * Returns false if the bitmap could not be completely read. In that case, it will be set 169 * Returns false if the image could not be completely read. In that case, i t will be set
170 * to have width/height, but no pixels. 170 * to have width/height, but no pixels.
171 */ 171 */
172 bool readBitmap(SkBitmap* bitmap); 172 sk_sp<SkImage> readBitmapAsImage();
173 173 sk_sp<SkImage> readImage();
174 SkImage* readImage();
175 174
176 virtual SkTypeface* readTypeface(); 175 virtual SkTypeface* readTypeface();
177 176
178 void setTypefaceArray(SkTypeface* array[], int count) { 177 void setTypefaceArray(SkTypeface* array[], int count) {
179 fTFArray = array; 178 fTFArray = array;
180 fTFCount = count; 179 fTFCount = count;
181 } 180 }
182 181
183 /** 182 /**
184 * Call this with a pre-loaded array of Factories, in the same order as 183 * Call this with a pre-loaded array of Factories, in the same order as
(...skipping 16 matching lines...) Expand all
201 */ 200 */
202 void setCustomFactory(const SkString& name, SkFlattenable::Factory factory) { 201 void setCustomFactory(const SkString& name, SkFlattenable::Factory factory) {
203 fCustomFactory.set(name, factory); 202 fCustomFactory.set(name, factory);
204 } 203 }
205 204
206 /** 205 /**
207 * Provide a function to decode an SkBitmap from encoded data. Only used if the writer 206 * Provide a function to decode an SkBitmap from encoded data. Only used if the writer
208 * encoded the SkBitmap. If the proper decoder cannot be used, a red bitmap with the 207 * encoded the SkBitmap. If the proper decoder cannot be used, a red bitmap with the
209 * appropriate size will be used. 208 * appropriate size will be used.
210 */ 209 */
210 #if 0
211 void setBitmapDecoder(SkPicture::InstallPixelRefProc bitmapDecoder) { 211 void setBitmapDecoder(SkPicture::InstallPixelRefProc bitmapDecoder) {
212 fBitmapDecoder = bitmapDecoder; 212 fBitmapDecoder = bitmapDecoder;
213 } 213 }
214 #endif
215 void setImageDeserializer(SkImageDeserializer* factory) { fImageDeserializer = factory; }
214 216
215 // Default impelementations don't check anything. 217 // Default impelementations don't check anything.
216 virtual bool validate(bool isValid) { return isValid; } 218 virtual bool validate(bool isValid) { return isValid; }
217 virtual bool isValid() const { return true; } 219 virtual bool isValid() const { return true; }
218 virtual bool validateAvailable(size_t size) { return true; } 220 virtual bool validateAvailable(size_t size) { return true; }
219 bool validateIndex(int index, int count) { 221 bool validateIndex(int index, int count) {
220 return this->validate(index >= 0 && index < count); 222 return this->validate(index >= 0 && index < count);
221 } 223 }
222 224
223 protected: 225 protected:
(...skipping 28 matching lines...) Expand all
252 254
253 SkTypeface** fTFArray; 255 SkTypeface** fTFArray;
254 int fTFCount; 256 int fTFCount;
255 257
256 SkFlattenable::Factory* fFactoryArray; 258 SkFlattenable::Factory* fFactoryArray;
257 int fFactoryCount; 259 int fFactoryCount;
258 260
259 // Only used if we do not have an fFactoryArray. 261 // Only used if we do not have an fFactoryArray.
260 SkTHashMap<SkString, SkFlattenable::Factory> fCustomFactory; 262 SkTHashMap<SkString, SkFlattenable::Factory> fCustomFactory;
261 263
262 SkPicture::InstallPixelRefProc fBitmapDecoder; 264 // SkPicture::InstallPixelRefProc fBitmapDecoder;
265 SkImageDeserializer* fImageDeserializer;
263 266
264 #ifdef DEBUG_NON_DETERMINISTIC_ASSERT 267 #ifdef DEBUG_NON_DETERMINISTIC_ASSERT
265 // Debugging counter to keep track of how many bitmaps we 268 // Debugging counter to keep track of how many bitmaps we
266 // have decoded. 269 // have decoded.
267 int fDecodedBitmapIndex; 270 int fDecodedBitmapIndex;
268 #endif // DEBUG_NON_DETERMINISTIC_ASSERT 271 #endif // DEBUG_NON_DETERMINISTIC_ASSERT
269 }; 272 };
270 273
271 #endif // SkReadBuffer_DEFINED 274 #endif // SkReadBuffer_DEFINED
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698