From b42b785d1cbc98bd34aceae338060831b974f9c5 Mon Sep 17 00:00:00 2001 From: reed Date: Mon, 11 Jul 2016 13:17:35 -0700 Subject: 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 Review-Url: https://codereview.chromium.org/2133413002 --- tests/RectTest.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'tests/RectTest.cpp') diff --git a/tests/RectTest.cpp b/tests/RectTest.cpp index 820586c3c6..719b5b9ae7 100644 --- a/tests/RectTest.cpp +++ b/tests/RectTest.cpp @@ -88,3 +88,35 @@ DEF_TEST(Rect, reporter) { test_stroke_width_clipping(reporter); test_skbug4406(reporter); } + +DEF_TEST(Rect_round, reporter) { + SkRandom rand; + + for (int i = 0; i < 100000; ++i) { + SkRect src = SkRect::MakeXYWH(rand.nextSScalar1() * 1000, + rand.nextSScalar1() * 1000, + rand.nextUScalar1() * 1000, + rand.nextUScalar1() * 1000); + SkRect rd0 = { + SkScalarRoundToScalar(src.fLeft), + SkScalarRoundToScalar(src.fTop), + SkScalarRoundToScalar(src.fRight), + SkScalarRoundToScalar(src.fBottom) + }; + SkRect rd1 = src.round2s(); + + REPORTER_ASSERT(reporter, rd0 == rd1); + + SkIRect ir0 = { + SkScalarRoundToInt(src.fLeft), + SkScalarRoundToInt(src.fTop), + SkScalarRoundToInt(src.fRight), + SkScalarRoundToInt(src.fBottom) + }; + SkIRect ir1 = src.round(); + SkIRect ir2 = src.round2i(); + + REPORTER_ASSERT(reporter, ir0 == ir1); + REPORTER_ASSERT(reporter, ir0 == ir2); + } +} -- cgit v1.2.3