Index: include/gpu/GrCoordTransform.h |
diff --git a/include/gpu/GrCoordTransform.h b/include/gpu/GrCoordTransform.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..931526092c9a68747ce9fae856626b33423cb1b3 |
--- /dev/null |
+++ b/include/gpu/GrCoordTransform.h |
@@ -0,0 +1,73 @@ |
+/* |
+ * Copyright 2013 Google Inc. |
+ * |
+ * Use of this source code is governed by a BSD-style license that can be |
+ * found in the LICENSE file. |
+ */ |
+ |
+#ifndef GrCoordTransform_DEFINED |
+#define GrCoordTransform_DEFINED |
+ |
+#include "GrEffect.h" |
+#include "SkMatrix.h" |
+#include "GrTexture.h" |
+#include "GrTypes.h" |
+ |
+/** |
+ * A class representing a linear transformation from one of the built-in coordinate sets (local or |
+ * position). GrEffects just define these transformations, and the framework does the rest of the |
+ * work to make the transformed coordinates available in their shaders. |
bsalomon
2013/09/27 19:23:57
... ^fragment shaders.
Chris Dalton
2013/09/27 23:33:45
Done.
|
+ */ |
+class GrCoordTransform : public SkNoncopyable { |
+public: |
+ GrCoordTransform() {} |
+ |
+ GrCoordTransform(GrCoordSet sourceCoords, const GrTexture* texture) { |
+ this->reset(sourceCoords, texture); |
+ } |
+ |
+ GrCoordTransform(GrCoordSet sourceCoords, const SkMatrix& m, const GrTexture* texture) { |
bsalomon
2013/09/27 19:23:57
Maybe some documentation that the texture is just
Chris Dalton
2013/09/27 23:33:45
Done.
|
+ this->reset(sourceCoords, m, texture); |
+ } |
+ |
+ GrCoordTransform(GrCoordSet sourceCoords, const SkMatrix& m, bool reverseY = false) { |
bsalomon
2013/09/27 19:23:57
Is this constructor used in practice?
Chris Dalton
2013/09/27 23:33:45
Removed.
|
+ this->reset(sourceCoords, m, reverseY); |
+ } |
+ |
+ void reset(GrCoordSet sourceCoords, const GrTexture* texture) { |
+ SkASSERT(NULL != texture); |
+ this->reset(sourceCoords, |
+ GrEffect::MakeDivByTextureWHMatrix(texture), |
+ kBottomLeft_GrSurfaceOrigin == texture->origin()); |
+ } |
+ |
+ void reset(GrCoordSet sourceCoords, const SkMatrix& m, const GrTexture* texture) { |
+ SkASSERT(NULL != texture); |
+ this->reset(sourceCoords, m, kBottomLeft_GrSurfaceOrigin == texture->origin()); |
+ } |
+ |
+ void reset(GrCoordSet sourceCoords, const SkMatrix& m, bool reverseY = false) { |
bsalomon
2013/09/27 19:23:57
If this version could be private that would seem n
Chris Dalton
2013/09/27 23:33:45
Done.
|
+ fSourceCoords = sourceCoords; |
+ fMatrix = m; |
+ fReverseY = reverseY; |
+ } |
+ |
+ bool operator== (const GrCoordTransform& other) const { |
+ return fSourceCoords == other.fSourceCoords && |
+ fMatrix.cheapEqualTo(other.fMatrix) && |
+ fReverseY == other.fReverseY; |
+ } |
+ |
+ GrCoordSet sourceCoords() const { return fSourceCoords; } |
+ const SkMatrix& getMatrix() const { return fMatrix; } |
+ bool reverseY() const { return fReverseY; } |
+ |
+private: |
+ GrCoordSet fSourceCoords; |
+ SkMatrix fMatrix; |
+ bool fReverseY; |
+ |
+ typedef SkNoncopyable INHERITED; |
+}; |
+ |
+#endif |