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

Unified Diff: gm/gamma.cpp

Issue 2336973003: Add tests for gamma correction of gradient stops to gamma GM (Closed)
Patch Set: Created 4 years, 3 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/gamma.cpp
diff --git a/gm/gamma.cpp b/gm/gamma.cpp
index d484aae0af339ffa463f04b408018122dee33089..f6b4a9ceeddc55b29e7cac59cc4406676ee298d0 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");
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698