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

Side by Side Diff: gm/color4f.cpp

Issue 1670063002: extend modecolorfilter to 4f (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove pin for modulate 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
« no previous file with comments | « no previous file | include/core/SkColor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "gm.h" 8 #include "gm.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 27 matching lines...) Expand all
38 SkAutoTUnref<SkColorFilter> a(SkColorMatrixFilter::Create(cm)); 38 SkAutoTUnref<SkColorFilter> a(SkColorMatrixFilter::Create(cm));
39 // CreateComposedFilter will try to concat these two matrices, resulting in a single 39 // CreateComposedFilter will try to concat these two matrices, resulting in a single
40 // filter (which is good for speed). For this test, we want to force a real compose of 40 // filter (which is good for speed). For this test, we want to force a real compose of
41 // these two, so our inner filter has a scale-up, which disables the optimiz ation of 41 // these two, so our inner filter has a scale-up, which disables the optimiz ation of
42 // combining the two matrices. 42 // combining the two matrices.
43 cm.setScale(1.1f, 0.9f, 1); 43 cm.setScale(1.1f, 0.9f, 1);
44 SkAutoTUnref<SkColorFilter> b(SkColorMatrixFilter::Create(cm)); 44 SkAutoTUnref<SkColorFilter> b(SkColorMatrixFilter::Create(cm));
45 return SkColorFilter::CreateComposeFilter(a, b); 45 return SkColorFilter::CreateComposeFilter(a, b);
46 } 46 }
47 47
48 static SkColorFilter* make_cf2() {
49 return SkColorFilter::CreateModeFilter(0x8044CC88, SkXfermode::kSrcATop_Mode );
50 }
51
48 static void draw_into_canvas(SkCanvas* canvas) { 52 static void draw_into_canvas(SkCanvas* canvas) {
49 const SkRect r = SkRect::MakeWH(100, 100); 53 const SkRect r = SkRect::MakeWH(50, 100);
50 SkShader* (*shaders[])() { make_opaque_color, make_alpha_color }; 54 SkShader* (*shaders[])() { make_opaque_color, make_alpha_color };
51 SkColorFilter* (*filters[])() { make_cf_null, make_cf0, make_cf1 }; 55 SkColorFilter* (*filters[])() { make_cf_null, make_cf0, make_cf1, make_cf2 } ;
52 56
53 SkPaint paint; 57 SkPaint paint;
54 for (auto shProc : shaders) { 58 for (auto shProc : shaders) {
55 paint.setShader(shProc())->unref(); 59 paint.setShader(shProc())->unref();
56 for (auto cfProc : filters) { 60 for (auto cfProc : filters) {
57 SkSafeUnref(paint.setColorFilter(cfProc())); 61 SkSafeUnref(paint.setColorFilter(cfProc()));
58 canvas->drawRect(r, paint); 62 canvas->drawRect(r, paint);
59 canvas->translate(120, 0); 63 canvas->translate(60, 0);
60 } 64 }
61 } 65 }
62 } 66 }
63 67
64 DEF_SIMPLE_GM(color4f, canvas, 620, 260) { 68 DEF_SIMPLE_GM(color4f, canvas, 1024, 260) {
65 canvas->translate(20, 20); 69 canvas->translate(10, 10);
66 70
67 SkPaint bg; 71 SkPaint bg;
68 // need the target to be opaque, so we can draw it to the screen 72 // need the target to be opaque, so we can draw it to the screen
69 // even if it holds sRGB values. 73 // even if it holds sRGB values.
70 bg.setColor(0xFFFFFFFF); 74 bg.setColor(0xFFFFFFFF);
71 75
72 SkColorProfileType const profiles[] { kLinear_SkColorProfileType, kSRGB_SkCo lorProfileType }; 76 SkColorProfileType const profiles[] { kLinear_SkColorProfileType, kSRGB_SkCo lorProfileType };
73 for (auto profile : profiles) { 77 for (auto profile : profiles) {
74 const SkImageInfo info = SkImageInfo::Make(600, 100, kN32_SkColorType, k Premul_SkAlphaType, 78 const SkImageInfo info = SkImageInfo::Make(1024, 100, kN32_SkColorType, kPremul_SkAlphaType,
75 profile); 79 profile);
76 SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info)); 80 SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info));
77 surface->getCanvas()->drawPaint(bg); 81 surface->getCanvas()->drawPaint(bg);
78 draw_into_canvas(surface->getCanvas()); 82 draw_into_canvas(surface->getCanvas());
79 surface->draw(canvas, 0, 0, nullptr); 83 surface->draw(canvas, 0, 0, nullptr);
80 canvas->translate(0, 120); 84 canvas->translate(0, 120);
81 } 85 }
82 } 86 }
OLDNEW
« no previous file with comments | « no previous file | include/core/SkColor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698