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

Unified Diff: src/gpu/GrClipMaskManager.cpp

Issue 1471083002: Add debug option to clip each GrBatch to its device bounds (Closed) Base URL: https://skia.googlesource.com/skia.git@clipbounds
Patch Set: update Created 5 years, 1 month 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/GrClipMaskManager.h ('k') | src/gpu/GrContext.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrClipMaskManager.cpp
diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp
index fa9d189e8c384ac9d6207b68f8f53470e10b151d..303aeccc8a5ae8527c3a2ed4d04d203d87d96bf1 100644
--- a/src/gpu/GrClipMaskManager.cpp
+++ b/src/gpu/GrClipMaskManager.cpp
@@ -126,9 +126,10 @@ GrPathRenderer* GrClipMaskManager::GetPathRenderer(GrContext* context,
return pr;
}
-GrClipMaskManager::GrClipMaskManager(GrDrawTarget* drawTarget)
+GrClipMaskManager::GrClipMaskManager(GrDrawTarget* drawTarget, bool debugClipBatchToBounds)
: fDrawTarget(drawTarget)
- , fClipMode(kIgnoreClip_StencilClipMode) {
+ , fClipMode(kIgnoreClip_StencilClipMode)
+ , fDebugClipBatchToBounds(debugClipBatchToBounds) {
}
GrContext* GrClipMaskManager::getContext() {
@@ -272,6 +273,38 @@ bool GrClipMaskManager::getAnalyticClipProcessor(const GrReducedClip::ElementLis
return !failed;
}
+static void add_rect_to_clip(const GrClip& clip, const SkRect& devRect, GrClip* out) {
+ switch (clip.clipType()) {
+ case GrClip::kClipStack_ClipType: {
+ SkClipStack* stack = new SkClipStack;
+ *stack = *clip.clipStack();
+ // The stack is actually in clip space not device space.
+ SkRect clipRect = devRect;
+ SkPoint origin = { SkIntToScalar(clip.origin().fX), SkIntToScalar(clip.origin().fY) };
+ clipRect.offset(origin);
+ SkIRect iclipRect;
+ clipRect.roundOut(&iclipRect);
+ clipRect = SkRect::Make(iclipRect);
+ stack->clipDevRect(clipRect, SkRegion::kIntersect_Op, false);
+ out->setClipStack(stack, &clip.origin());
+ break;
+ }
+ case GrClip::kWideOpen_ClipType:
+ *out = GrClip(devRect);
+ break;
+ case GrClip::kIRect_ClipType: {
+ SkIRect intersect;
+ devRect.roundOut(&intersect);
+ if (intersect.intersect(clip.irect())) {
+ *out = GrClip(intersect);
+ } else {
+ *out = clip;
+ }
+ break;
+ }
+ }
+}
+
////////////////////////////////////////////////////////////////////////////////
// sort out what kind of clip mask needs to be created: alpha, stencil,
// scissor, or entirely software
@@ -294,7 +327,13 @@ bool GrClipMaskManager::setupClipping(const GrPipelineBuilder& pipelineBuilder,
SkASSERT(rt);
SkIRect clipSpaceRTIBounds = SkIRect::MakeWH(rt->width(), rt->height());
- const GrClip& clip = pipelineBuilder.clip();
+ GrClip devBoundsClip;
+ bool doDevBoundsClip = fDebugClipBatchToBounds && devBounds;
+ if (doDevBoundsClip) {
+ add_rect_to_clip(pipelineBuilder.clip(), *devBounds, &devBoundsClip);
+ }
+ const GrClip& clip = doDevBoundsClip ? devBoundsClip : pipelineBuilder.clip();
+
if (clip.isWideOpen(clipSpaceRTIBounds)) {
this->setPipelineBuilderStencil(pipelineBuilder, ars);
return true;
« no previous file with comments | « src/gpu/GrClipMaskManager.h ('k') | src/gpu/GrContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698