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

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

Issue 571163002: removing GrDrawEffect (Closed) Base URL: https://skia.googlesource.com/skia.git@gp3
Patch Set: rebase after revert 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/GrConvolutionEffect.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 "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/GrGLGeometryProcessor.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 GrGLGeometryProcessor { 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 rEffect& effect)
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 GrEffect& effect,
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 const GrCustomCoordsTextureEffect& customCoordsTextureEffect = 29 const GrCustomCoordsTextureEffect& customCoordsTextureEffect =
30 drawEffect.castEffect<GrCustomCoordsTextureEffect>(); 30 effect.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 GrGLVertexShaderBuilder* 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 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder (); 43 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder ();
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& pdman, 52 virtual void setData(const GrGLProgramDataManager& pdman,
53 const GrDrawEffect& drawEffect) SK_OVERRIDE {} 53 const GrEffect& effect) SK_OVERRIDE {}
54 54
55 private: 55 private:
56 typedef GrGLGeometryProcessor INHERITED; 56 typedef GrGLGeometryProcessor INHERITED;
57 }; 57 };
58 58
59 /////////////////////////////////////////////////////////////////////////////// 59 ///////////////////////////////////////////////////////////////////////////////
60 60
61 GrCustomCoordsTextureEffect::GrCustomCoordsTextureEffect(GrTexture* texture, 61 GrCustomCoordsTextureEffect::GrCustomCoordsTextureEffect(GrTexture* texture,
62 const GrTextureParams& params) 62 const GrTextureParams& params)
63 : fTextureAccess(texture, params) 63 : fTextureAccess(texture, params)
64 , fInTextureCoords(this->addVertexAttrib(GrShaderVar("inTextureCoords", 64 , fInTextureCoords(this->addVertexAttrib(GrShaderVar("inTextureCoords",
65 kVec2f_GrSLType, 65 kVec2f_GrSLType,
66 GrShaderVar::kAttribute _TypeModifier))) { 66 GrShaderVar::kAttribute _TypeModifier))) {
67 this->addTextureAccess(&fTextureAccess); 67 this->addTextureAccess(&fTextureAccess);
68 } 68 }
69 69
70 bool GrCustomCoordsTextureEffect::onIsEqual(const GrEffect& other) const { 70 bool GrCustomCoordsTextureEffect::onIsEqual(const GrEffect& other) const {
71 const GrCustomCoordsTextureEffect& cte = CastEffect<GrCustomCoordsTextureEff ect>(other); 71 const GrCustomCoordsTextureEffect& cte = other.cast<GrCustomCoordsTextureEff ect>();
72 return fTextureAccess == cte.fTextureAccess; 72 return fTextureAccess == cte.fTextureAccess;
73 } 73 }
74 74
75 void GrCustomCoordsTextureEffect::getConstantColorComponents(GrColor* color, 75 void GrCustomCoordsTextureEffect::getConstantColorComponents(GrColor* color,
76 uint32_t* validFlag s) const { 76 uint32_t* validFlag s) const {
77 if ((*validFlags & kA_GrColorComponentFlag) && 0xFF == GrColorUnpackA(*color ) && 77 if ((*validFlags & kA_GrColorComponentFlag) && 0xFF == GrColorUnpackA(*color ) &&
78 GrPixelConfigIsOpaque(this->texture(0)->config())) { 78 GrPixelConfigIsOpaque(this->texture(0)->config())) {
79 *validFlags = kA_GrColorComponentFlag; 79 *validFlags = kA_GrColorComponentFlag;
80 } else { 80 } else {
81 *validFlags = 0; 81 *validFlags = 0;
(...skipping 21 matching lines...) Expand all
103 }; 103 };
104 SkShader::TileMode tileModes[] = { 104 SkShader::TileMode tileModes[] = {
105 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], 105 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
106 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], 106 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
107 }; 107 };
108 GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBil erp_FilterMode : 108 GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBil erp_FilterMode :
109 GrTextureParams::kNon e_FilterMode); 109 GrTextureParams::kNon e_FilterMode);
110 110
111 return GrCustomCoordsTextureEffect::Create(textures[texIdx], params); 111 return GrCustomCoordsTextureEffect::Create(textures[texIdx], params);
112 } 112 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrConvolutionEffect.cpp ('k') | src/gpu/effects/GrDashingEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698