Flutter Engine
The Flutter Engine
bug6783.cpp
Go to the documentation of this file.
1/*
2* Copyright 2017 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/gm.h"
14#include "include/core/SkRect.h"
19
20// This GM reproduces skia:6783, which demonstrated a bug in repeat and mirror
21// image sampling tiling modes as implemented in software. We want to tile to
22// [0,limit), and the old incorrect logic was:
23//
24// limit = ulp_before(limit)
25// val = val - floor(val/limit)*limit (This is repeat; mirror is similar.)
26//
27// while the correct logic is more like:
28//
29// val = val - floor(val/limit)*limit
30// val = min(val, ulp_before(limit))
31//
32// You would see ugly jaggies on the blue/yellow edge near the bottom left if
33// the bug were still present. All stripes should now look roughly the same.
34
35DEF_SIMPLE_GM(bug6783, canvas, 500, 500) {
37
38 SkPaint p;
39 p.setColor(SK_ColorYELLOW);
40 surface->getCanvas()->drawPaint(p);
41 p.setColor(SK_ColorBLUE);
42 surface->getCanvas()->drawRect(SkRect::MakeWH(50, 100), p);
43
44 sk_sp<SkImage> img = surface->makeImageSnapshot();
45
47 m.preSkew(0.5f, 0.5f);
48
49 // The bug was present at all filter levels, but you might not notice it at nearest.
51
52 // It's only important to repeat or mirror in x to show off the bug.
54 canvas->drawPaint(p);
55}
constexpr SkColor SK_ColorYELLOW
Definition: SkColor.h:139
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
DEF_SIMPLE_GM(bug6783, canvas, 500, 500)
Definition: bug6783.cpp:35
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
Definition: SkImage.cpp:179
static SkMatrix Scale(SkScalar sx, SkScalar sy)
Definition: SkMatrix.h:75
static SkMatrix Translate(SkScalar dx, SkScalar dy)
Definition: SkMatrix.h:91
VkSurfaceKHR surface
Definition: main.cc:49
SkSamplingOptions sampling
Definition: SkRecords.h:337
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
static SkImageInfo MakeN32Premul(int width, int height)
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609