aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/gamma.cpp
diff options
context:
space:
mode:
authorGravatar brianosman <brianosman@google.com>2016-09-13 08:24:56 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-09-13 08:24:56 -0700
commit490452ec4743813b9508e6fe78755ae9e006dbe2 (patch)
treeb1dc07408f8353570eed531eb57c600255c9fc95 /gm/gamma.cpp
parent54dc4878b02765efea39e68b218df1e4bfff4b88 (diff)
Add tests for gamma correction of gradient stops to gamma GM
Includes three different cases to exercise different cases in Ganesh. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2336973003 Review-Url: https://codereview.chromium.org/2336973003
Diffstat (limited to 'gm/gamma.cpp')
-rw-r--r--gm/gamma.cpp63
1 files changed, 52 insertions, 11 deletions
diff --git a/gm/gamma.cpp b/gm/gamma.cpp
index d484aae0af..f6b4a9ceed 100644
--- a/gm/gamma.cpp
+++ b/gm/gamma.cpp
@@ -11,7 +11,7 @@
#include "SkGradientShader.h"
#include "SkPM4fPriv.h"
-DEF_SIMPLE_GM(gamma, canvas, 650, 200) {
+DEF_SIMPLE_GM(gamma, canvas, 850, 200) {
SkPaint p;
const SkScalar sz = 50.0f;
const int szInt = SkScalarTruncToInt(sz);
@@ -131,16 +131,57 @@ DEF_SIMPLE_GM(gamma, canvas, 650, 200) {
p.setColor(0xffbcbcbc);
nextRect("Color", 0);
- // Black -> White gradient, scaled to sample just the middle.
- // Tests gradient interpolation.
- SkPoint points[2] = {
- SkPoint::Make(0 - (sz * 10), 0),
- SkPoint::Make(sz + (sz * 10), 0)
- };
- SkColor colors[2] = { SK_ColorBLACK, SK_ColorWHITE };
- p.setShader(SkGradientShader::MakeLinear(points, colors, nullptr, 2,
- SkShader::kClamp_TileMode));
- nextRect("Gradient", 0);
+ {
+ // Black -> White gradient, scaled to sample just the middle.
+ // Tests gradient interpolation.
+ SkPoint points[2] = {
+ SkPoint::Make(0 - (sz * 10), 0),
+ SkPoint::Make(sz + (sz * 10), 0)
+ };
+ SkColor colors[2] = { SK_ColorBLACK, SK_ColorWHITE };
+ p.setShader(SkGradientShader::MakeLinear(points, colors, nullptr, 2,
+ SkShader::kClamp_TileMode));
+ nextRect("Gradient", "Interpolation");
+ }
+
+ {
+ // Shallow gradient around 50% (perceptual) gray. Endpoints are SkColor, so sRGB.
+ // Tests gamma-correction of gradient stops before interpolation in two-stop case
+ SkPoint points[2] = {
+ SkPoint::Make(0, 0),
+ SkPoint::Make(sz, 0)
+ };
+ SkColor colors[2] = { 0xffbbbbbb, 0xffbdbdbd };
+ p.setShader(SkGradientShader::MakeLinear(points, colors, nullptr, 2,
+ SkShader::kClamp_TileMode));
+ nextRect("Gradient", "Endpoints");
+ }
+
+ {
+ // Shallow 3-stop gradient around 50% (perceptual) gray. Endpoints are SkColor, so sRGB.
+ // Tests gamma-correction of gradient stops before interpolation in three-stop case
+ SkPoint points[2] = {
+ SkPoint::Make(0, 0),
+ SkPoint::Make(sz, 0)
+ };
+ SkColor colors[3] = { 0xffbbbbbb, 0xffbdbdbd, 0xffbbbbbb };
+ p.setShader(SkGradientShader::MakeLinear(points, colors, nullptr, 3,
+ SkShader::kClamp_TileMode));
+ nextRect("Gradient", "3-Stop");
+ }
+
+ {
+ // Shallow N-stop gradient around 50% (perceptual) gray. Endpoints are SkColor, so sRGB.
+ // Tests gamma-correction of gradient stops before interpolation in texture implementation
+ SkPoint points[2] = {
+ SkPoint::Make(0, 0),
+ SkPoint::Make(sz, 0)
+ };
+ SkColor colors[5] = { 0xffbbbbbb, 0xffbdbdbd, 0xffbbbbbb, 0xffbdbdbd, 0xffbbbbbb };
+ p.setShader(SkGradientShader::MakeLinear(points, colors, nullptr, 5,
+ SkShader::kClamp_TileMode));
+ nextRect("Gradient", "Texture");
+ }
// 50% grey from linear bitmap, with drawBitmap
nextBitmap(linearGreyBmp, "Lnr BMP");