| 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 "SkBitmapDevice.h" | 8 #include "SkBitmapDevice.h" |
| 9 #include "SkBitmapSource.h" | 9 #include "SkBitmapSource.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 invalidBitmap.setConfig(info); | 363 invalidBitmap.setConfig(info); |
| 364 | 364 |
| 365 // The deserialization should succeed, and the rendering shouldn't crash
, | 365 // The deserialization should succeed, and the rendering shouldn't crash
, |
| 366 // even when the device fails to initialize, due to its size | 366 // even when the device fails to initialize, due to its size |
| 367 TestBitmapSerialization(validBitmap, invalidBitmap, true, reporter); | 367 TestBitmapSerialization(validBitmap, invalidBitmap, true, reporter); |
| 368 } | 368 } |
| 369 | 369 |
| 370 // Test simple SkPicture serialization | 370 // Test simple SkPicture serialization |
| 371 { | 371 { |
| 372 SkPictureRecorder recorder; | 372 SkPictureRecorder recorder; |
| 373 bool didDraw = drawSomething(recorder.beginRecording(kBitmapSize, kBitma
pSize)); | 373 bool didDraw = drawSomething(recorder.beginRecording(kBitmapSize, kBitma
pSize, NULL, 0)); |
| 374 REPORTER_ASSERT(reporter, didDraw); | 374 REPORTER_ASSERT(reporter, didDraw); |
| 375 SkAutoTUnref<SkPicture> pict(recorder.endRecording()); | 375 SkAutoTUnref<SkPicture> pict(recorder.endRecording()); |
| 376 | 376 |
| 377 // Serialize picture | 377 // Serialize picture |
| 378 SkWriteBuffer writer(SkWriteBuffer::kValidation_Flag); | 378 SkWriteBuffer writer(SkWriteBuffer::kValidation_Flag); |
| 379 pict->flatten(writer); | 379 pict->flatten(writer); |
| 380 size_t size = writer.bytesWritten(); | 380 size_t size = writer.bytesWritten(); |
| 381 SkAutoTMalloc<unsigned char> data(size); | 381 SkAutoTMalloc<unsigned char> data(size); |
| 382 writer.writeToMemory(static_cast<void*>(data.get())); | 382 writer.writeToMemory(static_cast<void*>(data.get())); |
| 383 | 383 |
| 384 // Deserialize picture | 384 // Deserialize picture |
| 385 SkValidatingReadBuffer reader(static_cast<void*>(data.get()), size); | 385 SkValidatingReadBuffer reader(static_cast<void*>(data.get()), size); |
| 386 SkAutoTUnref<SkPicture> readPict( | 386 SkAutoTUnref<SkPicture> readPict( |
| 387 SkPicture::CreateFromBuffer(reader)); | 387 SkPicture::CreateFromBuffer(reader)); |
| 388 REPORTER_ASSERT(reporter, NULL != readPict.get()); | 388 REPORTER_ASSERT(reporter, NULL != readPict.get()); |
| 389 } | 389 } |
| 390 } | 390 } |
| OLD | NEW |