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 "GrDistanceFieldTextContext.h" | 8 #include "GrDistanceFieldTextContext.h" |
9 #include "GrAtlas.h" | 9 #include "GrAtlas.h" |
| 10 #include "GrBitmapTextContext.h" |
10 #include "GrDrawTarget.h" | 11 #include "GrDrawTarget.h" |
11 #include "GrDrawTargetCaps.h" | 12 #include "GrDrawTargetCaps.h" |
12 #include "GrFontScaler.h" | 13 #include "GrFontScaler.h" |
13 #include "GrGpu.h" | 14 #include "GrGpu.h" |
14 #include "GrIndexBuffer.h" | 15 #include "GrIndexBuffer.h" |
15 #include "GrStrokeInfo.h" | 16 #include "GrStrokeInfo.h" |
16 #include "GrTexturePriv.h" | 17 #include "GrTexturePriv.h" |
17 #include "GrTextStrike.h" | 18 #include "GrTextStrike.h" |
18 #include "GrTextStrike_impl.h" | 19 #include "GrTextStrike_impl.h" |
19 | 20 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 fEffectTextureUniqueID = SK_InvalidUniqueID; | 74 fEffectTextureUniqueID = SK_InvalidUniqueID; |
74 fEffectColor = GrColor_ILLEGAL; | 75 fEffectColor = GrColor_ILLEGAL; |
75 fEffectFlags = 0; | 76 fEffectFlags = 0; |
76 | 77 |
77 fVertices = NULL; | 78 fVertices = NULL; |
78 fMaxVertices = 0; | 79 fMaxVertices = 0; |
79 | 80 |
80 fVertexBounds.setLargestInverted(); | 81 fVertexBounds.setLargestInverted(); |
81 } | 82 } |
82 | 83 |
| 84 GrDistanceFieldTextContext* GrDistanceFieldTextContext::Create(GrContext* contex
t, |
| 85 const SkDevicePro
perties& props, |
| 86 bool enable) { |
| 87 GrDistanceFieldTextContext* textContext = SkNEW_ARGS(GrDistanceFieldTextCont
ext, |
| 88 (context, props, enable
)); |
| 89 textContext->fFallbackTextContext = GrBitmapTextContext::Create(context, pro
ps); |
| 90 |
| 91 return textContext; |
| 92 } |
| 93 |
83 GrDistanceFieldTextContext::~GrDistanceFieldTextContext() { | 94 GrDistanceFieldTextContext::~GrDistanceFieldTextContext() { |
84 this->flush(); | 95 this->flush(); |
85 SkSafeSetNull(fGammaTexture); | 96 SkSafeSetNull(fGammaTexture); |
86 } | 97 } |
87 | 98 |
88 bool GrDistanceFieldTextContext::canDraw(const SkPaint& paint) { | 99 bool GrDistanceFieldTextContext::canDraw(const SkPaint& paint) { |
89 if (!fEnableDFRendering && !paint.isDistanceFieldTextTEMP()) { | 100 if (!fEnableDFRendering && !paint.isDistanceFieldTextTEMP()) { |
90 return false; | 101 return false; |
91 } | 102 } |
92 | 103 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 return; | 201 return; |
191 } | 202 } |
192 | 203 |
193 context->writeTexturePixels(*gammaTexture, | 204 context->writeTexturePixels(*gammaTexture, |
194 0, 0, width, height, | 205 0, 0, width, height, |
195 (*gammaTexture)->config(), data.get(), 0, | 206 (*gammaTexture)->config(), data.get(), 0, |
196 GrContext::kDontFlush_PixelOpsFlag); | 207 GrContext::kDontFlush_PixelOpsFlag); |
197 } | 208 } |
198 } | 209 } |
199 | 210 |
200 void GrDistanceFieldTextContext::drawText(const GrPaint& paint, const SkPaint& s
kPaint, | 211 void GrDistanceFieldTextContext::onDrawText(const GrPaint& paint, const SkPaint&
skPaint, |
201 const char text[], size_t byteLength, | 212 const char text[], size_t byteLength, |
202 SkScalar x, SkScalar y) { | 213 SkScalar x, SkScalar y) { |
203 SkASSERT(byteLength == 0 || text != NULL); | 214 SkASSERT(byteLength == 0 || text != NULL); |
204 | 215 |
205 // nothing to draw or can't draw | 216 // nothing to draw or can't draw |
206 if (text == NULL || byteLength == 0 /* no raster clip? || fRC->isEmpty()*/ | 217 if (text == NULL || byteLength == 0 /* no raster clip? || fRC->isEmpty()*/ |
207 || fSkPaint.getRasterizer()) { | 218 || fSkPaint.getRasterizer()) { |
208 return; | 219 return; |
209 } | 220 } |
210 | 221 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 fontScaler); | 276 fontScaler); |
266 } | 277 } |
267 | 278 |
268 fx += SkFixedMul_portable(glyph.fAdvanceX, fixedScale); | 279 fx += SkFixedMul_portable(glyph.fAdvanceX, fixedScale); |
269 fy += SkFixedMul_portable(glyph.fAdvanceY, fixedScale); | 280 fy += SkFixedMul_portable(glyph.fAdvanceY, fixedScale); |
270 } | 281 } |
271 | 282 |
272 this->finish(); | 283 this->finish(); |
273 } | 284 } |
274 | 285 |
275 void GrDistanceFieldTextContext::drawPosText(const GrPaint& paint, const SkPaint
& skPaint, | 286 void GrDistanceFieldTextContext::onDrawPosText(const GrPaint& paint, const SkPai
nt& skPaint, |
276 const char text[], size_t byteLengt
h, | 287 const char text[], size_t byteLengt
h, |
277 const SkScalar pos[], int scalarsPe
rPosition, | 288 const SkScalar pos[], int scalarsPe
rPosition, |
278 const SkPoint& offset) { | 289 const SkPoint& offset) { |
279 | 290 |
280 SkASSERT(byteLength == 0 || text != NULL); | 291 SkASSERT(byteLength == 0 || text != NULL); |
281 SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition); | 292 SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition); |
282 | 293 |
283 // nothing to draw | 294 // nothing to draw |
284 if (text == NULL || byteLength == 0 /* no raster clip? || fRC->isEmpty()*/)
{ | 295 if (text == NULL || byteLength == 0 /* no raster clip? || fRC->isEmpty()*/)
{ |
285 return; | 296 return; |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 fVertexBounds.setLargestInverted(); | 679 fVertexBounds.setLargestInverted(); |
669 } | 680 } |
670 } | 681 } |
671 | 682 |
672 inline void GrDistanceFieldTextContext::finish() { | 683 inline void GrDistanceFieldTextContext::finish() { |
673 this->flush(); | 684 this->flush(); |
674 | 685 |
675 GrTextContext::finish(); | 686 GrTextContext::finish(); |
676 } | 687 } |
677 | 688 |
OLD | NEW |