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 "SkAnnotationKeys.h" | 8 #include "SkAnnotationKeys.h" |
9 #include "Resources.h" | 9 #include "Resources.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 size_t bytesReadFromMemory = testObj->readFromMemory(dataWritten, bytesWritt
enToMemory); | 35 size_t bytesReadFromMemory = testObj->readFromMemory(dataWritten, bytesWritt
enToMemory); |
36 REPORTER_ASSERT(reporter, SkAlign4(bytesReadFromMemory) == bytesReadFromMemo
ry); | 36 REPORTER_ASSERT(reporter, SkAlign4(bytesReadFromMemory) == bytesReadFromMemo
ry); |
37 } | 37 } |
38 | 38 |
39 template<typename T> struct SerializationUtils { | 39 template<typename T> struct SerializationUtils { |
40 // Generic case for flattenables | 40 // Generic case for flattenables |
41 static void Write(SkWriteBuffer& writer, const T* flattenable) { | 41 static void Write(SkWriteBuffer& writer, const T* flattenable) { |
42 writer.writeFlattenable(flattenable); | 42 writer.writeFlattenable(flattenable); |
43 } | 43 } |
44 static void Read(SkValidatingReadBuffer& reader, T** flattenable) { | 44 static void Read(SkValidatingReadBuffer& reader, T** flattenable) { |
45 *flattenable = (T*)reader.readFlattenable(); | 45 *flattenable = (T*)reader.readFlattenable(T::GetFlattenableType()); |
46 } | 46 } |
47 }; | 47 }; |
48 | 48 |
49 template<> struct SerializationUtils<SkMatrix> { | 49 template<> struct SerializationUtils<SkMatrix> { |
50 static void Write(SkWriteBuffer& writer, const SkMatrix* matrix) { | 50 static void Write(SkWriteBuffer& writer, const SkMatrix* matrix) { |
51 writer.writeMatrix(*matrix); | 51 writer.writeMatrix(*matrix); |
52 } | 52 } |
53 static void Read(SkValidatingReadBuffer& reader, SkMatrix* matrix) { | 53 static void Read(SkValidatingReadBuffer& reader, SkMatrix* matrix) { |
54 reader.readMatrix(matrix); | 54 reader.readMatrix(matrix); |
55 } | 55 } |
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 { r1, SkAnnotationKeys::Define_Named_Dest_Key(), d1 }, | 620 { r1, SkAnnotationKeys::Define_Named_Dest_Key(), d1 }, |
621 { r2, SkAnnotationKeys::Link_Named_Dest_Key(), d2 }, | 621 { r2, SkAnnotationKeys::Link_Named_Dest_Key(), d2 }, |
622 }; | 622 }; |
623 | 623 |
624 sk_sp<SkPicture> pict0(recorder.finishRecordingAsPicture()); | 624 sk_sp<SkPicture> pict0(recorder.finishRecordingAsPicture()); |
625 sk_sp<SkPicture> pict1(copy_picture_via_serialization(pict0.get())); | 625 sk_sp<SkPicture> pict1(copy_picture_via_serialization(pict0.get())); |
626 | 626 |
627 TestAnnotationCanvas canvas(reporter, recs, SK_ARRAY_COUNT(recs)); | 627 TestAnnotationCanvas canvas(reporter, recs, SK_ARRAY_COUNT(recs)); |
628 canvas.drawPicture(pict1); | 628 canvas.drawPicture(pict1); |
629 } | 629 } |
OLD | NEW |