Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: tests/ValueTest.cpp

Issue 1613053006: SkValue: to/from SkImage (Closed) Base URL: https://skia.googlesource.com/skia.git@skvalue_xfermode2
Patch Set: 2016-01-21 (Thursday) 17:20:39 EST Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/effects/SkToFromValue.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
OLDNEW
« no previous file with comments | « src/effects/SkToFromValue.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698