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

Unified Diff: src/gpu/GrAppliedClip.h

Issue 2251573002: Implement difference clip rects with window rectangles (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: return type Created 4 years, 4 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 | « include/gpu/GrClip.h ('k') | src/gpu/GrCaps.cpp » ('j') | src/gpu/GrCaps.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrAppliedClip.h
diff --git a/src/gpu/GrAppliedClip.h b/src/gpu/GrAppliedClip.h
new file mode 100644
index 0000000000000000000000000000000000000000..c02e9d01c268ea7b162c66cc30b47f88ad59fac3
--- /dev/null
+++ b/src/gpu/GrAppliedClip.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrAppliedClip_DEFINED
+#define GrAppliedClip_DEFINED
+
+#include "GrTypesPriv.h"
+#include "GrWindowRectangles.h"
+
+class GrFragmentProcessor;
+
+/**
+ * Produced by GrClip. It provides a set of modifications to the drawing state that are used to
+ * create the final GrPipeline for a GrBatch.
+ */
+class GrAppliedClip : public SkNoncopyable {
+public:
+ GrAppliedClip(const SkRect& drawBounds)
+ : fHasStencilClip(false)
+ , fClippedDrawBounds(drawBounds) {
+ }
+
+ const GrScissorState& scissorState() const { return fScissorState; }
+ const GrWindowRectangles& windowRects() const { return fWindowRects; }
+ GrFragmentProcessor* clipCoverageFragmentProcessor() const { return fClipCoverageFP.get(); }
+ bool hasStencilClip() const { return fHasStencilClip; }
+
+ /**
+ * Intersects the applied clip with the provided rect. Returns false if the draw became empty.
+ */
+ bool addScissor(const SkIRect& irect) {
+ return fScissorState.intersect(irect) && fClippedDrawBounds.intersect(SkRect::Make(irect));
+ }
+
+ /**
+ * Adds an exclusive window rectangle to the clip. It is not currently supported to switch the
+ * windows to inclusive mode.
+ */
+ void addWindowRectangle(const SkIRect& window) {
+ fWindowRects.addWindow(window);
+ }
+
+ void addCoverageFP(sk_sp<GrFragmentProcessor> fp) {
+ SkASSERT(!fClipCoverageFP);
+ fClipCoverageFP = fp;
+ }
+
+ void addStencilClip() {
+ SkASSERT(!fHasStencilClip);
+ fHasStencilClip = true;
+ }
+
+ /**
+ * Returns the device bounds of the draw after clip has been applied. TODO: Ideally this would
+ * consider the combined effect of all clipping techniques in play (scissor, stencil, fp, etc.).
+ */
+ const SkRect& clippedDrawBounds() const { return fClippedDrawBounds; }
+
+private:
+ GrScissorState fScissorState;
+ GrWindowRectangles fWindowRects;
+ sk_sp<GrFragmentProcessor> fClipCoverageFP;
+ bool fHasStencilClip;
+ SkRect fClippedDrawBounds;
+ typedef SkNoncopyable INHERITED;
+};
+
+#endif
« no previous file with comments | « include/gpu/GrClip.h ('k') | src/gpu/GrCaps.cpp » ('j') | src/gpu/GrCaps.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698