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

Side by Side Diff: tests/SerializationTest.cpp

Issue 1343123002: Convert unit tests, GMs from SkBitmapSource to SkImagesource (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: review comments Created 5 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
« no previous file with comments | « tests/ImageFilterTest.cpp ('k') | no next file » | 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 * 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 "SkBitmapSource.h"
10 #include "SkCanvas.h" 9 #include "SkCanvas.h"
11 #include "SkFixed.h" 10 #include "SkFixed.h"
12 #include "SkFontDescriptor.h" 11 #include "SkFontDescriptor.h"
12 #include "SkImage.h"
13 #include "SkImageSource.h"
13 #include "SkMallocPixelRef.h" 14 #include "SkMallocPixelRef.h"
14 #include "SkOSFile.h" 15 #include "SkOSFile.h"
15 #include "SkPictureRecorder.h" 16 #include "SkPictureRecorder.h"
16 #include "SkTableColorFilter.h" 17 #include "SkTableColorFilter.h"
17 #include "SkTemplates.h" 18 #include "SkTemplates.h"
18 #include "SkTypeface.h" 19 #include "SkTypeface.h"
19 #include "SkWriteBuffer.h" 20 #include "SkWriteBuffer.h"
20 #include "SkValidatingReadBuffer.h" 21 #include "SkValidatingReadBuffer.h"
21 #include "SkXfermodeImageFilter.h" 22 #include "SkXfermodeImageFilter.h"
22 #include "Test.h" 23 #include "Test.h"
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 SkValidatingReadBuffer buffer2(dataWritten, bytesWritten); 234 SkValidatingReadBuffer buffer2(dataWritten, bytesWritten);
234 success = SerializationUtils<T>::Read(buffer2, dataRead, kArraySize); 235 success = SerializationUtils<T>::Read(buffer2, dataRead, kArraySize);
235 // This should have succeeded, since there are enough bytes to read this 236 // This should have succeeded, since there are enough bytes to read this
236 REPORTER_ASSERT(reporter, success); 237 REPORTER_ASSERT(reporter, success);
237 } 238 }
238 239
239 static void TestBitmapSerialization(const SkBitmap& validBitmap, 240 static void TestBitmapSerialization(const SkBitmap& validBitmap,
240 const SkBitmap& invalidBitmap, 241 const SkBitmap& invalidBitmap,
241 bool shouldSucceed, 242 bool shouldSucceed,
242 skiatest::Reporter* reporter) { 243 skiatest::Reporter* reporter) {
243 SkAutoTUnref<SkBitmapSource> validBitmapSource(SkBitmapSource::Create(validB itmap)); 244 SkAutoTUnref<SkImage> validImage(SkImage::NewFromBitmap(validBitmap));
244 SkAutoTUnref<SkBitmapSource> invalidBitmapSource(SkBitmapSource::Create(inva lidBitmap)); 245 SkAutoTUnref<SkImageFilter> validBitmapSource(SkImageSource::Create(validIma ge));
246 SkAutoTUnref<SkImage> invalidImage(SkImage::NewFromBitmap(invalidBitmap));
247 SkAutoTUnref<SkImageFilter> invalidBitmapSource(SkImageSource::Create(invali dImage));
245 SkAutoTUnref<SkXfermode> mode(SkXfermode::Create(SkXfermode::kSrcOver_Mode)) ; 248 SkAutoTUnref<SkXfermode> mode(SkXfermode::Create(SkXfermode::kSrcOver_Mode)) ;
246 SkAutoTUnref<SkXfermodeImageFilter> xfermodeImageFilter( 249 SkAutoTUnref<SkXfermodeImageFilter> xfermodeImageFilter(
247 SkXfermodeImageFilter::Create(mode, invalidBitmapSource, validBitmapSour ce)); 250 SkXfermodeImageFilter::Create(mode, invalidBitmapSource, validBitmapSour ce));
248 251
249 SkAutoTUnref<SkImageFilter> deserializedFilter( 252 SkAutoTUnref<SkImageFilter> deserializedFilter(
250 TestFlattenableSerialization<SkImageFilter>( 253 TestFlattenableSerialization<SkImageFilter>(
251 xfermodeImageFilter, shouldSucceed, reporter)); 254 xfermodeImageFilter, shouldSucceed, reporter));
252 255
253 // Try to render a small bitmap using the invalid deserialized filter 256 // Try to render a small bitmap using the invalid deserialized filter
254 // 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
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 539
537 // Deserialize picture 540 // Deserialize picture
538 SkValidatingReadBuffer reader(static_cast<void*>(data.get()), size); 541 SkValidatingReadBuffer reader(static_cast<void*>(data.get()), size);
539 SkAutoTUnref<SkPicture> readPict( 542 SkAutoTUnref<SkPicture> readPict(
540 SkPicture::CreateFromBuffer(reader)); 543 SkPicture::CreateFromBuffer(reader));
541 REPORTER_ASSERT(reporter, readPict.get()); 544 REPORTER_ASSERT(reporter, readPict.get());
542 } 545 }
543 546
544 TestPictureTypefaceSerialization(reporter); 547 TestPictureTypefaceSerialization(reporter);
545 } 548 }
OLDNEW
« no previous file with comments | « tests/ImageFilterTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698