OLD | NEW |
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 #include "Resources.h" | 8 #include "Resources.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkFixed.h" | 10 #include "SkFixed.h" |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 | 239 |
240 static void TestBitmapSerialization(const SkBitmap& validBitmap, | 240 static void TestBitmapSerialization(const SkBitmap& validBitmap, |
241 const SkBitmap& invalidBitmap, | 241 const SkBitmap& invalidBitmap, |
242 bool shouldSucceed, | 242 bool shouldSucceed, |
243 skiatest::Reporter* reporter) { | 243 skiatest::Reporter* reporter) { |
244 SkAutoTUnref<SkImage> validImage(SkImage::NewFromBitmap(validBitmap)); | 244 SkAutoTUnref<SkImage> validImage(SkImage::NewFromBitmap(validBitmap)); |
245 SkAutoTUnref<SkImageFilter> validBitmapSource(SkImageSource::Create(validIma
ge)); | 245 SkAutoTUnref<SkImageFilter> validBitmapSource(SkImageSource::Create(validIma
ge)); |
246 SkAutoTUnref<SkImage> invalidImage(SkImage::NewFromBitmap(invalidBitmap)); | 246 SkAutoTUnref<SkImage> invalidImage(SkImage::NewFromBitmap(invalidBitmap)); |
247 SkAutoTUnref<SkImageFilter> invalidBitmapSource(SkImageSource::Create(invali
dImage)); | 247 SkAutoTUnref<SkImageFilter> invalidBitmapSource(SkImageSource::Create(invali
dImage)); |
248 SkAutoTUnref<SkXfermode> mode(SkXfermode::Create(SkXfermode::kSrcOver_Mode))
; | 248 SkAutoTUnref<SkXfermode> mode(SkXfermode::Create(SkXfermode::kSrcOver_Mode))
; |
249 SkAutoTUnref<SkXfermodeImageFilter> xfermodeImageFilter( | 249 SkAutoTUnref<SkImageFilter> xfermodeImageFilter( |
250 SkXfermodeImageFilter::Create(mode, invalidBitmapSource, validBitmapSour
ce)); | 250 SkXfermodeImageFilter::Create(mode, invalidBitmapSource, validBitmapSour
ce)); |
251 | 251 |
252 SkAutoTUnref<SkImageFilter> deserializedFilter( | 252 SkAutoTUnref<SkImageFilter> deserializedFilter( |
253 TestFlattenableSerialization<SkImageFilter>( | 253 TestFlattenableSerialization<SkImageFilter>( |
254 xfermodeImageFilter, shouldSucceed, reporter)); | 254 xfermodeImageFilter, shouldSucceed, reporter)); |
255 | 255 |
256 // Try to render a small bitmap using the invalid deserialized filter | 256 // Try to render a small bitmap using the invalid deserialized filter |
257 // to make sure we don't crash while trying to render it | 257 // to make sure we don't crash while trying to render it |
258 if (shouldSucceed) { | 258 if (shouldSucceed) { |
259 SkBitmap bitmap; | 259 SkBitmap bitmap; |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 | 539 |
540 // Deserialize picture | 540 // Deserialize picture |
541 SkValidatingReadBuffer reader(static_cast<void*>(data.get()), size); | 541 SkValidatingReadBuffer reader(static_cast<void*>(data.get()), size); |
542 SkAutoTUnref<SkPicture> readPict( | 542 SkAutoTUnref<SkPicture> readPict( |
543 SkPicture::CreateFromBuffer(reader)); | 543 SkPicture::CreateFromBuffer(reader)); |
544 REPORTER_ASSERT(reporter, readPict.get()); | 544 REPORTER_ASSERT(reporter, readPict.get()); |
545 } | 545 } |
546 | 546 |
547 TestPictureTypefaceSerialization(reporter); | 547 TestPictureTypefaceSerialization(reporter); |
548 } | 548 } |
OLD | NEW |