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

Side by Side Diff: tests/SerializationTest.cpp

Issue 596333002: Fix SkXfermode deserialization. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix test: unref the deserialized object 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) {
reed1 2014/09/24 17:09:16 // skip srcover, as it is allowed to return NULL f
267 continue;
268 }
269 SkAutoTUnref<SkXfermode> mode(SkXfermode::Create(static_cast<SkXfermode: :Mode>(i)));
270 REPORTER_ASSERT(reporter, mode.get());
271 SkAutoTUnref<SkXfermode> copy(
272 TestFlattenableSerialization<SkXfermode>(mode.get(), true, reporter) );
273 }
274 }
275
264 static SkBitmap draw_picture(SkPicture& picture) { 276 static SkBitmap draw_picture(SkPicture& picture) {
265 SkBitmap bitmap; 277 SkBitmap bitmap;
266 bitmap.allocN32Pixels(SkScalarCeilToInt(picture.cullRect().width()), 278 bitmap.allocN32Pixels(SkScalarCeilToInt(picture.cullRect().width()),
267 SkScalarCeilToInt(picture.cullRect().height())); 279 SkScalarCeilToInt(picture.cullRect().height()));
268 SkCanvas canvas(bitmap); 280 SkCanvas canvas(bitmap);
269 picture.playback(&canvas); 281 picture.playback(&canvas);
270 return bitmap; 282 return bitmap;
271 } 283 }
272 284
273 static void compare_bitmaps(skiatest::Reporter* reporter, 285 static void compare_bitmaps(skiatest::Reporter* reporter,
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 SkPath path; 411 SkPath path;
400 TestObjectSerialization(&path, reporter); 412 TestObjectSerialization(&path, reporter);
401 } 413 }
402 414
403 // Test region serialization 415 // Test region serialization
404 { 416 {
405 SkRegion region; 417 SkRegion region;
406 TestObjectSerialization(&region, reporter); 418 TestObjectSerialization(&region, reporter);
407 } 419 }
408 420
421 // Test xfermode serialization
422 {
423 TestXfermodeSerialization(reporter);
424 }
425
409 // Test string serialization 426 // Test string serialization
410 { 427 {
411 SkString string("string"); 428 SkString string("string");
412 TestObjectSerializationNoAlign<SkString, false>(&string, reporter); 429 TestObjectSerializationNoAlign<SkString, false>(&string, reporter);
413 TestObjectSerializationNoAlign<SkString, true>(&string, reporter); 430 TestObjectSerializationNoAlign<SkString, true>(&string, reporter);
414 } 431 }
415 432
416 // Test rrect serialization 433 // Test rrect serialization
417 { 434 {
418 // SkRRect does not initialize anything. 435 // SkRRect does not initialize anything.
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 505
489 // Deserialize picture 506 // Deserialize picture
490 SkValidatingReadBuffer reader(static_cast<void*>(data.get()), size); 507 SkValidatingReadBuffer reader(static_cast<void*>(data.get()), size);
491 SkAutoTUnref<SkPicture> readPict( 508 SkAutoTUnref<SkPicture> readPict(
492 SkPicture::CreateFromBuffer(reader)); 509 SkPicture::CreateFromBuffer(reader));
493 REPORTER_ASSERT(reporter, readPict.get()); 510 REPORTER_ASSERT(reporter, readPict.get());
494 } 511 }
495 512
496 TestPictureTypefaceSerialization(reporter); 513 TestPictureTypefaceSerialization(reporter);
497 } 514 }
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