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

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

Issue 635533005: Revert of Cleanup of shader building system (Closed) Base URL: https://skia.googlesource.com/skia.git@solo_gp
Patch Set: Created 6 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
« no previous file with comments | « src/gpu/effects/GrBezierEffect.cpp ('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 "GrCustomCoordsTextureEffect.h" 8 #include "GrCustomCoordsTextureEffect.h"
9 #include "gl/builders/GrGLProgramBuilder.h" 9 #include "gl/builders/GrGLFullProgramBuilder.h"
10 #include "gl/GrGLProcessor.h" 10 #include "gl/GrGLProcessor.h"
11 #include "gl/GrGLSL.h" 11 #include "gl/GrGLSL.h"
12 #include "gl/GrGLTexture.h" 12 #include "gl/GrGLTexture.h"
13 #include "gl/GrGLGeometryProcessor.h" 13 #include "gl/GrGLGeometryProcessor.h"
14 #include "GrTBackendProcessorFactory.h" 14 #include "GrTBackendProcessorFactory.h"
15 #include "GrTexture.h" 15 #include "GrTexture.h"
16 16
17 class GrGLCustomCoordsTextureEffect : public GrGLGeometryProcessor { 17 class GrGLCustomCoordsTextureEffect : public GrGLGeometryProcessor {
18 public: 18 public:
19 GrGLCustomCoordsTextureEffect(const GrBackendProcessorFactory& factory, cons t GrProcessor&) 19 GrGLCustomCoordsTextureEffect(const GrBackendProcessorFactory& factory, cons t GrProcessor&)
20 : INHERITED (factory) {} 20 : INHERITED (factory) {}
21 21
22 virtual void emitCode(GrGLGPBuilder* builder, 22 virtual void emitCode(GrGLFullProgramBuilder* builder,
23 const GrGeometryProcessor& geometryProcessor, 23 const GrGeometryProcessor& geometryProcessor,
24 const GrProcessorKey& key, 24 const GrProcessorKey& 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 const GrCustomCoordsTextureEffect& customCoordsTextureEffect = 29 const GrCustomCoordsTextureEffect& customCoordsTextureEffect =
30 geometryProcessor.cast<GrCustomCoordsTextureEffect>(); 30 geometryProcessor.cast<GrCustomCoordsTextureEffect>();
31 SkASSERT(1 == customCoordsTextureEffect.getVertexAttribs().count()); 31 SkASSERT(1 == customCoordsTextureEffect.getVertexAttribs().count());
32 32
33 SkString fsCoordName; 33 SkString fsCoordName;
34 const char* vsVaryingName; 34 const char* vsVaryingName;
35 const char* fsVaryingNamePtr; 35 const char* fsVaryingNamePtr;
36 builder->addVarying(kVec2f_GrSLType, "textureCoords", &vsVaryingName, &f sVaryingNamePtr); 36 builder->addVarying(kVec2f_GrSLType, "textureCoords", &vsVaryingName, &f sVaryingNamePtr);
37 fsCoordName = fsVaryingNamePtr; 37 fsCoordName = fsVaryingNamePtr;
38 38
39 GrGLVertexBuilder* vsBuilder = builder->getVertexShaderBuilder(); 39 GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder();
40 const GrShaderVar& inTextureCoords = customCoordsTextureEffect.inTexture Coords(); 40 const GrShaderVar& inTextureCoords = customCoordsTextureEffect.inTexture Coords();
41 vsBuilder->codeAppendf("\t%s = %s;\n", vsVaryingName, inTextureCoords.c_ str()); 41 vsBuilder->codeAppendf("\t%s = %s;\n", vsVaryingName, inTextureCoords.c_ str());
42 42
43 GrGLGPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); 43 GrGLProcessorFragmentShaderBuilder* fsBuilder = builder->getFragmentShad erBuilder();
44 fsBuilder->codeAppendf("\t%s = ", outputColor); 44 fsBuilder->codeAppendf("\t%s = ", outputColor);
45 fsBuilder->appendTextureLookupAndModulate(inputColor, 45 fsBuilder->appendTextureLookupAndModulate(inputColor,
46 samplers[0], 46 samplers[0],
47 fsCoordName.c_str(), 47 fsCoordName.c_str(),
48 kVec2f_GrSLType); 48 kVec2f_GrSLType);
49 fsBuilder->codeAppend(";\n"); 49 fsBuilder->codeAppend(";\n");
50 } 50 }
51 51
52 virtual void setData(const GrGLProgramDataManager&, 52 virtual void setData(const GrGLProgramDataManager&,
53 const GrProcessor&) SK_OVERRIDE {} 53 const GrProcessor&) SK_OVERRIDE {}
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 }; 102 };
103 SkShader::TileMode tileModes[] = { 103 SkShader::TileMode tileModes[] = {
104 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], 104 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
105 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], 105 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
106 }; 106 };
107 GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBil erp_FilterMode : 107 GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBil erp_FilterMode :
108 GrTextureParams::kNon e_FilterMode); 108 GrTextureParams::kNon e_FilterMode);
109 109
110 return GrCustomCoordsTextureEffect::Create(textures[texIdx], params); 110 return GrCustomCoordsTextureEffect::Create(textures[texIdx], params);
111 } 111 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrBezierEffect.cpp ('k') | src/gpu/effects/GrDashingEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698