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

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

Issue 648463003: FPs now use the correct builder types(just a rename) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 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
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" 8 #include "gl/builders/GrGLProgramBuilder.h"
9 #include "GrBicubicEffect.h" 9 #include "GrBicubicEffect.h"
10 10
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 GrBackendProcessorFactory& factory,
25 const GrProcessor&); 25 const GrProcessor&);
26 26
27 virtual void emitCode(GrGLProgramBuilder*, 27 virtual void emitCode(GrGLFPBuilder*,
28 const GrFragmentProcessor&, 28 const GrFragmentProcessor&,
29 const GrProcessorKey&, 29 const GrProcessorKey&,
30 const char* outputColor, 30 const char* outputColor,
31 const char* inputColor, 31 const char* inputColor,
32 const TransformedCoordsArray&, 32 const TransformedCoordsArray&,
33 const TextureSamplerArray&) SK_OVERRIDE; 33 const TextureSamplerArray&) SK_OVERRIDE;
34 34
35 virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_O VERRIDE; 35 virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_O VERRIDE;
36 36
37 static inline void GenKey(const GrProcessor& effect, const GrGLCaps&, 37 static inline void GenKey(const GrProcessor& effect, const GrGLCaps&,
38 GrProcessorKeyBuilder* b) { 38 GrProcessorKeyBuilder* b) {
39 const GrTextureDomain& domain = effect.cast<GrBicubicEffect>().domain(); 39 const GrTextureDomain& domain = effect.cast<GrBicubicEffect>().domain();
40 b->add32(GrTextureDomain::GLDomain::DomainKey(domain)); 40 b->add32(GrTextureDomain::GLDomain::DomainKey(domain));
41 } 41 }
42 42
43 private: 43 private:
44 typedef GrGLProgramDataManager::UniformHandle UniformHandle; 44 typedef GrGLProgramDataManager::UniformHandle UniformHandle;
45 45
46 UniformHandle fCoefficientsUni; 46 UniformHandle fCoefficientsUni;
47 UniformHandle fImageIncrementUni; 47 UniformHandle fImageIncrementUni;
48 GrTextureDomain::GLDomain fDomain; 48 GrTextureDomain::GLDomain fDomain;
49 49
50 typedef GrGLFragmentProcessor INHERITED; 50 typedef GrGLFragmentProcessor INHERITED;
51 }; 51 };
52 52
53 GrGLBicubicEffect::GrGLBicubicEffect(const GrBackendProcessorFactory& factory, c onst GrProcessor&) 53 GrGLBicubicEffect::GrGLBicubicEffect(const GrBackendProcessorFactory& factory, c onst GrProcessor&)
54 : INHERITED(factory) { 54 : INHERITED(factory) {
55 } 55 }
56 56
57 void GrGLBicubicEffect::emitCode(GrGLProgramBuilder* builder, 57 void GrGLBicubicEffect::emitCode(GrGLFPBuilder* builder,
58 const GrFragmentProcessor& effect, 58 const GrFragmentProcessor& effect,
59 const GrProcessorKey& key, 59 const GrProcessorKey& key,
60 const char* outputColor, 60 const char* outputColor,
61 const char* inputColor, 61 const char* inputColor,
62 const TransformedCoordsArray& coords, 62 const TransformedCoordsArray& coords,
63 const TextureSamplerArray& samplers) { 63 const TextureSamplerArray& samplers) {
64 const GrTextureDomain& domain = effect.cast<GrBicubicEffect>().domain(); 64 const GrTextureDomain& domain = effect.cast<GrBicubicEffect>().domain();
65 65
66 fCoefficientsUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibil ity, 66 fCoefficientsUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibil ity,
67 kMat44f_GrSLType, "Coefficients"); 67 kMat44f_GrSLType, "Coefficients");
68 fImageIncrementUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visib ility, 68 fImageIncrementUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visib ility,
69 kVec2f_GrSLType, "ImageIncrement"); 69 kVec2f_GrSLType, "ImageIncrement");
70 70
71 const char* imgInc = builder->getUniformCStr(fImageIncrementUni); 71 const char* imgInc = builder->getUniformCStr(fImageIncrementUni);
72 const char* coeff = builder->getUniformCStr(fCoefficientsUni); 72 const char* coeff = builder->getUniformCStr(fCoefficientsUni);
73 73
74 SkString cubicBlendName; 74 SkString cubicBlendName;
75 75
76 static const GrGLShaderVar gCubicBlendArgs[] = { 76 static const GrGLShaderVar gCubicBlendArgs[] = {
77 GrGLShaderVar("coefficients", kMat44f_GrSLType), 77 GrGLShaderVar("coefficients", kMat44f_GrSLType),
78 GrGLShaderVar("t", kFloat_GrSLType), 78 GrGLShaderVar("t", kFloat_GrSLType),
79 GrGLShaderVar("c0", kVec4f_GrSLType), 79 GrGLShaderVar("c0", kVec4f_GrSLType),
80 GrGLShaderVar("c1", kVec4f_GrSLType), 80 GrGLShaderVar("c1", kVec4f_GrSLType),
81 GrGLShaderVar("c2", kVec4f_GrSLType), 81 GrGLShaderVar("c2", kVec4f_GrSLType),
82 GrGLShaderVar("c3", kVec4f_GrSLType), 82 GrGLShaderVar("c3", kVec4f_GrSLType),
83 }; 83 };
84 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder(); 84 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
85 SkString coords2D = fsBuilder->ensureFSCoords2D(coords, 0); 85 SkString coords2D = fsBuilder->ensureFSCoords2D(coords, 0);
86 fsBuilder->emitFunction(kVec4f_GrSLType, 86 fsBuilder->emitFunction(kVec4f_GrSLType,
87 "cubicBlend", 87 "cubicBlend",
88 SK_ARRAY_COUNT(gCubicBlendArgs), 88 SK_ARRAY_COUNT(gCubicBlendArgs),
89 gCubicBlendArgs, 89 gCubicBlendArgs,
90 "\tvec4 ts = vec4(1.0, t, t * t, t * t * t);\n" 90 "\tvec4 ts = vec4(1.0, t, t * t, t * t * t);\n"
91 "\tvec4 c = coefficients * ts;\n" 91 "\tvec4 c = coefficients * ts;\n"
92 "\treturn c.x * c0 + c.y * c1 + c.z * c2 + c.w * c3; \n", 92 "\treturn c.x * c0 + c.y * c1 + c.z * c2 + c.w * c3; \n",
93 &cubicBlendName); 93 &cubicBlendName);
94 fsBuilder->codeAppendf("\tvec2 coord = %s - %s * vec2(0.5);\n", coords2D.c_s tr(), imgInc); 94 fsBuilder->codeAppendf("\tvec2 coord = %s - %s * vec2(0.5);\n", coords2D.c_s tr(), imgInc);
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 // Use bilerp to handle rotation or fractional translation. 216 // Use bilerp to handle rotation or fractional translation.
217 *filterMode = GrTextureParams::kBilerp_FilterMode; 217 *filterMode = GrTextureParams::kBilerp_FilterMode;
218 } 218 }
219 return false; 219 return false;
220 } 220 }
221 // 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
222 // nearest neighbor sampling. 222 // nearest neighbor sampling.
223 *filterMode = GrTextureParams::kNone_FilterMode; 223 *filterMode = GrTextureParams::kNone_FilterMode;
224 return true; 224 return true;
225 } 225 }
OLDNEW
« no previous file with comments | « src/effects/gradients/SkTwoPointRadialGradient.cpp ('k') | src/gpu/effects/GrConfigConversionEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698