aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-07-04 14:42:26 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-07-04 14:42:26 +0000
commit5e6c3557f8254d3f73f37f322f7560f7594ea793 (patch)
treeb159c01558f5baa21f3e72cfbaab3d6bc02a8c49 /tests
parente7db8d6c0291371ae2766fd0b6fc0918a0ed1c03 (diff)
Consider conical shader opaque if it covers entire plane.
BUG=222380 R=junov@chromium.org, senorblanco@chromium.org, reed@google.com Author: arbesfeld@chromium.org Review URL: https://chromiumcodereview.appspot.com/18533006 git-svn-id: http://skia.googlecode.com/svn/trunk@9902 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests')
-rw-r--r--tests/GradientTest.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/GradientTest.cpp b/tests/GradientTest.cpp
index cf8fbee206..b67cc05380 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) {