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 1634273002: float components in xfermodes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: disable blitter for official checkin Created 4 years, 11 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
Index: gm/color4f.cpp
diff --git a/gm/color4f.cpp b/gm/color4f.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..98ce0824cca6c6231b9c6619d0b91de15d045357
--- /dev/null
+++ b/gm/color4f.cpp
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2011 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "gm.h"
+#include "SkCanvas.h"
+#include "SkColorPriv.h"
+#include "SkShader.h"
+#include "SkSurface.h"
+
+#include "SkColorMatrixFilter.h"
+#include "SkGradientShader.h"
+
+static SkShader* make_opaque_color() {
+ return SkShader::CreateColorShader(0xFFFF0000);
+}
+
+static SkShader* make_alpha_color() {
+ return SkShader::CreateColorShader(0x80FF0000);
+}
+
+static SkColorFilter* make_cf_null() {
+ return nullptr;
+}
+
+static SkColorFilter* make_cf0() {
+ SkColorMatrix cm;
+ cm.setSaturation(0.75f);
+ return SkColorMatrixFilter::Create(cm);
+}
+
+static void draw_into_canvas(SkCanvas* canvas) {
+ const SkRect r = SkRect::MakeWH(100, 100);
+ SkShader* (*shaders[])() { make_opaque_color, make_alpha_color };
+ SkColorFilter* (*filters[])() { make_cf_null, make_cf0 };
+
+ SkPaint paint;
+ for (auto shProc : shaders) {
+ paint.setShader(shProc())->unref();
+ for (auto cfProc : filters) {
+ SkSafeUnref(paint.setColorFilter(cfProc()));
+ canvas->drawRect(r, paint);
+ canvas->translate(120, 0);
+ }
+ }
+}
+
+DEF_SIMPLE_GM(color4f, canvas, 510, 250) {
+ canvas->translate(20, 20);
+
+ SkPaint bg;
+ // need the target to be opaque, so we can draw it to the screen
+ // even if it holds sRGB values.
+ bg.setColor(0xFFFFFFFF);
+
+ SkColorProfileType const profiles[] { kLinear_SkColorProfileType, kSRGB_SkColorProfileType };
+ for (auto profile : profiles) {
+ const SkImageInfo info = SkImageInfo::Make(500, 100, kN32_SkColorType, kPremul_SkAlphaType,
+ profile);
+ SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info));
+ surface->getCanvas()->drawPaint(bg);
+ draw_into_canvas(surface->getCanvas());
+ surface->draw(canvas, 0, 0, nullptr);
+ canvas->translate(0, 120);
+ }
+}
« no previous file with comments | « bench/Xfer4fBench.cpp ('k') | gm/xfer4f.cpp » ('j') | include/core/SkXfermode.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698