aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrPendingFragmentStage.h
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2014-11-19 08:23:49 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-11-19 08:23:49 -0800
commitae59b77612c42ff6b793dc33e3d115e6a5db34cc (patch)
treef3124daeb6c8a0619d60ee09e7cdd3dae47bffdb /src/gpu/GrPendingFragmentStage.h
parent78e276889795454891cbba48ab11927968114953 (diff)
Create GrOptDrawState before recording draw in GrInOrderDrawBuffer
Diffstat (limited to 'src/gpu/GrPendingFragmentStage.h')
-rw-r--r--src/gpu/GrPendingFragmentStage.h66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/gpu/GrPendingFragmentStage.h b/src/gpu/GrPendingFragmentStage.h
new file mode 100644
index 0000000000..6c61029eca
--- /dev/null
+++ b/src/gpu/GrPendingFragmentStage.h
@@ -0,0 +1,66 @@
+/*
+ * 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 GrPendingProcessorStage_DEFINED
+#define GrPendingProcessorStage_DEFINED
+
+#include "GrFragmentStage.h"
+#include "GrCoordTransform.h"
+#include "GrFragmentProcessor.h"
+#include "GrPendingProgramElement.h"
+#include "SkMatrix.h"
+
+/**
+ * This a baked variant of GrFragmentStage, as recorded in GrOptDrawState.
+ */
+class GrPendingFragmentStage {
+public:
+ GrPendingFragmentStage(const GrFragmentStage& stage, bool ignoreMatrix)
+ : fProc(stage.getProcessor())
+ , fCoordChangeMatrix(ignoreMatrix ? SkMatrix::I() : stage.getCoordChangeMatrix()) {
+ }
+
+ GrPendingFragmentStage(const GrPendingFragmentStage& that) { *this = that; }
+
+ GrPendingFragmentStage& operator=(const GrPendingFragmentStage& that) {
+ fProc.reset(that.fProc.get());
+ fCoordChangeMatrix = that.fCoordChangeMatrix;
+ return *this;
+ }
+
+ bool operator==(const GrPendingFragmentStage& that) const {
+ return this->getProcessor()->isEqual(*that.getProcessor()) &&
+ fCoordChangeMatrix == that.fCoordChangeMatrix;
+ }
+
+ bool operator!=(const GrPendingFragmentStage& that) const { return !(*this == that); }
+
+ const SkMatrix& getCoordChangeMatrix() const { return fCoordChangeMatrix; }
+
+ /**
+ * For a coord transform on the fragment processor, does it or the coord change matrix (if
+ * relevant) contain perspective?
+ */
+ bool isPerspectiveCoordTransform(int matrixIndex) const {
+ const GrCoordTransform& coordTransform = this->getProcessor()->coordTransform(matrixIndex);
+ uint32_t type = coordTransform.getMatrix().getType();
+ if (kLocal_GrCoordSet == coordTransform.sourceCoords()) {
+ type |= this->getCoordChangeMatrix().getType();
+ }
+
+ return SkToBool(SkMatrix::kPerspective_Mask & type);
+ }
+
+ const char* name() const { return fProc->name(); }
+
+ const GrFragmentProcessor* getProcessor() const { return fProc.get(); }
+
+protected:
+ GrPendingProgramElement<const GrFragmentProcessor> fProc;
+ SkMatrix fCoordChangeMatrix;
+};
+#endif