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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/effects/gradients/SkTwoPointConicalGradient.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/GradientTest.cpp
diff --git a/tests/GradientTest.cpp b/tests/GradientTest.cpp
index cf8fbee20635614d275c9ae93c07298dd3bcdee1..b67cc0538027d66bcabb3b8ee5fc7fff70b2c3e1 100644
--- a/tests/GradientTest.cpp
+++ b/tests/GradientTest.cpp
@@ -126,6 +126,34 @@ static void conical_gradproc(skiatest::Reporter* reporter, const GradRec& rec) {
rec.gradCheck(reporter, s, &info, SkShader::kConical_GradientType);
REPORTER_ASSERT(reporter, !memcmp(info.fPoint, rec.fPoint, 2 * sizeof(SkPoint)));
REPORTER_ASSERT(reporter, !memcmp(info.fRadius, rec.fRadius, 2 * sizeof(SkScalar)));
+ REPORTER_ASSERT(reporter, !s->isOpaque());
+}
+
+// 2-point radial gradient should behave as opaque when it extends to the entire plane
+static void conical_gradproc_opaque(skiatest::Reporter* reporter, const GradRec& rec) {
+ SkAutoTUnref<SkShader> s(SkGradientShader::CreateTwoPointConical(rec.fPoint[0],
+ rec.fRadius[0],
+ rec.fPoint[0],
+ rec.fRadius[1],
+ rec.fColors,
+ rec.fPos,
+ rec.fColorCount,
+ rec.fTileMode));
+ REPORTER_ASSERT(reporter, s->isOpaque());
+}
+
+// 2nd circle center lies on edge of first circle should not be considered opaque
+static void conical_gradproc_not_opaque(skiatest::Reporter* reporter, const GradRec& rec) {
+ SkScalar dist = SkPoint::Distance(rec.fPoint[0], rec.fPoint[1]);
+ SkAutoTUnref<SkShader> s(SkGradientShader::CreateTwoPointConical(rec.fPoint[0],
+ dist,
+ rec.fPoint[1],
+ rec.fRadius[1],
+ rec.fColors,
+ rec.fPos,
+ rec.fColorCount,
+ rec.fTileMode));
+ REPORTER_ASSERT(reporter, !s->isOpaque());
}
// Ensure that repeated color gradients behave like drawing a single color
@@ -185,6 +213,8 @@ static void TestGradientShaders(skiatest::Reporter* reporter) {
radial2_gradproc,
sweep_gradproc,
conical_gradproc,
+ conical_gradproc_opaque,
+ conical_gradproc_not_opaque,
};
for (size_t i = 0; i < SK_ARRAY_COUNT(gProcs); ++i) {
« 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