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

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

Issue 571163002: removing GrDrawEffect (Closed) Base URL: https://skia.googlesource.com/skia.git@gp3
Patch Set: rebase after revert Created 6 years, 3 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/effects/GrBicubicEffect.cpp ('k') | src/gpu/effects/GrConvexPolyEffect.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 2012 Google Inc. 2 * Copyright 2012 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 "GrConfigConversionEffect.h" 8 #include "GrConfigConversionEffect.h"
9 #include "GrContext.h" 9 #include "GrContext.h"
10 #include "GrTBackendEffectFactory.h" 10 #include "GrTBackendEffectFactory.h"
11 #include "GrSimpleTextureEffect.h" 11 #include "GrSimpleTextureEffect.h"
12 #include "gl/GrGLEffect.h" 12 #include "gl/GrGLEffect.h"
13 #include "gl/builders/GrGLProgramBuilder.h" 13 #include "gl/builders/GrGLProgramBuilder.h"
14 #include "SkMatrix.h" 14 #include "SkMatrix.h"
15 15
16 class GrGLConfigConversionEffect : public GrGLEffect { 16 class GrGLConfigConversionEffect : public GrGLEffect {
17 public: 17 public:
18 GrGLConfigConversionEffect(const GrBackendEffectFactory& factory, 18 GrGLConfigConversionEffect(const GrBackendEffectFactory& factory,
19 const GrDrawEffect& drawEffect) 19 const GrEffect& effect)
20 : INHERITED (factory) { 20 : INHERITED (factory) {
21 const GrConfigConversionEffect& effect = drawEffect.castEffect<GrConfigC onversionEffect>(); 21 const GrConfigConversionEffect& configConversionEffect = effect.cast<GrC onfigConversionEffect>();
22 fSwapRedAndBlue = effect.swapsRedAndBlue(); 22 fSwapRedAndBlue = configConversionEffect.swapsRedAndBlue();
23 fPMConversion = effect.pmConversion(); 23 fPMConversion = configConversionEffect.pmConversion();
24 } 24 }
25 25
26 virtual void emitCode(GrGLProgramBuilder* builder, 26 virtual void emitCode(GrGLProgramBuilder* builder,
27 const GrDrawEffect&, 27 const GrEffect&,
28 const GrEffectKey& key, 28 const GrEffectKey& key,
29 const char* outputColor, 29 const char* outputColor,
30 const char* inputColor, 30 const char* inputColor,
31 const TransformedCoordsArray& coords, 31 const TransformedCoordsArray& coords,
32 const TextureSamplerArray& samplers) SK_OVERRIDE { 32 const TextureSamplerArray& samplers) SK_OVERRIDE {
33 // Using highp for GLES here in order to avoid some precision issues on specific GPUs. 33 // Using highp for GLES here in order to avoid some precision issues on specific GPUs.
34 GrGLShaderVar tmpVar("tmpColor", kVec4f_GrSLType, 0, GrGLShaderVar::kHig h_Precision); 34 GrGLShaderVar tmpVar("tmpColor", kVec4f_GrSLType, 0, GrGLShaderVar::kHig h_Precision);
35 SkString tmpDecl; 35 SkString tmpDecl;
36 tmpVar.appendDecl(builder->ctxInfo(), &tmpDecl); 36 tmpVar.appendDecl(builder->ctxInfo(), &tmpDecl);
37 37
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 SkFAIL("Unknown conversion op."); 77 SkFAIL("Unknown conversion op.");
78 break; 78 break;
79 } 79 }
80 fsBuilder->codeAppendf("%s = %s;", outputColor, tmpVar.c_str()); 80 fsBuilder->codeAppendf("%s = %s;", outputColor, tmpVar.c_str());
81 } 81 }
82 SkString modulate; 82 SkString modulate;
83 GrGLSLMulVarBy4f(&modulate, 2, outputColor, inputColor); 83 GrGLSLMulVarBy4f(&modulate, 2, outputColor, inputColor);
84 fsBuilder->codeAppend(modulate.c_str()); 84 fsBuilder->codeAppend(modulate.c_str());
85 } 85 }
86 86
87 static inline void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&, 87 static inline void GenKey(const GrEffect& effect, const GrGLCaps&,
88 GrEffectKeyBuilder* b) { 88 GrEffectKeyBuilder* b) {
89 const GrConfigConversionEffect& conv = drawEffect.castEffect<GrConfigCon versionEffect>(); 89 const GrConfigConversionEffect& conv = effect.cast<GrConfigConversionEff ect>();
90 uint32_t key = (conv.swapsRedAndBlue() ? 0 : 1) | (conv.pmConversion() < < 1); 90 uint32_t key = (conv.swapsRedAndBlue() ? 0 : 1) | (conv.pmConversion() < < 1);
91 b->add32(key); 91 b->add32(key);
92 } 92 }
93 93
94 private: 94 private:
95 bool fSwapRedAndBlue; 95 bool fSwapRedAndBlue;
96 GrConfigConversionEffect::PMConversion fPMConversion; 96 GrConfigConversionEffect::PMConversion fPMConversion;
97 97
98 typedef GrGLEffect INHERITED; 98 typedef GrGLEffect INHERITED;
99 99
(...skipping 12 matching lines...) Expand all
112 kBGRA_8888_GrPixelConfig == texture->config()); 112 kBGRA_8888_GrPixelConfig == texture->config());
113 // Why did we pollute our texture cache instead of using a GrSingleTextureEf fect? 113 // Why did we pollute our texture cache instead of using a GrSingleTextureEf fect?
114 SkASSERT(swapRedAndBlue || kNone_PMConversion != pmConversion); 114 SkASSERT(swapRedAndBlue || kNone_PMConversion != pmConversion);
115 } 115 }
116 116
117 const GrBackendEffectFactory& GrConfigConversionEffect::getFactory() const { 117 const GrBackendEffectFactory& GrConfigConversionEffect::getFactory() const {
118 return GrTBackendEffectFactory<GrConfigConversionEffect>::getInstance(); 118 return GrTBackendEffectFactory<GrConfigConversionEffect>::getInstance();
119 } 119 }
120 120
121 bool GrConfigConversionEffect::onIsEqual(const GrEffect& s) const { 121 bool GrConfigConversionEffect::onIsEqual(const GrEffect& s) const {
122 const GrConfigConversionEffect& other = CastEffect<GrConfigConversionEffect> (s); 122 const GrConfigConversionEffect& other = s.cast<GrConfigConversionEffect>();
123 return this->texture(0) == s.texture(0) && 123 return this->texture(0) == s.texture(0) &&
124 other.fSwapRedAndBlue == fSwapRedAndBlue && 124 other.fSwapRedAndBlue == fSwapRedAndBlue &&
125 other.fPMConversion == fPMConversion; 125 other.fPMConversion == fPMConversion;
126 } 126 }
127 127
128 void GrConfigConversionEffect::getConstantColorComponents(GrColor* color, 128 void GrConfigConversionEffect::getConstantColorComponents(GrColor* color,
129 uint32_t* validFlags) const { 129 uint32_t* validFlags) const {
130 this->updateConstantColorComponentsForModulation(color, validFlags); 130 this->updateConstantColorComponentsForModulation(color, validFlags);
131 } 131 }
132 132
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 kNone_PMConversion != pmConversion) { 278 kNone_PMConversion != pmConversion) {
279 // The PM conversions assume colors are 0..255 279 // The PM conversions assume colors are 0..255
280 return NULL; 280 return NULL;
281 } 281 }
282 return SkNEW_ARGS(GrConfigConversionEffect, (texture, 282 return SkNEW_ARGS(GrConfigConversionEffect, (texture,
283 swapRedAndBlue, 283 swapRedAndBlue,
284 pmConversion, 284 pmConversion,
285 matrix)); 285 matrix));
286 } 286 }
287 } 287 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrBicubicEffect.cpp ('k') | src/gpu/effects/GrConvexPolyEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698