OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "Test.h" | 8 #include "Test.h" |
9 #include "SkDevice.h" | 9 #include "SkDevice.h" |
10 #include "SkTemplates.h" | 10 #include "SkTemplates.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 REPORTER_ASSERT(reporter, info->fColorCount == fColorCount); | 35 REPORTER_ASSERT(reporter, info->fColorCount == fColorCount); |
36 REPORTER_ASSERT(reporter, | 36 REPORTER_ASSERT(reporter, |
37 !memcmp(info->fColors, fColors, fColorCount * sizeof(SkC
olor))); | 37 !memcmp(info->fColors, fColors, fColorCount * sizeof(SkC
olor))); |
38 REPORTER_ASSERT(reporter, | 38 REPORTER_ASSERT(reporter, |
39 !memcmp(info->fColorOffsets, fPos, fColorCount * sizeof(
SkScalar))); | 39 !memcmp(info->fColorOffsets, fPos, fColorCount * sizeof(
SkScalar))); |
40 REPORTER_ASSERT(reporter, fTileMode == info->fTileMode); | 40 REPORTER_ASSERT(reporter, fTileMode == info->fTileMode); |
41 } | 41 } |
42 }; | 42 }; |
43 | 43 |
44 | 44 |
45 static void none_gradproc(skiatest::Reporter* reporter, const GradRec& rec) { | 45 static void none_gradproc(skiatest::Reporter* reporter, const GradRec&) { |
46 SkAutoTUnref<SkShader> s(new SkEmptyShader); | 46 SkAutoTUnref<SkShader> s(new SkEmptyShader); |
47 REPORTER_ASSERT(reporter, SkShader::kNone_GradientType == s->asAGradient(NUL
L)); | 47 REPORTER_ASSERT(reporter, SkShader::kNone_GradientType == s->asAGradient(NUL
L)); |
48 } | 48 } |
49 | 49 |
50 static void color_gradproc(skiatest::Reporter* reporter, const GradRec& rec) { | 50 static void color_gradproc(skiatest::Reporter* reporter, const GradRec& rec) { |
51 SkAutoTUnref<SkShader> s(new SkColorShader(rec.fColors[0])); | 51 SkAutoTUnref<SkShader> s(new SkColorShader(rec.fColors[0])); |
52 REPORTER_ASSERT(reporter, SkShader::kColor_GradientType == s->asAGradient(NU
LL)); | 52 REPORTER_ASSERT(reporter, SkShader::kColor_GradientType == s->asAGradient(NU
LL)); |
53 | 53 |
54 SkShader::GradientInfo info; | 54 SkShader::GradientInfo info; |
55 info.fColors = NULL; | 55 info.fColors = NULL; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 rec.fColorCount, | 122 rec.fColorCount, |
123 rec.fTileMode)); | 123 rec.fTileMode)); |
124 | 124 |
125 SkShader::GradientInfo info; | 125 SkShader::GradientInfo info; |
126 rec.gradCheck(reporter, s, &info, SkShader::kConical_GradientType); | 126 rec.gradCheck(reporter, s, &info, SkShader::kConical_GradientType); |
127 REPORTER_ASSERT(reporter, !memcmp(info.fPoint, rec.fPoint, 2 * sizeof(SkPoin
t))); | 127 REPORTER_ASSERT(reporter, !memcmp(info.fPoint, rec.fPoint, 2 * sizeof(SkPoin
t))); |
128 REPORTER_ASSERT(reporter, !memcmp(info.fRadius, rec.fRadius, 2 * sizeof(SkSc
alar))); | 128 REPORTER_ASSERT(reporter, !memcmp(info.fRadius, rec.fRadius, 2 * sizeof(SkSc
alar))); |
129 } | 129 } |
130 | 130 |
131 // Ensure that repeated color gradients behave like drawing a single color | 131 // Ensure that repeated color gradients behave like drawing a single color |
132 static void TestConstantGradient(skiatest::Reporter* reporter) { | 132 static void TestConstantGradient(skiatest::Reporter*) { |
133 const SkPoint pts[] = { | 133 const SkPoint pts[] = { |
134 { 0, 0 }, | 134 { 0, 0 }, |
135 { SkIntToScalar(10), 0 } | 135 { SkIntToScalar(10), 0 } |
136 }; | 136 }; |
137 SkColor colors[] = { SK_ColorBLUE, SK_ColorBLUE }; | 137 SkColor colors[] = { SK_ColorBLUE, SK_ColorBLUE }; |
138 const SkScalar pos[] = { 0, SK_Scalar1 }; | 138 const SkScalar pos[] = { 0, SK_Scalar1 }; |
139 SkAutoTUnref<SkShader> s(SkGradientShader::CreateLinear(pts, | 139 SkAutoTUnref<SkShader> s(SkGradientShader::CreateLinear(pts, |
140 colors, | 140 colors, |
141 pos, | 141 pos, |
142 2, | 142 2, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 gProcs[i](reporter, rec); | 191 gProcs[i](reporter, rec); |
192 } | 192 } |
193 } | 193 } |
194 | 194 |
195 static void TestGradients(skiatest::Reporter* reporter) { | 195 static void TestGradients(skiatest::Reporter* reporter) { |
196 TestGradientShaders(reporter); | 196 TestGradientShaders(reporter); |
197 TestConstantGradient(reporter); | 197 TestConstantGradient(reporter); |
198 } | 198 } |
199 #include "TestClassDef.h" | 199 #include "TestClassDef.h" |
200 DEFINE_TESTCLASS("Gradients", TestGradientsClass, TestGradients) | 200 DEFINE_TESTCLASS("Gradients", TestGradientsClass, TestGradients) |
OLD | NEW |