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

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

Issue 26190003: Potentially optimize some GrGLEffects for known input color values (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « src/gpu/effects/GrSimpleTextureEffect.cpp ('k') | src/gpu/gl/GrGLEffect.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 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 "GrTextureDomainEffect.h" 8 #include "GrTextureDomainEffect.h"
9 #include "GrSimpleTextureEffect.h" 9 #include "GrSimpleTextureEffect.h"
10 #include "GrTBackendEffectFactory.h" 10 #include "GrTBackendEffectFactory.h"
11 #include "gl/GrGLEffect.h" 11 #include "gl/GrGLEffect.h"
12 #include "SkFloatingPoint.h" 12 #include "SkFloatingPoint.h"
13 13
14 class GrGLTextureDomainEffect : public GrGLEffect { 14 class GrGLTextureDomainEffect : public GrGLEffect {
15 public: 15 public:
16 GrGLTextureDomainEffect(const GrBackendEffectFactory&, const GrDrawEffect&); 16 GrGLTextureDomainEffect(const GrBackendEffectFactory&, const GrDrawEffect&);
17 17
18 virtual void emitCode(GrGLShaderBuilder*, 18 virtual void emitCode(GrGLShaderBuilder*,
19 const GrDrawEffect&, 19 const GrDrawEffect&,
20 EffectKey, 20 EffectKey,
21 const char* outputColor, 21 const char* outputColor,
22 const char* inputColor, 22 const GrGLSLExpr4& inputColor,
23 const TransformedCoordsArray&, 23 const TransformedCoordsArray&,
24 const TextureSamplerArray&) SK_OVERRIDE; 24 const TextureSamplerArray&) SK_OVERRIDE;
25 25
26 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVER RIDE; 26 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVER RIDE;
27 27
28 static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&); 28 static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&);
29 29
30 private: 30 private:
31 GrGLUniformManager::UniformHandle fNameUni; 31 GrGLUniformManager::UniformHandle fNameUni;
32 GrGLfloat fPrevDomain[4]; 32 GrGLfloat fPrevDomain[4];
33 33
34 typedef GrGLEffect INHERITED; 34 typedef GrGLEffect INHERITED;
35 }; 35 };
36 36
37 GrGLTextureDomainEffect::GrGLTextureDomainEffect(const GrBackendEffectFactory& f actory, 37 GrGLTextureDomainEffect::GrGLTextureDomainEffect(const GrBackendEffectFactory& f actory,
38 const GrDrawEffect&) 38 const GrDrawEffect&)
39 : INHERITED(factory) { 39 : INHERITED(factory) {
40 fPrevDomain[0] = SK_FloatNaN; 40 fPrevDomain[0] = SK_FloatNaN;
41 } 41 }
42 42
43 void GrGLTextureDomainEffect::emitCode(GrGLShaderBuilder* builder, 43 void GrGLTextureDomainEffect::emitCode(GrGLShaderBuilder* builder,
44 const GrDrawEffect& drawEffect, 44 const GrDrawEffect& drawEffect,
45 EffectKey key, 45 EffectKey key,
46 const char* outputColor, 46 const char* outputColor,
47 const char* inputColor, 47 const GrGLSLExpr4& inputColor,
48 const TransformedCoordsArray& coords, 48 const TransformedCoordsArray& coords,
49 const TextureSamplerArray& samplers) { 49 const TextureSamplerArray& samplers) {
50 const GrTextureDomainEffect& texDom = drawEffect.castEffect<GrTextureDomainE ffect>(); 50 const GrTextureDomainEffect& texDom = drawEffect.castEffect<GrTextureDomainE ffect>();
51 51
52 SkString coords2D = builder->ensureFSCoords2D(coords, 0); 52 SkString coords2D = builder->ensureFSCoords2D(coords, 0);
53 const char* domain; 53 const char* domain;
54 fNameUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, 54 fNameUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility,
55 kVec4f_GrSLType, "TexDom", &domain); 55 kVec4f_GrSLType, "TexDom", &domain);
56 if (GrTextureDomainEffect::kClamp_WrapMode == texDom.wrapMode()) { 56 if (GrTextureDomainEffect::kClamp_WrapMode == texDom.wrapMode()) {
57 57
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 const SkMatrix& matrix = GrEffectUnitTest::TestMatrix(random); 212 const SkMatrix& matrix = GrEffectUnitTest::TestMatrix(random);
213 bool bilerp = random->nextBool(); 213 bool bilerp = random->nextBool();
214 GrCoordSet coords = random->nextBool() ? kLocal_GrCoordSet : kPosition_GrCoo rdSet; 214 GrCoordSet coords = random->nextBool() ? kLocal_GrCoordSet : kPosition_GrCoo rdSet;
215 return GrTextureDomainEffect::Create(textures[texIdx], 215 return GrTextureDomainEffect::Create(textures[texIdx],
216 matrix, 216 matrix,
217 domain, 217 domain,
218 wrapMode, 218 wrapMode,
219 bilerp ? GrTextureParams::kBilerp_Filte rMode : GrTextureParams::kNone_FilterMode, 219 bilerp ? GrTextureParams::kBilerp_Filte rMode : GrTextureParams::kNone_FilterMode,
220 coords); 220 coords);
221 } 221 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrSimpleTextureEffect.cpp ('k') | src/gpu/gl/GrGLEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698