| 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 16 matching lines...) Expand all Loading... |
| 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 namespace { | 33 namespace { |
| 34 // position + texture coord | 34 // position + texture coord |
| 35 extern const GrVertexAttrib gTextVertexAttribs[] = { | 35 extern const GrVertexAttrib gTextVertexAttribs[] = { |
| 36 {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding
}, | 36 {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding
}, |
| 37 {kVec2f_GrVertexAttribType, sizeof(SkPoint) , kEffect_GrVertexAttribBinding} | 37 {kVec2f_GrVertexAttribType, sizeof(SkPoint), kGeometryProcessor_GrVertexAttr
ibBinding} |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 static const size_t kTextVASize = 2 * sizeof(SkPoint); | 40 static const size_t kTextVASize = 2 * sizeof(SkPoint); |
| 41 | 41 |
| 42 // position + color + texture coord | 42 // position + color + texture coord |
| 43 extern const GrVertexAttrib gTextVertexWithColorAttribs[] = { | 43 extern const GrVertexAttrib gTextVertexWithColorAttribs[] = { |
| 44 {kVec2f_GrVertexAttribType, 0, kPosition_Gr
VertexAttribBinding}, | 44 {kVec2f_GrVertexAttribType, 0, kPosition_Gr
VertexAttribBinding}, |
| 45 {kVec4ub_GrVertexAttribType, sizeof(SkPoint), kColor_GrVer
texAttribBinding}, | 45 {kVec4ub_GrVertexAttribType, sizeof(SkPoint), kColor_GrVer
texAttribBinding}, |
| 46 {kVec2f_GrVertexAttribType, sizeof(SkPoint) + sizeof(GrColor), kEffect_GrVe
rtexAttribBinding} | 46 {kVec2f_GrVertexAttribType, sizeof(SkPoint) + sizeof(GrColor), kGeometryPro
cessor_GrVertexAttribBinding} |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 static const size_t kTextVAColorSize = 2 * sizeof(SkPoint) + sizeof(GrColor); | 49 static const size_t kTextVAColorSize = 2 * sizeof(SkPoint) + sizeof(GrColor); |
| 50 | 50 |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 GrBitmapTextContext::GrBitmapTextContext(GrContext* context, | 53 GrBitmapTextContext::GrBitmapTextContext(GrContext* context, |
| 54 const SkDeviceProperties& properties) | 54 const SkDeviceProperties& properties) |
| 55 : GrTextContext(context, properties) { | 55 : GrTextContext(context, properties) { |
| 56 fStrike = NULL; | 56 fStrike = NULL; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 91 |
| 92 if (fCurrVertex > 0) { | 92 if (fCurrVertex > 0) { |
| 93 // setup our sampler state for our text texture/atlas | 93 // setup our sampler state for our text texture/atlas |
| 94 SkASSERT(SkIsAlign4(fCurrVertex)); | 94 SkASSERT(SkIsAlign4(fCurrVertex)); |
| 95 SkASSERT(fCurrTexture); | 95 SkASSERT(fCurrTexture); |
| 96 GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kNon
e_FilterMode); | 96 GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kNon
e_FilterMode); |
| 97 | 97 |
| 98 uint32_t textureUniqueID = fCurrTexture->getUniqueID(); | 98 uint32_t textureUniqueID = fCurrTexture->getUniqueID(); |
| 99 | 99 |
| 100 if (textureUniqueID != fEffectTextureUniqueID) { | 100 if (textureUniqueID != fEffectTextureUniqueID) { |
| 101 fCachedEffect.reset(GrCustomCoordsTextureEffect::Create(fCurrTexture
, params)); | 101 fCachedGeometryProcessor.reset(GrCustomCoordsTextureEffect::Create(f
CurrTexture, |
| 102 p
arams)); |
| 102 fEffectTextureUniqueID = textureUniqueID; | 103 fEffectTextureUniqueID = textureUniqueID; |
| 103 } | 104 } |
| 104 | 105 |
| 105 // This effect could be stored with one of the cache objects (atlas?) | 106 // This effect could be stored with one of the cache objects (atlas?) |
| 106 drawState->setGeometryProcessor(fCachedEffect.get()); | 107 drawState->setGeometryProcessor(fCachedGeometryProcessor.get()); |
| 107 SkASSERT(fStrike); | 108 SkASSERT(fStrike); |
| 108 switch (fStrike->getMaskFormat()) { | 109 switch (fStrike->getMaskFormat()) { |
| 109 // Color bitmap text | 110 // Color bitmap text |
| 110 case kARGB_GrMaskFormat: | 111 case kARGB_GrMaskFormat: |
| 111 SkASSERT(!drawState->hasColorVertexAttribute()); | 112 SkASSERT(!drawState->hasColorVertexAttribute()); |
| 112 drawState->setBlendFunc(fPaint.getSrcBlendCoeff(), fPaint.getDst
BlendCoeff()); | 113 drawState->setBlendFunc(fPaint.getSrcBlendCoeff(), fPaint.getDst
BlendCoeff()); |
| 113 drawState->setColor(0xffffffff); | 114 drawState->setColor(0xffffffff); |
| 114 break; | 115 break; |
| 115 // LCD text | 116 // LCD text |
| 116 case kA888_GrMaskFormat: | 117 case kA888_GrMaskFormat: |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 } | 597 } |
| 597 // color comes after position. | 598 // color comes after position. |
| 598 GrColor* colors = reinterpret_cast<GrColor*>(positions + 1); | 599 GrColor* colors = reinterpret_cast<GrColor*>(positions + 1); |
| 599 for (int i = 0; i < 4; ++i) { | 600 for (int i = 0; i < 4; ++i) { |
| 600 *colors = fPaint.getColor(); | 601 *colors = fPaint.getColor(); |
| 601 colors = reinterpret_cast<GrColor*>(reinterpret_cast<intptr_t>(colors
) + vertSize); | 602 colors = reinterpret_cast<GrColor*>(reinterpret_cast<intptr_t>(colors
) + vertSize); |
| 602 } | 603 } |
| 603 } | 604 } |
| 604 fCurrVertex += 4; | 605 fCurrVertex += 4; |
| 605 } | 606 } |
| OLD | NEW |