| 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 "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 Loading... |
| 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 Loading... |
| 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(®ion, reporter); | 419 TestObjectSerialization(®ion, 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 Loading... |
| 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 } |
| OLD | NEW |