e2556a43ad
Following up on a bug report, I'm learning how cull_path() in SkDashPath.cpp works by refactoring it. This first CL inlines and removes its helper functions between() and contains_inclusive(). First thing to notice is that the old between() function is checking `a <= b <= c || a >= b >= c` in a generic way, ignoring that `a` and `c` are always rectangle bounds. Since bounds are sorted, we really only ever need test lo <= v <= hi, for {left,x,right} or {top,y,bottom}. So rewrite between() as auto between = [](SkScalar lo, SkScalar v, SkScalar hi) { return lo <= v && v <= hi; }; Then notice that contains_inclusive() is actually now just auto contains_inclusive = [](const SkRect& bounds, const SkPoint& pt) { return between(bounds.fLeft, pt.fX, bounds.fRight ) && between(bounds.fTop , pt.fY, bounds.fBottom); }; And then notice that we're using the same inputs to both the original calls to between() and the original call to contains_inclusive()... if we inline everything it's really just two calls to between() to `&&` together later to make contains_inclusive(). Finally, once it's all inlined, it's no clearer to keep between() as its own standalone lambda than to just write out two lines for `inX` and `inY`. This removes the between() approximation added when between() itself was added in https://skia-review.googlesource.com/c/skia/+/84862/. I'm skeptical that it was ever faster than the comparisons I've got written here now, but it's not clear what Cary was timing when writing that CL, nor how much of that speedup comes from this between() approximation or and how much more generally from the added rectangle specialization. (I've updated the comment to mention that rectangle specialization too.) I did run calmbench, which doesn't think this is interesting perf-wise: cull_path (compared to master) is likely 8.31% faster in constXTile_CC JSON results available in /var/tmp/bench_cull_path_master.json Compared 731 benches. 1 of them seem to be significantly differrent. Bug: skia:9331 Cq-Include-Trybots: luci.chromium.try:linux-blink-rel Change-Id: I1b6d2c1cd8ee86df6c46b5c6a8c02634b6bb0238 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/233996 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Mike Klein <mtklein@google.com> |
||
---|---|---|
animations | ||
bench | ||
bin | ||
build_overrides | ||
dm | ||
docker | ||
docs/examples | ||
example | ||
experimental | ||
fuzz | ||
gm | ||
gn | ||
include | ||
infra | ||
modules | ||
platform_tools | ||
resources | ||
samplecode | ||
site | ||
specs | ||
src | ||
tests | ||
third_party | ||
tools | ||
.clang-format | ||
.clang-tidy | ||
.gitignore | ||
.gn | ||
AUTHORS | ||
BUILD.gn | ||
codereview.settings | ||
CONTRIBUTING | ||
CQ_COMMITTERS | ||
DEPS | ||
go.mod | ||
go.sum | ||
LICENSE | ||
OWNERS | ||
PRESUBMIT.py | ||
public.bzl | ||
README | ||
README.chromium | ||
RELEASE_NOTES.txt | ||
whitespace.txt |
Skia is a complete 2D graphic library for drawing Text, Geometries, and Images. See full details, and build instructions, at https://skia.org.