Add a GM that reproduces layout test failures with my new xfermode code.
Inspired by https://storage.googleapis.com/chromium-layout-test-archives/linux_blink_rel/69169/layout-test-results/results.html I think the root cause is overflow. Also, adds tests for Sk16b::operator<(). It wasn't wrong, but it was suspect (used in all three of these xfermode implementations) and so it's best to have tests. BUG=skia: Review URL: https://codereview.chromium.org/1228393006
This commit is contained in:
parent
cd8c499f2e
commit
e20633ed26
52
gm/buggy_blend_modes.cpp
Normal file
52
gm/buggy_blend_modes.cpp
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright 2015 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SkCanvas.h"
|
||||
#include "SkGradientShader.h"
|
||||
#include "gm.h"
|
||||
|
||||
// This GM reproduces what I think are overflow bugs in the CPU implementations of a
|
||||
// couple xfermodes. I've marked non-obvious keys to reproducing the bug // Essential!
|
||||
DEF_SIMPLE_GM(buggy_blend_modes, canvas, 800, 200) {
|
||||
const auto tiling = SkShader::kClamp_TileMode;
|
||||
const auto flags = SkGradientShader::kInterpolateColorsInPremul_Flag; // Essential!
|
||||
|
||||
SkAutoTUnref<SkShader> cyanH, magentaV;
|
||||
{
|
||||
SkPoint pts[] = { {0,0}, {200, 0} };
|
||||
SkColor colors[] = { 0x00000000, 0xFF00FFFF };
|
||||
cyanH.reset(
|
||||
SkGradientShader::CreateLinear(pts, colors, nullptr, 2, tiling, flags, nullptr));
|
||||
}
|
||||
{
|
||||
SkPoint pts[] = { {0,0}, {0, 200} };
|
||||
SkColor colors[] = { 0x00000000, 0xFFFF00FF };
|
||||
magentaV.reset(
|
||||
SkGradientShader::CreateLinear(pts, colors, nullptr, 2, tiling, flags, nullptr));
|
||||
}
|
||||
|
||||
SkXfermode::Mode modes[] = {
|
||||
SkXfermode::kDarken_Mode, // Looks ok?
|
||||
SkXfermode::kHardLight_Mode, // Definitely wrong.
|
||||
SkXfermode::kLighten_Mode, // Definitely wrong.
|
||||
SkXfermode::kOverlay_Mode, // Same code as kHardLight_Mode.
|
||||
};
|
||||
|
||||
canvas->clear(SK_ColorWHITE);
|
||||
for (auto mode : modes) {
|
||||
canvas->saveLayer(nullptr, nullptr); // Essential!
|
||||
SkPaint h, v;
|
||||
h.setShader(cyanH);
|
||||
v.setShader(magentaV);
|
||||
v.setXfermodeMode(mode);
|
||||
canvas->drawRect(SkRect::MakeWH(200,200), h);
|
||||
canvas->drawRect(SkRect::MakeWH(200,200), v);
|
||||
canvas->restore();
|
||||
|
||||
canvas->translate(200, 0);
|
||||
}
|
||||
}
|
@ -133,11 +133,13 @@ DEF_TEST(SkNi, r) {
|
||||
test_Ni<8, int>(r);
|
||||
}
|
||||
|
||||
DEF_TEST(SkNi_min, r) {
|
||||
DEF_TEST(SkNi_min_lt, r) {
|
||||
// Exhaustively check the 8x8 bit space.
|
||||
for (int a = 0; a < (1<<8); a++) {
|
||||
for (int b = 0; b < (1<<8); b++) {
|
||||
REPORTER_ASSERT(r, Sk16b::Min(Sk16b(a), Sk16b(b)).kth<0>() == SkTMin(a, b));
|
||||
Sk16b aw(a), bw(b);
|
||||
REPORTER_ASSERT(r, Sk16b::Min(aw, bw).kth<0>() == SkTMin(a, b));
|
||||
REPORTER_ASSERT(r, !(aw < bw).kth<0>() == !(a < b));
|
||||
}}
|
||||
|
||||
// Exhausting the 16x16 bit space is kind of slow, so only do that in release builds.
|
||||
|
Loading…
Reference in New Issue
Block a user