aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrPipelineAnalysis.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu/GrPipelineAnalysis.cpp')
-rw-r--r--src/gpu/GrPipelineAnalysis.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/gpu/GrPipelineAnalysis.cpp b/src/gpu/GrPipelineAnalysis.cpp
new file mode 100644
index 0000000000..3512c940b0
--- /dev/null
+++ b/src/gpu/GrPipelineAnalysis.cpp
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "GrPipelineAnalysis.h"
+#include "GrGeometryProcessor.h"
+#include "ops/GrDrawOp.h"
+
+void GrColorFragmentProcessorAnalysis::analyzeProcessors(
+ const GrFragmentProcessor* const* processors, int cnt) {
+ for (int i = 0; i < cnt; ++i) {
+ bool knowCurrentOutput = fProcessorsVisitedWithKnownOutput == fTotalProcessorsVisited;
+ if (fUsesLocalCoords && !knowCurrentOutput &&
+ !fAllProcessorsCompatibleWithCoverageAsAlpha && !fIsOpaque) {
+ fTotalProcessorsVisited += cnt - i;
+ return;
+ }
+ const GrFragmentProcessor* fp = processors[i];
+ if (knowCurrentOutput &&
+ fp->hasConstantOutputForConstantInput(fLastKnownOutputColor, &fLastKnownOutputColor)) {
+ ++fProcessorsVisitedWithKnownOutput;
+ fIsOpaque = fLastKnownOutputColor.isOpaque();
+ // We reset these since the caller is expected to not use the earlier fragment
+ // processors.
+ fAllProcessorsCompatibleWithCoverageAsAlpha = true;
+ fUsesLocalCoords = false;
+ } else if (fIsOpaque && !fp->preservesOpaqueInput()) {
+ fIsOpaque = false;
+ }
+ if (fAllProcessorsCompatibleWithCoverageAsAlpha && !fp->compatibleWithCoverageAsAlpha()) {
+ fAllProcessorsCompatibleWithCoverageAsAlpha = false;
+ }
+ if (fp->usesLocalCoords()) {
+ fUsesLocalCoords = true;
+ }
+ ++fTotalProcessorsVisited;
+ }
+}