| OLD | NEW |
| 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 "GrBitmapTextGeoProc.h" | 8 #include "GrBitmapTextGeoProc.h" |
| 9 #include "GrInvariantOutput.h" | 9 #include "GrInvariantOutput.h" |
| 10 #include "GrTexture.h" | 10 #include "GrTexture.h" |
| 11 #include "gl/GrGLGeometryProcessor.h" | |
| 12 #include "glsl/GrGLSLFragmentProcessor.h" | |
| 13 #include "glsl/GrGLSLFragmentShaderBuilder.h" | 11 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
| 12 #include "glsl/GrGLSLGeometryProcessor.h" |
| 14 #include "glsl/GrGLSLProgramBuilder.h" | 13 #include "glsl/GrGLSLProgramBuilder.h" |
| 15 #include "glsl/GrGLSLProgramDataManager.h" | 14 #include "glsl/GrGLSLProgramDataManager.h" |
| 16 #include "glsl/GrGLSLVertexShaderBuilder.h" | 15 #include "glsl/GrGLSLVertexShaderBuilder.h" |
| 17 | 16 |
| 18 class GrGLBitmapTextGeoProc : public GrGLGeometryProcessor { | 17 class GrGLBitmapTextGeoProc : public GrGLSLGeometryProcessor { |
| 19 public: | 18 public: |
| 20 GrGLBitmapTextGeoProc() : fColor(GrColor_ILLEGAL) {} | 19 GrGLBitmapTextGeoProc() : fColor(GrColor_ILLEGAL) {} |
| 21 | 20 |
| 22 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override { | 21 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override { |
| 23 const GrBitmapTextGeoProc& cte = args.fGP.cast<GrBitmapTextGeoProc>(); | 22 const GrBitmapTextGeoProc& cte = args.fGP.cast<GrBitmapTextGeoProc>(); |
| 24 | 23 |
| 25 GrGLSLGPBuilder* pb = args.fPB; | 24 GrGLSLGPBuilder* pb = args.fPB; |
| 26 GrGLSLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder(); | 25 GrGLSLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder(); |
| 27 | 26 |
| 28 // emit attributes | 27 // emit attributes |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 GrTexture* atlas = gp.textureAccess(0).getTexture(); | 111 GrTexture* atlas = gp.textureAccess(0).getTexture(); |
| 113 SkASSERT(atlas); | 112 SkASSERT(atlas); |
| 114 b->add32(atlas->width()); | 113 b->add32(atlas->width()); |
| 115 b->add32(atlas->height()); | 114 b->add32(atlas->height()); |
| 116 } | 115 } |
| 117 | 116 |
| 118 private: | 117 private: |
| 119 GrColor fColor; | 118 GrColor fColor; |
| 120 UniformHandle fColorUniform; | 119 UniformHandle fColorUniform; |
| 121 | 120 |
| 122 typedef GrGLGeometryProcessor INHERITED; | 121 typedef GrGLSLGeometryProcessor INHERITED; |
| 123 }; | 122 }; |
| 124 | 123 |
| 125 /////////////////////////////////////////////////////////////////////////////// | 124 /////////////////////////////////////////////////////////////////////////////// |
| 126 | 125 |
| 127 GrBitmapTextGeoProc::GrBitmapTextGeoProc(GrColor color, GrTexture* texture, | 126 GrBitmapTextGeoProc::GrBitmapTextGeoProc(GrColor color, GrTexture* texture, |
| 128 const GrTextureParams& params, GrMaskFo
rmat format, | 127 const GrTextureParams& params, GrMaskFo
rmat format, |
| 129 const SkMatrix& localMatrix, bool usesL
ocalCoords) | 128 const SkMatrix& localMatrix, bool usesL
ocalCoords) |
| 130 : fColor(color) | 129 : fColor(color) |
| 131 , fLocalMatrix(localMatrix) | 130 , fLocalMatrix(localMatrix) |
| 132 , fUsesLocalCoords(usesLocalCoords) | 131 , fUsesLocalCoords(usesLocalCoords) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 144 } | 143 } |
| 145 fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords", | 144 fInTextureCoords = &this->addVertexAttrib(Attribute("inTextureCoords", |
| 146 kVec2s_GrVertexAttribTyp
e)); | 145 kVec2s_GrVertexAttribTyp
e)); |
| 147 this->addTextureAccess(&fTextureAccess); | 146 this->addTextureAccess(&fTextureAccess); |
| 148 } | 147 } |
| 149 | 148 |
| 150 void GrBitmapTextGeoProc::getGLProcessorKey(const GrGLSLCaps& caps,GrProcessorKe
yBuilder* b) const { | 149 void GrBitmapTextGeoProc::getGLProcessorKey(const GrGLSLCaps& caps,GrProcessorKe
yBuilder* b) const { |
| 151 GrGLBitmapTextGeoProc::GenKey(*this, caps, b); | 150 GrGLBitmapTextGeoProc::GenKey(*this, caps, b); |
| 152 } | 151 } |
| 153 | 152 |
| 154 GrGLPrimitiveProcessor* GrBitmapTextGeoProc::createGLInstance(const GrGLSLCaps&
caps) const { | 153 GrGLSLPrimitiveProcessor* GrBitmapTextGeoProc::createGLInstance(const GrGLSLCaps
& caps) const { |
| 155 return new GrGLBitmapTextGeoProc(); | 154 return new GrGLBitmapTextGeoProc(); |
| 156 } | 155 } |
| 157 | 156 |
| 158 /////////////////////////////////////////////////////////////////////////////// | 157 /////////////////////////////////////////////////////////////////////////////// |
| 159 | 158 |
| 160 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrBitmapTextGeoProc); | 159 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrBitmapTextGeoProc); |
| 161 | 160 |
| 162 const GrGeometryProcessor* GrBitmapTextGeoProc::TestCreate(GrProcessorTestData*
d) { | 161 const GrGeometryProcessor* GrBitmapTextGeoProc::TestCreate(GrProcessorTestData*
d) { |
| 163 int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
: | 162 int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
: |
| 164 GrProcessorUnitTest::kAlphaTextureIdx; | 163 GrProcessorUnitTest::kAlphaTextureIdx; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 184 break; | 183 break; |
| 185 case 2: | 184 case 2: |
| 186 format = kARGB_GrMaskFormat; | 185 format = kARGB_GrMaskFormat; |
| 187 break; | 186 break; |
| 188 } | 187 } |
| 189 | 188 |
| 190 return GrBitmapTextGeoProc::Create(GrRandomColor(d->fRandom), d->fTextures[t
exIdx], params, | 189 return GrBitmapTextGeoProc::Create(GrRandomColor(d->fRandom), d->fTextures[t
exIdx], params, |
| 191 format, GrTest::TestMatrix(d->fRandom), | 190 format, GrTest::TestMatrix(d->fRandom), |
| 192 d->fRandom->nextBool()); | 191 d->fRandom->nextBool()); |
| 193 } | 192 } |
| OLD | NEW |