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

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

Issue 1428543003: Create GLSL base class for ProgramDataManager (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add space Created 5 years, 1 month 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 | « src/gpu/effects/GrBezierEffect.cpp ('k') | src/gpu/effects/GrBitmapTextGeoProc.cpp » ('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 2014 Google Inc. 2 * Copyright 2014 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 #include "GrBicubicEffect.h" 8 #include "GrBicubicEffect.h"
9 #include "GrInvariantOutput.h" 9 #include "GrInvariantOutput.h"
10 #include "gl/builders/GrGLProgramBuilder.h" 10 #include "gl/builders/GrGLProgramBuilder.h"
11 #include "glsl/GrGLSLProgramDataManager.h"
11 12
12 #define DS(x) SkDoubleToScalar(x) 13 #define DS(x) SkDoubleToScalar(x)
13 14
14 const SkScalar GrBicubicEffect::gMitchellCoefficients[16] = { 15 const SkScalar GrBicubicEffect::gMitchellCoefficients[16] = {
15 DS( 1.0 / 18.0), DS(-9.0 / 18.0), DS( 15.0 / 18.0), DS( -7.0 / 18.0), 16 DS( 1.0 / 18.0), DS(-9.0 / 18.0), DS( 15.0 / 18.0), DS( -7.0 / 18.0),
16 DS(16.0 / 18.0), DS( 0.0 / 18.0), DS(-36.0 / 18.0), DS( 21.0 / 18.0), 17 DS(16.0 / 18.0), DS( 0.0 / 18.0), DS(-36.0 / 18.0), DS( 21.0 / 18.0),
17 DS( 1.0 / 18.0), DS( 9.0 / 18.0), DS( 27.0 / 18.0), DS(-21.0 / 18.0), 18 DS( 1.0 / 18.0), DS( 9.0 / 18.0), DS( 27.0 / 18.0), DS(-21.0 / 18.0),
18 DS( 0.0 / 18.0), DS( 0.0 / 18.0), DS( -6.0 / 18.0), DS( 7.0 / 18.0), 19 DS( 0.0 / 18.0), DS( 0.0 / 18.0), DS( -6.0 / 18.0), DS( 7.0 / 18.0),
19 }; 20 };
20 21
21 22
22 class GrGLBicubicEffect : public GrGLFragmentProcessor { 23 class GrGLBicubicEffect : public GrGLFragmentProcessor {
23 public: 24 public:
24 GrGLBicubicEffect(const GrProcessor&); 25 GrGLBicubicEffect(const GrProcessor&);
25 26
26 virtual void emitCode(EmitArgs&) override; 27 virtual void emitCode(EmitArgs&) override;
27 28
28 static inline void GenKey(const GrProcessor& effect, const GrGLSLCaps&, 29 static inline void GenKey(const GrProcessor& effect, const GrGLSLCaps&,
29 GrProcessorKeyBuilder* b) { 30 GrProcessorKeyBuilder* b) {
30 const GrTextureDomain& domain = effect.cast<GrBicubicEffect>().domain(); 31 const GrTextureDomain& domain = effect.cast<GrBicubicEffect>().domain();
31 b->add32(GrTextureDomain::GLDomain::DomainKey(domain)); 32 b->add32(GrTextureDomain::GLDomain::DomainKey(domain));
32 } 33 }
33 34
34 protected: 35 protected:
35 void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override; 36 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override ;
36 37
37 private: 38 private:
38 typedef GrGLProgramDataManager::UniformHandle UniformHandle; 39 typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
39 40
40 UniformHandle fCoefficientsUni; 41 UniformHandle fCoefficientsUni;
41 UniformHandle fImageIncrementUni; 42 UniformHandle fImageIncrementUni;
42 GrTextureDomain::GLDomain fDomain; 43 GrTextureDomain::GLDomain fDomain;
43 44
44 typedef GrGLFragmentProcessor INHERITED; 45 typedef GrGLFragmentProcessor INHERITED;
45 }; 46 };
46 47
47 GrGLBicubicEffect::GrGLBicubicEffect(const GrProcessor&) { 48 GrGLBicubicEffect::GrGLBicubicEffect(const GrProcessor&) {
48 } 49 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 fDomain.sampleTexture(fsBuilder, domain, sampleVar.c_str(), coord, a rgs.fSamplers[0]); 99 fDomain.sampleTexture(fsBuilder, domain, sampleVar.c_str(), coord, a rgs.fSamplers[0]);
99 } 100 }
100 fsBuilder->codeAppendf("\tvec4 s%d = %s(%s, f.x, rowColors[0], rowColors [1], rowColors[2], rowColors[3]);\n", y, cubicBlendName.c_str(), coeff); 101 fsBuilder->codeAppendf("\tvec4 s%d = %s(%s, f.x, rowColors[0], rowColors [1], rowColors[2], rowColors[3]);\n", y, cubicBlendName.c_str(), coeff);
101 } 102 }
102 SkString bicubicColor; 103 SkString bicubicColor;
103 bicubicColor.printf("%s(%s, f.y, s0, s1, s2, s3)", cubicBlendName.c_str(), c oeff); 104 bicubicColor.printf("%s(%s, f.y, s0, s1, s2, s3)", cubicBlendName.c_str(), c oeff);
104 fsBuilder->codeAppendf("\t%s = %s;\n", args.fOutputColor,(GrGLSLExpr4(bicubi cColor.c_str()) * 105 fsBuilder->codeAppendf("\t%s = %s;\n", args.fOutputColor,(GrGLSLExpr4(bicubi cColor.c_str()) *
105 GrGLSLExpr4(args.fInputColor)).c_str()); 106 GrGLSLExpr4(args.fInputColor)).c_str());
106 } 107 }
107 108
108 void GrGLBicubicEffect::onSetData(const GrGLProgramDataManager& pdman, 109 void GrGLBicubicEffect::onSetData(const GrGLSLProgramDataManager& pdman,
109 const GrProcessor& processor) { 110 const GrProcessor& processor) {
110 const GrBicubicEffect& bicubicEffect = processor.cast<GrBicubicEffect>(); 111 const GrBicubicEffect& bicubicEffect = processor.cast<GrBicubicEffect>();
111 const GrTexture& texture = *processor.texture(0); 112 const GrTexture& texture = *processor.texture(0);
112 float imageIncrement[2]; 113 float imageIncrement[2];
113 imageIncrement[0] = 1.0f / texture.width(); 114 imageIncrement[0] = 1.0f / texture.width();
114 imageIncrement[1] = 1.0f / texture.height(); 115 imageIncrement[1] = 1.0f / texture.height();
115 pdman.set2fv(fImageIncrementUni, 1, imageIncrement); 116 pdman.set2fv(fImageIncrementUni, 1, imageIncrement);
116 pdman.setMatrix4f(fCoefficientsUni, bicubicEffect.coefficients()); 117 pdman.setMatrix4f(fCoefficientsUni, bicubicEffect.coefficients());
117 fDomain.setData(pdman, bicubicEffect.domain(), texture.origin()); 118 fDomain.setData(pdman, bicubicEffect.domain(), texture.origin());
118 } 119 }
119 120
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 // Use bilerp to handle rotation or fractional translation. 208 // Use bilerp to handle rotation or fractional translation.
208 *filterMode = GrTextureParams::kBilerp_FilterMode; 209 *filterMode = GrTextureParams::kBilerp_FilterMode;
209 } 210 }
210 return false; 211 return false;
211 } 212 }
212 // When we use the bicubic filtering effect each sample is read from the tex ture using 213 // When we use the bicubic filtering effect each sample is read from the tex ture using
213 // nearest neighbor sampling. 214 // nearest neighbor sampling.
214 *filterMode = GrTextureParams::kNone_FilterMode; 215 *filterMode = GrTextureParams::kNone_FilterMode;
215 return true; 216 return true;
216 } 217 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrBezierEffect.cpp ('k') | src/gpu/effects/GrBitmapTextGeoProc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698