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

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

Issue 1434313002: Make all GrFragmentProcessors GL independent. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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/GrBicubicEffect.h ('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 "glsl/GrGLSLFragmentShaderBuilder.h" 10 #include "glsl/GrGLSLFragmentShaderBuilder.h"
11 #include "glsl/GrGLSLProgramBuilder.h" 11 #include "glsl/GrGLSLProgramBuilder.h"
12 #include "glsl/GrGLSLProgramDataManager.h" 12 #include "glsl/GrGLSLProgramDataManager.h"
13 13
14 #define DS(x) SkDoubleToScalar(x) 14 #define DS(x) SkDoubleToScalar(x)
15 15
16 const SkScalar GrBicubicEffect::gMitchellCoefficients[16] = { 16 const SkScalar GrBicubicEffect::gMitchellCoefficients[16] = {
17 DS( 1.0 / 18.0), DS(-9.0 / 18.0), DS( 15.0 / 18.0), DS( -7.0 / 18.0), 17 DS( 1.0 / 18.0), DS(-9.0 / 18.0), DS( 15.0 / 18.0), DS( -7.0 / 18.0),
18 DS(16.0 / 18.0), DS( 0.0 / 18.0), DS(-36.0 / 18.0), DS( 21.0 / 18.0), 18 DS(16.0 / 18.0), DS( 0.0 / 18.0), DS(-36.0 / 18.0), DS( 21.0 / 18.0),
19 DS( 1.0 / 18.0), DS( 9.0 / 18.0), DS( 27.0 / 18.0), DS(-21.0 / 18.0), 19 DS( 1.0 / 18.0), DS( 9.0 / 18.0), DS( 27.0 / 18.0), DS(-21.0 / 18.0),
20 DS( 0.0 / 18.0), DS( 0.0 / 18.0), DS( -6.0 / 18.0), DS( 7.0 / 18.0), 20 DS( 0.0 / 18.0), DS( 0.0 / 18.0), DS( -6.0 / 18.0), DS( 7.0 / 18.0),
21 }; 21 };
22 22
23 23
24 class GrGLBicubicEffect : public GrGLFragmentProcessor { 24 class GrGLBicubicEffect : public GrGLSLFragmentProcessor {
25 public: 25 public:
26 GrGLBicubicEffect(const GrProcessor&); 26 GrGLBicubicEffect(const GrProcessor&);
27 27
28 virtual void emitCode(EmitArgs&) override; 28 virtual void emitCode(EmitArgs&) override;
29 29
30 static inline void GenKey(const GrProcessor& effect, const GrGLSLCaps&, 30 static inline void GenKey(const GrProcessor& effect, const GrGLSLCaps&,
31 GrProcessorKeyBuilder* b) { 31 GrProcessorKeyBuilder* b) {
32 const GrTextureDomain& domain = effect.cast<GrBicubicEffect>().domain(); 32 const GrTextureDomain& domain = effect.cast<GrBicubicEffect>().domain();
33 b->add32(GrTextureDomain::GLDomain::DomainKey(domain)); 33 b->add32(GrTextureDomain::GLDomain::DomainKey(domain));
34 } 34 }
35 35
36 protected: 36 protected:
37 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override ; 37 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override ;
38 38
39 private: 39 private:
40 typedef GrGLSLProgramDataManager::UniformHandle UniformHandle; 40 typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
41 41
42 UniformHandle fCoefficientsUni; 42 UniformHandle fCoefficientsUni;
43 UniformHandle fImageIncrementUni; 43 UniformHandle fImageIncrementUni;
44 GrTextureDomain::GLDomain fDomain; 44 GrTextureDomain::GLDomain fDomain;
45 45
46 typedef GrGLFragmentProcessor INHERITED; 46 typedef GrGLSLFragmentProcessor INHERITED;
47 }; 47 };
48 48
49 GrGLBicubicEffect::GrGLBicubicEffect(const GrProcessor&) { 49 GrGLBicubicEffect::GrGLBicubicEffect(const GrProcessor&) {
50 } 50 }
51 51
52 void GrGLBicubicEffect::emitCode(EmitArgs& args) { 52 void GrGLBicubicEffect::emitCode(EmitArgs& args) {
53 const GrTextureDomain& domain = args.fFp.cast<GrBicubicEffect>().domain(); 53 const GrTextureDomain& domain = args.fFp.cast<GrBicubicEffect>().domain();
54 54
55 fCoefficientsUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment _Visibility, 55 fCoefficientsUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment _Visibility,
56 kMat44f_GrSLType, kDefault_GrSLPrecis ion, 56 kMat44f_GrSLType, kDefault_GrSLPrecis ion,
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 } 150 }
151 151
152 GrBicubicEffect::~GrBicubicEffect() { 152 GrBicubicEffect::~GrBicubicEffect() {
153 } 153 }
154 154
155 void GrBicubicEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, 155 void GrBicubicEffect::onGetGLProcessorKey(const GrGLSLCaps& caps,
156 GrProcessorKeyBuilder* b) const { 156 GrProcessorKeyBuilder* b) const {
157 GrGLBicubicEffect::GenKey(*this, caps, b); 157 GrGLBicubicEffect::GenKey(*this, caps, b);
158 } 158 }
159 159
160 GrGLFragmentProcessor* GrBicubicEffect::onCreateGLInstance() const { 160 GrGLSLFragmentProcessor* GrBicubicEffect::onCreateGLInstance() const {
161 return new GrGLBicubicEffect(*this); 161 return new GrGLBicubicEffect(*this);
162 } 162 }
163 163
164 bool GrBicubicEffect::onIsEqual(const GrFragmentProcessor& sBase) const { 164 bool GrBicubicEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
165 const GrBicubicEffect& s = sBase.cast<GrBicubicEffect>(); 165 const GrBicubicEffect& s = sBase.cast<GrBicubicEffect>();
166 return !memcmp(fCoefficients, s.coefficients(), 16) && 166 return !memcmp(fCoefficients, s.coefficients(), 16) &&
167 fDomain == s.fDomain; 167 fDomain == s.fDomain;
168 } 168 }
169 169
170 void GrBicubicEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const { 170 void GrBicubicEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 // Use bilerp to handle rotation or fractional translation. 209 // Use bilerp to handle rotation or fractional translation.
210 *filterMode = GrTextureParams::kBilerp_FilterMode; 210 *filterMode = GrTextureParams::kBilerp_FilterMode;
211 } 211 }
212 return false; 212 return false;
213 } 213 }
214 // When we use the bicubic filtering effect each sample is read from the tex ture using 214 // When we use the bicubic filtering effect each sample is read from the tex ture using
215 // nearest neighbor sampling. 215 // nearest neighbor sampling.
216 *filterMode = GrTextureParams::kNone_FilterMode; 216 *filterMode = GrTextureParams::kNone_FilterMode;
217 return true; 217 return true;
218 } 218 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrBicubicEffect.h ('k') | src/gpu/effects/GrBitmapTextGeoProc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698