OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2007 The Android Open Source Project | 3 * Copyright 2007 The Android Open Source Project |
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 | 9 |
10 #include "SkPictureFlat.h" | 10 #include "SkPictureFlat.h" |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 } | 294 } |
295 | 295 |
296 // do this at the end, so that they will be zero if we hit an error. | 296 // do this at the end, so that they will be zero if we hit an error. |
297 fWidth = info.fWidth; | 297 fWidth = info.fWidth; |
298 fHeight = info.fHeight; | 298 fHeight = info.fHeight; |
299 if (success) { | 299 if (success) { |
300 *success = true; | 300 *success = true; |
301 } | 301 } |
302 } | 302 } |
303 | 303 |
304 #define PREVENT_CHROME_BREAKAGE | |
305 #ifdef PREVENT_CHROME_BREAKAGE | |
306 // This block of code is to allow chromium to build until https://codereview.chr
omium.org/15496006/ | |
307 // is submitted. Then it will be reverted. | |
308 #include "SkThread.h" | |
309 | |
310 static SkPicture::OldEncodeBitmap gOldEncodeBitmapFunction; | |
311 | |
312 SK_DECLARE_STATIC_MUTEX(gEncodeFunctionMutex); | |
313 | |
314 static SkData* encode_from_old_encoder(size_t* pixelRefOffset, const SkBitmap& b
m) { | |
315 SkASSERT(gOldEncodeBitmapFunction != NULL); | |
316 SkDynamicMemoryWStream stream; | |
317 if (!gOldEncodeBitmapFunction(&stream, bm)) { | |
318 return NULL; | |
319 } | |
320 return stream.copyToData(); | |
321 } | |
322 | |
323 void SkPicture::serialize(SkWStream* stream, OldEncodeBitmap oldEncoder) const { | |
324 SkAutoMutexAcquire ac(gEncodeFunctionMutex); | |
325 gOldEncodeBitmapFunction = oldEncoder; | |
326 this->serialize(stream, &encode_from_old_encoder); | |
327 gOldEncodeBitmapFunction = NULL; | |
328 } | |
329 | |
330 #endif // PREVENT_CHROME_BREAKAGE | |
331 | |
332 void SkPicture::serialize(SkWStream* stream, EncodeBitmap encoder) const { | 304 void SkPicture::serialize(SkWStream* stream, EncodeBitmap encoder) const { |
333 SkPicturePlayback* playback = fPlayback; | 305 SkPicturePlayback* playback = fPlayback; |
334 | 306 |
335 if (NULL == playback && fRecord) { | 307 if (NULL == playback && fRecord) { |
336 playback = SkNEW_ARGS(SkPicturePlayback, (*fRecord)); | 308 playback = SkNEW_ARGS(SkPicturePlayback, (*fRecord)); |
337 } | 309 } |
338 | 310 |
339 SkPictInfo info; | 311 SkPictInfo info; |
340 | 312 |
341 info.fVersion = PICTURE_VERSION; | 313 info.fVersion = PICTURE_VERSION; |
(...skipping 21 matching lines...) Expand all Loading... |
363 } | 335 } |
364 | 336 |
365 #ifdef SK_BUILD_FOR_ANDROID | 337 #ifdef SK_BUILD_FOR_ANDROID |
366 void SkPicture::abortPlayback() { | 338 void SkPicture::abortPlayback() { |
367 if (NULL == fPlayback) { | 339 if (NULL == fPlayback) { |
368 return; | 340 return; |
369 } | 341 } |
370 fPlayback->abort(); | 342 fPlayback->abort(); |
371 } | 343 } |
372 #endif | 344 #endif |
OLD | NEW |