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

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

Issue 786293002: Rename CustomCoordTextureEffect to GrBitmapTextGeoProc. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Review updates Created 6 years 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/GrBitmapTextGeoProc.h ('k') | src/gpu/effects/GrCustomCoordsTextureEffect.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 "GrBitmapTextGeoProc.h"
9 #include "GrInvariantOutput.h" 9 #include "GrInvariantOutput.h"
10 #include "GrTexture.h" 10 #include "GrTexture.h"
11 #include "gl/GrGLProcessor.h" 11 #include "gl/GrGLProcessor.h"
12 #include "gl/GrGLSL.h" 12 #include "gl/GrGLSL.h"
13 #include "gl/GrGLTexture.h" 13 #include "gl/GrGLTexture.h"
14 #include "gl/GrGLGeometryProcessor.h" 14 #include "gl/GrGLGeometryProcessor.h"
15 #include "gl/builders/GrGLProgramBuilder.h" 15 #include "gl/builders/GrGLProgramBuilder.h"
16 16
17 class GrGLCustomCoordsTextureEffect : public GrGLGeometryProcessor { 17 class GrGLBitmapTextGeoProc : public GrGLGeometryProcessor {
18 public: 18 public:
19 GrGLCustomCoordsTextureEffect(const GrGeometryProcessor&, 19 GrGLBitmapTextGeoProc(const GrGeometryProcessor&, const GrBatchTracker&) {}
20 const GrBatchTracker&) {}
21 20
22 virtual void emitCode(const EmitArgs& args) SK_OVERRIDE { 21 virtual void emitCode(const EmitArgs& args) SK_OVERRIDE {
23 const GrCustomCoordsTextureEffect& cte = 22 const GrBitmapTextGeoProc& cte = args.fGP.cast<GrBitmapTextGeoProc>();
24 args.fGP.cast<GrCustomCoordsTextureEffect>();
25 23
26 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); 24 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
27 25
28 GrGLVertToFrag v(kVec2f_GrSLType); 26 GrGLVertToFrag v(kVec2f_GrSLType);
29 args.fPB->addVarying("TextureCoords", &v); 27 args.fPB->addVarying("TextureCoords", &v);
30 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), cte.inTextureCoords()->fNa me); 28 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), cte.inTextureCoords()->fNa me);
31 29
32 if (cte.inColor()) { 30 if (cte.inColor()) {
33 args.fPB->addPassThroughAttribute(cte.inColor(), args.fOutputColor); 31 args.fPB->addPassThroughAttribute(cte.inColor(), args.fOutputColor);
34 } 32 }
(...skipping 13 matching lines...) Expand all
48 } 46 }
49 47
50 virtual void setData(const GrGLProgramDataManager&, 48 virtual void setData(const GrGLProgramDataManager&,
51 const GrGeometryProcessor&, 49 const GrGeometryProcessor&,
52 const GrBatchTracker&) SK_OVERRIDE {} 50 const GrBatchTracker&) SK_OVERRIDE {}
53 51
54 static inline void GenKey(const GrGeometryProcessor& proc, 52 static inline void GenKey(const GrGeometryProcessor& proc,
55 const GrBatchTracker&, 53 const GrBatchTracker&,
56 const GrGLCaps&, 54 const GrGLCaps&,
57 GrProcessorKeyBuilder* b) { 55 GrProcessorKeyBuilder* b) {
58 const GrCustomCoordsTextureEffect& gp = proc.cast<GrCustomCoordsTextureE ffect>(); 56 const GrBitmapTextGeoProc& gp = proc.cast<GrBitmapTextGeoProc>();
59 57
60 b->add32(SkToBool(gp.inColor())); 58 b->add32(SkToBool(gp.inColor()));
61 } 59 }
62 60
63 61
64 private: 62 private:
65 typedef GrGLGeometryProcessor INHERITED; 63 typedef GrGLGeometryProcessor INHERITED;
66 }; 64 };
67 65
68 /////////////////////////////////////////////////////////////////////////////// 66 ///////////////////////////////////////////////////////////////////////////////
69 67
70 GrCustomCoordsTextureEffect::GrCustomCoordsTextureEffect(GrTexture* texture, 68 GrBitmapTextGeoProc::GrBitmapTextGeoProc(GrTexture* texture, const GrTexturePara ms& params,
71 const GrTextureParams& params, 69 bool useColorAttrib)
72 bool hasColor)
73 : fTextureAccess(texture, params), fInColor(NULL) { 70 : fTextureAccess(texture, params), fInColor(NULL) {
74 this->initClassID<GrCustomCoordsTextureEffect>(); 71 this->initClassID<GrBitmapTextGeoProc>();
75 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVert exAttribType)); 72 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVert exAttribType));
76 if (hasColor) { 73 if (useColorAttrib) {
77 fInColor = &this->addVertexAttrib(GrAttribute("inColor", kVec4ub_GrVerte xAttribType)); 74 fInColor = &this->addVertexAttrib(GrAttribute("inColor", kVec4ub_GrVerte xAttribType));
78 this->setHasVertexColor(); 75 this->setHasVertexColor();
79 } 76 }
80 fInTextureCoords = &this->addVertexAttrib(GrAttribute("inTextureCoords", 77 fInTextureCoords = &this->addVertexAttrib(GrAttribute("inTextureCoords",
81 kVec2f_GrVertexAttribT ype)); 78 kVec2f_GrVertexAttribT ype));
82 this->addTextureAccess(&fTextureAccess); 79 this->addTextureAccess(&fTextureAccess);
83 } 80 }
84 81
85 bool GrCustomCoordsTextureEffect::onIsEqual(const GrGeometryProcessor& other) co nst { 82 bool GrBitmapTextGeoProc::onIsEqual(const GrGeometryProcessor& other) const {
86 const GrCustomCoordsTextureEffect& gp = other.cast<GrCustomCoordsTextureEffe ct>(); 83 const GrBitmapTextGeoProc& gp = other.cast<GrBitmapTextGeoProc>();
87 return SkToBool(this->inColor()) == SkToBool(gp.inColor()); 84 return SkToBool(this->inColor()) == SkToBool(gp.inColor());
88 } 85 }
89 86
90 void GrCustomCoordsTextureEffect::onComputeInvariantOutput(GrInvariantOutput* in out) const { 87 void GrBitmapTextGeoProc::onComputeInvariantOutput(GrInvariantOutput* inout) con st {
91 if (GrPixelConfigIsAlphaOnly(this->texture(0)->config())) { 88 if (GrPixelConfigIsAlphaOnly(this->texture(0)->config())) {
92 inout->mulByUnknownAlpha(); 89 inout->mulByUnknownAlpha();
93 } else if (GrPixelConfigIsOpaque(this->texture(0)->config())) { 90 } else if (GrPixelConfigIsOpaque(this->texture(0)->config())) {
94 inout->mulByUnknownOpaqueColor(); 91 inout->mulByUnknownOpaqueColor();
92 inout->setUsingLCDCoverage();
95 } else { 93 } else {
96 inout->mulByUnknownColor(); 94 inout->mulByUnknownColor();
95 inout->setUsingLCDCoverage();
97 } 96 }
98 } 97 }
99 98
100 void GrCustomCoordsTextureEffect::getGLProcessorKey(const GrBatchTracker& bt, 99 void GrBitmapTextGeoProc::getGLProcessorKey(const GrBatchTracker& bt,
101 const GrGLCaps& caps, 100 const GrGLCaps& caps,
102 GrProcessorKeyBuilder* b) co nst { 101 GrProcessorKeyBuilder* b) const {
103 GrGLCustomCoordsTextureEffect::GenKey(*this, bt, caps, b); 102 GrGLBitmapTextGeoProc::GenKey(*this, bt, caps, b);
104 } 103 }
105 104
106 GrGLGeometryProcessor* 105 GrGLGeometryProcessor*
107 GrCustomCoordsTextureEffect::createGLInstance(const GrBatchTracker& bt) const { 106 GrBitmapTextGeoProc::createGLInstance(const GrBatchTracker& bt) const {
108 return SkNEW_ARGS(GrGLCustomCoordsTextureEffect, (*this, bt)); 107 return SkNEW_ARGS(GrGLBitmapTextGeoProc, (*this, bt));
109 } 108 }
110 /////////////////////////////////////////////////////////////////////////////// 109 ///////////////////////////////////////////////////////////////////////////////
111 110
112 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrCustomCoordsTextureEffect); 111 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrBitmapTextGeoProc);
113 112
114 GrGeometryProcessor* GrCustomCoordsTextureEffect::TestCreate(SkRandom* random, 113 GrGeometryProcessor* GrBitmapTextGeoProc::TestCreate(SkRandom* random,
115 GrContext*, 114 GrContext*,
116 const GrDrawTargetC aps&, 115 const GrDrawTargetCaps&,
117 GrTexture* textures []) { 116 GrTexture* textures[]) {
118 int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : 117 int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
119 GrProcessorUnitTest::kAlphaTextureIdx; 118 GrProcessorUnitTest::kAlphaTextureIdx;
120 static const SkShader::TileMode kTileModes[] = { 119 static const SkShader::TileMode kTileModes[] = {
121 SkShader::kClamp_TileMode, 120 SkShader::kClamp_TileMode,
122 SkShader::kRepeat_TileMode, 121 SkShader::kRepeat_TileMode,
123 SkShader::kMirror_TileMode, 122 SkShader::kMirror_TileMode,
124 }; 123 };
125 SkShader::TileMode tileModes[] = { 124 SkShader::TileMode tileModes[] = {
126 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], 125 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
127 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], 126 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
128 }; 127 };
129 GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBil erp_FilterMode : 128 GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBil erp_FilterMode :
130 GrTextureParams::kNon e_FilterMode); 129 GrTextureParams::kNon e_FilterMode);
131 130
132 return GrCustomCoordsTextureEffect::Create(textures[texIdx], params, random- >nextBool()); 131 return GrBitmapTextGeoProc::Create(textures[texIdx], params, random->nextBoo l());
133 } 132 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrBitmapTextGeoProc.h ('k') | src/gpu/effects/GrCustomCoordsTextureEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698