Fix clipping when all analytic FP creations can be skipped
BUG=skia:
Review URL: https://codereview.chromium.org/1400343004
diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp
index 882f607..4b464bb 100644
--- a/src/gpu/GrClipMaskManager.cpp
+++ b/src/gpu/GrClipMaskManager.cpp
@@ -108,10 +108,10 @@
return false;
}
-const GrFragmentProcessor* GrClipMaskManager::getAnalyticClipProcessor(
- const GrReducedClip::ElementList& elements,
- const SkVector& clipToRTOffset,
- const SkRect* drawBounds) {
+bool GrClipMaskManager::getAnalyticClipProcessor(const GrReducedClip::ElementList& elements,
+ SkVector& clipToRTOffset,
+ const SkRect* drawBounds,
+ const GrFragmentProcessor** resultFP) {
SkRect boundsInClipSpace;
if (drawBounds) {
boundsInClipSpace = *drawBounds;
@@ -190,14 +190,14 @@
iter.next();
}
- const GrFragmentProcessor* resultFP = nullptr;
- if (!failed) {
- resultFP = GrFragmentProcessor::RunInSeries(fps, fpCnt);
+ *resultFP = nullptr;
+ if (!failed && fpCnt) {
+ *resultFP = GrFragmentProcessor::RunInSeries(fps, fpCnt);
}
for (int i = 0; i < fpCnt; ++i) {
fps[i]->unref();
}
- return resultFP;
+ return !failed;
}
////////////////////////////////////////////////////////////////////////////////
@@ -283,7 +283,7 @@
const GrFragmentProcessor* clipFP = nullptr;
if (elements.isEmpty() ||
(requiresAA && !disallowAnalyticAA &&
- SkToBool(clipFP = this->getAnalyticClipProcessor(elements, clipToRTOffset, devBounds)))) {
+ this->getAnalyticClipProcessor(elements, clipToRTOffset, devBounds, &clipFP))) {
SkIRect scissorSpaceIBounds(clipSpaceIBounds);
scissorSpaceIBounds.offset(-clip.origin());
if (nullptr == devBounds ||
diff --git a/src/gpu/GrClipMaskManager.h b/src/gpu/GrClipMaskManager.h
index 005830c..90352f4 100644
--- a/src/gpu/GrClipMaskManager.h
+++ b/src/gpu/GrClipMaskManager.h
@@ -87,10 +87,13 @@
};
// Attempts to install a series of coverage effects to implement the clip. Return indicates
- // whether the element list was successfully converted to effects.
- const GrFragmentProcessor* getAnalyticClipProcessor(const GrReducedClip::ElementList&,
- const SkVector& clipOffset,
- const SkRect* devBounds);
+ // whether the element list was successfully converted to processors. *fp may be nullptr even
+ // when the function succeeds because all the elements were ignored. TODO: Make clip reduction
+ // bounds-aware and stop checking bounds in this function.
+ bool getAnalyticClipProcessor(const GrReducedClip::ElementList&,
+ SkVector& clipOffset,
+ const SkRect* devBounds,
+ const GrFragmentProcessor** fp);
// Draws the clip into the stencil buffer
bool createStencilClipMask(GrRenderTarget*,