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>
61 lines
1.9 KiB
C++
61 lines
1.9 KiB
C++
/*
|
|
* Copyright 2011 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/SkPath.h"
|
|
#include "include/utils/SkRandom.h"
|
|
|
|
static void test_hittest(SkCanvas* canvas, const SkPath& path) {
|
|
SkPaint paint;
|
|
SkRect r = path.getBounds();
|
|
|
|
paint.setColor(SK_ColorRED);
|
|
canvas->drawPath(path, paint);
|
|
|
|
const SkScalar MARGIN = SkIntToScalar(4);
|
|
|
|
paint.setColor(0x800000FF);
|
|
for (SkScalar y = r.fTop + SK_ScalarHalf - MARGIN; y < r.fBottom + MARGIN; y += SK_Scalar1) {
|
|
for (SkScalar x = r.fLeft + SK_ScalarHalf - MARGIN; x < r.fRight + MARGIN; x += SK_Scalar1) {
|
|
if (path.contains(x, y)) {
|
|
canvas->drawPoint(x, y, paint);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
DEF_SIMPLE_GM(hittestpath, canvas, 700, 460) {
|
|
SkPath path;
|
|
SkRandom rand;
|
|
|
|
int scale = 300;
|
|
for (int i = 0; i < 4; ++i) {
|
|
// get the random values deterministically
|
|
SkScalar randoms[12];
|
|
for (int index = 0; index < (int) SK_ARRAY_COUNT(randoms); ++index) {
|
|
randoms[index] = rand.nextUScalar1();
|
|
}
|
|
path.lineTo(randoms[0] * scale, randoms[1] * scale);
|
|
path.quadTo(randoms[2] * scale, randoms[3] * scale,
|
|
randoms[4] * scale, randoms[5] * scale);
|
|
path.cubicTo(randoms[6] * scale, randoms[7] * scale,
|
|
randoms[8] * scale, randoms[9] * scale,
|
|
randoms[10] * scale, randoms[11] * scale);
|
|
}
|
|
|
|
path.setFillType(SkPath::kEvenOdd_FillType);
|
|
path.offset(SkIntToScalar(20), SkIntToScalar(20));
|
|
|
|
test_hittest(canvas, path);
|
|
|
|
canvas->translate(SkIntToScalar(scale), 0);
|
|
path.setFillType(SkPath::kWinding_FillType);
|
|
|
|
test_hittest(canvas, path);
|
|
}
|