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

Unified Diff: gm/gamma.cpp

Issue 2267773002: Demo slides for color presentation Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase Created 4 years, 4 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 | samplecode/SampleApp.cpp » ('j') | 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 eb4c7607feb1e4b9d9d3a2a488595dd9c215e84c..66c555f6ecdb0159c3b4628a783f67e9a1fba79a 100644
--- a/gm/gamma.cpp
+++ b/gm/gamma.cpp
@@ -10,6 +10,8 @@
#include "Resources.h"
#include "SkGradientShader.h"
#include "SkPM4fPriv.h"
+#include "SkPath.h"
+#include "sk_tool_utils.h"
DEF_SIMPLE_GM(gamma, canvas, 560, 200) {
SkPaint p;
@@ -182,3 +184,111 @@ DEF_SIMPLE_GM(gamma, canvas, 560, 200) {
canvas->restore();
}
+
+DEF_SIMPLE_GM(gamma1b, canvas, 800, 600) {
+ SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
+ canvas->getProps(&props);
+ SkPaint bgp;
+// if (props.isGammaCorrect()) {
+ bgp.setColor(0xFF7f7f7f);
+// } else {
+// bgp.setColor(0xFFbcbcbc);
+// }
+ canvas->drawRect(SkRect::MakeWH(1100, 650), bgp);
+
+ SkPaint p;
+
+ // Black -> White gradient, scaled to sample just the middle.
+ // Tests gradient interpolation.
+ SkPoint points[2] = {
+ SkPoint::Make(50, 0),
+ SkPoint::Make(1050, 0)
+ };
+ SkColor colors[2] = { SK_ColorBLACK, SK_ColorWHITE };
+ SkColor colors2[2] = { SK_ColorRED, SK_ColorGREEN };
+ SkColor colors3[2] = { SK_ColorRED, SK_ColorBLUE };
+ SkColor colors4[2] = { SK_ColorCYAN, SK_ColorYELLOW };
+ p.setShader(SkGradientShader::MakeLinear(points, colors, nullptr, 2,
+ SkShader::kClamp_TileMode));
+ canvas->drawRect(SkRect::MakeXYWH(50, 50, 1000, 100), p);
+
+ p.setShader(SkGradientShader::MakeLinear(points, colors2, nullptr, 2,
+ SkShader::kClamp_TileMode));
+ canvas->drawRect(SkRect::MakeXYWH(50, 200, 1000, 100), p);
+
+ p.setShader(SkGradientShader::MakeLinear(points, colors3, nullptr, 2,
+ SkShader::kClamp_TileMode));
+ canvas->drawRect(SkRect::MakeXYWH(50, 350, 1000, 100), p);
+
+ p.setShader(SkGradientShader::MakeLinear(points, colors4, nullptr, 2,
+ SkShader::kClamp_TileMode));
+ canvas->drawRect(SkRect::MakeXYWH(50, 500, 1000, 100), p);
+}
+
+DEF_SIMPLE_GM(gamma2, canvas, 800, 600) {
+ canvas->clear(SK_ColorBLACK);
+ SkBitmap bmp = sk_tool_utils::create_checkerboard_bitmap(400, 400,
+ SK_ColorRED, SK_ColorGREEN, 1);
+ SkPaint p2;
+ p2.setFilterQuality(SkFilterQuality::kMedium_SkFilterQuality);
+ canvas->drawBitmap(bmp, 50, 50, &p2);
+}
+
+DEF_SIMPLE_GM(gamma3, canvas, 800, 600) {
+ canvas->clear(SK_ColorBLACK);
+ SkBitmap bmp = sk_tool_utils::create_checkerboard_bitmap(400, 400,
+ SK_ColorRED, SK_ColorGREEN, 1);
+
+ SkPaint p2;
+ p2.setFilterQuality(SkFilterQuality::kMedium_SkFilterQuality);
+ canvas->drawBitmap(bmp, 50, 50, &p2);
+
+ SkPaint p;
+ p.setColor(SK_ColorRED);
+ canvas->drawRect(SkRect::MakeXYWH(600, 50, 400, 400), p);
+ p.setColor(0x7f00FF00);
+ canvas->drawRect(SkRect::MakeXYWH(1000, 450, 400, 400), p);
+}
+
+DEF_SIMPLE_GM(gamma4, canvas, 800, 600) {
+ canvas->clear(SK_ColorBLACK);
+ SkBitmap bmp = sk_tool_utils::create_checkerboard_bitmap(400, 400,
+ SK_ColorRED, SK_ColorGREEN, 1);
+
+ SkPaint p2;
+ p2.setFilterQuality(SkFilterQuality::kMedium_SkFilterQuality);
+ canvas->drawBitmap(bmp, 50, 50, &p2);
+
+ SkPaint p;
+ p.setColor(SK_ColorRED);
+ canvas->drawRect(SkRect::MakeXYWH(600, 50, 400, 400), p);
+ p.setColor(0x7f00FF00);
+ canvas->drawRect(SkRect::MakeXYWH(800, 250, 400, 400), p);
+}
+
+DEF_SIMPLE_GM(gamma5, canvas, 500, 200) {
+ SkPaint p;
+ p.setAntiAlias(true);
+
+ canvas->clear(SK_ColorWHITE);
+
+ SkPath path;
+/* path.moveTo(50, 500);
+ path.lineTo(400, 400);
+ path.lineTo(850, 350);
+ path.lineTo(650, 140);
+ path.close();
+ */
+ for (int i = 0; i < 12; ++i) {
+ SkScalar r = 2 * SK_ScalarPI * (i / 12.f);
+ auto s = SkScalarSin(r) * 400.f;
+ auto c = SkScalarCos(r) * 700.f;
+ if (i == 0) {
+ path.moveTo(1000.f + c, 500.f + s);
+ } else {
+ path.lineTo(1000.f + c, 500.f + s);
+ }
+ }
+ path.close();
+ canvas->drawPath(path, p);
+}
« no previous file with comments | « no previous file | samplecode/SampleApp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698