afb8539f62
Reason for revert: Breaking the roll... https://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_rel_ng/builds/253294/steps/compile%20%28with%20patch%29/logs/stdio Original issue's description: > try to speed-up maprect + round2i + contains > > We call roundOut in a few places. If we can get SkNx::Ceil we could efficiently implement that as well. > > > BUG=skia: > GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2133413002 > CQ_INCLUDE_TRYBOTS=client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot > > Committed: https://skia.googlesource.com/skia/+/b42b785d1cbc98bd34aceae338060831b974f9c5 TBR=mtklein@google.com,reed@google.com # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review-Url: https://codereview.chromium.org/2136343002
91 lines
2.6 KiB
C++
91 lines
2.6 KiB
C++
/*
|
|
* 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 "SkBitmap.h"
|
|
#include "SkCanvas.h"
|
|
#include "SkRect.h"
|
|
#include "Test.h"
|
|
|
|
static bool has_green_pixels(const SkBitmap& bm) {
|
|
for (int j = 0; j < bm.height(); ++j) {
|
|
for (int i = 0; i < bm.width(); ++i) {
|
|
if (SkColorGetG(bm.getColor(i, j))) {
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
static void test_stroke_width_clipping(skiatest::Reporter* reporter) {
|
|
SkBitmap bm;
|
|
bm.allocN32Pixels(100, 10);
|
|
bm.eraseColor(SK_ColorTRANSPARENT);
|
|
|
|
SkCanvas canvas(bm);
|
|
SkPaint paint;
|
|
paint.setStyle(SkPaint::kStroke_Style);
|
|
paint.setStrokeWidth(10);
|
|
paint.setColor(0xff00ff00);
|
|
|
|
// clip out the left half of our canvas
|
|
canvas.clipRect(SkRect::MakeXYWH(51, 0, 49, 100));
|
|
|
|
// no stroke bleed should be visible
|
|
canvas.drawRect(SkRect::MakeWH(44, 100), paint);
|
|
REPORTER_ASSERT(reporter, !has_green_pixels(bm));
|
|
|
|
// right stroke edge should bleed into the visible area
|
|
canvas.scale(2, 2);
|
|
canvas.drawRect(SkRect::MakeWH(22, 50), paint);
|
|
REPORTER_ASSERT(reporter, has_green_pixels(bm));
|
|
}
|
|
|
|
static void test_skbug4406(skiatest::Reporter* reporter) {
|
|
SkBitmap bm;
|
|
bm.allocN32Pixels(10, 10);
|
|
bm.eraseColor(SK_ColorTRANSPARENT);
|
|
|
|
SkCanvas canvas(bm);
|
|
const SkRect r = { 1.5f, 1, 3.5f, 3 };
|
|
// draw filled green rect first
|
|
SkPaint paint;
|
|
paint.setStyle(SkPaint::kFill_Style);
|
|
paint.setColor(0xff00ff00);
|
|
paint.setStrokeWidth(1);
|
|
paint.setAntiAlias(true);
|
|
canvas.drawRect(r, paint);
|
|
|
|
// paint black with stroke rect (that asserts in bug 4406)
|
|
// over the filled rect, it should cover it
|
|
paint.setStyle(SkPaint::kStroke_Style);
|
|
paint.setColor(0xff000000);
|
|
paint.setStrokeWidth(1);
|
|
canvas.drawRect(r, paint);
|
|
REPORTER_ASSERT(reporter, !has_green_pixels(bm));
|
|
|
|
// do it again with thinner stroke
|
|
paint.setStyle(SkPaint::kFill_Style);
|
|
paint.setColor(0xff00ff00);
|
|
paint.setStrokeWidth(1);
|
|
paint.setAntiAlias(true);
|
|
canvas.drawRect(r, paint);
|
|
// paint black with stroke rect (that asserts in bug 4406)
|
|
// over the filled rect, it doesnt cover it completelly with thinner stroke
|
|
paint.setStyle(SkPaint::kStroke_Style);
|
|
paint.setColor(0xff000000);
|
|
paint.setStrokeWidth(0.99f);
|
|
canvas.drawRect(r, paint);
|
|
REPORTER_ASSERT(reporter, has_green_pixels(bm));
|
|
}
|
|
|
|
DEF_TEST(Rect, reporter) {
|
|
test_stroke_width_clipping(reporter);
|
|
test_skbug4406(reporter);
|
|
}
|