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

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 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
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 =
22 fSwapRedAndBlue = effect.swapsRedAndBlue(); 22 GrEffect::CastEffect<GrConfigConversionEffect>(effect);
23 fPMConversion = effect.pmConversion(); 23 fSwapRedAndBlue = configConversionEffect.swapsRedAndBlue();
24 fPMConversion = configConversionEffect.pmConversion();
24 } 25 }
25 26
26 virtual void emitCode(GrGLProgramBuilder* builder, 27 virtual void emitCode(GrGLProgramBuilder* builder,
27 const GrDrawEffect&, 28 const GrEffect&,
28 const GrEffectKey& key, 29 const GrEffectKey& key,
29 const char* outputColor, 30 const char* outputColor,
30 const char* inputColor, 31 const char* inputColor,
31 const TransformedCoordsArray& coords, 32 const TransformedCoordsArray& coords,
32 const TextureSamplerArray& samplers) SK_OVERRIDE { 33 const TextureSamplerArray& samplers) SK_OVERRIDE {
33 // Using highp for GLES here in order to avoid some precision issues on specific GPUs. 34 // 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); 35 GrGLShaderVar tmpVar("tmpColor", kVec4f_GrSLType, 0, GrGLShaderVar::kHig h_Precision);
35 SkString tmpDecl; 36 SkString tmpDecl;
36 tmpVar.appendDecl(builder->ctxInfo(), &tmpDecl); 37 tmpVar.appendDecl(builder->ctxInfo(), &tmpDecl);
37 38
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 SkFAIL("Unknown conversion op."); 78 SkFAIL("Unknown conversion op.");
78 break; 79 break;
79 } 80 }
80 fsBuilder->codeAppendf("%s = %s;", outputColor, tmpVar.c_str()); 81 fsBuilder->codeAppendf("%s = %s;", outputColor, tmpVar.c_str());
81 } 82 }
82 SkString modulate; 83 SkString modulate;
83 GrGLSLMulVarBy4f(&modulate, 2, outputColor, inputColor); 84 GrGLSLMulVarBy4f(&modulate, 2, outputColor, inputColor);
84 fsBuilder->codeAppend(modulate.c_str()); 85 fsBuilder->codeAppend(modulate.c_str());
85 } 86 }
86 87
87 static inline void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&, 88 static inline void GenKey(const GrEffect& effect, const GrGLCaps&,
88 GrEffectKeyBuilder* b) { 89 GrEffectKeyBuilder* b) {
89 const GrConfigConversionEffect& conv = drawEffect.castEffect<GrConfigCon versionEffect>(); 90 const GrConfigConversionEffect& conv =
91 GrEffect::CastEffect<GrConfigConversionEffect>(effect);
90 uint32_t key = (conv.swapsRedAndBlue() ? 0 : 1) | (conv.pmConversion() < < 1); 92 uint32_t key = (conv.swapsRedAndBlue() ? 0 : 1) | (conv.pmConversion() < < 1);
91 b->add32(key); 93 b->add32(key);
92 } 94 }
93 95
94 private: 96 private:
95 bool fSwapRedAndBlue; 97 bool fSwapRedAndBlue;
96 GrConfigConversionEffect::PMConversion fPMConversion; 98 GrConfigConversionEffect::PMConversion fPMConversion;
97 99
98 typedef GrGLEffect INHERITED; 100 typedef GrGLEffect INHERITED;
99 101
(...skipping 12 matching lines...) Expand all
112 kBGRA_8888_GrPixelConfig == texture->config()); 114 kBGRA_8888_GrPixelConfig == texture->config());
113 // Why did we pollute our texture cache instead of using a GrSingleTextureEf fect? 115 // Why did we pollute our texture cache instead of using a GrSingleTextureEf fect?
114 SkASSERT(swapRedAndBlue || kNone_PMConversion != pmConversion); 116 SkASSERT(swapRedAndBlue || kNone_PMConversion != pmConversion);
115 } 117 }
116 118
117 const GrBackendEffectFactory& GrConfigConversionEffect::getFactory() const { 119 const GrBackendEffectFactory& GrConfigConversionEffect::getFactory() const {
118 return GrTBackendEffectFactory<GrConfigConversionEffect>::getInstance(); 120 return GrTBackendEffectFactory<GrConfigConversionEffect>::getInstance();
119 } 121 }
120 122
121 bool GrConfigConversionEffect::onIsEqual(const GrEffect& s) const { 123 bool GrConfigConversionEffect::onIsEqual(const GrEffect& s) const {
122 const GrConfigConversionEffect& other = CastEffect<GrConfigConversionEffect> (s); 124 const GrConfigConversionEffect& other = GrEffect::CastEffect<GrConfigConvers ionEffect>(s);
123 return this->texture(0) == s.texture(0) && 125 return this->texture(0) == s.texture(0) &&
124 other.fSwapRedAndBlue == fSwapRedAndBlue && 126 other.fSwapRedAndBlue == fSwapRedAndBlue &&
125 other.fPMConversion == fPMConversion; 127 other.fPMConversion == fPMConversion;
126 } 128 }
127 129
128 void GrConfigConversionEffect::getConstantColorComponents(GrColor* color, 130 void GrConfigConversionEffect::getConstantColorComponents(GrColor* color,
129 uint32_t* validFlags) const { 131 uint32_t* validFlags) const {
130 this->updateConstantColorComponentsForModulation(color, validFlags); 132 this->updateConstantColorComponentsForModulation(color, validFlags);
131 } 133 }
132 134
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 kNone_PMConversion != pmConversion) { 280 kNone_PMConversion != pmConversion) {
279 // The PM conversions assume colors are 0..255 281 // The PM conversions assume colors are 0..255
280 return NULL; 282 return NULL;
281 } 283 }
282 return SkNEW_ARGS(GrConfigConversionEffect, (texture, 284 return SkNEW_ARGS(GrConfigConversionEffect, (texture,
283 swapRedAndBlue, 285 swapRedAndBlue,
284 pmConversion, 286 pmConversion,
285 matrix)); 287 matrix));
286 } 288 }
287 } 289 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698