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

Unified Diff: include/gpu/GrClip.h

Issue 2138083002: skip call to clip::apply when clip is wide open Base URL: https://chromium.googlesource.com/skia.git@llist
Patch Set: rm gcmm Created 4 years, 5 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 | « gyp/gpu.gypi ('k') | include/gpu/GrContext.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/gpu/GrClip.h
diff --git a/include/gpu/GrClip.h b/include/gpu/GrClip.h
index e58528114e873f2caa78f807337cdbb30d46b7e1..e7238841817c7417b05ee62b48c17bd4d3c9cb5a 100644
--- a/include/gpu/GrClip.h
+++ b/include/gpu/GrClip.h
@@ -8,11 +8,9 @@
#ifndef GrClip_DEFINED
#define GrClip_DEFINED
+#include "GrTypes.h"
#include "GrFragmentProcessor.h"
-#include "GrTypesPriv.h"
-#include "SkClipStack.h"
-class GrDrawContext;
class GrPipelineBuilder;
/**
@@ -109,18 +107,27 @@ public:
const SkRect* devBounds, GrAppliedClip*) const = 0;
virtual ~GrClip() {}
+
+ bool isWideOpen() const { return fIsWideOpen; }
+
+protected:
+ GrClip(bool isWideOpen) : fIsWideOpen(isWideOpen) {}
+ bool fIsWideOpen;
};
/**
* Specialized implementation for no clip.
*/
class GrNoClip final : public GrClip {
+public:
+ GrNoClip() : INHERITED(true) {}
private:
bool quickContains(const SkRect&) const final { return true; }
void getConservativeBounds(int width, int height, SkIRect* devResult,
bool* isIntersectionOfRects) const final;
bool apply(GrContext*, const GrPipelineBuilder&, GrDrawContext*,
const SkRect*, GrAppliedClip*) const final { return true; }
+ typedef GrClip INHERITED;
};
/**
@@ -129,19 +136,25 @@ private:
*/
class GrFixedClip final : public GrClip {
public:
- GrFixedClip() : fDeviceBounds(SkRect::MakeLargest()), fHasStencilClip(false) {}
- GrFixedClip(const SkIRect& scissorRect)
- : fScissorState(scissorRect)
- , fDeviceBounds(SkRect::Make(scissorRect))
- , fHasStencilClip(false) {}
+ GrFixedClip() : INHERITED(true) {
+ fDeviceBounds = SkRect::MakeLargest();
+ fHasStencilClip = false;
+ }
+ GrFixedClip(const SkIRect& scissorRect) : INHERITED(false) {
+ fScissorState = scissorRect;
+ fDeviceBounds = SkRect::Make(scissorRect);
+ fHasStencilClip = false;
+ }
void reset() {
+ fIsWideOpen = true;
fScissorState.setDisabled();
fDeviceBounds.setLargest();
fHasStencilClip = false;
}
void reset(const SkIRect& scissorRect) {
+ fIsWideOpen = false;
fScissorState.set(scissorRect);
fDeviceBounds = SkRect::Make(scissorRect);
fHasStencilClip = false;
@@ -152,6 +165,7 @@ public:
* may pass.
*/
void enableStencilClip(const SkRect& stencilBounds) {
+ fIsWideOpen = false;
fHasStencilClip = true;
fDeviceBounds = stencilBounds;
if (fScissorState.enabled()) {
@@ -166,8 +180,10 @@ public:
void disableStencilClip() {
fHasStencilClip = false;
if (fScissorState.enabled()) {
+ fIsWideOpen = false;
fDeviceBounds = SkRect::Make(fScissorState.rect());
} else {
+ fIsWideOpen = true;
fDeviceBounds.setLargest();
}
}
@@ -186,35 +202,7 @@ private:
GrScissorState fScissorState;
SkRect fDeviceBounds;
bool fHasStencilClip;
-};
-
-/**
- * GrClipStackClip can apply a generic SkClipStack to the draw state. It may generate clip masks or
- * write to the stencil buffer during apply().
- */
-class GrClipStackClip final : public GrClip {
-public:
- GrClipStackClip(const SkClipStack* stack = nullptr, const SkIPoint* origin = nullptr) {
- this->reset(stack, origin);
- }
-
- void reset(const SkClipStack* stack = nullptr, const SkIPoint* origin = nullptr) {
- fOrigin = origin ? *origin : SkIPoint::Make(0, 0);
- fStack.reset(SkSafeRef(stack));
- }
-
- const SkIPoint& origin() const { return fOrigin; }
- const SkClipStack* clipStack() const { return fStack; }
-
- bool quickContains(const SkRect&) const final;
- void getConservativeBounds(int width, int height, SkIRect* devResult,
- bool* isIntersectionOfRects) const final;
- bool apply(GrContext*, const GrPipelineBuilder&, GrDrawContext*,
- const SkRect* devBounds, GrAppliedClip*) const final;
-
-private:
- SkIPoint fOrigin;
- SkAutoTUnref<const SkClipStack> fStack;
+ typedef GrClip INHERITED;
};
#endif
« no previous file with comments | « gyp/gpu.gypi ('k') | include/gpu/GrContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698