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

Unified Diff: src/gpu/GrProcOptInfo.h

Issue 719203002: Add GrProcOptInfo class to track various output information for color and coverage stages. (Closed) Base URL: https://skia.googlesource.com/skia.git@moveIO
Patch Set: initialize values Created 6 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/GrPaint.cpp ('k') | src/gpu/GrProcOptInfo.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrProcOptInfo.h
diff --git a/src/gpu/GrProcOptInfo.h b/src/gpu/GrProcOptInfo.h
new file mode 100644
index 0000000000000000000000000000000000000000..5252e8535475b0e042eabeeab32c02783a280ae1
--- /dev/null
+++ b/src/gpu/GrProcOptInfo.h
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrProcOptInfo_DEFINED
+#define GrProcOptInfo_DEFINED
+
+#include "GrColor.h"
+#include "GrInvariantOutput.h"
+
+class GrFragmentStage;
+class GrGeometryProcessor;
+
+/**
+ * GrProcOptInfo gathers invariant data from a set of processor stages.It is used to recognize
+ * optimizations related to eliminating stages and vertex attributes that aren't necessary for a
+ * draw.
+ */
+class GrProcOptInfo {
+public:
+ GrProcOptInfo()
+ : fInOut(0, static_cast<GrColorComponentFlags>(0), false)
+ , fFirstEffectStageIndex(0)
+ , fInputColorIsUsed(true)
+ , fInputColor(0)
+ , fRemoveVertexAttrib(false)
+ , fReadsDst(false) {}
+
+ void calcWithInitialValues(const GrFragmentStage*, int stageCount, GrColor startColor,
+ GrColorComponentFlags flags, bool areCoverageStages,
+ const GrGeometryProcessor* gp = NULL);
+
+ bool isSolidWhite() const { return fInOut.isSolidWhite(); }
+ bool isOpaque() const { return fInOut.isOpaque(); }
+
+ GrColor color() const { return fInOut.color(); }
+ uint8_t validFlags() const { return fInOut.validFlags(); }
+
+ /**
+ * Returns the index of the first effective color stage. If an intermediate stage doesn't read
+ * its input or has a known output, then we can ignore all earlier stages since they will not
+ * affect the final output. Thus the first effective stage index is the index to the first stage
+ * that will have an effect on the final output.
+ *
+ * If stages before the firstEffectiveStageIndex are removed, corresponding values from
+ * inputColorIsUsed(), inputColorToEffectiveStage(), removeVertexAttribs(), and readsDst() must
+ * be used when setting up the draw to ensure correct drawing.
+ */
+ int firstEffectiveStageIndex() const { return fFirstEffectStageIndex; }
+
+ /**
+ * True if the first effective stage reads its input, false otherwise.
+ */
+ bool inputColorIsUsed() const { return fInputColorIsUsed; }
+
+ /**
+ * If input color is used and per-vertex colors are not used, this is the input color to the
+ * first effective stage.
+ */
+ GrColor inputColorToEffectiveStage() const { return fInputColor; }
+
+ /**
+ * Given the set of optimizations determined by GrProcOptInfo, should the caller remove the
+ * color/coverage vertex attribute that was input to the first stage.
+ */
+ bool removeVertexAttrib() const { return fRemoveVertexAttrib; }
+
+ /**
+ * Returns true if any of the stages preserved by GrProcOptInfo read the dst color.
+ */
+ bool readsDst() const { return fReadsDst; }
+
+private:
+ GrInvariantOutput fInOut;
+ int fFirstEffectStageIndex;
+ bool fInputColorIsUsed;
+ GrColor fInputColor;
+ bool fRemoveVertexAttrib;
+ bool fReadsDst;
+};
+
+#endif
« no previous file with comments | « src/gpu/GrPaint.cpp ('k') | src/gpu/GrProcOptInfo.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698