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

Side by Side Diff: src/gpu/effects/GrBicubicEffect.cpp

Issue 99523008: Make GrBicubicEffect take tile modes rather than GrTextureParams. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: small simplification Created 7 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 | Annotate | Revision Log
« no previous file with comments | « src/gpu/effects/GrBicubicEffect.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include "GrBicubicEffect.h" 1 #include "GrBicubicEffect.h"
2 2
3 #define DS(x) SkDoubleToScalar(x) 3 #define DS(x) SkDoubleToScalar(x)
4 4
5 const SkScalar GrBicubicEffect::gMitchellCoefficients[16] = { 5 const SkScalar GrBicubicEffect::gMitchellCoefficients[16] = {
6 DS( 1.0 / 18.0), DS(-9.0 / 18.0), DS( 15.0 / 18.0), DS( -7.0 / 18.0), 6 DS( 1.0 / 18.0), DS(-9.0 / 18.0), DS( 15.0 / 18.0), DS( -7.0 / 18.0),
7 DS(16.0 / 18.0), DS( 0.0 / 18.0), DS(-36.0 / 18.0), DS( 21.0 / 18.0), 7 DS(16.0 / 18.0), DS( 0.0 / 18.0), DS(-36.0 / 18.0), DS( 21.0 / 18.0),
8 DS( 1.0 / 18.0), DS( 9.0 / 18.0), DS( 27.0 / 18.0), DS(-21.0 / 18.0), 8 DS( 1.0 / 18.0), DS( 9.0 / 18.0), DS( 27.0 / 18.0), DS(-21.0 / 18.0),
9 DS( 0.0 / 18.0), DS( 0.0 / 18.0), DS( -6.0 / 18.0), DS( 7.0 / 18.0), 9 DS( 0.0 / 18.0), DS( 0.0 / 18.0), DS( -6.0 / 18.0), DS( 7.0 / 18.0),
10 }; 10 };
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 const GrBicubicEffect& effect = drawEffect.castEffect<GrBicubicEffect>(); 99 const GrBicubicEffect& effect = drawEffect.castEffect<GrBicubicEffect>();
100 GrTexture& texture = *effect.texture(0); 100 GrTexture& texture = *effect.texture(0);
101 float imageIncrement[2]; 101 float imageIncrement[2];
102 imageIncrement[0] = 1.0f / texture.width(); 102 imageIncrement[0] = 1.0f / texture.width();
103 imageIncrement[1] = 1.0f / texture.height(); 103 imageIncrement[1] = 1.0f / texture.height();
104 uman.set2fv(fImageIncrementUni, 1, imageIncrement); 104 uman.set2fv(fImageIncrementUni, 1, imageIncrement);
105 uman.setMatrix4f(fCoefficientsUni, effect.coefficients()); 105 uman.setMatrix4f(fCoefficientsUni, effect.coefficients());
106 } 106 }
107 107
108 GrBicubicEffect::GrBicubicEffect(GrTexture* texture, 108 GrBicubicEffect::GrBicubicEffect(GrTexture* texture,
109 const SkScalar coefficients[16])
110 : INHERITED(texture, MakeDivByTextureWHMatrix(texture)) {
111 for (int y = 0; y < 4; y++) {
112 for (int x = 0; x < 4; x++) {
113 // Convert from row-major scalars to column-major floats.
114 fCoefficients[x * 4 + y] = SkScalarToFloat(coefficients[y * 4 + x]);
115 }
116 }
117 this->setWillNotUseInputColor();
118 }
119
120 GrBicubicEffect::GrBicubicEffect(GrTexture* texture,
121 const SkScalar coefficients[16], 109 const SkScalar coefficients[16],
122 const SkMatrix &matrix, 110 const SkMatrix &matrix,
123 const GrTextureParams &params, 111 const SkShader::TileMode tileModes[2])
124 GrCoordSet coordSet) 112 : INHERITED(texture, matrix, GrTextureParams(tileModes, GrTextureParams::kNone _FilterMode)) {
125 : INHERITED(texture, matrix, params, coordSet) {
126 for (int y = 0; y < 4; y++) { 113 for (int y = 0; y < 4; y++) {
127 for (int x = 0; x < 4; x++) { 114 for (int x = 0; x < 4; x++) {
128 // Convert from row-major scalars to column-major floats. 115 // Convert from row-major scalars to column-major floats.
129 fCoefficients[x * 4 + y] = SkScalarToFloat(coefficients[y * 4 + x]); 116 fCoefficients[x * 4 + y] = SkScalarToFloat(coefficients[y * 4 + x]);
130 } 117 }
131 } 118 }
132 this->setWillNotUseInputColor(); 119 this->setWillNotUseInputColor();
133 } 120 }
134 121
135 GrBicubicEffect::~GrBicubicEffect() { 122 GrBicubicEffect::~GrBicubicEffect() {
(...skipping 22 matching lines...) Expand all
158 const GrDrawTargetCaps&, 145 const GrDrawTargetCaps&,
159 GrTexture* textures[]) { 146 GrTexture* textures[]) {
160 int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx : 147 int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
161 GrEffectUnitTest::kAlphaTextureIdx; 148 GrEffectUnitTest::kAlphaTextureIdx;
162 SkScalar coefficients[16]; 149 SkScalar coefficients[16];
163 for (int i = 0; i < 16; i++) { 150 for (int i = 0; i < 16; i++) {
164 coefficients[i] = random->nextSScalar1(); 151 coefficients[i] = random->nextSScalar1();
165 } 152 }
166 return GrBicubicEffect::Create(textures[texIdx], coefficients); 153 return GrBicubicEffect::Create(textures[texIdx], coefficients);
167 } 154 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrBicubicEffect.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698