Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Side by Side Diff: include/gpu/GrCoordTransform.h

Issue 777443003: Move shader precision out of GrShaderVar (Closed) Base URL: https://skia.googlesource.com/skia.git@prec
Patch Set: rebase Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | include/gpu/GrShaderVar.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 GrCoordTransform(GrCoordSet sourceCoords, const SkMatrix& m, const GrTexture * texture) { 65 GrCoordTransform(GrCoordSet sourceCoords, const SkMatrix& m, const GrTexture * texture) {
66 SkDEBUGCODE(fInProcessor = false); 66 SkDEBUGCODE(fInProcessor = false);
67 SkASSERT(texture); 67 SkASSERT(texture);
68 this->reset(sourceCoords, m, texture); 68 this->reset(sourceCoords, m, texture);
69 } 69 }
70 70
71 /** 71 /**
72 * Create a transformation that applies the matrix to a coord set. 72 * Create a transformation that applies the matrix to a coord set.
73 */ 73 */
74 GrCoordTransform(GrCoordSet sourceCoords, const SkMatrix& m, 74 GrCoordTransform(GrCoordSet sourceCoords, const SkMatrix& m,
75 GrShaderVar::Precision precision = GrShaderVar::kDefault_Pr ecision) { 75 GrSLPrecision precision = kDefault_GrSLPrecision) {
76 SkDEBUGCODE(fInProcessor = false); 76 SkDEBUGCODE(fInProcessor = false);
77 this->reset(sourceCoords, m, precision); 77 this->reset(sourceCoords, m, precision);
78 } 78 }
79 79
80 void reset(GrCoordSet sourceCoords, const GrTexture* texture) { 80 void reset(GrCoordSet sourceCoords, const GrTexture* texture) {
81 SkASSERT(!fInProcessor); 81 SkASSERT(!fInProcessor);
82 SkASSERT(texture); 82 SkASSERT(texture);
83 this->reset(sourceCoords, MakeDivByTextureWHMatrix(texture), texture); 83 this->reset(sourceCoords, MakeDivByTextureWHMatrix(texture), texture);
84 } 84 }
85 85
86 void reset(GrCoordSet, const SkMatrix&, const GrTexture*); 86 void reset(GrCoordSet, const SkMatrix&, const GrTexture*);
87 void reset(GrCoordSet sourceCoords, const SkMatrix& m, 87 void reset(GrCoordSet sourceCoords, const SkMatrix& m,
88 GrShaderVar::Precision precision = GrShaderVar::kDefault_Precisio n); 88 GrSLPrecision precision = kDefault_GrSLPrecision);
89 89
90 GrCoordTransform& operator= (const GrCoordTransform& that) { 90 GrCoordTransform& operator= (const GrCoordTransform& that) {
91 SkASSERT(!fInProcessor); 91 SkASSERT(!fInProcessor);
92 fSourceCoords = that.fSourceCoords; 92 fSourceCoords = that.fSourceCoords;
93 fMatrix = that.fMatrix; 93 fMatrix = that.fMatrix;
94 fReverseY = that.fReverseY; 94 fReverseY = that.fReverseY;
95 fPrecision = that.fPrecision; 95 fPrecision = that.fPrecision;
96 return *this; 96 return *this;
97 } 97 }
98 98
(...skipping 11 matching lines...) Expand all
110 fMatrix.cheapEqualTo(that.fMatrix) && 110 fMatrix.cheapEqualTo(that.fMatrix) &&
111 fReverseY == that.fReverseY && 111 fReverseY == that.fReverseY &&
112 fPrecision == that.fPrecision; 112 fPrecision == that.fPrecision;
113 } 113 }
114 114
115 bool operator!=(const GrCoordTransform& that) const { return !(*this == that ); } 115 bool operator!=(const GrCoordTransform& that) const { return !(*this == that ); }
116 116
117 GrCoordSet sourceCoords() const { return fSourceCoords; } 117 GrCoordSet sourceCoords() const { return fSourceCoords; }
118 const SkMatrix& getMatrix() const { return fMatrix; } 118 const SkMatrix& getMatrix() const { return fMatrix; }
119 bool reverseY() const { return fReverseY; } 119 bool reverseY() const { return fReverseY; }
120 GrShaderVar::Precision precision() const { return fPrecision; } 120 GrSLPrecision precision() const { return fPrecision; }
121 121
122 /** Useful for effects that want to insert a texture matrix that is implied by the texture 122 /** Useful for effects that want to insert a texture matrix that is implied by the texture
123 dimensions */ 123 dimensions */
124 static inline SkMatrix MakeDivByTextureWHMatrix(const GrTexture* texture) { 124 static inline SkMatrix MakeDivByTextureWHMatrix(const GrTexture* texture) {
125 SkASSERT(texture); 125 SkASSERT(texture);
126 SkMatrix mat; 126 SkMatrix mat;
127 mat.setIDiv(texture->width(), texture->height()); 127 mat.setIDiv(texture->width(), texture->height());
128 return mat; 128 return mat;
129 } 129 }
130 130
131 private: 131 private:
132 GrCoordSet fSourceCoords; 132 GrCoordSet fSourceCoords;
133 SkMatrix fMatrix; 133 SkMatrix fMatrix;
134 bool fReverseY; 134 bool fReverseY;
135 GrShaderVar::Precision fPrecision; 135 GrSLPrecision fPrecision;
136 typedef SkNoncopyable INHERITED; 136 typedef SkNoncopyable INHERITED;
137 137
138 #ifdef SK_DEBUG 138 #ifdef SK_DEBUG
139 public: 139 public:
140 void setInProcessor() const { fInProcessor = true; } 140 void setInProcessor() const { fInProcessor = true; }
141 private: 141 private:
142 mutable bool fInProcessor; 142 mutable bool fInProcessor;
143 #endif 143 #endif
144 }; 144 };
145 145
146 #endif 146 #endif
OLDNEW
« no previous file with comments | « no previous file | include/gpu/GrShaderVar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698