aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core
diff options
context:
space:
mode:
authorGravatar msarett <msarett@google.com>2016-08-12 08:29:08 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-08-12 08:29:08 -0700
commitfbfa25802709139c2f14e304319c9541da65ca27 (patch)
tree8ae96384c128dd1dc4caaa78beba56c2b5ae6de4 /include/core
parent7e8d5d3519ea2d4c7f158ff9737843e20daad0cb (diff)
Optimized implementation of quickReject()
Impl Overview (1) Keep the device clip bounds up to date. This requires minimal additional work in a few places throughout canvas. (2) Keep track of if the ctm isScaleTranslate. Yes, there's a function that does this, but it's slow to call. (3) Perform the src->device transform in quick reject, then check intersection/nan. Other Notes: (1) NaN and intersection checks are performed simultaneously. (2) We no longer quick reject infinity. (3) Affine and perspective are both handled in the slow case. (4) SkRasterClip::isEmpty() is handled by the intersection check. Performance on Nexus 6P: 93.2ms -> 59.8ms Overall Android Jank Tests Performance Impact: Should gain us a ms or two on some tests. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2225393002 Committed: https://skia.googlesource.com/skia/+/d22a817ff57986407facd16af36320fc86ce02da Review-Url: https://codereview.chromium.org/2225393002
Diffstat (limited to 'include/core')
-rw-r--r--include/core/SkCanvas.h21
-rw-r--r--include/core/SkPostConfig.h12
2 files changed, 19 insertions, 14 deletions
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index ef2d7dad70..73fcf43a5f 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -1609,25 +1609,18 @@ private:
*/
bool canDrawBitmapAsSprite(SkScalar x, SkScalar y, int w, int h, const SkPaint&);
- /* These maintain a cache of the clip bounds in local coordinates,
- (converted to 2s-compliment if floats are slow).
+
+ /**
+ * Keep track of the device clip bounds and if the matrix is scale-translate. This allows
+ * us to do a fast quick reject in the common case.
*/
- mutable SkRect fCachedLocalClipBounds;
- mutable bool fCachedLocalClipBoundsDirty;
+ bool fConservativeIsScaleTranslate;
+ SkRect fDeviceClipBounds;
+
bool fAllowSoftClip;
bool fAllowSimplifyClip;
const bool fConservativeRasterClip;
- const SkRect& getLocalClipBounds() const {
- if (fCachedLocalClipBoundsDirty) {
- if (!this->getClipBounds(&fCachedLocalClipBounds)) {
- fCachedLocalClipBounds.setEmpty();
- }
- fCachedLocalClipBoundsDirty = false;
- }
- return fCachedLocalClipBounds;
- }
-
class AutoValidateClip : ::SkNoncopyable {
public:
explicit AutoValidateClip(SkCanvas* canvas) : fCanvas(canvas) {
diff --git a/include/core/SkPostConfig.h b/include/core/SkPostConfig.h
index b67c863887..97c868f30f 100644
--- a/include/core/SkPostConfig.h
+++ b/include/core/SkPostConfig.h
@@ -275,6 +275,18 @@
# endif
#endif
+/**
+ * If your judgment is better than the compiler's (i.e. you've profiled it),
+ * you can use SK_NEVER_INLINE to prevent inlining.
+ */
+#if !defined(SK_NEVER_INLINE)
+# if defined(SK_BUILD_FOR_WIN)
+# define SK_NEVER_INLINE __declspec(noinline)
+# else
+# define SK_NEVER_INLINE SK_ATTRIBUTE(noinline)
+# endif
+#endif
+
//////////////////////////////////////////////////////////////////////
#if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE1