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

Unified Diff: gm/aaclip.cpp

Issue 492963002: extend SkShader to report a luminance-color to be used for gamma correction (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 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 | include/core/SkShader.h » ('j') | src/effects/gradients/SkGradientShader.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/aaclip.cpp
diff --git a/gm/aaclip.cpp b/gm/aaclip.cpp
index 6419c8f989d98e72d802bd6fd2219be49513d4f9..b56ccd6a1c6af9e2e0ed6cbbad029af0a41e0062 100644
--- a/gm/aaclip.cpp
+++ b/gm/aaclip.cpp
@@ -9,6 +9,49 @@
#include "SkCanvas.h"
#include "SkPath.h"
+#include "SkGradientShader.h"
+static void set_gradient(SkPaint* paint) {
+ const SkPoint pts[] = { { 0, 0 }, { 240, 0 } };
+ SkColor colors[2];
+ colors[0] = paint->getColor();
+ colors[1] = SkColorSetA(colors[0], 0);
+ SkShader* shader = SkGradientShader::CreateLinear(pts, colors, NULL, 2, SkShader::kClamp_TileMode);
+ paint->setShader(shader)->unref();
+}
+
+static void set_face(SkPaint* paint) {
+ SkTypeface* face = SkTypeface::CreateFromName("serif", SkTypeface::kItalic);
+ SkSafeUnref(paint->setTypeface(face));
+}
+
+static void draw_pair(SkCanvas* canvas, SkPaint* paint) {
+ const char text[] = "Now is the time for all good";
+ const size_t len = strlen(text);
+
+ paint->setShader(NULL);
+ canvas->drawText(text, len, 10, 20, *paint);
+ set_gradient(paint);
+ canvas->drawText(text, len, 10, 40, *paint);
+}
+
+static void test_gamma(SkCanvas* canvas) {
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ paint.setLCDRenderText(true);
+ paint.setTextSize(18);
+ set_face(&paint);
+
+ draw_pair(canvas, &paint);
+
+ canvas->translate(0, 50);
+ paint.setColor(SK_ColorRED);
+ draw_pair(canvas, &paint);
+
+ canvas->translate(0, 50);
+ paint.setColor(SK_ColorBLUE);
+ draw_pair(canvas, &paint);
+}
+
/** Draw a 2px border around the target, then red behind the target;
set the clip to match the target, then draw >> the target in blue.
*/
@@ -80,6 +123,7 @@ protected:
}
virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ if (true) { test_gamma(canvas); return; }
bungeman-skia 2014/08/21 14:15:43 I'm supposing this needs to be updated.
reed1 2014/08/21 20:07:38 Done.
// Initial pixel-boundary-aligned draw
draw_rect_tests(canvas);
« no previous file with comments | « no previous file | include/core/SkShader.h » ('j') | src/effects/gradients/SkGradientShader.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698