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

Unified Diff: gm/color4f.cpp

Issue 1934313002: move colorshader into its own .cpp, add color4f variant (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: register for serialization, amend GM view for future picture expansion Created 4 years, 7 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 | gyp/core.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/color4f.cpp
diff --git a/gm/color4f.cpp b/gm/color4f.cpp
index 2585ad87c111ed02389982db698aae0c920d2bae..829434c2484671cdae765448a7b7c35e0dc83982 100644
--- a/gm/color4f.cpp
+++ b/gm/color4f.cpp
@@ -84,3 +84,42 @@ DEF_SIMPLE_GM(color4f, canvas, 1024, 260) {
canvas->translate(0, 120);
}
}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+#include "SkColorSpace.h"
+
+DEF_SIMPLE_GM(color4shader, canvas, 1024, 260) {
+ canvas->translate(10, 10);
+
+ SkMatrix44 mat(SkMatrix44::kUninitialized_Constructor);
+ // red -> blue, green -> red, blue -> green
+ mat.set3x3(0, 1, 0, 0, 0, 1, 1, 0, 0);
+
+ const SkColor4f colors[] {
+ { 1, 1, 0, 0 },
+ { 1, 0, 1, 0 },
+ { 1, 0, 0, 1 },
+ { 1, 0.5, 0.5, 0.5 },
+ };
+
+ SkPaint paint;
+ SkRect r = SkRect::MakeWH(100, 100);
+
+ for (const auto& c4 : colors) {
+ sk_sp<SkShader> shaders[] {
+ SkShader::MakeColorShader(c4, nullptr),
+ SkShader::MakeColorShader(c4, SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named)),
+ SkShader::MakeColorShader(c4, SkColorSpace::NewRGB(SkColorSpace::SkGammas(1, 1, 1),
+ mat)),
+ };
+
+ canvas->save();
+ for (const auto& s : shaders) {
+ paint.setShader(s);
+ canvas->drawRect(r, paint);
+ canvas->translate(r.width() * 6 / 5, 0);
+ }
+ canvas->restore();
+ canvas->translate(0, r.height() * 6 / 5);
+ }
+}
« no previous file with comments | « no previous file | gyp/core.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698