Index: src/gpu/GrClipStackClip.h |
diff --git a/src/gpu/GrClipStackClip.h b/src/gpu/GrClipStackClip.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..9ff6c581ffc97f2f763ec757ff74525a47367b43 |
--- /dev/null |
+++ b/src/gpu/GrClipStackClip.h |
@@ -0,0 +1,68 @@ |
+/* |
+ * 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 GrClipStackClip_DEFINED |
+#define GrClipStackClip_DEFINED |
+ |
+#include "GrClip.h" |
+#include "GrReducedClip.h" |
+#include "GrTypesPriv.h" |
+#include "SkClipStack.h" |
+ |
+class GrDrawContext; |
+class GrPathRenderer; |
+ |
+/** |
+ * 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) |
+ : INHERITED(!stack || stack->isWideOpen()) { |
+ this->reset(stack, origin); |
+ } |
+ |
+ void reset(const SkClipStack* stack = nullptr, const SkIPoint* origin = nullptr) { |
+ fIsWideOpen = !stack || stack->isWideOpen(); |
+ 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: |
+ static bool UseSWOnlyPath(GrContext* context, |
+ const GrPipelineBuilder& pipelineBuilder, |
+ const GrDrawContext* drawContext, |
+ const SkVector& clipToMaskOffset, |
+ const GrReducedClip::ElementList& elements); |
+ static bool PathNeedsSWRenderer(GrContext* context, bool hasUserStencilSettings, |
+ const GrDrawContext*, const SkMatrix& viewMatrix, |
+ const SkClipStack::Element* element, GrPathRenderer** prOut, |
+ bool needsStencil); |
+ static bool CreateStencilClipMask(GrContext* context, |
+ GrDrawContext* drawContext, |
+ int32_t elementsGenID, |
+ GrReducedClip::InitialState initialState, |
+ const GrReducedClip::ElementList& elements, |
+ const SkIRect& clipSpaceIBounds, |
+ const SkIPoint& clipSpaceToStencilOffset); |
+ |
+ SkIPoint fOrigin; |
+ SkAutoTUnref<const SkClipStack> fStack; |
+ typedef GrClip INHERITED; |
+}; |
+ |
+#endif |