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

Side by Side Diff: tests/SerializationTest.cpp

Issue 596333002: Fix SkXfermode deserialization. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add comment per review. Created 6 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
« no previous file with comments | « src/core/SkXfermode.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" 9 #include "SkBitmapSource.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 bitmap.allocN32Pixels(24, 24); 254 bitmap.allocN32Pixels(24, 24);
255 SkCanvas canvas(bitmap); 255 SkCanvas canvas(bitmap);
256 canvas.clear(0x00000000); 256 canvas.clear(0x00000000);
257 SkPaint paint; 257 SkPaint paint;
258 paint.setImageFilter(deserializedFilter); 258 paint.setImageFilter(deserializedFilter);
259 canvas.clipRect(SkRect::MakeXYWH(0, 0, SkIntToScalar(24), SkIntToScalar( 24))); 259 canvas.clipRect(SkRect::MakeXYWH(0, 0, SkIntToScalar(24), SkIntToScalar( 24)));
260 canvas.drawBitmap(bitmap, 0, 0, &paint); 260 canvas.drawBitmap(bitmap, 0, 0, &paint);
261 } 261 }
262 } 262 }
263 263
264 static void TestXfermodeSerialization(skiatest::Reporter* reporter) {
265 for (size_t i = 0; i <= SkXfermode::kLastMode; ++i) {
266 if (i == SkXfermode::kSrcOver_Mode) {
267 // skip SrcOver, as it is allowed to return NULL from Create()
268 continue;
269 }
270 SkAutoTUnref<SkXfermode> mode(SkXfermode::Create(static_cast<SkXfermode: :Mode>(i)));
271 REPORTER_ASSERT(reporter, mode.get());
272 SkAutoTUnref<SkXfermode> copy(
273 TestFlattenableSerialization<SkXfermode>(mode.get(), true, reporter) );
274 }
275 }
276
264 static SkBitmap draw_picture(SkPicture& picture) { 277 static SkBitmap draw_picture(SkPicture& picture) {
265 SkBitmap bitmap; 278 SkBitmap bitmap;
266 bitmap.allocN32Pixels(SkScalarCeilToInt(picture.cullRect().width()), 279 bitmap.allocN32Pixels(SkScalarCeilToInt(picture.cullRect().width()),
267 SkScalarCeilToInt(picture.cullRect().height())); 280 SkScalarCeilToInt(picture.cullRect().height()));
268 SkCanvas canvas(bitmap); 281 SkCanvas canvas(bitmap);
269 picture.playback(&canvas); 282 picture.playback(&canvas);
270 return bitmap; 283 return bitmap;
271 } 284 }
272 285
273 static void compare_bitmaps(skiatest::Reporter* reporter, 286 static void compare_bitmaps(skiatest::Reporter* reporter,
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 SkPath path; 412 SkPath path;
400 TestObjectSerialization(&path, reporter); 413 TestObjectSerialization(&path, reporter);
401 } 414 }
402 415
403 // Test region serialization 416 // Test region serialization
404 { 417 {
405 SkRegion region; 418 SkRegion region;
406 TestObjectSerialization(&region, reporter); 419 TestObjectSerialization(&region, reporter);
407 } 420 }
408 421
422 // Test xfermode serialization
423 {
424 TestXfermodeSerialization(reporter);
425 }
426
409 // Test string serialization 427 // Test string serialization
410 { 428 {
411 SkString string("string"); 429 SkString string("string");
412 TestObjectSerializationNoAlign<SkString, false>(&string, reporter); 430 TestObjectSerializationNoAlign<SkString, false>(&string, reporter);
413 TestObjectSerializationNoAlign<SkString, true>(&string, reporter); 431 TestObjectSerializationNoAlign<SkString, true>(&string, reporter);
414 } 432 }
415 433
416 // Test rrect serialization 434 // Test rrect serialization
417 { 435 {
418 // SkRRect does not initialize anything. 436 // SkRRect does not initialize anything.
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 506
489 // Deserialize picture 507 // Deserialize picture
490 SkValidatingReadBuffer reader(static_cast<void*>(data.get()), size); 508 SkValidatingReadBuffer reader(static_cast<void*>(data.get()), size);
491 SkAutoTUnref<SkPicture> readPict( 509 SkAutoTUnref<SkPicture> readPict(
492 SkPicture::CreateFromBuffer(reader)); 510 SkPicture::CreateFromBuffer(reader));
493 REPORTER_ASSERT(reporter, readPict.get()); 511 REPORTER_ASSERT(reporter, readPict.get());
494 } 512 }
495 513
496 TestPictureTypefaceSerialization(reporter); 514 TestPictureTypefaceSerialization(reporter);
497 } 515 }
OLDNEW
« no previous file with comments | « src/core/SkXfermode.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698