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

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

Issue 25474006: Move VertexBuilder to a GrGLFullShaderBuilder subclass (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
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 "GrCustomCoordsTextureEffect.h" 8 #include "GrCustomCoordsTextureEffect.h"
9 #include "gl/GrGLEffect.h" 9 #include "gl/GrGLEffect.h"
10 #include "gl/GrGLSL.h" 10 #include "gl/GrGLSL.h"
11 #include "gl/GrGLTexture.h" 11 #include "gl/GrGLTexture.h"
12 #include "GrTBackendEffectFactory.h" 12 #include "GrTBackendEffectFactory.h"
13 #include "GrTexture.h" 13 #include "GrTexture.h"
14 14
15 class GrGLCustomCoordsTextureEffect : public GrGLEffect { 15 class GrGLCustomCoordsTextureEffect : public GrGLVertexEffect {
16 public: 16 public:
17 GrGLCustomCoordsTextureEffect(const GrBackendEffectFactory& factory, const G rDrawEffect& drawEffect) 17 GrGLCustomCoordsTextureEffect(const GrBackendEffectFactory& factory, const G rDrawEffect& drawEffect)
18 : INHERITED (factory) {} 18 : INHERITED (factory) {}
19 19
20 virtual void emitCode(GrGLShaderBuilder* builder, 20 virtual void emitCode(GrGLFullShaderBuilder* builder,
21 const GrDrawEffect& drawEffect, 21 const GrDrawEffect& drawEffect,
22 EffectKey key, 22 EffectKey key,
23 const char* outputColor, 23 const char* outputColor,
24 const char* inputColor, 24 const char* inputColor,
25 const TransformedCoordsArray&, 25 const TransformedCoordsArray&,
26 const TextureSamplerArray& samplers) SK_OVERRIDE { 26 const TextureSamplerArray& samplers) SK_OVERRIDE {
27 GrGLShaderBuilder::VertexBuilder* vertexBuilder = builder->getVertexBuil der();
28 SkASSERT(NULL != vertexBuilder);
29 SkASSERT(1 == drawEffect.castEffect<GrCustomCoordsTextureEffect>().numVe rtexAttribs()); 27 SkASSERT(1 == drawEffect.castEffect<GrCustomCoordsTextureEffect>().numVe rtexAttribs());
30 28
31 SkString fsCoordName; 29 SkString fsCoordName;
32 const char* vsVaryingName; 30 const char* vsVaryingName;
33 const char* fsVaryingNamePtr; 31 const char* fsVaryingNamePtr;
34 vertexBuilder->addVarying(kVec2f_GrSLType, "textureCoords", &vsVaryingNa me, &fsVaryingNamePtr); 32 builder->addVarying(kVec2f_GrSLType, "textureCoords", &vsVaryingName, &f sVaryingNamePtr);
35 fsCoordName = fsVaryingNamePtr; 33 fsCoordName = fsVaryingNamePtr;
36 34
37 const char* attrName = 35 const char* attrName =
38 vertexBuilder->getEffectAttributeName(drawEffect.getVertexAttribIndi ces()[0])->c_str(); 36 builder->getEffectAttributeName(drawEffect.getVertexAttribIndices()[ 0])->c_str();
39 vertexBuilder->vsCodeAppendf("\t%s = %s;\n", vsVaryingName, attrName); 37 builder->vsCodeAppendf("\t%s = %s;\n", vsVaryingName, attrName);
40 38
41 builder->fsCodeAppendf("\t%s = ", outputColor); 39 builder->fsCodeAppendf("\t%s = ", outputColor);
42 builder->fsAppendTextureLookupAndModulate(inputColor, 40 builder->fsAppendTextureLookupAndModulate(inputColor,
43 samplers[0], 41 samplers[0],
44 fsCoordName.c_str(), 42 fsCoordName.c_str(),
45 kVec2f_GrSLType); 43 kVec2f_GrSLType);
46 builder->fsCodeAppend(";\n"); 44 builder->fsCodeAppend(";\n");
47 } 45 }
48 46
49 virtual void setData(const GrGLUniformManager& uman, 47 virtual void setData(const GrGLUniformManager& uman,
50 const GrDrawEffect& drawEffect) SK_OVERRIDE {} 48 const GrDrawEffect& drawEffect) SK_OVERRIDE {}
51 49
52 private: 50 private:
53 typedef GrGLEffect INHERITED; 51 typedef GrGLVertexEffect INHERITED;
54 }; 52 };
55 53
56 /////////////////////////////////////////////////////////////////////////////// 54 ///////////////////////////////////////////////////////////////////////////////
57 55
58 GrCustomCoordsTextureEffect::GrCustomCoordsTextureEffect(GrTexture* texture, 56 GrCustomCoordsTextureEffect::GrCustomCoordsTextureEffect(GrTexture* texture,
59 const GrTextureParams& params) 57 const GrTextureParams& params)
60 : fTextureAccess(texture, params) { 58 : fTextureAccess(texture, params) {
61 this->addTextureAccess(&fTextureAccess); 59 this->addTextureAccess(&fTextureAccess);
62 this->addVertexAttrib(kVec2f_GrSLType); 60 this->addVertexAttrib(kVec2f_GrSLType);
63 } 61 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 }; 96 };
99 SkShader::TileMode tileModes[] = { 97 SkShader::TileMode tileModes[] = {
100 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], 98 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
101 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], 99 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
102 }; 100 };
103 GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBil erp_FilterMode : 101 GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBil erp_FilterMode :
104 GrTextureParams::kNon e_FilterMode); 102 GrTextureParams::kNon e_FilterMode);
105 103
106 return GrCustomCoordsTextureEffect::Create(textures[texIdx], params); 104 return GrCustomCoordsTextureEffect::Create(textures[texIdx], params);
107 } 105 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698