diff options
author | Chris Dalton <csmartdalton@google.com> | 2017-11-15 13:14:01 -0700 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-11-16 19:32:55 +0000 |
commit | 584a79a1d5396cccd159ec6b8660be8fe128334f (patch) | |
tree | 7b1370c745daf1138e30d37d33c66402207324dd /src/gpu/GrReducedClip.h | |
parent | 47c8ed3c064f5176750f370b88119735163c0e8a (diff) |
Reland "Fold analytic clip FPs into GrReducedClip"
This is a reland of 4355b26b359d5f2597a10012e7eb11fb3a1f025b
Original change's description:
> Fold analytic clip FPs into GrReducedClip
>
> Perf result on Pixel phone (sorted by impact):
>
> GEOMEAN 7.44 -> 6.92 ms [ 93%]
>
> keymobi_cnn_com.skp 3.55 -> 3.59 ms [101%]
> keymobi_theverge_com.skp 4.08 -> 4.13 ms [101%]
> desk_skbug6850autoscroll.skp 1.21 -> 1.22 ms [101%]
> ...
> top25desk_weather_com.skp 14.2 -> 11.5 ms [ 81%]
> keymobi_androidpolice_com_2012_.skp 3.84 -> 2.95 ms [ 77%]
> keymobi_shop_mobileweb_ebay_com.skp 2.94 -> 2.26 ms [ 77%]
> keymobi_boingboing_net.skp 3.08 -> 2.24 ms [ 73%]
> desk_jsfiddlebigcar.skp 1.90 -> 1.25 ms [ 66%]
> keymobi_m_youtube_com_watch_v_9.skp 13.5 -> 8.84 ms [ 65%]
> keymobi_sfgate_com_.skp 8.55 -> 5.55 ms [ 65%]
> keymobi_blogger.skp 4.01 -> 2.60 ms [ 65%]
>
> 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: Ia93f68b2f971ea66b3ab19dc73557ea602932a92
> Reviewed-on: https://skia-review.googlesource.com/67424
> Commit-Queue: Chris Dalton <csmartdalton@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>
TBR=bsalomon@google.com
Bug: skia:7190
Change-Id: I92f1ed21b6292feb3209fcbd1725487784d420da
Reviewed-on: https://skia-review.googlesource.com/72562
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Diffstat (limited to 'src/gpu/GrReducedClip.h')
-rw-r--r-- | src/gpu/GrReducedClip.h | 46 |
1 files changed, 33 insertions, 13 deletions
diff --git a/src/gpu/GrReducedClip.h b/src/gpu/GrReducedClip.h index 0746439ba3..3ad2ab9971 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, @@ -91,24 +100,35 @@ private: // Clips the the given element's interior out of the final clip. // NOTE: do not call for elements followed by ops that can grow the clip. - ClipResult clipInsideElement(const Element* element); + ClipResult clipInsideElement(const Element*); // 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*); 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(); - SkIRect fScissor; - bool fHasScissor; - SkRect fAAClipRect; - uint32_t fAAClipRectGenID; // GenID the mask will have if includes the AA clip rect. - GrWindowRectangles fWindowRects; - ElementList fMaskElements; - uint32_t fMaskGenID; - bool fMaskRequiresAA; - InitialState fInitialState; + 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; + InitialState fInitialState; }; #endif |