| 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 "SkAnnotationKeys.h" | 9 #include "SkAnnotationKeys.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 // Serialize picture | 559 // Serialize picture |
| 560 SkBinaryWriteBuffer writer; | 560 SkBinaryWriteBuffer writer; |
| 561 pict->flatten(writer); | 561 pict->flatten(writer); |
| 562 size_t size = writer.bytesWritten(); | 562 size_t size = writer.bytesWritten(); |
| 563 SkAutoTMalloc<unsigned char> data(size); | 563 SkAutoTMalloc<unsigned char> data(size); |
| 564 writer.writeToMemory(static_cast<void*>(data.get())); | 564 writer.writeToMemory(static_cast<void*>(data.get())); |
| 565 | 565 |
| 566 // Deserialize picture | 566 // Deserialize picture |
| 567 SkValidatingReadBuffer reader(static_cast<void*>(data.get()), size); | 567 SkValidatingReadBuffer reader(static_cast<void*>(data.get()), size); |
| 568 sk_sp<SkPicture> readPict(SkPicture::MakeFromBuffer(reader)); | 568 sk_sp<SkPicture> readPict(SkPicture::MakeFromBuffer(reader)); |
| 569 REPORTER_ASSERT(reporter, reader.isValid()); |
| 569 REPORTER_ASSERT(reporter, readPict.get()); | 570 REPORTER_ASSERT(reporter, readPict.get()); |
| 570 } | 571 } |
| 571 | 572 |
| 572 TestPictureTypefaceSerialization(reporter); | 573 TestPictureTypefaceSerialization(reporter); |
| 573 | 574 |
| 574 // Test SkLightingShader/NormalMapSource serialization | 575 // Test SkLightingShader/NormalMapSource serialization |
| 575 { | 576 { |
| 576 const int kTexSize = 2; | 577 const int kTexSize = 2; |
| 577 | 578 |
| 578 SkLights::Builder builder; | 579 SkLights::Builder builder; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 { r1, SkAnnotationKeys::Define_Named_Dest_Key(), std::move(d1) }, | 715 { r1, SkAnnotationKeys::Define_Named_Dest_Key(), std::move(d1) }, |
| 715 { r2, SkAnnotationKeys::Link_Named_Dest_Key(), std::move(d2) }, | 716 { r2, SkAnnotationKeys::Link_Named_Dest_Key(), std::move(d2) }, |
| 716 }; | 717 }; |
| 717 | 718 |
| 718 sk_sp<SkPicture> pict0(recorder.finishRecordingAsPicture()); | 719 sk_sp<SkPicture> pict0(recorder.finishRecordingAsPicture()); |
| 719 sk_sp<SkPicture> pict1(copy_picture_via_serialization(pict0.get())); | 720 sk_sp<SkPicture> pict1(copy_picture_via_serialization(pict0.get())); |
| 720 | 721 |
| 721 TestAnnotationCanvas canvas(reporter, recs, SK_ARRAY_COUNT(recs)); | 722 TestAnnotationCanvas canvas(reporter, recs, SK_ARRAY_COUNT(recs)); |
| 722 canvas.drawPicture(pict1); | 723 canvas.drawPicture(pict1); |
| 723 } | 724 } |
| OLD | NEW |