| 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 "GrDrawTarget.h" | 10 #include "GrDrawTarget.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "SkDraw.h" | 23 #include "SkDraw.h" |
| 24 #include "SkDrawProcs.h" | 24 #include "SkDrawProcs.h" |
| 25 #include "SkGlyphCache.h" | 25 #include "SkGlyphCache.h" |
| 26 #include "SkGpuDevice.h" | 26 #include "SkGpuDevice.h" |
| 27 #include "SkGr.h" | 27 #include "SkGr.h" |
| 28 #include "SkTextMapStateProc.h" | 28 #include "SkTextMapStateProc.h" |
| 29 | 29 |
| 30 SK_CONF_DECLARE(bool, c_DumpFontCache, "gpu.dumpFontCache", false, | 30 SK_CONF_DECLARE(bool, c_DumpFontCache, "gpu.dumpFontCache", false, |
| 31 "Dump the contents of the font cache before every purge."); | 31 "Dump the contents of the font cache before every purge."); |
| 32 | 32 |
| 33 static const int kGlyphCoordsNoColorAttributeIndex = 1; | |
| 34 static const int kGlyphCoordsWithColorAttributeIndex = 2; | |
| 35 | |
| 36 namespace { | 33 namespace { |
| 37 // position + texture coord | 34 // position + texture coord |
| 38 extern const GrVertexAttrib gTextVertexAttribs[] = { | 35 extern const GrVertexAttrib gTextVertexAttribs[] = { |
| 39 {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding
}, | 36 {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding
}, |
| 40 {kVec2f_GrVertexAttribType, sizeof(SkPoint) , kEffect_GrVertexAttribBinding} | 37 {kVec2f_GrVertexAttribType, sizeof(SkPoint) , kEffect_GrVertexAttribBinding} |
| 41 }; | 38 }; |
| 42 | 39 |
| 43 static const size_t kTextVASize = 2 * sizeof(SkPoint); | 40 static const size_t kTextVASize = 2 * sizeof(SkPoint); |
| 44 | 41 |
| 45 // position + color + texture coord | 42 // position + color + texture coord |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kNon
e_FilterMode); | 96 GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kNon
e_FilterMode); |
| 100 | 97 |
| 101 uint32_t textureUniqueID = fCurrTexture->getUniqueID(); | 98 uint32_t textureUniqueID = fCurrTexture->getUniqueID(); |
| 102 | 99 |
| 103 if (textureUniqueID != fEffectTextureUniqueID) { | 100 if (textureUniqueID != fEffectTextureUniqueID) { |
| 104 fCachedEffect.reset(GrCustomCoordsTextureEffect::Create(fCurrTexture
, params)); | 101 fCachedEffect.reset(GrCustomCoordsTextureEffect::Create(fCurrTexture
, params)); |
| 105 fEffectTextureUniqueID = textureUniqueID; | 102 fEffectTextureUniqueID = textureUniqueID; |
| 106 } | 103 } |
| 107 | 104 |
| 108 // This effect could be stored with one of the cache objects (atlas?) | 105 // This effect could be stored with one of the cache objects (atlas?) |
| 109 int coordsIdx = drawState->hasColorVertexAttribute() ? kGlyphCoordsWithC
olorAttributeIndex : | 106 drawState->setGeometryProcessor(fCachedEffect.get()); |
| 110 kGlyphCoordsNoCol
orAttributeIndex; | |
| 111 drawState->setGeometryProcessor(fCachedEffect.get(), coordsIdx); | |
| 112 SkASSERT(fStrike); | 107 SkASSERT(fStrike); |
| 113 switch (fStrike->getMaskFormat()) { | 108 switch (fStrike->getMaskFormat()) { |
| 114 // Color bitmap text | 109 // Color bitmap text |
| 115 case kARGB_GrMaskFormat: | 110 case kARGB_GrMaskFormat: |
| 116 SkASSERT(!drawState->hasColorVertexAttribute()); | 111 SkASSERT(!drawState->hasColorVertexAttribute()); |
| 117 drawState->setBlendFunc(fPaint.getSrcBlendCoeff(), fPaint.getDst
BlendCoeff()); | 112 drawState->setBlendFunc(fPaint.getSrcBlendCoeff(), fPaint.getDst
BlendCoeff()); |
| 118 drawState->setColor(0xffffffff); | 113 drawState->setColor(0xffffffff); |
| 119 break; | 114 break; |
| 120 // LCD text | 115 // LCD text |
| 121 case kA888_GrMaskFormat: | 116 case kA888_GrMaskFormat: |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 } | 596 } |
| 602 // color comes after position. | 597 // color comes after position. |
| 603 GrColor* colors = reinterpret_cast<GrColor*>(positions + 1); | 598 GrColor* colors = reinterpret_cast<GrColor*>(positions + 1); |
| 604 for (int i = 0; i < 4; ++i) { | 599 for (int i = 0; i < 4; ++i) { |
| 605 *colors = fPaint.getColor(); | 600 *colors = fPaint.getColor(); |
| 606 colors = reinterpret_cast<GrColor*>(reinterpret_cast<intptr_t>(colors
) + vertSize); | 601 colors = reinterpret_cast<GrColor*>(reinterpret_cast<intptr_t>(colors
) + vertSize); |
| 607 } | 602 } |
| 608 } | 603 } |
| 609 fCurrVertex += 4; | 604 fCurrVertex += 4; |
| 610 } | 605 } |
| OLD | NEW |