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

Side by Side Diff: tests/GradientTest.cpp

Issue 18533006: Consider conical shader opaque if it covers entire plane. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « src/effects/gradients/SkTwoPointConicalGradient.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 /* 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 rec.fRadius[1], 119 rec.fRadius[1],
120 rec.fColors, 120 rec.fColors,
121 rec.fPos, 121 rec.fPos,
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 REPORTER_ASSERT(reporter, !s->isOpaque());
130 }
131
132 // 2-point radial gradient should behave as opaque when it extends to the entire plane
133 static void conical_gradproc_opaque(skiatest::Reporter* reporter, const GradRec& rec) {
134 SkAutoTUnref<SkShader> s(SkGradientShader::CreateTwoPointConical(rec.fPoint[ 0],
135 rec.fRadius [0],
136 rec.fPoint[ 0],
137 rec.fRadius [1],
138 rec.fColors ,
139 rec.fPos,
140 rec.fColorC ount,
141 rec.fTileMo de));
142 REPORTER_ASSERT(reporter, s->isOpaque());
143 }
144
145 // 2nd circle center lies on edge of first circle should not be considered opaqu e
146 static void conical_gradproc_not_opaque(skiatest::Reporter* reporter, const Grad Rec& rec) {
147 SkScalar dist = SkPoint::Distance(rec.fPoint[0], rec.fPoint[1]);
148 SkAutoTUnref<SkShader> s(SkGradientShader::CreateTwoPointConical(rec.fPoint[ 0],
149 dist,
150 rec.fPoint[ 1],
151 rec.fRadius [1],
152 rec.fColors ,
153 rec.fPos,
154 rec.fColorC ount,
155 rec.fTileMo de));
156 REPORTER_ASSERT(reporter, !s->isOpaque());
129 } 157 }
130 158
131 // Ensure that repeated color gradients behave like drawing a single color 159 // Ensure that repeated color gradients behave like drawing a single color
132 static void TestConstantGradient(skiatest::Reporter*) { 160 static void TestConstantGradient(skiatest::Reporter*) {
133 const SkPoint pts[] = { 161 const SkPoint pts[] = {
134 { 0, 0 }, 162 { 0, 0 },
135 { SkIntToScalar(10), 0 } 163 { SkIntToScalar(10), 0 }
136 }; 164 };
137 SkColor colors[] = { SK_ColorBLUE, SK_ColorBLUE }; 165 SkColor colors[] = { SK_ColorBLUE, SK_ColorBLUE };
138 const SkScalar pos[] = { 0, SK_Scalar1 }; 166 const SkScalar pos[] = { 0, SK_Scalar1 };
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 rec.fTileMode = SkShader::kClamp_TileMode; 206 rec.fTileMode = SkShader::kClamp_TileMode;
179 207
180 static const GradProc gProcs[] = { 208 static const GradProc gProcs[] = {
181 none_gradproc, 209 none_gradproc,
182 color_gradproc, 210 color_gradproc,
183 linear_gradproc, 211 linear_gradproc,
184 radial_gradproc, 212 radial_gradproc,
185 radial2_gradproc, 213 radial2_gradproc,
186 sweep_gradproc, 214 sweep_gradproc,
187 conical_gradproc, 215 conical_gradproc,
216 conical_gradproc_opaque,
217 conical_gradproc_not_opaque,
188 }; 218 };
189 219
190 for (size_t i = 0; i < SK_ARRAY_COUNT(gProcs); ++i) { 220 for (size_t i = 0; i < SK_ARRAY_COUNT(gProcs); ++i) {
191 gProcs[i](reporter, rec); 221 gProcs[i](reporter, rec);
192 } 222 }
193 } 223 }
194 224
195 static void TestGradients(skiatest::Reporter* reporter) { 225 static void TestGradients(skiatest::Reporter* reporter) {
196 TestGradientShaders(reporter); 226 TestGradientShaders(reporter);
197 TestConstantGradient(reporter); 227 TestConstantGradient(reporter);
198 } 228 }
199 #include "TestClassDef.h" 229 #include "TestClassDef.h"
200 DEFINE_TESTCLASS("Gradients", TestGradientsClass, TestGradients) 230 DEFINE_TESTCLASS("Gradients", TestGradientsClass, TestGradients)
OLDNEW
« no previous file with comments | « src/effects/gradients/SkTwoPointConicalGradient.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698