c0bd9f9fe5
Current strategy: everything from the top Things to look at first are the manual changes: - added tools/rewrite_includes.py - removed -Idirectives from BUILD.gn - various compile.sh simplifications - tweak tools/embed_resources.py - update gn/find_headers.py to write paths from the top - update gn/gn_to_bp.py SkUserConfig.h layout so that #include "include/config/SkUserConfig.h" always gets the header we want. No-Presubmit: true Change-Id: I73a4b181654e0e38d229bc456c0d0854bae3363e Reviewed-on: https://skia-review.googlesource.com/c/skia/+/209706 Commit-Queue: Mike Klein <mtklein@google.com> Reviewed-by: Hal Canary <halcanary@google.com> Reviewed-by: Brian Osman <brianosman@google.com> Reviewed-by: Florin Malita <fmalita@chromium.org>
45 lines
1.7 KiB
C++
45 lines
1.7 KiB
C++
/*
|
|
* Copyright 2019 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#include "gm/gm.h"
|
|
#include "include/core/SkCanvas.h"
|
|
#include "include/core/SkPaint.h"
|
|
#include "include/effects/SkGradientShader.h"
|
|
|
|
// This draws a hard stop gradient applied to a rectangle. The hard stops fall at half pixel
|
|
// boundaries in y. On some GPUs we've found that the winding of the two triangles that make up the
|
|
// rectangle can affect whether the interpolants for local coords wind up agreeing across a row.
|
|
// When they disagree the hard stop gradient appears jagged. We draw the rectangle four times:
|
|
// no-mirroring, mirror in x, mirror in y, and mirror in x and y.
|
|
DEF_SIMPLE_GM(crbug_938592, canvas, 500, 300) {
|
|
static constexpr SkPoint pts[] = {{0, 0}, {0, 30}};
|
|
static constexpr SkScalar pos[] = {0.f, 9.f / 20, 9.f / 20, 11.f / 20, 11.f / 20, 20.f / 20};
|
|
static constexpr SkColor c0 = SK_ColorBLUE;
|
|
static constexpr SkColor c1 = SK_ColorRED;
|
|
static constexpr SkColor c2 = SK_ColorGREEN;
|
|
static constexpr SkColor colors[] = {c0, c0, c1, c1, c2, c2};
|
|
auto grad = SkGradientShader::MakeLinear(pts, colors, pos, 6, SkTileMode::kClamp);
|
|
SkPaint paint;
|
|
paint.setShader(grad);
|
|
static constexpr int kMirrorX = 400;
|
|
static constexpr int kMirrorY = 200;
|
|
canvas->translate(50, 50);
|
|
for (int i = 0; i < 4; ++i) {
|
|
canvas->save();
|
|
if (i & 0b01) {
|
|
canvas->translate(0, kMirrorY);
|
|
canvas->scale(1.f, -1.f);
|
|
}
|
|
if (i & 0b10) {
|
|
canvas->translate(kMirrorX, 0);
|
|
canvas->scale(-1.f, 1.f);
|
|
}
|
|
canvas->drawRect({0, 0, 150, 30}, paint);
|
|
canvas->restore();
|
|
}
|
|
}
|