diff options
author | Chris Dalton <csmartdalton@google.com> | 2017-10-31 17:50:41 -0600 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-11-01 16:25:00 +0000 |
commit | 1af37b758bc3c285effb7b96bd27faf4481d90d0 (patch) | |
tree | 0263f28275e9c39c6cf2d613846d9d6623fd1cd8 /src/gpu/GrReducedClip.h | |
parent | d4685403e25efe85eca108f7b9db5b7cfb8ffcd8 (diff) |
Fold analytic clip FPs into GrReducedClip
Perf result on Pixel phone (sorted by impact):
GEOMEAN 6.73 -> 6.49 ms [96% ]
top25desk_pinterest.skp 0.45 -> 0.49 ms [107%]
desk_pokemonwiki.skp 14.6 -> 15.9 ms [106%]
keymobi_pinterest.skp 0.47 -> 0.49 ms [104%]
...
keymobi_androidpolice_com_2012_.skp 3.69 -> 3.09 ms [83% ]
keymobi_shop_mobileweb_ebay_com.skp 2.90 -> 2.29 ms [78% ]
keymobi_boingboing_net.skp 2.95 -> 2.29 ms [76% ]
desk_jsfiddlebigcar.skp 1.79 -> 1.29 ms [71% ]
keymobi_m_youtube_com_watch_v_9.skp 12.9 -> 9.09 ms [70% ]
keymobi_blogger.skp 3.80 -> 2.69 ms [70% ]
keymobi_sfgate_com_.skp 8.16 -> 5.69 ms [69% ]
Cleaner code, improved skps, slightly better geometric mean time.
Pixel C is mostly unaffected, presumably because it uses window
rectangles.
Bug: skia:7190
Change-Id: I070148258d04284def535134a72a4584c5d6f7c7
Reviewed-on: https://skia-review.googlesource.com/65460
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Diffstat (limited to 'src/gpu/GrReducedClip.h')
-rw-r--r-- | src/gpu/GrReducedClip.h | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/gpu/GrReducedClip.h b/src/gpu/GrReducedClip.h index 0746439ba3..ca133550dd 100644 --- a/src/gpu/GrReducedClip.h +++ b/src/gpu/GrReducedClip.h @@ -8,6 +8,7 @@ #ifndef GrReducedClip_DEFINED #define GrReducedClip_DEFINED +#include "GrFragmentProcessor.h" #include "GrWindowRectangles.h" #include "SkClipStack.h" #include "SkTLList.h" @@ -24,7 +25,8 @@ public: using Element = SkClipStack::Element; using ElementList = SkTLList<SkClipStack::Element, 16>; - GrReducedClip(const SkClipStack&, const SkRect& queryBounds, int maxWindowRectangles = 0); + GrReducedClip(const SkClipStack&, const SkRect& queryBounds, + int maxWindowRectangles = 0, int maxAnalyticFPs = 0); /** * If hasScissor() is true, the clip mask is not valid outside this rect and the caller must @@ -48,6 +50,13 @@ public: */ const GrWindowRectangles& windowRectangles() const { return fWindowRects; } + int numAnalyticFPs() const { return fAnalyticFPs.count(); } + + std::unique_ptr<GrFragmentProcessor> detachAnalyticFPs() { + SkDEBUGCODE(for (const auto& fp : fAnalyticFPs) { SkASSERT(fp); }) + return GrFragmentProcessor::RunInSeries(fAnalyticFPs.begin(), fAnalyticFPs.count()); + } + /** * An ordered list of clip elements that could not be skipped or implemented by other means. If * nonempty, the caller must create an alpha and/or stencil mask for these elements and apply it @@ -81,7 +90,7 @@ public: bool drawStencilClipMask(GrContext*, GrRenderTargetContext*) const; private: - void walkStack(const SkClipStack&, const SkRect& queryBounds, int maxWindowRectangles); + void walkStack(const SkClipStack&, const SkRect& queryBounds); enum class ClipResult { kNotClipped, @@ -95,16 +104,27 @@ private: // Clips the the given element's exterior out of the final clip. // NOTE: do not call for elements followed by ops that can grow the clip. - ClipResult clipOutsideElement(const Element* element, int maxWindowRectangles); + ClipResult clipOutsideElement(const Element* element); void addWindowRectangle(const SkRect& elementInteriorRect, bool elementIsAA); + + enum class Invert : bool { + kNo, + kYes + }; + + template<typename T> ClipResult addAnalyticFP(const T& deviceSpaceShape, Invert, bool aa); + void makeEmpty(); + const int fMaxWindowRectangles; + const int fMaxAnalyticFPs; SkIRect fScissor; bool fHasScissor; SkRect fAAClipRect; uint32_t fAAClipRectGenID; // GenID the mask will have if includes the AA clip rect. GrWindowRectangles fWindowRects; + SkSTArray<4, std::unique_ptr<GrFragmentProcessor>> fAnalyticFPs; ElementList fMaskElements; uint32_t fMaskGenID; bool fMaskRequiresAA; |