| 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 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 } | 456 } |
| 457 | 457 |
| 458 // Test invalid deserializations | 458 // Test invalid deserializations |
| 459 { | 459 { |
| 460 SkImageInfo info = SkImageInfo::MakeN32Premul(kBitmapSize, kBitmapSize); | 460 SkImageInfo info = SkImageInfo::MakeN32Premul(kBitmapSize, kBitmapSize); |
| 461 | 461 |
| 462 SkBitmap validBitmap; | 462 SkBitmap validBitmap; |
| 463 validBitmap.setInfo(info); | 463 validBitmap.setInfo(info); |
| 464 | 464 |
| 465 // Create a bitmap with a really large height | 465 // Create a bitmap with a really large height |
| 466 info.fHeight = 1000000000; | |
| 467 SkBitmap invalidBitmap; | 466 SkBitmap invalidBitmap; |
| 468 invalidBitmap.setInfo(info); | 467 invalidBitmap.setInfo(info.makeWH(info.width(), 1000000000)); |
| 469 | 468 |
| 470 // The deserialization should succeed, and the rendering shouldn't crash
, | 469 // The deserialization should succeed, and the rendering shouldn't crash
, |
| 471 // even when the device fails to initialize, due to its size | 470 // even when the device fails to initialize, due to its size |
| 472 TestBitmapSerialization(validBitmap, invalidBitmap, true, reporter); | 471 TestBitmapSerialization(validBitmap, invalidBitmap, true, reporter); |
| 473 } | 472 } |
| 474 | 473 |
| 475 // Test simple SkPicture serialization | 474 // Test simple SkPicture serialization |
| 476 { | 475 { |
| 477 SkPictureRecorder recorder; | 476 SkPictureRecorder recorder; |
| 478 draw_something(recorder.beginRecording(SkIntToScalar(kBitmapSize), | 477 draw_something(recorder.beginRecording(SkIntToScalar(kBitmapSize), |
| (...skipping 10 matching lines...) Expand all Loading... |
| 489 | 488 |
| 490 // Deserialize picture | 489 // Deserialize picture |
| 491 SkValidatingReadBuffer reader(static_cast<void*>(data.get()), size); | 490 SkValidatingReadBuffer reader(static_cast<void*>(data.get()), size); |
| 492 SkAutoTUnref<SkPicture> readPict( | 491 SkAutoTUnref<SkPicture> readPict( |
| 493 SkPicture::CreateFromBuffer(reader)); | 492 SkPicture::CreateFromBuffer(reader)); |
| 494 REPORTER_ASSERT(reporter, NULL != readPict.get()); | 493 REPORTER_ASSERT(reporter, NULL != readPict.get()); |
| 495 } | 494 } |
| 496 | 495 |
| 497 TestPictureTypefaceSerialization(reporter); | 496 TestPictureTypefaceSerialization(reporter); |
| 498 } | 497 } |
| OLD | NEW |