Go to file
Mike Klein e2556a43ad inline helpers in SkDashPath.cpp cull_path()
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>
2019-08-12 19:50:01 +00:00
animations
bench gm: GMFactory returns a unique_ptr<> 2019-08-12 19:02:40 +00:00
bin Add bin/try-clients to trigger client tryjobs 2019-06-11 16:55:53 +00:00
build_overrides Update to Dawn ToT. 2019-07-22 16:20:36 +00:00
dm gm: GMFactory returns a unique_ptr<> 2019-08-12 19:02:40 +00:00
docker fix Dockerfile? 2019-06-24 16:34:59 +00:00
docs/examples Update docs and samplecode to use new image filter factories 2019-08-02 14:47:35 +00:00
example ModifierKey unifies sk_app::Window::ModifierKey & Sample::Click::ModifierKey 2019-07-09 16:16:41 +00:00
experimental experimental/editor/README.md fix 2019-08-12 14:36:01 +00:00
fuzz Move SkImageFilter functionality into private SkImageFilter_Base 2019-08-02 18:56:39 +00:00
gm add GM for skbug.com/9331 2019-08-12 19:32:40 +00:00
gn add GM for skbug.com/9331 2019-08-12 19:32:40 +00:00
include Reland: Enable YCbCr sampler support on platforms other than Android 2019-08-12 14:21:01 +00:00
infra Roll recipe dependencies (trivial). 2019-08-12 18:32:10 +00:00
modules Build fix 2019-08-09 19:49:13 +00:00
platform_tools SkQP: Refactor Java method SkQP.runTests() 2019-07-24 13:54:15 +00:00
resources [skottie] Initial Hue/Saturate effect support 2019-08-02 18:04:14 +00:00
samplecode Move initilization of Lighting sample. 2019-08-09 20:42:39 +00:00
site documentation/build, BUILDCONFIG: Visual Studio Build Tools 2019 2019-07-12 14:17:16 +00:00
specs [img-decode] Start on proposed new spec 2019-05-06 17:39:19 +00:00
src inline helpers in SkDashPath.cpp cull_path() 2019-08-12 19:50:01 +00:00
tests Reland: Enable YCbCr sampler support on platforms other than Android 2019-08-12 14:21:01 +00:00
third_party Roll third_party/externals/angle2 1ebe6014389e..1dbbc7b3e232 (5 commits) 2019-08-02 01:12:49 +00:00
tools gm: GMFactory returns a unique_ptr<> 2019-08-12 19:02:40 +00:00
.clang-format restore .clang-format 2019-03-21 15:52:32 +00:00
.clang-tidy add google-build-namespaces to clang-tidy checks 2018-12-12 16:33:59 +00:00
.gitignore clean up some .gitignores 2019-05-15 19:55:45 +00:00
.gn Basic standalone GN configs. 2016-07-21 12:25:45 -07:00
AUTHORS Fix Metal includes breaking macOS local builds 2019-07-08 14:02:47 +00:00
BUILD.gn Reland "add a stub for running fiddles as GMs" 2019-08-09 16:22:51 +00:00
codereview.settings Make uploading to Gerrit the default for Skia 2016-11-09 19:07:56 +00:00
CONTRIBUTING
CQ_COMMITTERS Moved committer list to chrome-infra-auth and deleted it from the repo 2015-09-02 13:37:54 -07:00
DEPS Roll third_party/externals/angle2 eb0479e245f0..b90755ba7793 (12 commits) 2019-08-12 05:28:10 +00:00
go.mod Update Go deps 2019-08-12 05:25:10 +00:00
go.sum Update Go deps 2019-08-12 05:25:10 +00:00
LICENSE BUG=skia:5602 2016-09-02 11:19:34 -07:00
OWNERS add OWNERS file 2017-12-01 19:50:19 +00:00
PRESUBMIT.py rewrite_includes.py: make it work on windows 2019-08-05 16:14:35 +00:00
public.bzl Reland "add a stub for running fiddles as GMs" 2019-08-09 16:22:51 +00:00
README
README.chromium
RELEASE_NOTES.txt Reland: Enable YCbCr sampler support on platforms other than Android 2019-08-12 14:21:01 +00:00
whitespace.txt Whitespace test 2019-05-18 13:05:29 +00:00

Skia is a complete 2D graphic library for drawing Text, Geometries, and Images.

See full details, and build instructions, at https://skia.org.