| 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/GrGLFragmentProcessor.h" |   11 #include "gl/GrGLFragmentProcessor.h" | 
|   12 #include "gl/GrGLTexture.h" |   12 #include "gl/GrGLTexture.h" | 
|   13 #include "gl/GrGLGeometryProcessor.h" |   13 #include "gl/GrGLGeometryProcessor.h" | 
|   14 #include "gl/builders/GrGLProgramBuilder.h" |   14 #include "gl/builders/GrGLProgramBuilder.h" | 
|   15 #include "glsl/GrGLSLProgramDataManager.h" |   15 #include "glsl/GrGLSLProgramDataManager.h" | 
|   16  |   16  | 
|   17 class GrGLBitmapTextGeoProc : public GrGLGeometryProcessor { |   17 class GrGLBitmapTextGeoProc : public GrGLGeometryProcessor { | 
|   18 public: |   18 public: | 
|   19     GrGLBitmapTextGeoProc() : fColor(GrColor_ILLEGAL) {} |   19     GrGLBitmapTextGeoProc() : fColor(GrColor_ILLEGAL) {} | 
|   20  |   20  | 
|   21     void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override { |   21     void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override { | 
|   22         const GrBitmapTextGeoProc& cte = args.fGP.cast<GrBitmapTextGeoProc>(); |   22         const GrBitmapTextGeoProc& cte = args.fGP.cast<GrBitmapTextGeoProc>(); | 
|   23  |   23  | 
|   24         GrGLGPBuilder* pb = args.fPB; |   24         GrGLSLGPBuilder* pb = args.fPB; | 
|   25         GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder(); |   25         GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder(); | 
|   26  |   26  | 
|   27         // emit attributes |   27         // emit attributes | 
|   28         vsBuilder->emitAttributes(cte); |   28         vsBuilder->emitAttributes(cte); | 
|   29  |   29  | 
|   30         // compute numbers to be hardcoded to convert texture coordinates from i
     nt to float |   30         // compute numbers to be hardcoded to convert texture coordinates from i
     nt to float | 
|   31         SkASSERT(cte.numTextures() == 1); |   31         SkASSERT(cte.numTextures() == 1); | 
|   32         GrTexture* atlas = cte.textureAccess(0).getTexture(); |   32         GrTexture* atlas = cte.textureAccess(0).getTexture(); | 
|   33         SkASSERT(atlas && SkIsPow2(atlas->width()) && SkIsPow2(atlas->height()))
     ; |   33         SkASSERT(atlas && SkIsPow2(atlas->width()) && SkIsPow2(atlas->height()))
     ; | 
|   34         SkScalar recipWidth = 1.0f / atlas->width(); |   34         SkScalar recipWidth = 1.0f / atlas->width(); | 
|   35         SkScalar recipHeight = 1.0f / atlas->height(); |   35         SkScalar recipHeight = 1.0f / atlas->height(); | 
|   36  |   36  | 
|   37         GrGLVertToFrag v(kVec2f_GrSLType); |   37         GrGLSLVertToFrag v(kVec2f_GrSLType); | 
|   38         pb->addVarying("TextureCoords", &v); |   38         pb->addVarying("TextureCoords", &v); | 
|   39         vsBuilder->codeAppendf("%s = vec2(%.*f, %.*f) * %s;", v.vsOut(), |   39         vsBuilder->codeAppendf("%s = vec2(%.*f, %.*f) * %s;", v.vsOut(), | 
|   40                                GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipWidth, |   40                                GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipWidth, | 
|   41                                GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipHeight, |   41                                GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipHeight, | 
|   42                                cte.inTextureCoords()->fName); |   42                                cte.inTextureCoords()->fName); | 
|   43  |   43  | 
|   44         // Setup pass through color |   44         // Setup pass through color | 
|   45         if (!cte.colorIgnored()) { |   45         if (!cte.colorIgnored()) { | 
|   46             if (cte.hasVertexColor()) { |   46             if (cte.hasVertexColor()) { | 
|   47                 pb->addPassThroughAttribute(cte.inColor(), args.fOutputColor); |   47                 pb->addPassThroughAttribute(cte.inColor(), args.fOutputColor); | 
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  183             break; |  183             break; | 
|  184         case 2: |  184         case 2: | 
|  185             format = kARGB_GrMaskFormat; |  185             format = kARGB_GrMaskFormat; | 
|  186             break; |  186             break; | 
|  187     } |  187     } | 
|  188  |  188  | 
|  189     return GrBitmapTextGeoProc::Create(GrRandomColor(d->fRandom), d->fTextures[t
     exIdx], params, |  189     return GrBitmapTextGeoProc::Create(GrRandomColor(d->fRandom), d->fTextures[t
     exIdx], params, | 
|  190                                        format, GrTest::TestMatrix(d->fRandom), |  190                                        format, GrTest::TestMatrix(d->fRandom), | 
|  191                                        d->fRandom->nextBool()); |  191                                        d->fRandom->nextBool()); | 
|  192 } |  192 } | 
| OLD | NEW |