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" |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 } | 164 } |
165 | 165 |
166 while (text < stop) { | 166 while (text < stop) { |
167 const SkGlyph& glyph = glyphCacheProc(cache, &text, fx & fxMask, fy & fy
Mask); | 167 const SkGlyph& glyph = glyphCacheProc(cache, &text, fx & fxMask, fy & fy
Mask); |
168 | 168 |
169 fx += autokern.adjust(glyph); | 169 fx += autokern.adjust(glyph); |
170 | 170 |
171 if (glyph.fWidth) { | 171 if (glyph.fWidth) { |
172 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), | 172 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), |
173 glyph.getSubXFixed(), | 173 glyph.getSubXFixed(), |
174 glyph.getSubYFixed()), | 174 glyph.getSubYFixed(), |
| 175 GrGlyph::kCoverage_MaskStyle), |
175 Sk48Dot16FloorToInt(fx), | 176 Sk48Dot16FloorToInt(fx), |
176 Sk48Dot16FloorToInt(fy), | 177 Sk48Dot16FloorToInt(fy), |
177 fontScaler); | 178 fontScaler); |
178 } | 179 } |
179 | 180 |
180 fx += glyph.fAdvanceX; | 181 fx += glyph.fAdvanceX; |
181 fy += glyph.fAdvanceY; | 182 fy += glyph.fAdvanceY; |
182 } | 183 } |
183 | 184 |
184 this->finish(); | 185 this->finish(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 tmsProc(pos, &tmsLoc); | 242 tmsProc(pos, &tmsLoc); |
242 Sk48Dot16 fx = SkScalarTo48Dot16(tmsLoc.fX + halfSampleX); | 243 Sk48Dot16 fx = SkScalarTo48Dot16(tmsLoc.fX + halfSampleX); |
243 Sk48Dot16 fy = SkScalarTo48Dot16(tmsLoc.fY + halfSampleY); | 244 Sk48Dot16 fy = SkScalarTo48Dot16(tmsLoc.fY + halfSampleY); |
244 | 245 |
245 const SkGlyph& glyph = glyphCacheProc(cache, &text, | 246 const SkGlyph& glyph = glyphCacheProc(cache, &text, |
246 fx & fxMask, fy & fyMask); | 247 fx & fxMask, fy & fyMask); |
247 | 248 |
248 if (glyph.fWidth) { | 249 if (glyph.fWidth) { |
249 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), | 250 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), |
250 glyph.getSubXFixed(), | 251 glyph.getSubXFixed(), |
251 glyph.getSubYFixed()), | 252 glyph.getSubYFixed(), |
| 253 GrGlyph::kCoverage_MaskStyle
), |
252 Sk48Dot16FloorToInt(fx), | 254 Sk48Dot16FloorToInt(fx), |
253 Sk48Dot16FloorToInt(fy), | 255 Sk48Dot16FloorToInt(fy), |
254 fontScaler); | 256 fontScaler); |
255 } | 257 } |
256 pos += scalarsPerPosition; | 258 pos += scalarsPerPosition; |
257 } | 259 } |
258 } else { | 260 } else { |
259 while (text < stop) { | 261 while (text < stop) { |
260 const char* currentText = text; | 262 const char* currentText = text; |
261 const SkGlyph& metricGlyph = glyphCacheProc(cache, &text, 0, 0); | 263 const SkGlyph& metricGlyph = glyphCacheProc(cache, &text, 0, 0); |
(...skipping 12 matching lines...) Expand all Loading... |
274 // have to call again, now that we've been "aligned" | 276 // have to call again, now that we've been "aligned" |
275 const SkGlyph& glyph = glyphCacheProc(cache, ¤tText, | 277 const SkGlyph& glyph = glyphCacheProc(cache, ¤tText, |
276 fx & fxMask, fy & fyMa
sk); | 278 fx & fxMask, fy & fyMa
sk); |
277 // the assumption is that the metrics haven't changed | 279 // the assumption is that the metrics haven't changed |
278 SkASSERT(prevAdvX == glyph.fAdvanceX); | 280 SkASSERT(prevAdvX == glyph.fAdvanceX); |
279 SkASSERT(prevAdvY == glyph.fAdvanceY); | 281 SkASSERT(prevAdvY == glyph.fAdvanceY); |
280 SkASSERT(glyph.fWidth); | 282 SkASSERT(glyph.fWidth); |
281 | 283 |
282 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), | 284 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), |
283 glyph.getSubXFixed(), | 285 glyph.getSubXFixed(), |
284 glyph.getSubYFixed()), | 286 glyph.getSubYFixed(), |
| 287 GrGlyph::kCoverage_MaskStyle
), |
285 Sk48Dot16FloorToInt(fx), | 288 Sk48Dot16FloorToInt(fx), |
286 Sk48Dot16FloorToInt(fy), | 289 Sk48Dot16FloorToInt(fy), |
287 fontScaler); | 290 fontScaler); |
288 } | 291 } |
289 pos += scalarsPerPosition; | 292 pos += scalarsPerPosition; |
290 } | 293 } |
291 } | 294 } |
292 } else { // not subpixel | 295 } else { // not subpixel |
293 | 296 |
294 if (SkPaint::kLeft_Align == fSkPaint.getTextAlign()) { | 297 if (SkPaint::kLeft_Align == fSkPaint.getTextAlign()) { |
295 while (text < stop) { | 298 while (text < stop) { |
296 // the last 2 parameters are ignored | 299 // the last 2 parameters are ignored |
297 const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0); | 300 const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0); |
298 | 301 |
299 if (glyph.fWidth) { | 302 if (glyph.fWidth) { |
300 SkPoint tmsLoc; | 303 SkPoint tmsLoc; |
301 tmsProc(pos, &tmsLoc); | 304 tmsProc(pos, &tmsLoc); |
302 | 305 |
303 Sk48Dot16 fx = SkScalarTo48Dot16(tmsLoc.fX + SK_ScalarHalf);
//halfSampleX; | 306 Sk48Dot16 fx = SkScalarTo48Dot16(tmsLoc.fX + SK_ScalarHalf);
//halfSampleX; |
304 Sk48Dot16 fy = SkScalarTo48Dot16(tmsLoc.fY + SK_ScalarHalf);
//halfSampleY; | 307 Sk48Dot16 fy = SkScalarTo48Dot16(tmsLoc.fY + SK_ScalarHalf);
//halfSampleY; |
305 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), | 308 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), |
306 glyph.getSubXFixed(), | 309 glyph.getSubXFixed(), |
307 glyph.getSubYFixed()), | 310 glyph.getSubYFixed(), |
| 311 GrGlyph::kCoverage_MaskStyle
), |
308 Sk48Dot16FloorToInt(fx), | 312 Sk48Dot16FloorToInt(fx), |
309 Sk48Dot16FloorToInt(fy), | 313 Sk48Dot16FloorToInt(fy), |
310 fontScaler); | 314 fontScaler); |
311 } | 315 } |
312 pos += scalarsPerPosition; | 316 pos += scalarsPerPosition; |
313 } | 317 } |
314 } else { | 318 } else { |
315 while (text < stop) { | 319 while (text < stop) { |
316 // the last 2 parameters are ignored | 320 // the last 2 parameters are ignored |
317 const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0); | 321 const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0); |
318 | 322 |
319 if (glyph.fWidth) { | 323 if (glyph.fWidth) { |
320 SkPoint tmsLoc; | 324 SkPoint tmsLoc; |
321 tmsProc(pos, &tmsLoc); | 325 tmsProc(pos, &tmsLoc); |
322 | 326 |
323 SkPoint alignLoc; | 327 SkPoint alignLoc; |
324 alignProc(tmsLoc, glyph, &alignLoc); | 328 alignProc(tmsLoc, glyph, &alignLoc); |
325 | 329 |
326 Sk48Dot16 fx = SkScalarTo48Dot16(alignLoc.fX + SK_ScalarHalf
); //halfSampleX; | 330 Sk48Dot16 fx = SkScalarTo48Dot16(alignLoc.fX + SK_ScalarHalf
); //halfSampleX; |
327 Sk48Dot16 fy = SkScalarTo48Dot16(alignLoc.fY + SK_ScalarHalf
); //halfSampleY; | 331 Sk48Dot16 fy = SkScalarTo48Dot16(alignLoc.fY + SK_ScalarHalf
); //halfSampleY; |
328 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), | 332 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), |
329 glyph.getSubXFixed(), | 333 glyph.getSubXFixed(), |
330 glyph.getSubYFixed()), | 334 glyph.getSubYFixed(), |
| 335 GrGlyph::kCoverage_MaskStyle
), |
331 Sk48Dot16FloorToInt(fx), | 336 Sk48Dot16FloorToInt(fx), |
332 Sk48Dot16FloorToInt(fy), | 337 Sk48Dot16FloorToInt(fy), |
333 fontScaler); | 338 fontScaler); |
334 } | 339 } |
335 pos += scalarsPerPosition; | 340 pos += scalarsPerPosition; |
336 } | 341 } |
337 } | 342 } |
338 } | 343 } |
339 | 344 |
340 this->finish(); | 345 this->finish(); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 } | 410 } |
406 | 411 |
407 void GrBitmapTextContext::appendGlyph(GrGlyph::PackedID packed, | 412 void GrBitmapTextContext::appendGlyph(GrGlyph::PackedID packed, |
408 int vx, int vy, | 413 int vx, int vy, |
409 GrFontScaler* scaler) { | 414 GrFontScaler* scaler) { |
410 if (NULL == fDrawTarget) { | 415 if (NULL == fDrawTarget) { |
411 return; | 416 return; |
412 } | 417 } |
413 | 418 |
414 if (NULL == fStrike) { | 419 if (NULL == fStrike) { |
415 fStrike = fContext->getFontCache()->getStrike(scaler, false); | 420 fStrike = fContext->getFontCache()->getStrike(scaler); |
416 } | 421 } |
417 | 422 |
418 GrGlyph* glyph = fStrike->getGlyph(packed, scaler); | 423 GrGlyph* glyph = fStrike->getGlyph(packed, scaler); |
419 if (NULL == glyph || glyph->fBounds.isEmpty()) { | 424 if (NULL == glyph || glyph->fBounds.isEmpty()) { |
420 return; | 425 return; |
421 } | 426 } |
422 | 427 |
423 int x = vx + glyph->fBounds.fLeft; | 428 int x = vx + glyph->fBounds.fLeft; |
424 int y = vy + glyph->fBounds.fTop; | 429 int y = vy + glyph->fBounds.fTop; |
425 | 430 |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 } | 625 } |
621 } | 626 } |
622 | 627 |
623 inline void GrBitmapTextContext::finish() { | 628 inline void GrBitmapTextContext::finish() { |
624 this->flush(); | 629 this->flush(); |
625 fTotalVertexCount = 0; | 630 fTotalVertexCount = 0; |
626 | 631 |
627 GrTextContext::finish(); | 632 GrTextContext::finish(); |
628 } | 633 } |
629 | 634 |
OLD | NEW |