aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrStencilClip.h
diff options
context:
space:
mode:
authorGravatar Chris Dalton <csmartdalton@google.com>2017-11-06 13:48:04 -0700
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-11-07 17:28:34 +0000
commit4c92d4aa3ed653afdff9996b90a1139ed1dc9420 (patch)
tree33ab60f731462de4747188e0307ba8f76d4ec19a /src/gpu/GrStencilClip.h
parentfbe0793526526ae47f02c7a011e29c401ef191f4 (diff)
Don't use analytic clip FPs when drawing to stencil
It doesn't make sense to multiply by coverage when drawing to stencil. This could theoretically work with FPs that discard and/or modify the sample mask, but for the time being an analytic FP means one that calculates a coverage value. Bug: skia:7190 Change-Id: Ic40cf6c19c377cba80bad458993582f5cc07022a Reviewed-on: https://skia-review.googlesource.com/67423 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
Diffstat (limited to 'src/gpu/GrStencilClip.h')
-rw-r--r--src/gpu/GrStencilClip.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/gpu/GrStencilClip.h b/src/gpu/GrStencilClip.h
new file mode 100644
index 0000000000..2bbf3b44de
--- /dev/null
+++ b/src/gpu/GrStencilClip.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2017 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrStencilClip_DEFINED
+#define GrStencilClip_DEFINED
+
+#include "GrAppliedClip.h"
+#include "GrFixedClip.h"
+
+/**
+ * Implements GrHardClip with the currently-existing stencil buffer contents and GrFixedClip.
+ */
+class GrStencilClip final : public GrHardClip {
+public:
+ GrStencilClip(uint32_t stencilStackID = SK_InvalidGenID) : fStencilStackID(stencilStackID) {}
+
+ explicit GrStencilClip(const SkIRect& scissorRect, uint32_t stencilStackID = SK_InvalidGenID)
+ : fFixedClip(scissorRect)
+ , fStencilStackID(stencilStackID) {
+ }
+
+ const GrFixedClip& fixedClip() const { return fFixedClip; }
+ GrFixedClip& fixedClip() { return fFixedClip; }
+
+ bool stencilStackID() const { return fStencilStackID; }
+ bool hasStencilClip() const { return SK_InvalidGenID != fStencilStackID; }
+ void setStencilClip(uint32_t stencilStackID) { fStencilStackID = stencilStackID; }
+
+ bool quickContains(const SkRect& rect) const override {
+ return !this->hasStencilClip() && fFixedClip.quickContains(rect);
+ }
+ void getConservativeBounds(int width, int height, SkIRect* bounds, bool* iior) const override {
+ fFixedClip.getConservativeBounds(width, height, bounds, iior);
+ }
+ bool isRRect(const SkRect& rtBounds, SkRRect* rr, GrAA* aa) const override {
+ return !this->hasStencilClip() && fFixedClip.isRRect(rtBounds, rr, aa);
+ }
+ bool apply(int rtWidth, int rtHeight, GrAppliedHardClip* out, SkRect* bounds) const override {
+ if (!fFixedClip.apply(rtWidth, rtHeight, out, bounds)) {
+ return false;
+ }
+ if (this->hasStencilClip()) {
+ out->addStencilClip(fStencilStackID);
+ }
+ return true;
+ }
+
+private:
+ GrFixedClip fFixedClip;
+ uint32_t fStencilStackID;
+
+ typedef GrClip INHERITED;
+};
+
+#endif