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

Side by Side Diff: gm/buggy_blend_modes.cpp

Issue 1228393006: Add a GM that reproduces layout test failures with my new xfermode code. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 5 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 | tests/SkNxTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 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 "SkCanvas.h"
9 #include "SkGradientShader.h"
10 #include "gm.h"
11
12 // This GM reproduces what I think are overflow bugs in the CPU implementations of a
13 // couple xfermodes. I've marked non-obvious keys to reproducing the bug // Ess ential!
14 DEF_SIMPLE_GM(buggy_blend_modes, canvas, 800, 200) {
15 const auto tiling = SkShader::kClamp_TileMode;
16 const auto flags = SkGradientShader::kInterpolateColorsInPremul_Flag; // Es sential!
17
18 SkAutoTUnref<SkShader> cyanH, magentaV;
19 {
20 SkPoint pts[] = { {0,0}, {200, 0} };
21 SkColor colors[] = { 0x00000000, 0xFF00FFFF };
22 cyanH.reset(
23 SkGradientShader::CreateLinear(pts, colors, nullptr, 2, tiling, flags, nullptr));
24 }
25 {
26 SkPoint pts[] = { {0,0}, {0, 200} };
27 SkColor colors[] = { 0x00000000, 0xFFFF00FF };
28 magentaV.reset(
29 SkGradientShader::CreateLinear(pts, colors, nullptr, 2, tiling, flags, nullptr));
30 }
31
32 SkXfermode::Mode modes[] = {
33 SkXfermode::kDarken_Mode, // Looks ok?
34 SkXfermode::kHardLight_Mode, // Definitely wrong.
35 SkXfermode::kLighten_Mode, // Definitely wrong.
36 SkXfermode::kOverlay_Mode, // Same code as kHardLight_Mode.
37 };
38
39 canvas->clear(SK_ColorWHITE);
40 for (auto mode : modes) {
41 canvas->saveLayer(nullptr, nullptr); // Essential!
42 SkPaint h, v;
43 h.setShader(cyanH);
44 v.setShader(magentaV);
45 v.setXfermodeMode(mode);
46 canvas->drawRect(SkRect::MakeWH(200,200), h);
47 canvas->drawRect(SkRect::MakeWH(200,200), v);
48 canvas->restore();
49
50 canvas->translate(200, 0);
51 }
52 }
OLDNEW
« no previous file with comments | « no previous file | tests/SkNxTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698