| 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 "GrFontAtlasSizes.h" | 9 #include "GrFontAtlasSizes.h" |
| 10 #include "GrInvariantOutput.h" | 10 #include "GrInvariantOutput.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 GrGLGPBuilder* pb = args.fPB; | 25 GrGLGPBuilder* pb = args.fPB; |
| 26 GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder(); | 26 GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder(); |
| 27 | 27 |
| 28 // emit attributes | 28 // emit attributes |
| 29 vsBuilder->emitAttributes(cte); | 29 vsBuilder->emitAttributes(cte); |
| 30 | 30 |
| 31 // compute numbers to be hardcoded to convert texture coordinates from i
nt to float | 31 // compute numbers to be hardcoded to convert texture coordinates from i
nt to float |
| 32 SkASSERT(cte.numTextures() == 1); | 32 SkASSERT(cte.numTextures() == 1); |
| 33 GrTexture* atlas = cte.textureAccess(0).getTexture(); | 33 GrTexture* atlas = cte.textureAccess(0).getTexture(); |
| 34 SkASSERT(atlas); | 34 SkASSERT(atlas && SkIsPow2(atlas->width()) && SkIsPow2(atlas->height()))
; |
| 35 SkScalar recipWidth = 1.0f / atlas->width(); | 35 SkScalar recipWidth = 1.0f / atlas->width(); |
| 36 SkScalar recipHeight = 1.0f / atlas->height(); | 36 SkScalar recipHeight = 1.0f / atlas->height(); |
| 37 | 37 |
| 38 GrGLVertToFrag v(kVec2f_GrSLType); | 38 GrGLVertToFrag v(kVec2f_GrSLType); |
| 39 pb->addVarying("TextureCoords", &v); | 39 pb->addVarying("TextureCoords", &v); |
| 40 vsBuilder->codeAppendf("%s = vec2(%.*f, %.*f) * %s;", v.vsOut(), | 40 vsBuilder->codeAppendf("%s = vec2(%.*f, %.*f) * %s;", v.vsOut(), |
| 41 SK_FLT_DECIMAL_DIG, recipWidth, | 41 GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipWidth, |
| 42 SK_FLT_DECIMAL_DIG, recipHeight, | 42 GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipHeight, |
| 43 cte.inTextureCoords()->fName); | 43 cte.inTextureCoords()->fName); |
| 44 | 44 |
| 45 // Setup pass through color | 45 // Setup pass through color |
| 46 if (!cte.colorIgnored()) { | 46 if (!cte.colorIgnored()) { |
| 47 if (cte.hasVertexColor()) { | 47 if (cte.hasVertexColor()) { |
| 48 pb->addPassThroughAttribute(cte.inColor(), args.fOutputColor); | 48 pb->addPassThroughAttribute(cte.inColor(), args.fOutputColor); |
| 49 } else { | 49 } else { |
| 50 this->setupUniformColor(pb, args.fOutputColor, &fColorUniform); | 50 this->setupUniformColor(pb, args.fOutputColor, &fColorUniform); |
| 51 } | 51 } |
| 52 } | 52 } |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 break; | 185 break; |
| 186 case 2: | 186 case 2: |
| 187 format = kARGB_GrMaskFormat; | 187 format = kARGB_GrMaskFormat; |
| 188 break; | 188 break; |
| 189 } | 189 } |
| 190 | 190 |
| 191 return GrBitmapTextGeoProc::Create(GrRandomColor(d->fRandom), d->fTextures[t
exIdx], params, | 191 return GrBitmapTextGeoProc::Create(GrRandomColor(d->fRandom), d->fTextures[t
exIdx], params, |
| 192 format, GrTest::TestMatrix(d->fRandom), | 192 format, GrTest::TestMatrix(d->fRandom), |
| 193 d->fRandom->nextBool()); | 193 d->fRandom->nextBool()); |
| 194 } | 194 } |
| OLD | NEW |