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

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

Issue 543623004: Removing vertex attrib indices (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: warning fixed 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/GrCustomCoordsTextureEffect.h ('k') | src/gpu/effects/GrDashingEffect.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 2013 Google Inc. 2 * Copyright 2013 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 "GrCustomCoordsTextureEffect.h" 9 #include "GrCustomCoordsTextureEffect.h"
10 #include "gl/GrGLEffect.h" 10 #include "gl/GrGLEffect.h"
11 #include "gl/GrGLSL.h" 11 #include "gl/GrGLSL.h"
12 #include "gl/GrGLTexture.h" 12 #include "gl/GrGLTexture.h"
13 #include "gl/GrGLVertexEffect.h" 13 #include "gl/GrGLGeometryProcessor.h"
14 #include "GrTBackendEffectFactory.h" 14 #include "GrTBackendEffectFactory.h"
15 #include "GrTexture.h" 15 #include "GrTexture.h"
16 16
17 class GrGLCustomCoordsTextureEffect : public GrGLVertexEffect { 17 class GrGLCustomCoordsTextureEffect : public GrGLGeometryProcessor {
18 public: 18 public:
19 GrGLCustomCoordsTextureEffect(const GrBackendEffectFactory& factory, const G rDrawEffect& drawEffect) 19 GrGLCustomCoordsTextureEffect(const GrBackendEffectFactory& factory, const G rDrawEffect& drawEffect)
20 : INHERITED (factory) {} 20 : INHERITED (factory) {}
21 21
22 virtual void emitCode(GrGLFullProgramBuilder* builder, 22 virtual void emitCode(GrGLFullProgramBuilder* builder,
23 const GrDrawEffect& drawEffect, 23 const GrDrawEffect& drawEffect,
24 const GrEffectKey& key, 24 const GrEffectKey& key,
25 const char* outputColor, 25 const char* outputColor,
26 const char* inputColor, 26 const char* inputColor,
27 const TransformedCoordsArray&, 27 const TransformedCoordsArray&,
28 const TextureSamplerArray& samplers) SK_OVERRIDE { 28 const TextureSamplerArray& samplers) SK_OVERRIDE {
29 SkASSERT(1 == drawEffect.castEffect<GrCustomCoordsTextureEffect>().numVe rtexAttribs()); 29 const GrCustomCoordsTextureEffect& customCoordsTextureEffect =
30 drawEffect.castEffect<GrCustomCoordsTextureEffect>();
31 SkASSERT(1 == customCoordsTextureEffect.getVertexAttribs().count());
30 32
31 SkString fsCoordName; 33 SkString fsCoordName;
32 const char* vsVaryingName; 34 const char* vsVaryingName;
33 const char* fsVaryingNamePtr; 35 const char* fsVaryingNamePtr;
34 builder->addVarying(kVec2f_GrSLType, "textureCoords", &vsVaryingName, &f sVaryingNamePtr); 36 builder->addVarying(kVec2f_GrSLType, "textureCoords", &vsVaryingName, &f sVaryingNamePtr);
35 fsCoordName = fsVaryingNamePtr; 37 fsCoordName = fsVaryingNamePtr;
36 38
37 GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder(); 39 GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder();
38 const SkString* attr0Name = 40 const GrShaderVar& inTextureCoords = customCoordsTextureEffect.inTexture Coords();
39 vsBuilder->getEffectAttributeName(drawEffect.getVertexAttribIndices( )[0]); 41 vsBuilder->codeAppendf("\t%s = %s;\n", vsVaryingName, inTextureCoords.c_ str());
40 vsBuilder->codeAppendf("\t%s = %s;\n", vsVaryingName, attr0Name->c_str() );
41 42
42 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder (); 43 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder ();
43 fsBuilder->codeAppendf("\t%s = ", outputColor); 44 fsBuilder->codeAppendf("\t%s = ", outputColor);
44 fsBuilder->appendTextureLookupAndModulate(inputColor, 45 fsBuilder->appendTextureLookupAndModulate(inputColor,
45 samplers[0], 46 samplers[0],
46 fsCoordName.c_str(), 47 fsCoordName.c_str(),
47 kVec2f_GrSLType); 48 kVec2f_GrSLType);
48 fsBuilder->codeAppend(";\n"); 49 fsBuilder->codeAppend(";\n");
49 } 50 }
50 51
51 virtual void setData(const GrGLProgramDataManager& pdman, 52 virtual void setData(const GrGLProgramDataManager& pdman,
52 const GrDrawEffect& drawEffect) SK_OVERRIDE {} 53 const GrDrawEffect& drawEffect) SK_OVERRIDE {}
53 54
54 private: 55 private:
55 typedef GrGLVertexEffect INHERITED; 56 typedef GrGLGeometryProcessor INHERITED;
56 }; 57 };
57 58
58 /////////////////////////////////////////////////////////////////////////////// 59 ///////////////////////////////////////////////////////////////////////////////
59 60
60 GrCustomCoordsTextureEffect::GrCustomCoordsTextureEffect(GrTexture* texture, 61 GrCustomCoordsTextureEffect::GrCustomCoordsTextureEffect(GrTexture* texture,
61 const GrTextureParams& params) 62 const GrTextureParams& params)
62 : fTextureAccess(texture, params) { 63 : fTextureAccess(texture, params)
64 , fInTextureCoords(this->addVertexAttrib(GrShaderVar("inTextureCoords",
65 kVec2f_GrSLType,
66 GrShaderVar::kAttribute _TypeModifier))) {
63 this->addTextureAccess(&fTextureAccess); 67 this->addTextureAccess(&fTextureAccess);
64 this->addVertexAttrib(kVec2f_GrSLType);
65 } 68 }
66 69
67 bool GrCustomCoordsTextureEffect::onIsEqual(const GrEffect& other) const { 70 bool GrCustomCoordsTextureEffect::onIsEqual(const GrEffect& other) const {
68 const GrCustomCoordsTextureEffect& cte = CastEffect<GrCustomCoordsTextureEff ect>(other); 71 const GrCustomCoordsTextureEffect& cte = CastEffect<GrCustomCoordsTextureEff ect>(other);
69 return fTextureAccess == cte.fTextureAccess; 72 return fTextureAccess == cte.fTextureAccess;
70 } 73 }
71 74
72 void GrCustomCoordsTextureEffect::getConstantColorComponents(GrColor* color, 75 void GrCustomCoordsTextureEffect::getConstantColorComponents(GrColor* color,
73 uint32_t* validFlag s) const { 76 uint32_t* validFlag s) const {
74 if ((*validFlags & kA_GrColorComponentFlag) && 0xFF == GrColorUnpackA(*color ) && 77 if ((*validFlags & kA_GrColorComponentFlag) && 0xFF == GrColorUnpackA(*color ) &&
(...skipping 25 matching lines...) Expand all
100 }; 103 };
101 SkShader::TileMode tileModes[] = { 104 SkShader::TileMode tileModes[] = {
102 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], 105 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
103 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], 106 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
104 }; 107 };
105 GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBil erp_FilterMode : 108 GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBil erp_FilterMode :
106 GrTextureParams::kNon e_FilterMode); 109 GrTextureParams::kNon e_FilterMode);
107 110
108 return GrCustomCoordsTextureEffect::Create(textures[texIdx], params); 111 return GrCustomCoordsTextureEffect::Create(textures[texIdx], params);
109 } 112 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrCustomCoordsTextureEffect.h ('k') | src/gpu/effects/GrDashingEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698