| 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 "GrBitmapTextContext.h" | 8 #include "GrBitmapTextContext.h" |
| 9 #include "GrAtlas.h" | 9 #include "GrAtlas.h" |
| 10 #include "GrDefaultGeoProcFactory.h" |
| 10 #include "GrDrawTarget.h" | 11 #include "GrDrawTarget.h" |
| 11 #include "GrFontScaler.h" | 12 #include "GrFontScaler.h" |
| 12 #include "GrIndexBuffer.h" | 13 #include "GrIndexBuffer.h" |
| 13 #include "GrStrokeInfo.h" | 14 #include "GrStrokeInfo.h" |
| 14 #include "GrTexturePriv.h" | 15 #include "GrTexturePriv.h" |
| 15 #include "GrTextStrike.h" | 16 #include "GrTextStrike.h" |
| 16 #include "GrTextStrike_impl.h" | 17 #include "GrTextStrike_impl.h" |
| 17 #include "effects/GrCustomCoordsTextureEffect.h" | |
| 18 #include "effects/GrSimpleTextureEffect.h" | |
| 19 | 18 |
| 20 #include "SkAutoKern.h" | 19 #include "SkAutoKern.h" |
| 21 #include "SkColorPriv.h" | 20 #include "SkColorPriv.h" |
| 22 #include "SkDraw.h" | 21 #include "SkDraw.h" |
| 23 #include "SkDrawProcs.h" | 22 #include "SkDrawProcs.h" |
| 24 #include "SkGlyphCache.h" | 23 #include "SkGlyphCache.h" |
| 25 #include "SkGpuDevice.h" | 24 #include "SkGpuDevice.h" |
| 26 #include "SkGr.h" | 25 #include "SkGr.h" |
| 27 #include "SkPath.h" | 26 #include "SkPath.h" |
| 28 #include "SkRTConf.h" | 27 #include "SkRTConf.h" |
| 29 #include "SkStrokeRec.h" | 28 #include "SkStrokeRec.h" |
| 30 #include "SkTextMapStateProc.h" | 29 #include "SkTextMapStateProc.h" |
| 31 | 30 |
| 31 #include "effects/GrCustomCoordsTextureEffect.h" |
| 32 #include "effects/GrSimpleTextureEffect.h" |
| 33 |
| 32 SK_CONF_DECLARE(bool, c_DumpFontCache, "gpu.dumpFontCache", false, | 34 SK_CONF_DECLARE(bool, c_DumpFontCache, "gpu.dumpFontCache", false, |
| 33 "Dump the contents of the font cache before every purge."); | 35 "Dump the contents of the font cache before every purge."); |
| 34 | 36 |
| 35 namespace { | 37 namespace { |
| 36 // position + texture coord | 38 // position + texture coord |
| 37 extern const GrVertexAttrib gLCDVertexAttribs[] = { | 39 extern const GrVertexAttrib gLCDVertexAttribs[] = { |
| 38 {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding
}, | 40 {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding
}, |
| 39 {kVec2f_GrVertexAttribType, sizeof(SkPoint), kGeometryProcessor_GrVertexAttr
ibBinding} | 41 {kVec2f_GrVertexAttribType, sizeof(SkPoint), kGeometryProcessor_GrVertexAttr
ibBinding} |
| 40 }; | 42 }; |
| 41 | 43 |
| 42 static const size_t kLCDTextVASize = 2 * sizeof(SkPoint); | 44 static const size_t kLCDTextVASize = 2 * sizeof(SkPoint); |
| 43 | 45 |
| 44 // position + local coord | 46 // position + local coord |
| 45 extern const GrVertexAttrib gColorVertexAttribs[] = { | |
| 46 {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding
}, | |
| 47 {kVec2f_GrVertexAttribType, sizeof(SkPoint), kLocalCoord_GrVertexAttribBindi
ng} | |
| 48 }; | |
| 49 | |
| 50 static const size_t kColorTextVASize = 2 * sizeof(SkPoint); | 47 static const size_t kColorTextVASize = 2 * sizeof(SkPoint); |
| 51 | 48 |
| 52 // position + color + texture coord | 49 // position + color + texture coord |
| 53 extern const GrVertexAttrib gGrayVertexAttribs[] = { | 50 extern const GrVertexAttrib gGrayVertexAttribs[] = { |
| 54 {kVec2f_GrVertexAttribType, 0, kPosition_Gr
VertexAttribBinding}, | 51 {kVec2f_GrVertexAttribType, 0, kPosition_Gr
VertexAttribBinding}, |
| 55 {kVec4ub_GrVertexAttribType, sizeof(SkPoint), kColor_GrVer
texAttribBinding}, | 52 {kVec4ub_GrVertexAttribType, sizeof(SkPoint), kColor_GrVer
texAttribBinding}, |
| 56 {kVec2f_GrVertexAttribType, sizeof(SkPoint) + sizeof(GrColor), kGeometryPro
cessor_GrVertexAttribBinding} | 53 {kVec2f_GrVertexAttribType, sizeof(SkPoint) + sizeof(GrColor), kGeometryPro
cessor_GrVertexAttribBinding} |
| 57 }; | 54 }; |
| 58 | 55 |
| 59 static const size_t kGrayTextVASize = 2 * sizeof(SkPoint) + sizeof(GrColor); | 56 static const size_t kGrayTextVASize = 2 * sizeof(SkPoint) + sizeof(GrColor); |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 static void* alloc_vertices(GrDrawTarget* drawTarget, int numVertices, GrMaskFor
mat maskFormat) { | 350 static void* alloc_vertices(GrDrawTarget* drawTarget, int numVertices, GrMaskFor
mat maskFormat) { |
| 354 if (numVertices <= 0) { | 351 if (numVertices <= 0) { |
| 355 return NULL; | 352 return NULL; |
| 356 } | 353 } |
| 357 | 354 |
| 358 // set up attributes | 355 // set up attributes |
| 359 if (kA8_GrMaskFormat == maskFormat) { | 356 if (kA8_GrMaskFormat == maskFormat) { |
| 360 drawTarget->drawState()->setVertexAttribs<gGrayVertexAttribs>( | 357 drawTarget->drawState()->setVertexAttribs<gGrayVertexAttribs>( |
| 361 SK_ARRAY_COUNT(gGrayVertexAttribs), kGrayTex
tVASize); | 358 SK_ARRAY_COUNT(gGrayVertexAttribs), kGrayTex
tVASize); |
| 362 } else if (kARGB_GrMaskFormat == maskFormat) { | 359 } else if (kARGB_GrMaskFormat == maskFormat) { |
| 363 drawTarget->drawState()->setVertexAttribs<gColorVertexAttribs>( | 360 GrDefaultGeoProcFactory::SetAttribs(drawTarget->drawState(), |
| 364 SK_ARRAY_COUNT(gColorVertexAttribs), kColorT
extVASize); | 361 GrDefaultGeoProcFactory::kLocalCoord
_GPType); |
| 365 } else { | 362 } else { |
| 366 drawTarget->drawState()->setVertexAttribs<gLCDVertexAttribs>( | 363 drawTarget->drawState()->setVertexAttribs<gLCDVertexAttribs>( |
| 367 SK_ARRAY_COUNT(gLCDVertexAttribs), kLCDTextV
ASize); | 364 SK_ARRAY_COUNT(gLCDVertexAttribs), kLCDTextV
ASize); |
| 368 } | 365 } |
| 369 void* vertices = NULL; | 366 void* vertices = NULL; |
| 370 bool success = drawTarget->reserveVertexAndIndexSpace(numVertices, | 367 bool success = drawTarget->reserveVertexAndIndexSpace(numVertices, |
| 371 0, | 368 0, |
| 372 &vertices, | 369 &vertices, |
| 373 NULL); | 370 NULL); |
| 374 GrAlwaysAssert(success); | 371 GrAlwaysAssert(success); |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 drawState->setFromPaint(fPaint, SkMatrix::I(), fContext->getRenderTarget()); | 554 drawState->setFromPaint(fPaint, SkMatrix::I(), fContext->getRenderTarget()); |
| 558 | 555 |
| 559 if (fCurrVertex > 0) { | 556 if (fCurrVertex > 0) { |
| 560 // setup our sampler state for our text texture/atlas | 557 // setup our sampler state for our text texture/atlas |
| 561 SkASSERT(SkIsAlign4(fCurrVertex)); | 558 SkASSERT(SkIsAlign4(fCurrVertex)); |
| 562 SkASSERT(fCurrTexture); | 559 SkASSERT(fCurrTexture); |
| 563 GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kNon
e_FilterMode); | 560 GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kNon
e_FilterMode); |
| 564 | 561 |
| 565 // This effect could be stored with one of the cache objects (atlas?) | 562 // This effect could be stored with one of the cache objects (atlas?) |
| 566 if (kARGB_GrMaskFormat == fCurrMaskFormat) { | 563 if (kARGB_GrMaskFormat == fCurrMaskFormat) { |
| 564 drawState->setGeometryProcessor(GrDefaultGeoProcFactory::Create(true
))->unref(); |
| 567 GrFragmentProcessor* fragProcessor = GrSimpleTextureEffect::Create(f
CurrTexture, | 565 GrFragmentProcessor* fragProcessor = GrSimpleTextureEffect::Create(f
CurrTexture, |
| 568 S
kMatrix::I(), | 566 S
kMatrix::I(), |
| 569 p
arams); | 567 p
arams); |
| 570 drawState->addColorProcessor(fragProcessor)->unref(); | 568 drawState->addColorProcessor(fragProcessor)->unref(); |
| 571 } else { | 569 } else { |
| 572 uint32_t textureUniqueID = fCurrTexture->getUniqueID(); | 570 uint32_t textureUniqueID = fCurrTexture->getUniqueID(); |
| 573 if (textureUniqueID != fEffectTextureUniqueID) { | 571 if (textureUniqueID != fEffectTextureUniqueID) { |
| 574 fCachedGeometryProcessor.reset(GrCustomCoordsTextureEffect::Crea
te(fCurrTexture, | 572 fCachedGeometryProcessor.reset(GrCustomCoordsTextureEffect::Crea
te(fCurrTexture, |
| 575
params)); | 573
params)); |
| 576 fEffectTextureUniqueID = textureUniqueID; | 574 fEffectTextureUniqueID = textureUniqueID; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 } | 632 } |
| 635 } | 633 } |
| 636 | 634 |
| 637 inline void GrBitmapTextContext::finish() { | 635 inline void GrBitmapTextContext::finish() { |
| 638 this->flush(); | 636 this->flush(); |
| 639 fTotalVertexCount = 0; | 637 fTotalVertexCount = 0; |
| 640 | 638 |
| 641 GrTextContext::finish(); | 639 GrTextContext::finish(); |
| 642 } | 640 } |
| 643 | 641 |
| OLD | NEW |