Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Unified Diff: src/gpu/GrClipStackClip.cpp

Issue 2312173002: Revert of Improve usage of window rectangles (Closed) Base URL: https://skia.googlesource.com/skia.git@upload_drawsinreducedclip
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrAppliedClip.h ('k') | src/gpu/GrDrawContext.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrClipStackClip.cpp
diff --git a/src/gpu/GrClipStackClip.cpp b/src/gpu/GrClipStackClip.cpp
index ff5c860f68325c2808dbb876fce80fc5b372656b..003b4a5d439bb63782dd1370ea6bc7a0f94b4172 100644
--- a/src/gpu/GrClipStackClip.cpp
+++ b/src/gpu/GrClipStackClip.cpp
@@ -287,14 +287,11 @@
return false;
}
- GrRenderTarget* rt = drawContext->accessRenderTarget();
-
const SkScalar clipX = SkIntToScalar(fOrigin.x()),
clipY = SkIntToScalar(fOrigin.y());
SkRect clipSpaceDevBounds = devBounds.makeOffset(clipX, clipY);
- const GrReducedClip reducedClip(*fStack, clipSpaceDevBounds,
- rt->renderTargetPriv().maxWindowRectangles());
+ const GrReducedClip reducedClip(*fStack, clipSpaceDevBounds);
if (reducedClip.hasIBounds() &&
!GrClip::IsInsideClip(reducedClip.ibounds(), clipSpaceDevBounds)) {
@@ -303,16 +300,28 @@
out->addScissor(scissorSpaceIBounds);
}
- if (!reducedClip.windowRectangles().empty()) {
- out->addWindowRectangles(reducedClip.windowRectangles(), fOrigin,
- GrWindowRectsState::Mode::kExclusive);
- }
-
if (reducedClip.elements().isEmpty()) {
return InitialState::kAllIn == reducedClip.initialState();
}
SkASSERT(reducedClip.hasIBounds());
+
+ // Attempt to implement difference clip rects with window rectangles. This will eventually
+ // become more comprehensive.
+ if (drawContext->accessRenderTarget()->renderTargetPriv().supportsWindowRectangles() &&
+ 1 == reducedClip.elements().count() && !reducedClip.requiresAA() &&
+ InitialState::kAllIn == reducedClip.initialState()) {
+ const Element* element = reducedClip.elements().head();
+ SkRegion::Op op = element->getOp();
+ if (Element::kRect_Type == element->getType() &&
+ (SkRegion::kDifference_Op == op || SkRegion::kXOR_Op == op)) {
+ SkIRect window;
+ element->getRect().round(&window);
+ window.offset(-fOrigin);
+ out->addWindowRectangle(window);
+ return true;
+ }
+ }
// An element count of 4 was chosen because of the common pattern in Blink of:
// isect RR
@@ -368,15 +377,12 @@
// use the stencil clip if we can't represent the clip as a rectangle.
// TODO: these need to be swapped over to using a StencilAttachmentProxy
GrStencilAttachment* stencilAttachment =
- context->resourceProvider()->attachStencilAttachment(rt);
+ context->resourceProvider()->attachStencilAttachment(drawContext->accessRenderTarget());
if (nullptr == stencilAttachment) {
SkDebugf("WARNING: failed to attach stencil buffer for clip mask. Clip will be ignored.\n");
return true;
}
- // This relies on the property that a reduced sub-rect of the last clip will contain all the
- // relevant window rectangles that were in the last clip. This subtle requirement will go away
- // after clipping is overhauled.
if (stencilAttachment->mustRenderClip(reducedClip.elementsGenID(), reducedClip.ibounds(),
fOrigin)) {
reducedClip.drawStencilClipMask(context, drawContext, fOrigin);
« no previous file with comments | « src/gpu/GrAppliedClip.h ('k') | src/gpu/GrDrawContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698