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

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: cleanup 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
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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 const SkRect& domain) 147 const SkRect& domain)
150 : INHERITED(texture, matrix, GrTextureParams(SkShader::kClamp_TileMode, 148 : INHERITED(texture, matrix, GrTextureParams(SkShader::kClamp_TileMode,
151 GrTextureParams::kNone_FilterMode )) 149 GrTextureParams::kNone_FilterMode ))
152 , fDomain(domain, GrTextureDomain::kClamp_Mode) { 150 , fDomain(domain, GrTextureDomain::kClamp_Mode) {
153 convert_row_major_scalar_coeffs_to_column_major_floats(fCoefficients, coeffi cients); 151 convert_row_major_scalar_coeffs_to_column_major_floats(fCoefficients, coeffi cients);
154 } 152 }
155 153
156 GrBicubicEffect::~GrBicubicEffect() { 154 GrBicubicEffect::~GrBicubicEffect() {
157 } 155 }
158 156
159 const GrBackendFragmentProcessorFactory& GrBicubicEffect::getFactory() const { 157 void GrBicubicEffect::getGLProcessorKey(const GrGLCaps& caps,
160 return GrTBackendFragmentProcessorFactory<GrBicubicEffect>::getInstance(); 158 GrProcessorKeyBuilder* b) const {
159 GrGLBicubicEffect::GenKey(*this, caps, b);
160 }
161
162 GrGLFragmentProcessor* GrBicubicEffect::createGLInstance() const {
163 return SkNEW_ARGS(GrGLBicubicEffect, (*this));
161 } 164 }
162 165
163 bool GrBicubicEffect::onIsEqual(const GrFragmentProcessor& sBase) const { 166 bool GrBicubicEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
164 const GrBicubicEffect& s = sBase.cast<GrBicubicEffect>(); 167 const GrBicubicEffect& s = sBase.cast<GrBicubicEffect>();
165 return !memcmp(fCoefficients, s.coefficients(), 16) && 168 return !memcmp(fCoefficients, s.coefficients(), 16) &&
166 fDomain == s.fDomain; 169 fDomain == s.fDomain;
167 } 170 }
168 171
169 void GrBicubicEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const { 172 void GrBicubicEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
170 // FIXME: Perhaps we can do better. 173 // 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. 214 // Use bilerp to handle rotation or fractional translation.
212 *filterMode = GrTextureParams::kBilerp_FilterMode; 215 *filterMode = GrTextureParams::kBilerp_FilterMode;
213 } 216 }
214 return false; 217 return false;
215 } 218 }
216 // 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
217 // nearest neighbor sampling. 220 // nearest neighbor sampling.
218 *filterMode = GrTextureParams::kNone_FilterMode; 221 *filterMode = GrTextureParams::kNone_FilterMode;
219 return true; 222 return true;
220 } 223 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698