OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef GrCoordTransform_DEFINED | 8 #ifndef GrCoordTransform_DEFINED |
9 #define GrCoordTransform_DEFINED | 9 #define GrCoordTransform_DEFINED |
10 | 10 |
(...skipping 30 matching lines...) Expand all Loading... |
41 * A class representing a linear transformation from one of the built-in coordin
ate sets (local or | 41 * A class representing a linear transformation from one of the built-in coordin
ate sets (local or |
42 * position). GrProcessors just define these transformations, and the framework
does the rest of the | 42 * position). GrProcessors just define these transformations, and the framework
does the rest of the |
43 * work to make the transformed coordinates available in their fragment shader. | 43 * work to make the transformed coordinates available in their fragment shader. |
44 */ | 44 */ |
45 class GrCoordTransform : SkNoncopyable { | 45 class GrCoordTransform : SkNoncopyable { |
46 public: | 46 public: |
47 GrCoordTransform() { SkDEBUGCODE(fInProcessor = false); } | 47 GrCoordTransform() { SkDEBUGCODE(fInProcessor = false); } |
48 | 48 |
49 /** | 49 /** |
50 * Create a transformation that maps [0, 1] to a texture's boundaries. The p
recision is inferred | 50 * Create a transformation that maps [0, 1] to a texture's boundaries. The p
recision is inferred |
51 * from the texture size. | 51 * from the texture size and filter. The texture origin also implies whether
a y-reversal should |
| 52 * be performed. |
52 */ | 53 */ |
53 GrCoordTransform(GrCoordSet sourceCoords, const GrTexture* texture) { | 54 GrCoordTransform(GrCoordSet sourceCoords, |
| 55 const GrTexture* texture, |
| 56 GrTextureParams::FilterMode filter) { |
54 SkASSERT(texture); | 57 SkASSERT(texture); |
55 SkDEBUGCODE(fInProcessor = false); | 58 SkDEBUGCODE(fInProcessor = false); |
56 this->reset(sourceCoords, texture); | 59 this->reset(sourceCoords, texture, filter); |
57 } | 60 } |
58 | 61 |
59 /** | 62 /** |
60 * Create a transformation from a matrix. The texture parameter is used to i
nfer if the | 63 * Create a transformation from a matrix. The precision is inferred from the
texture size and |
61 * framework should internally do a y reversal to account for it being upsid
e down by Skia's | 64 * filter. The texture origin also implies whether a y-reversal should be pe
rformed. |
62 * coord convention and the precision of the shader variables used to implem
ent the coord | |
63 * transform. | |
64 */ | 65 */ |
65 GrCoordTransform(GrCoordSet sourceCoords, const SkMatrix& m, const GrTexture
* texture) { | 66 GrCoordTransform(GrCoordSet sourceCoords, const SkMatrix& m, |
| 67 const GrTexture* texture, GrTextureParams::FilterMode filte
r) { |
66 SkDEBUGCODE(fInProcessor = false); | 68 SkDEBUGCODE(fInProcessor = false); |
67 SkASSERT(texture); | 69 SkASSERT(texture); |
68 this->reset(sourceCoords, m, texture); | 70 this->reset(sourceCoords, m, texture, filter); |
69 } | 71 } |
70 | 72 |
71 /** | 73 /** |
72 * Create a transformation that applies the matrix to a coord set. | 74 * Create a transformation that applies the matrix to a coord set. |
73 */ | 75 */ |
74 GrCoordTransform(GrCoordSet sourceCoords, const SkMatrix& m, | 76 GrCoordTransform(GrCoordSet sourceCoords, const SkMatrix& m, |
75 GrSLPrecision precision = kDefault_GrSLPrecision) { | 77 GrSLPrecision precision = kDefault_GrSLPrecision) { |
76 SkDEBUGCODE(fInProcessor = false); | 78 SkDEBUGCODE(fInProcessor = false); |
77 this->reset(sourceCoords, m, precision); | 79 this->reset(sourceCoords, m, precision); |
78 } | 80 } |
79 | 81 |
80 void reset(GrCoordSet sourceCoords, const GrTexture* texture) { | 82 void reset(GrCoordSet sourceCoords, const GrTexture* texture, |
| 83 GrTextureParams::FilterMode filter) { |
81 SkASSERT(!fInProcessor); | 84 SkASSERT(!fInProcessor); |
82 SkASSERT(texture); | 85 SkASSERT(texture); |
83 this->reset(sourceCoords, MakeDivByTextureWHMatrix(texture), texture); | 86 this->reset(sourceCoords, MakeDivByTextureWHMatrix(texture), texture, fi
lter); |
84 } | 87 } |
85 | 88 |
86 void reset(GrCoordSet, const SkMatrix&, const GrTexture*); | 89 void reset(GrCoordSet, const SkMatrix&, const GrTexture*, GrTextureParams::F
ilterMode filter); |
87 void reset(GrCoordSet sourceCoords, const SkMatrix& m, | 90 void reset(GrCoordSet sourceCoords, const SkMatrix& m, |
88 GrSLPrecision precision = kDefault_GrSLPrecision); | 91 GrSLPrecision precision = kDefault_GrSLPrecision); |
89 | 92 |
90 GrCoordTransform& operator= (const GrCoordTransform& that) { | 93 GrCoordTransform& operator= (const GrCoordTransform& that) { |
91 SkASSERT(!fInProcessor); | 94 SkASSERT(!fInProcessor); |
92 fSourceCoords = that.fSourceCoords; | 95 fSourceCoords = that.fSourceCoords; |
93 fMatrix = that.fMatrix; | 96 fMatrix = that.fMatrix; |
94 fReverseY = that.fReverseY; | 97 fReverseY = that.fReverseY; |
95 fPrecision = that.fPrecision; | 98 fPrecision = that.fPrecision; |
96 return *this; | 99 return *this; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 | 140 |
138 #ifdef SK_DEBUG | 141 #ifdef SK_DEBUG |
139 public: | 142 public: |
140 void setInProcessor() const { fInProcessor = true; } | 143 void setInProcessor() const { fInProcessor = true; } |
141 private: | 144 private: |
142 mutable bool fInProcessor; | 145 mutable bool fInProcessor; |
143 #endif | 146 #endif |
144 }; | 147 }; |
145 | 148 |
146 #endif | 149 #endif |
OLD | NEW |