OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright 2013 Google Inc. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license that can be | |
5 * found in the LICENSE file. | |
6 */ | |
7 | |
8 #ifndef GrCoordTransform_DEFINED | |
9 #define GrCoordTransform_DEFINED | |
10 | |
11 #include "GrEffect.h" | |
12 #include "SkMatrix.h" | |
13 #include "GrTexture.h" | |
14 #include "GrTypes.h" | |
15 | |
16 /** | |
17 * A class representing a linear transformation from one of the built-in coordin ate sets (local or | |
18 * position). GrEffects just define these transformations, and the framework doe s the rest of the | |
19 * 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.
| |
20 */ | |
21 class GrCoordTransform : public SkNoncopyable { | |
22 public: | |
23 GrCoordTransform() {} | |
24 | |
25 GrCoordTransform(GrCoordSet sourceCoords, const GrTexture* texture) { | |
26 this->reset(sourceCoords, texture); | |
27 } | |
28 | |
29 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.
| |
30 this->reset(sourceCoords, m, texture); | |
31 } | |
32 | |
33 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.
| |
34 this->reset(sourceCoords, m, reverseY); | |
35 } | |
36 | |
37 void reset(GrCoordSet sourceCoords, const GrTexture* texture) { | |
38 SkASSERT(NULL != texture); | |
39 this->reset(sourceCoords, | |
40 GrEffect::MakeDivByTextureWHMatrix(texture), | |
41 kBottomLeft_GrSurfaceOrigin == texture->origin()); | |
42 } | |
43 | |
44 void reset(GrCoordSet sourceCoords, const SkMatrix& m, const GrTexture* text ure) { | |
45 SkASSERT(NULL != texture); | |
46 this->reset(sourceCoords, m, kBottomLeft_GrSurfaceOrigin == texture->ori gin()); | |
47 } | |
48 | |
49 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.
| |
50 fSourceCoords = sourceCoords; | |
51 fMatrix = m; | |
52 fReverseY = reverseY; | |
53 } | |
54 | |
55 bool operator== (const GrCoordTransform& other) const { | |
56 return fSourceCoords == other.fSourceCoords && | |
57 fMatrix.cheapEqualTo(other.fMatrix) && | |
58 fReverseY == other.fReverseY; | |
59 } | |
60 | |
61 GrCoordSet sourceCoords() const { return fSourceCoords; } | |
62 const SkMatrix& getMatrix() const { return fMatrix; } | |
63 bool reverseY() const { return fReverseY; } | |
64 | |
65 private: | |
66 GrCoordSet fSourceCoords; | |
67 SkMatrix fMatrix; | |
68 bool fReverseY; | |
69 | |
70 typedef SkNoncopyable INHERITED; | |
71 }; | |
72 | |
73 #endif | |
OLD | NEW |