Revert "Fold analytic clip FPs into GrReducedClip"
This reverts commit 4355b26b359d5f2597a10012e7eb11fb3a1f025b.
Reason for revert: Most likely CL for layout test failures on Chrome roll: https://bugs.chromium.org/p/chromium/issues/detail?id=785931
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,robertphillips@google.com,csmartdalton@google.com
Change-Id: I86ff05196eaaeca4fb63836c9b449bbea76fe80b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:7190
Reviewed-on: https://skia-review.googlesource.com/72480
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/src/gpu/GrReducedClip.cpp b/src/gpu/GrReducedClip.cpp
index 992411a..d37c83f 100644
--- a/src/gpu/GrReducedClip.cpp
+++ b/src/gpu/GrReducedClip.cpp
@@ -21,8 +21,6 @@
#include "GrStyle.h"
#include "GrUserStencilSettings.h"
#include "SkClipOpPriv.h"
-#include "effects/GrConvexPolyEffect.h"
-#include "effects/GrRRectEffect.h"
/**
* There are plenty of optimizations that could be added here. Maybe flips could be folded into
@@ -32,11 +30,8 @@
* take a rect in case the caller knows a bound on what is to be drawn through this clip.
*/
GrReducedClip::GrReducedClip(const SkClipStack& stack, const SkRect& queryBounds,
- int maxWindowRectangles, int maxAnalyticFPs)
- : fMaxWindowRectangles(maxWindowRectangles)
- , fMaxAnalyticFPs(maxAnalyticFPs) {
+ int maxWindowRectangles) {
SkASSERT(!queryBounds.isEmpty());
- SkASSERT(fMaxWindowRectangles <= GrWindowRectangles::kMaxWindows);
fHasScissor = false;
fAAClipRectGenID = SK_InvalidGenID;
@@ -102,13 +97,12 @@
}
fHasScissor = true;
- // Now that we have determined the bounds to use and filtered out the trivial cases, call
- // the helper that actually walks the stack.
- this->walkStack(stack, tighterQuery);
+ // Now that we have determined the bounds to use and filtered out the trivial cases, call the
+ // helper that actually walks the stack.
+ this->walkStack(stack, tighterQuery, maxWindowRectangles);
}
- if (SK_InvalidGenID != fAAClipRectGenID && // Is there an AA clip rect?
- ClipResult::kNotClipped == this->addAnalyticFP(fAAClipRect, Invert::kNo, true)) {
+ if (SK_InvalidGenID != fAAClipRectGenID) { // Is there an AA clip rect?
if (fMaskElements.isEmpty()) {
// Use a replace since it is faster than intersect.
fMaskElements.addToHead(fAAClipRect, SkMatrix::I(), kReplace_SkClipOp, true /*doAA*/);
@@ -118,10 +112,12 @@
}
fMaskRequiresAA = true;
fMaskGenID = fAAClipRectGenID;
+ fAAClipRectGenID = SK_InvalidGenID;
}
}
-void GrReducedClip::walkStack(const SkClipStack& stack, const SkRect& queryBounds) {
+void GrReducedClip::walkStack(const SkClipStack& stack, const SkRect& queryBounds,
+ int maxWindowRectangles) {
// walk backwards until we get to:
// a) the beginning
// b) an operation that is known to make the bounds all inside/outside
@@ -184,7 +180,7 @@
} else if (GrClip::IsOutsideClip(element->getBounds(), queryBounds)) {
skippable = true;
} else if (!embiggens) {
- ClipResult result = this->clipOutsideElement(element);
+ ClipResult result = this->clipOutsideElement(element, maxWindowRectangles);
if (ClipResult::kMadeEmpty == result) {
return;
}
@@ -484,43 +480,34 @@
return ClipResult::kClipped;
case Element::DeviceSpaceType::kRRect:
- return this->addAnalyticFP(element->getDeviceSpaceRRect(), Invert::kNo,
- element->isAA());
-
case Element::DeviceSpaceType::kPath:
- return this->addAnalyticFP(element->getDeviceSpacePath(), Invert::kNo, element->isAA());
+ return ClipResult::kNotClipped;
}
SK_ABORT("Unexpected DeviceSpaceType");
return ClipResult::kNotClipped;
}
-GrReducedClip::ClipResult GrReducedClip::clipOutsideElement(const Element* element) {
+GrReducedClip::ClipResult GrReducedClip::clipOutsideElement(const Element* element,
+ int maxWindowRectangles) {
+ if (fWindowRects.count() >= maxWindowRectangles) {
+ return ClipResult::kNotClipped;
+ }
+
switch (element->getDeviceSpaceType()) {
case Element::DeviceSpaceType::kEmpty:
return ClipResult::kMadeEmpty;
case Element::DeviceSpaceType::kRect:
- if (fWindowRects.count() < fMaxWindowRectangles) {
- // Clip out the inside of every rect. We won't be able to entirely skip the AA ones,
- // but it saves processing time.
- this->addWindowRectangle(element->getDeviceSpaceRect(), element->isAA());
- if (!element->isAA()) {
- return ClipResult::kClipped;
- }
- }
- return this->addAnalyticFP(element->getDeviceSpaceRect(), Invert::kYes,
- element->isAA());
+ // Clip out the inside of every rect. We won't be able to entirely skip the AA ones, but
+ // it saves processing time.
+ this->addWindowRectangle(element->getDeviceSpaceRect(), element->isAA());
+ return !element->isAA() ? ClipResult::kClipped : ClipResult::kNotClipped;
case Element::DeviceSpaceType::kRRect: {
- const SkRRect& clipRRect = element->getDeviceSpaceRRect();
- ClipResult clipResult = this->addAnalyticFP(clipRRect, Invert::kYes, element->isAA());
- if (fWindowRects.count() >= fMaxWindowRectangles) {
- return clipResult;
- }
-
// Clip out the interiors of round rects with two window rectangles in the shape of a
- // "plus". This doesn't let us skip the clip element, but still saves processing time.
+ // plus. It doesn't allow us to skip the clip element, but still saves processing time.
+ const SkRRect& clipRRect = element->getDeviceSpaceRRect();
SkVector insetTL = clipRRect.radii(SkRRect::kUpperLeft_Corner);
SkVector insetBR = clipRRect.radii(SkRRect::kLowerRight_Corner);
if (SkRRect::kComplex_Type == clipRRect.getType()) {
@@ -534,25 +521,24 @@
const SkRect& bounds = clipRRect.getBounds();
if (insetTL.x() + insetBR.x() >= bounds.width() ||
insetTL.y() + insetBR.y() >= bounds.height()) {
- return clipResult; // The interior "plus" is empty.
+ return ClipResult::kNotClipped; // The interior "plus" is empty.
}
SkRect horzRect = SkRect::MakeLTRB(bounds.left(), bounds.top() + insetTL.y(),
bounds.right(), bounds.bottom() - insetBR.y());
this->addWindowRectangle(horzRect, element->isAA());
-
- if (fWindowRects.count() < fMaxWindowRectangles) {
- SkRect vertRect = SkRect::MakeLTRB(bounds.left() + insetTL.x(), bounds.top(),
- bounds.right() - insetBR.x(), bounds.bottom());
- this->addWindowRectangle(vertRect, element->isAA());
+ if (fWindowRects.count() >= maxWindowRectangles) {
+ return ClipResult::kNotClipped;
}
- return clipResult;
+ SkRect vertRect = SkRect::MakeLTRB(bounds.left() + insetTL.x(), bounds.top(),
+ bounds.right() - insetBR.x(), bounds.bottom());
+ this->addWindowRectangle(vertRect, element->isAA());
+ return ClipResult::kNotClipped;
}
case Element::DeviceSpaceType::kPath:
- return this->addAnalyticFP(element->getDeviceSpacePath(), Invert::kYes,
- element->isAA());
+ return ClipResult::kNotClipped;
}
SK_ABORT("Unexpected DeviceSpaceType");
@@ -571,43 +557,6 @@
}
}
-template<typename T>
-inline GrReducedClip::ClipResult GrReducedClip::addAnalyticFP(const T& deviceSpaceShape,
- Invert invert, bool aa) {
- if (fAnalyticFPs.count() >= fMaxAnalyticFPs) {
- return ClipResult::kNotClipped;
- }
-
- GrClipEdgeType edgeType;
- if (Invert::kNo == invert) {
- edgeType = aa ? GrClipEdgeType::kFillAA : GrClipEdgeType::kFillBW;
- } else {
- edgeType = aa ? GrClipEdgeType::kInverseFillAA : GrClipEdgeType::kInverseFillBW;
- }
-
- if (auto fp = make_analytic_clip_fp(edgeType, deviceSpaceShape)) {
- fAnalyticFPs.push_back(std::move(fp));
- return ClipResult::kClipped;
- }
-
- return ClipResult::kNotClipped;
-}
-
-std::unique_ptr<GrFragmentProcessor> make_analytic_clip_fp(GrClipEdgeType edgeType,
- const SkRect& deviceSpaceRect) {
- return GrConvexPolyEffect::Make(edgeType, deviceSpaceRect);
-}
-
-std::unique_ptr<GrFragmentProcessor> make_analytic_clip_fp(GrClipEdgeType edgeType,
- const SkRRect& deviceSpaceRRect) {
- return GrRRectEffect::Make(edgeType, deviceSpaceRRect);
-}
-
-std::unique_ptr<GrFragmentProcessor> make_analytic_clip_fp(GrClipEdgeType edgeType,
- const SkPath& deviceSpacePath) {
- return GrConvexPolyEffect::Make(edgeType, deviceSpacePath);
-}
-
void GrReducedClip::makeEmpty() {
fHasScissor = false;
fAAClipRectGenID = SK_InvalidGenID;