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

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

Powered by Google App Engine
This is Rietveld 408576698