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

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

Issue 1666773002: Clean up GrGLSLFragmentProcessor-derived classes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 months 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/GrFragmentProcessor.cpp ('k') | src/gpu/effects/GrConfigConversionEffect.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/GrGLSLProgramDataManager.h" 11 #include "glsl/GrGLSLProgramDataManager.h"
12 #include "glsl/GrGLSLUniformHandler.h" 12 #include "glsl/GrGLSLUniformHandler.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 GrGLSLFragmentProcessor { 24 class GrGLBicubicEffect : public GrGLSLFragmentProcessor {
25 public: 25 public:
26 GrGLBicubicEffect(const GrProcessor&); 26 void emitCode(EmitArgs&) override;
27
28 virtual void emitCode(EmitArgs&) override;
29 27
30 static inline void GenKey(const GrProcessor& effect, const GrGLSLCaps&, 28 static inline void GenKey(const GrProcessor& effect, const GrGLSLCaps&,
31 GrProcessorKeyBuilder* b) { 29 GrProcessorKeyBuilder* b) {
32 const GrTextureDomain& domain = effect.cast<GrBicubicEffect>().domain(); 30 const GrTextureDomain& domain = effect.cast<GrBicubicEffect>().domain();
33 b->add32(GrTextureDomain::GLDomain::DomainKey(domain)); 31 b->add32(GrTextureDomain::GLDomain::DomainKey(domain));
34 } 32 }
35 33
36 protected: 34 protected:
37 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override ; 35 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override ;
38 36
39 private: 37 private:
40 typedef GrGLSLProgramDataManager::UniformHandle UniformHandle; 38 typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
41 39
42 UniformHandle fCoefficientsUni; 40 UniformHandle fCoefficientsUni;
43 UniformHandle fImageIncrementUni; 41 UniformHandle fImageIncrementUni;
44 GrTextureDomain::GLDomain fDomain; 42 GrTextureDomain::GLDomain fDomain;
45 43
46 typedef GrGLSLFragmentProcessor INHERITED; 44 typedef GrGLSLFragmentProcessor INHERITED;
47 }; 45 };
48 46
49 GrGLBicubicEffect::GrGLBicubicEffect(const GrProcessor&) {
50 }
51
52 void GrGLBicubicEffect::emitCode(EmitArgs& args) { 47 void GrGLBicubicEffect::emitCode(EmitArgs& args) {
53 const GrTextureDomain& domain = args.fFp.cast<GrBicubicEffect>().domain(); 48 const GrTextureDomain& domain = args.fFp.cast<GrBicubicEffect>().domain();
54 49
55 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; 50 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
56 fCoefficientsUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragmen t_Visibility, 51 fCoefficientsUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragmen t_Visibility,
57 kMat44f_GrSLType, kDefault_GrS LPrecision, 52 kMat44f_GrSLType, kDefault_GrS LPrecision,
58 "Coefficients"); 53 "Coefficients");
59 fImageIncrementUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragm ent_Visibility, 54 fImageIncrementUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragm ent_Visibility,
60 kVec2f_GrSLType, kDefault_Gr SLPrecision, 55 kVec2f_GrSLType, kDefault_Gr SLPrecision,
61 "ImageIncrement"); 56 "ImageIncrement");
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 156
162 GrBicubicEffect::~GrBicubicEffect() { 157 GrBicubicEffect::~GrBicubicEffect() {
163 } 158 }
164 159
165 void GrBicubicEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps, 160 void GrBicubicEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
166 GrProcessorKeyBuilder* b) const { 161 GrProcessorKeyBuilder* b) const {
167 GrGLBicubicEffect::GenKey(*this, caps, b); 162 GrGLBicubicEffect::GenKey(*this, caps, b);
168 } 163 }
169 164
170 GrGLSLFragmentProcessor* GrBicubicEffect::onCreateGLSLInstance() const { 165 GrGLSLFragmentProcessor* GrBicubicEffect::onCreateGLSLInstance() const {
171 return new GrGLBicubicEffect(*this); 166 return new GrGLBicubicEffect;
172 } 167 }
173 168
174 bool GrBicubicEffect::onIsEqual(const GrFragmentProcessor& sBase) const { 169 bool GrBicubicEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
175 const GrBicubicEffect& s = sBase.cast<GrBicubicEffect>(); 170 const GrBicubicEffect& s = sBase.cast<GrBicubicEffect>();
176 return !memcmp(fCoefficients, s.coefficients(), 16) && 171 return !memcmp(fCoefficients, s.coefficients(), 16) &&
177 fDomain == s.fDomain; 172 fDomain == s.fDomain;
178 } 173 }
179 174
180 void GrBicubicEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const { 175 void GrBicubicEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
181 // FIXME: Perhaps we can do better. 176 // FIXME: Perhaps we can do better.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 // Use bilerp to handle rotation or fractional translation. 214 // Use bilerp to handle rotation or fractional translation.
220 *filterMode = GrTextureParams::kBilerp_FilterMode; 215 *filterMode = GrTextureParams::kBilerp_FilterMode;
221 } 216 }
222 return false; 217 return false;
223 } 218 }
224 // When we use the bicubic filtering effect each sample is read from the tex ture using 219 // When we use the bicubic filtering effect each sample is read from the tex ture using
225 // nearest neighbor sampling. 220 // nearest neighbor sampling.
226 *filterMode = GrTextureParams::kNone_FilterMode; 221 *filterMode = GrTextureParams::kNone_FilterMode;
227 return true; 222 return true;
228 } 223 }
OLDNEW
« no previous file with comments | « src/gpu/GrFragmentProcessor.cpp ('k') | src/gpu/effects/GrConfigConversionEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698