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

Unified Diff: src/gpu/GrClipStackClip.cpp

Issue 2289363005: Improve usage of window rectangles (Closed) Base URL: https://skia.googlesource.com/skia.git@upload_drawsinreducedclip
Patch Set: Improve usage of window rectangles 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 4572db5f321303312244b4ef3ec1f85a931cb3cb..d6ad1d90f856c24ce79e7ac01db5a882428b2e77 100644
--- a/src/gpu/GrClipStackClip.cpp
+++ b/src/gpu/GrClipStackClip.cpp
@@ -287,11 +287,14 @@ bool GrClipStackClip::apply(GrContext* context, GrDrawContext* drawContext, bool
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);
+ const GrReducedClip reducedClip(*fStack, clipSpaceDevBounds,
+ rt->renderTargetPriv().maxWindowRectangles());
if (reducedClip.hasIBounds() &&
!GrClip::IsInsideClip(reducedClip.ibounds(), clipSpaceDevBounds)) {
@@ -300,29 +303,17 @@ bool GrClipStackClip::apply(GrContext* context, GrDrawContext* drawContext, bool
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
// diff RR
@@ -377,12 +368,15 @@ bool GrClipStackClip::apply(GrContext* context, GrDrawContext* drawContext, bool
// 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(drawContext->accessRenderTarget());
+ context->resourceProvider()->attachStencilAttachment(rt);
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