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

Side by Side 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, 10 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 unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright 2011 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "gm.h"
9 #include "SkCanvas.h"
10 #include "SkColorPriv.h"
11 #include "SkShader.h"
12 #include "SkSurface.h"
13
14 #include "SkColorMatrixFilter.h"
15 #include "SkGradientShader.h"
16
17 static SkShader* make_opaque_color() {
18 return SkShader::CreateColorShader(0xFFFF0000);
19 }
20
21 static SkShader* make_alpha_color() {
22 return SkShader::CreateColorShader(0x80FF0000);
23 }
24
25 static SkColorFilter* make_cf_null() {
26 return nullptr;
27 }
28
29 static SkColorFilter* make_cf0() {
30 SkColorMatrix cm;
31 cm.setSaturation(0.75f);
32 return SkColorMatrixFilter::Create(cm);
33 }
34
35 static void draw_into_canvas(SkCanvas* canvas) {
36 const SkRect r = SkRect::MakeWH(100, 100);
37 SkShader* (*shaders[])() { make_opaque_color, make_alpha_color };
38 SkColorFilter* (*filters[])() { make_cf_null, make_cf0 };
39
40 SkPaint paint;
41 for (auto shProc : shaders) {
42 paint.setShader(shProc())->unref();
43 for (auto cfProc : filters) {
44 SkSafeUnref(paint.setColorFilter(cfProc()));
45 canvas->drawRect(r, paint);
46 canvas->translate(120, 0);
47 }
48 }
49 }
50
51 DEF_SIMPLE_GM(color4f, canvas, 510, 250) {
52 canvas->translate(20, 20);
53
54 SkPaint bg;
55 // need the target to be opaque, so we can draw it to the screen
56 // even if it holds sRGB values.
57 bg.setColor(0xFFFFFFFF);
58
59 SkColorProfileType const profiles[] { kLinear_SkColorProfileType, kSRGB_SkCo lorProfileType };
60 for (auto profile : profiles) {
61 const SkImageInfo info = SkImageInfo::Make(500, 100, kN32_SkColorType, k Premul_SkAlphaType,
62 profile);
63 SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info));
64 surface->getCanvas()->drawPaint(bg);
65 draw_into_canvas(surface->getCanvas());
66 surface->draw(canvas, 0, 0, nullptr);
67 canvas->translate(0, 120);
68 }
69 }
OLDNEW
« 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