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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 static void* alloc_vertices(GrDrawTarget* drawTarget, int numVertices, GrMaskFor
mat maskFormat) { | 354 static void* alloc_vertices(GrDrawTarget* drawTarget, int numVertices, GrMaskFor
mat maskFormat) { |
358 if (numVertices <= 0) { | 355 if (numVertices <= 0) { |
359 return NULL; | 356 return NULL; |
360 } | 357 } |
361 | 358 |
362 // set up attributes | 359 // set up attributes |
363 if (kA8_GrMaskFormat == maskFormat) { | 360 if (kA8_GrMaskFormat == maskFormat) { |
364 drawTarget->drawState()->setVertexAttribs<gGrayVertexAttribs>( | 361 drawTarget->drawState()->setVertexAttribs<gGrayVertexAttribs>( |
365 SK_ARRAY_COUNT(gGrayVertexAttribs), kGrayTex
tVASize); | 362 SK_ARRAY_COUNT(gGrayVertexAttribs), kGrayTex
tVASize); |
366 } else if (kARGB_GrMaskFormat == maskFormat) { | 363 } else if (kARGB_GrMaskFormat == maskFormat) { |
367 drawTarget->drawState()->setVertexAttribs<gColorVertexAttribs>( | 364 GrDefaultGeoProcFactory::SetAttribs(drawTarget->drawState(), |
368 SK_ARRAY_COUNT(gColorVertexAttribs), kColorT
extVASize); | 365 GrDefaultGeoProcFactory::kLocalCoord
_GPType); |
369 } else { | 366 } else { |
370 drawTarget->drawState()->setVertexAttribs<gLCDVertexAttribs>( | 367 drawTarget->drawState()->setVertexAttribs<gLCDVertexAttribs>( |
371 SK_ARRAY_COUNT(gLCDVertexAttribs), kLCDTextV
ASize); | 368 SK_ARRAY_COUNT(gLCDVertexAttribs), kLCDTextV
ASize); |
372 } | 369 } |
373 void* vertices = NULL; | 370 void* vertices = NULL; |
374 bool success = drawTarget->reserveVertexAndIndexSpace(numVertices, | 371 bool success = drawTarget->reserveVertexAndIndexSpace(numVertices, |
375 0, | 372 0, |
376 &vertices, | 373 &vertices, |
377 NULL); | 374 NULL); |
378 GrAlwaysAssert(success); | 375 GrAlwaysAssert(success); |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 drawState->setFromPaint(fPaint, SkMatrix::I(), fContext->getRenderTarget()); | 558 drawState->setFromPaint(fPaint, SkMatrix::I(), fContext->getRenderTarget()); |
562 | 559 |
563 if (fCurrVertex > 0) { | 560 if (fCurrVertex > 0) { |
564 // setup our sampler state for our text texture/atlas | 561 // setup our sampler state for our text texture/atlas |
565 SkASSERT(SkIsAlign4(fCurrVertex)); | 562 SkASSERT(SkIsAlign4(fCurrVertex)); |
566 SkASSERT(fCurrTexture); | 563 SkASSERT(fCurrTexture); |
567 GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kNon
e_FilterMode); | 564 GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kNon
e_FilterMode); |
568 | 565 |
569 // This effect could be stored with one of the cache objects (atlas?) | 566 // This effect could be stored with one of the cache objects (atlas?) |
570 if (kARGB_GrMaskFormat == fCurrMaskFormat) { | 567 if (kARGB_GrMaskFormat == fCurrMaskFormat) { |
| 568 drawState->setGeometryProcessor(GrDefaultGeoProcFactory::Create(true
))->unref(); |
571 GrFragmentProcessor* fragProcessor = GrSimpleTextureEffect::Create(f
CurrTexture, | 569 GrFragmentProcessor* fragProcessor = GrSimpleTextureEffect::Create(f
CurrTexture, |
572 S
kMatrix::I(), | 570 S
kMatrix::I(), |
573 p
arams); | 571 p
arams); |
574 drawState->addColorProcessor(fragProcessor)->unref(); | 572 drawState->addColorProcessor(fragProcessor)->unref(); |
575 } else { | 573 } else { |
576 uint32_t textureUniqueID = fCurrTexture->getUniqueID(); | 574 uint32_t textureUniqueID = fCurrTexture->getUniqueID(); |
577 if (textureUniqueID != fEffectTextureUniqueID) { | 575 if (textureUniqueID != fEffectTextureUniqueID) { |
578 fCachedGeometryProcessor.reset(GrCustomCoordsTextureEffect::Crea
te(fCurrTexture, | 576 fCachedGeometryProcessor.reset(GrCustomCoordsTextureEffect::Crea
te(fCurrTexture, |
579
params)); | 577
params)); |
580 fEffectTextureUniqueID = textureUniqueID; | 578 fEffectTextureUniqueID = textureUniqueID; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 } | 637 } |
640 } | 638 } |
641 | 639 |
642 inline void GrBitmapTextContext::finish() { | 640 inline void GrBitmapTextContext::finish() { |
643 this->flush(); | 641 this->flush(); |
644 fTotalVertexCount = 0; | 642 fTotalVertexCount = 0; |
645 | 643 |
646 GrTextContext::finish(); | 644 GrTextContext::finish(); |
647 } | 645 } |
648 | 646 |
OLD | NEW |