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

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

Issue 778453002: Remove backend factories (Closed) Base URL: https://skia.googlesource.com/skia.git@unichoice
Patch Set: more clang warnings 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 | « src/gpu/effects/GrBicubicEffect.h ('k') | src/gpu/effects/GrConfigConversionEffect.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 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 "gl/builders/GrGLProgramBuilder.h"
9 #include "GrBicubicEffect.h" 8 #include "GrBicubicEffect.h"
10 #include "GrInvariantOutput.h" 9 #include "GrInvariantOutput.h"
10 #include "gl/builders/GrGLProgramBuilder.h"
11 11
12 #define DS(x) SkDoubleToScalar(x) 12 #define DS(x) SkDoubleToScalar(x)
13 13
14 const SkScalar GrBicubicEffect::gMitchellCoefficients[16] = { 14 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), 15 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), 16 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), 17 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), 18 DS( 0.0 / 18.0), DS( 0.0 / 18.0), DS( -6.0 / 18.0), DS( 7.0 / 18.0),
19 }; 19 };
20 20
21 21
22 class GrGLBicubicEffect : public GrGLFragmentProcessor { 22 class GrGLBicubicEffect : public GrGLFragmentProcessor {
23 public: 23 public:
24 GrGLBicubicEffect(const GrBackendProcessorFactory& factory, 24 GrGLBicubicEffect(const GrProcessor&);
25 const GrProcessor&);
26 25
27 virtual void emitCode(GrGLFPBuilder*, 26 virtual void emitCode(GrGLFPBuilder*,
28 const GrFragmentProcessor&, 27 const GrFragmentProcessor&,
29 const char* outputColor, 28 const char* outputColor,
30 const char* inputColor, 29 const char* inputColor,
31 const TransformedCoordsArray&, 30 const TransformedCoordsArray&,
32 const TextureSamplerArray&) SK_OVERRIDE; 31 const TextureSamplerArray&) SK_OVERRIDE;
33 32
34 virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_O VERRIDE; 33 virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_O VERRIDE;
35 34
36 static inline void GenKey(const GrProcessor& effect, const GrGLCaps&, 35 static inline void GenKey(const GrProcessor& effect, const GrGLCaps&,
37 GrProcessorKeyBuilder* b) { 36 GrProcessorKeyBuilder* b) {
38 const GrTextureDomain& domain = effect.cast<GrBicubicEffect>().domain(); 37 const GrTextureDomain& domain = effect.cast<GrBicubicEffect>().domain();
39 b->add32(GrTextureDomain::GLDomain::DomainKey(domain)); 38 b->add32(GrTextureDomain::GLDomain::DomainKey(domain));
40 } 39 }
41 40
42 private: 41 private:
43 typedef GrGLProgramDataManager::UniformHandle UniformHandle; 42 typedef GrGLProgramDataManager::UniformHandle UniformHandle;
44 43
45 UniformHandle fCoefficientsUni; 44 UniformHandle fCoefficientsUni;
46 UniformHandle fImageIncrementUni; 45 UniformHandle fImageIncrementUni;
47 GrTextureDomain::GLDomain fDomain; 46 GrTextureDomain::GLDomain fDomain;
48 47
49 typedef GrGLFragmentProcessor INHERITED; 48 typedef GrGLFragmentProcessor INHERITED;
50 }; 49 };
51 50
52 GrGLBicubicEffect::GrGLBicubicEffect(const GrBackendProcessorFactory& factory, c onst GrProcessor&) 51 GrGLBicubicEffect::GrGLBicubicEffect(const GrProcessor&) {
53 : INHERITED(factory) {
54 } 52 }
55 53
56 void GrGLBicubicEffect::emitCode(GrGLFPBuilder* builder, 54 void GrGLBicubicEffect::emitCode(GrGLFPBuilder* builder,
57 const GrFragmentProcessor& effect, 55 const GrFragmentProcessor& effect,
58 const char* outputColor, 56 const char* outputColor,
59 const char* inputColor, 57 const char* inputColor,
60 const TransformedCoordsArray& coords, 58 const TransformedCoordsArray& coords,
61 const TextureSamplerArray& samplers) { 59 const TextureSamplerArray& samplers) {
62 const GrTextureDomain& domain = effect.cast<GrBicubicEffect>().domain(); 60 const GrTextureDomain& domain = effect.cast<GrBicubicEffect>().domain();
63 61
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 } 131 }
134 } 132 }
135 } 133 }
136 134
137 GrBicubicEffect::GrBicubicEffect(GrTexture* texture, 135 GrBicubicEffect::GrBicubicEffect(GrTexture* texture,
138 const SkScalar coefficients[16], 136 const SkScalar coefficients[16],
139 const SkMatrix &matrix, 137 const SkMatrix &matrix,
140 const SkShader::TileMode tileModes[2]) 138 const SkShader::TileMode tileModes[2])
141 : INHERITED(texture, matrix, GrTextureParams(tileModes, GrTextureParams::kNone _FilterMode)) 139 : INHERITED(texture, matrix, GrTextureParams(tileModes, GrTextureParams::kNone _FilterMode))
142 , fDomain(GrTextureDomain::IgnoredDomain()) { 140 , fDomain(GrTextureDomain::IgnoredDomain()) {
141 this->initClassID<GrBicubicEffect>();
143 convert_row_major_scalar_coeffs_to_column_major_floats(fCoefficients, coeffi cients); 142 convert_row_major_scalar_coeffs_to_column_major_floats(fCoefficients, coeffi cients);
144 } 143 }
145 144
146 GrBicubicEffect::GrBicubicEffect(GrTexture* texture, 145 GrBicubicEffect::GrBicubicEffect(GrTexture* texture,
147 const SkScalar coefficients[16], 146 const SkScalar coefficients[16],
148 const SkMatrix &matrix, 147 const SkMatrix &matrix,
149 const SkRect& domain) 148 const SkRect& domain)
150 : INHERITED(texture, matrix, GrTextureParams(SkShader::kClamp_TileMode, 149 : INHERITED(texture, matrix, GrTextureParams(SkShader::kClamp_TileMode,
151 GrTextureParams::kNone_FilterMode )) 150 GrTextureParams::kNone_FilterMode ))
152 , fDomain(domain, GrTextureDomain::kClamp_Mode) { 151 , fDomain(domain, GrTextureDomain::kClamp_Mode) {
152 this->initClassID<GrBicubicEffect>();
153 convert_row_major_scalar_coeffs_to_column_major_floats(fCoefficients, coeffi cients); 153 convert_row_major_scalar_coeffs_to_column_major_floats(fCoefficients, coeffi cients);
154 } 154 }
155 155
156 GrBicubicEffect::~GrBicubicEffect() { 156 GrBicubicEffect::~GrBicubicEffect() {
157 } 157 }
158 158
159 const GrBackendFragmentProcessorFactory& GrBicubicEffect::getFactory() const { 159 void GrBicubicEffect::getGLProcessorKey(const GrGLCaps& caps,
160 return GrTBackendFragmentProcessorFactory<GrBicubicEffect>::getInstance(); 160 GrProcessorKeyBuilder* b) const {
161 GrGLBicubicEffect::GenKey(*this, caps, b);
162 }
163
164 GrGLFragmentProcessor* GrBicubicEffect::createGLInstance() const {
165 return SkNEW_ARGS(GrGLBicubicEffect, (*this));
161 } 166 }
162 167
163 bool GrBicubicEffect::onIsEqual(const GrFragmentProcessor& sBase) const { 168 bool GrBicubicEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
164 const GrBicubicEffect& s = sBase.cast<GrBicubicEffect>(); 169 const GrBicubicEffect& s = sBase.cast<GrBicubicEffect>();
165 return !memcmp(fCoefficients, s.coefficients(), 16) && 170 return !memcmp(fCoefficients, s.coefficients(), 16) &&
166 fDomain == s.fDomain; 171 fDomain == s.fDomain;
167 } 172 }
168 173
169 void GrBicubicEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const { 174 void GrBicubicEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
170 // FIXME: Perhaps we can do better. 175 // FIXME: Perhaps we can do better.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 // Use bilerp to handle rotation or fractional translation. 216 // Use bilerp to handle rotation or fractional translation.
212 *filterMode = GrTextureParams::kBilerp_FilterMode; 217 *filterMode = GrTextureParams::kBilerp_FilterMode;
213 } 218 }
214 return false; 219 return false;
215 } 220 }
216 // When we use the bicubic filtering effect each sample is read from the tex ture using 221 // When we use the bicubic filtering effect each sample is read from the tex ture using
217 // nearest neighbor sampling. 222 // nearest neighbor sampling.
218 *filterMode = GrTextureParams::kNone_FilterMode; 223 *filterMode = GrTextureParams::kNone_FilterMode;
219 return true; 224 return true;
220 } 225 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrBicubicEffect.h ('k') | src/gpu/effects/GrConfigConversionEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698