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" |
11 #include "GrFontScaler.h" | 11 #include "GrFontScaler.h" |
12 #include "GrIndexBuffer.h" | 12 #include "GrIndexBuffer.h" |
13 #include "GrTextStrike.h" | 13 #include "GrTextStrike.h" |
14 #include "GrTextStrike_impl.h" | 14 #include "GrTextStrike_impl.h" |
15 #include "SkColorPriv.h" | 15 #include "SkColorPriv.h" |
16 #include "SkPath.h" | 16 #include "SkPath.h" |
17 #include "SkRTConf.h" | 17 #include "SkRTConf.h" |
18 #include "SkStrokeRec.h" | 18 #include "SkStrokeRec.h" |
19 #include "effects/GrCustomCoordsTextureEffect.h" | 19 #include "effects/GrCustomCoordsTextureEffect.h" |
20 | 20 |
21 static const int kGlyphCoordsAttributeIndex = 1; | 21 static const int kGlyphCoordsAttributeIndex = 1; |
22 | 22 |
23 SK_CONF_DECLARE(bool, c_DumpFontCache, "gpu.dumpFontCache", false, | 23 SK_CONF_DECLARE(bool, c_DumpFontCache, "gpu.dumpFontCache", false, |
24 "Dump the contents of the font cache before every purge."); | 24 "Dump the contents of the font cache before every purge."); |
25 | 25 |
26 GrBitmapTextContext::GrBitmapTextContext(GrContext* context, const GrPaint& pain
t, | 26 GrBitmapTextContext::GrBitmapTextContext(GrContext* context, const GrPaint& pain
t, |
27 const SkPaint& skPaint) : | 27 SkColor color) : |
28 GrTextContext(context, paint, skPaint)
{ | 28 GrTextContext(context, paint) { |
29 fAutoMatrix.setIdentity(fContext, &fPaint); | 29 fAutoMatrix.setIdentity(fContext, &fPaint); |
30 | 30 |
| 31 fSkPaintColor = color; |
| 32 |
31 fStrike = NULL; | 33 fStrike = NULL; |
32 | 34 |
33 fCurrTexture = NULL; | 35 fCurrTexture = NULL; |
34 fCurrVertex = 0; | 36 fCurrVertex = 0; |
35 | 37 |
36 fVertices = NULL; | 38 fVertices = NULL; |
37 fMaxVertices = 0; | 39 fMaxVertices = 0; |
38 } | 40 } |
39 | 41 |
40 GrBitmapTextContext::~GrBitmapTextContext() { | 42 GrBitmapTextContext::~GrBitmapTextContext() { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 } else if (!GrPixelConfigIsAlphaOnly(fCurrTexture->config())) { | 76 } else if (!GrPixelConfigIsAlphaOnly(fCurrTexture->config())) { |
75 if (kOne_GrBlendCoeff != fPaint.getSrcBlendCoeff() || | 77 if (kOne_GrBlendCoeff != fPaint.getSrcBlendCoeff() || |
76 kISA_GrBlendCoeff != fPaint.getDstBlendCoeff() || | 78 kISA_GrBlendCoeff != fPaint.getDstBlendCoeff() || |
77 fPaint.numColorStages()) { | 79 fPaint.numColorStages()) { |
78 GrPrintf("LCD Text will not draw correctly.\n"); | 80 GrPrintf("LCD Text will not draw correctly.\n"); |
79 } | 81 } |
80 // We don't use the GrPaint's color in this case because it's been p
remultiplied by | 82 // We don't use the GrPaint's color in this case because it's been p
remultiplied by |
81 // alpha. Instead we feed in a non-premultiplied color, and multiply
its alpha by | 83 // alpha. Instead we feed in a non-premultiplied color, and multiply
its alpha by |
82 // the mask texture color. The end result is that we get | 84 // the mask texture color. The end result is that we get |
83 // mask*paintAlpha*paintColor + (1-mask*paintAlpha)*dstCo
lor | 85 // mask*paintAlpha*paintColor + (1-mask*paintAlpha)*dstCo
lor |
84 int a = SkColorGetA(fSkPaint.getColor()); | 86 int a = SkColorGetA(fSkPaintColor); |
85 // paintAlpha | 87 // paintAlpha |
86 drawState->setColor(SkColorSetARGB(a, a, a, a)); | 88 drawState->setColor(SkColorSetARGB(a, a, a, a)); |
87 // paintColor | 89 // paintColor |
88 drawState->setBlendConstant(skcolor_to_grcolor_nopremultiply(fSkPain
t.getColor())); | 90 drawState->setBlendConstant(skcolor_to_grcolor_nopremultiply(fSkPain
tColor)); |
89 drawState->setBlendFunc(kConstC_GrBlendCoeff, kISC_GrBlendCoeff); | 91 drawState->setBlendFunc(kConstC_GrBlendCoeff, kISC_GrBlendCoeff); |
90 } else { | 92 } else { |
91 // set back to normal in case we took LCD path previously. | 93 // set back to normal in case we took LCD path previously. |
92 drawState->setBlendFunc(fPaint.getSrcBlendCoeff(), fPaint.getDstBlen
dCoeff()); | 94 drawState->setBlendFunc(fPaint.getSrcBlendCoeff(), fPaint.getDstBlen
dCoeff()); |
93 drawState->setColor(fPaint.getColor()); | 95 drawState->setColor(fPaint.getColor()); |
94 } | 96 } |
95 | 97 |
96 int nGlyphs = fCurrVertex / 4; | 98 int nGlyphs = fCurrVertex / 4; |
97 fDrawTarget->setIndexSourceToBuffer(fContext->getQuadIndexBuffer()); | 99 fDrawTarget->setIndexSourceToBuffer(fContext->getQuadIndexBuffer()); |
98 fDrawTarget->drawIndexedInstances(kTriangles_GrPrimitiveType, | 100 fDrawTarget->drawIndexedInstances(kTriangles_GrPrimitiveType, |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 SkFixedToFloat(vx + width), | 262 SkFixedToFloat(vx + width), |
261 SkFixedToFloat(vy + height), | 263 SkFixedToFloat(vy + height), |
262 2 * sizeof(SkPoint)); | 264 2 * sizeof(SkPoint)); |
263 fVertices[2*fCurrVertex+1].setRectFan(SkFixedToFloat(texture->normalizeFixed
X(tx)), | 265 fVertices[2*fCurrVertex+1].setRectFan(SkFixedToFloat(texture->normalizeFixed
X(tx)), |
264 SkFixedToFloat(texture->normalizeFixed
Y(ty)), | 266 SkFixedToFloat(texture->normalizeFixed
Y(ty)), |
265 SkFixedToFloat(texture->normalizeFixed
X(tx + width)), | 267 SkFixedToFloat(texture->normalizeFixed
X(tx + width)), |
266 SkFixedToFloat(texture->normalizeFixed
Y(ty + height)), | 268 SkFixedToFloat(texture->normalizeFixed
Y(ty + height)), |
267 2 * sizeof(SkPoint)); | 269 2 * sizeof(SkPoint)); |
268 fCurrVertex += 4; | 270 fCurrVertex += 4; |
269 } | 271 } |
OLD | NEW |