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 "GrDefaultGeoProcFactory.h" |
11 #include "GrDrawTarget.h" | 11 #include "GrDrawTarget.h" |
12 #include "GrFontCache.h" | 12 #include "GrFontCache.h" |
13 #include "GrFontScaler.h" | 13 #include "GrFontScaler.h" |
14 #include "GrIndexBuffer.h" | 14 #include "GrIndexBuffer.h" |
15 #include "GrStrokeInfo.h" | 15 #include "GrStrokeInfo.h" |
16 #include "GrTexturePriv.h" | 16 #include "GrTexturePriv.h" |
17 | 17 |
18 #include "SkAutoKern.h" | 18 #include "SkAutoKern.h" |
19 #include "SkColorPriv.h" | 19 #include "SkColorPriv.h" |
20 #include "SkDraw.h" | 20 #include "SkDraw.h" |
21 #include "SkDrawProcs.h" | 21 #include "SkDrawProcs.h" |
22 #include "SkGlyphCache.h" | 22 #include "SkGlyphCache.h" |
23 #include "SkGpuDevice.h" | 23 #include "SkGpuDevice.h" |
24 #include "SkGr.h" | 24 #include "SkGr.h" |
25 #include "SkPath.h" | 25 #include "SkPath.h" |
26 #include "SkRTConf.h" | 26 #include "SkRTConf.h" |
27 #include "SkStrokeRec.h" | 27 #include "SkStrokeRec.h" |
28 #include "SkTextMapStateProc.h" | 28 #include "SkTextMapStateProc.h" |
29 | 29 |
30 #include "effects/GrCustomCoordsTextureEffect.h" | 30 #include "effects/GrBitmapTextGeoProc.h" |
31 #include "effects/GrSimpleTextureEffect.h" | 31 #include "effects/GrSimpleTextureEffect.h" |
32 | 32 |
33 SK_CONF_DECLARE(bool, c_DumpFontCache, "gpu.dumpFontCache", false, | 33 SK_CONF_DECLARE(bool, c_DumpFontCache, "gpu.dumpFontCache", false, |
34 "Dump the contents of the font cache before every purge."); | 34 "Dump the contents of the font cache before every purge."); |
35 | 35 |
36 namespace { | 36 namespace { |
37 static const size_t kLCDTextVASize = 2 * sizeof(SkPoint); | 37 static const size_t kLCDTextVASize = 2 * sizeof(SkPoint); |
38 | 38 |
39 // position + local coord | 39 // position + local coord |
40 static const size_t kColorTextVASize = 2 * sizeof(SkPoint); | 40 static const size_t kColorTextVASize = 2 * sizeof(SkPoint); |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 if (kARGB_GrMaskFormat == fCurrMaskFormat) { | 540 if (kARGB_GrMaskFormat == fCurrMaskFormat) { |
541 uint32_t flags = GrDefaultGeoProcFactory::kLocalCoord_GPType; | 541 uint32_t flags = GrDefaultGeoProcFactory::kLocalCoord_GPType; |
542 drawState.setGeometryProcessor(GrDefaultGeoProcFactory::Create(flags
))->unref(); | 542 drawState.setGeometryProcessor(GrDefaultGeoProcFactory::Create(flags
))->unref(); |
543 GrFragmentProcessor* fragProcessor = GrSimpleTextureEffect::Create(f
CurrTexture, | 543 GrFragmentProcessor* fragProcessor = GrSimpleTextureEffect::Create(f
CurrTexture, |
544 S
kMatrix::I(), | 544 S
kMatrix::I(), |
545 p
arams); | 545 p
arams); |
546 drawState.addColorProcessor(fragProcessor)->unref(); | 546 drawState.addColorProcessor(fragProcessor)->unref(); |
547 } else { | 547 } else { |
548 uint32_t textureUniqueID = fCurrTexture->getUniqueID(); | 548 uint32_t textureUniqueID = fCurrTexture->getUniqueID(); |
549 if (textureUniqueID != fEffectTextureUniqueID) { | 549 if (textureUniqueID != fEffectTextureUniqueID) { |
550 bool hasColor = kA8_GrMaskFormat == fCurrMaskFormat; | 550 bool useColorAttrib = kA8_GrMaskFormat == fCurrMaskFormat; |
551 fCachedGeometryProcessor.reset(GrCustomCoordsTextureEffect::Crea
te(fCurrTexture, | 551 fCachedGeometryProcessor.reset(GrBitmapTextGeoProc::Create(fCurr
Texture, |
552
params, | 552 param
s, |
553
hasColor)); | 553 useCo
lorAttrib)); |
554 fEffectTextureUniqueID = textureUniqueID; | 554 fEffectTextureUniqueID = textureUniqueID; |
555 } | 555 } |
556 drawState.setGeometryProcessor(fCachedGeometryProcessor.get()); | 556 drawState.setGeometryProcessor(fCachedGeometryProcessor.get()); |
557 } | 557 } |
558 | 558 |
559 SkASSERT(fStrike); | 559 SkASSERT(fStrike); |
560 switch (fCurrMaskFormat) { | 560 switch (fCurrMaskFormat) { |
561 // Color bitmap text | 561 // Color bitmap text |
562 case kARGB_GrMaskFormat: | 562 case kARGB_GrMaskFormat: |
563 SkASSERT(!drawState.hasColorVertexAttribute()); | 563 SkASSERT(!drawState.hasColorVertexAttribute()); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 } | 617 } |
618 } | 618 } |
619 | 619 |
620 inline void GrBitmapTextContext::finish() { | 620 inline void GrBitmapTextContext::finish() { |
621 this->flush(); | 621 this->flush(); |
622 fTotalVertexCount = 0; | 622 fTotalVertexCount = 0; |
623 | 623 |
624 GrTextContext::finish(); | 624 GrTextContext::finish(); |
625 } | 625 } |
626 | 626 |
OLD | NEW |