| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 "SkData.h" | 9 #include "SkData.h" |
| 10 #include "SkImage.h" |
| 9 #include "SkMatrix.h" | 11 #include "SkMatrix.h" |
| 10 #include "SkToFromValue.h" | 12 #include "SkToFromValue.h" |
| 11 #include "Test.h" | 13 #include "Test.h" |
| 12 | 14 |
| 13 static const SkValue::Type example_type = | 15 static const SkValue::Type example_type = |
| 14 SkValue::Type(SkValue::kMaxPublicObject + 1); | 16 SkValue::Type(SkValue::kMaxPublicObject + 1); |
| 15 | 17 |
| 16 enum { kExampleS32, kExampleF32, kExampleU32, kExampleObject, kExampleBytes, | 18 enum { kExampleS32, kExampleF32, kExampleU32, kExampleObject, kExampleBytes, |
| 17 kExampleF32s, kExampleU32s, kExampleU16s, kExampleArray }; | 19 kExampleF32s, kExampleU32s, kExampleU16s, kExampleArray }; |
| 18 | 20 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 val.foreach(fn); | 104 val.foreach(fn); |
| 103 } | 105 } |
| 104 | 106 |
| 105 DEF_TEST(Value_Matrix, r) { | 107 DEF_TEST(Value_Matrix, r) { |
| 106 auto m = SkMatrix::MakeTrans(900.0f, 1000.0f); | 108 auto m = SkMatrix::MakeTrans(900.0f, 1000.0f); |
| 107 auto val = SkToValue(m); | 109 auto val = SkToValue(m); |
| 108 SkMatrix dst; | 110 SkMatrix dst; |
| 109 REPORTER_ASSERT(r, SkFromValue(val, &dst)); | 111 REPORTER_ASSERT(r, SkFromValue(val, &dst)); |
| 110 REPORTER_ASSERT(r, dst == m); | 112 REPORTER_ASSERT(r, dst == m); |
| 111 } | 113 } |
| 114 |
| 115 DEF_TEST(Value_Image, r) { |
| 116 SkAutoTUnref<SkImage> img1(GetResourceAsImage("mandrill_512.png")); |
| 117 if (!img1) { |
| 118 return; |
| 119 } |
| 120 auto val = SkToValue((const SkImage*)img1); |
| 121 SkAutoTUnref<SkImage> img2; |
| 122 REPORTER_ASSERT(r, SkFromValue(val, &img2)); |
| 123 if (!img2) { |
| 124 return; |
| 125 } |
| 126 SkAutoTUnref<SkData> data1(img1->refEncoded()); |
| 127 SkAutoTUnref<SkData> data2(img2->refEncoded()); |
| 128 REPORTER_ASSERT(r, data1); |
| 129 REPORTER_ASSERT(r, data2); |
| 130 REPORTER_ASSERT(r, data1.get() == data2.get()); |
| 131 } |
| OLD | NEW |