| 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 "GrDrawTarget.h" | 10 #include "GrDrawTarget.h" |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 | 409 |
| 410 if (fSkPaint.getTextAlign() == SkPaint::kCenter_Align) { | 410 if (fSkPaint.getTextAlign() == SkPaint::kCenter_Align) { |
| 411 alignX = SkScalarHalf(alignX); | 411 alignX = SkScalarHalf(alignX); |
| 412 alignY = SkScalarHalf(alignY); | 412 alignY = SkScalarHalf(alignY); |
| 413 } | 413 } |
| 414 | 414 |
| 415 x -= alignX; | 415 x -= alignX; |
| 416 y -= alignY; | 416 y -= alignY; |
| 417 } | 417 } |
| 418 | 418 |
| 419 SkFixed fx = SkScalarToFixed(x) + SK_FixedHalf; | 419 SkFixed fx = SkScalarToFixed(x); |
| 420 SkFixed fy = SkScalarToFixed(y) + SK_FixedHalf; | 420 SkFixed fy = SkScalarToFixed(y); |
| 421 SkFixed fixedScale = SkScalarToFixed(sizeRatio); | 421 SkFixed fixedScale = SkScalarToFixed(sizeRatio); |
| 422 while (text < stop) { | 422 while (text < stop) { |
| 423 const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0); | 423 const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0); |
| 424 | 424 |
| 425 if (glyph.fWidth) { | 425 if (glyph.fWidth) { |
| 426 this->drawPackedGlyph(GrGlyph::Pack(glyph.getGlyphID(), | 426 this->drawPackedGlyph(GrGlyph::Pack(glyph.getGlyphID(), |
| 427 glyph.getSubXFixed(), | 427 glyph.getSubXFixed(), |
| 428 glyph.getSubYFixed()), | 428 glyph.getSubYFixed()), |
| 429 SkFixedFloorToFixed(fx), | 429 fx, |
| 430 SkFixedFloorToFixed(fy), | 430 fy, |
| 431 fontScaler); | 431 fontScaler); |
| 432 } | 432 } |
| 433 | 433 |
| 434 fx += SkFixedMul_portable(glyph.fAdvanceX, fixedScale); | 434 fx += SkFixedMul_portable(glyph.fAdvanceX, fixedScale); |
| 435 fy += SkFixedMul_portable(glyph.fAdvanceY, fixedScale); | 435 fy += SkFixedMul_portable(glyph.fAdvanceY, fixedScale); |
| 436 } | 436 } |
| 437 | 437 |
| 438 this->finish(); | 438 this->finish(); |
| 439 } | 439 } |
| 440 | 440 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 466 // the last 2 parameters are ignored | 466 // the last 2 parameters are ignored |
| 467 const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0); | 467 const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0); |
| 468 | 468 |
| 469 if (glyph.fWidth) { | 469 if (glyph.fWidth) { |
| 470 SkScalar x = pos[0]; | 470 SkScalar x = pos[0]; |
| 471 SkScalar y = scalarsPerPosition == 1 ? constY : pos[1]; | 471 SkScalar y = scalarsPerPosition == 1 ? constY : pos[1]; |
| 472 | 472 |
| 473 this->drawPackedGlyph(GrGlyph::Pack(glyph.getGlyphID(), | 473 this->drawPackedGlyph(GrGlyph::Pack(glyph.getGlyphID(), |
| 474 glyph.getSubXFixed(), | 474 glyph.getSubXFixed(), |
| 475 glyph.getSubYFixed()), | 475 glyph.getSubYFixed()), |
| 476 SkScalarToFixed(x) + SK_FixedHalf, //d1g.f
HalfSampleX, | 476 SkScalarToFixed(x), |
| 477 SkScalarToFixed(y) + SK_FixedHalf, //d1g.f
HalfSampleY, | 477 SkScalarToFixed(y), |
| 478 fontScaler); | 478 fontScaler); |
| 479 } | 479 } |
| 480 pos += scalarsPerPosition; | 480 pos += scalarsPerPosition; |
| 481 } | 481 } |
| 482 } else { | 482 } else { |
| 483 int alignShift = SkPaint::kCenter_Align == fSkPaint.getTextAlign() ? 1 :
0; | 483 int alignShift = SkPaint::kCenter_Align == fSkPaint.getTextAlign() ? 1 :
0; |
| 484 while (text < stop) { | 484 while (text < stop) { |
| 485 // the last 2 parameters are ignored | 485 // the last 2 parameters are ignored |
| 486 const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0); | 486 const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0); |
| 487 | 487 |
| 488 if (glyph.fWidth) { | 488 if (glyph.fWidth) { |
| 489 SkScalar x = pos[0]; | 489 SkScalar x = pos[0]; |
| 490 SkScalar y = scalarsPerPosition == 1 ? constY : pos[1]; | 490 SkScalar y = scalarsPerPosition == 1 ? constY : pos[1]; |
| 491 | 491 |
| 492 this->drawPackedGlyph(GrGlyph::Pack(glyph.getGlyphID(), | 492 this->drawPackedGlyph(GrGlyph::Pack(glyph.getGlyphID(), |
| 493 glyph.getSubXFixed(), | 493 glyph.getSubXFixed(), |
| 494 glyph.getSubYFixed()), | 494 glyph.getSubYFixed()), |
| 495 SkScalarToFixed(x) - (glyph.fAdvanceX >> a
lignShift) | 495 SkScalarToFixed(x) - (glyph.fAdvanceX >> a
lignShift), |
| 496 + SK_FixedHalf, //d1g.fHalfSampleX, | 496 SkScalarToFixed(y) - (glyph.fAdvanceY >> a
lignShift), |
| 497 SkScalarToFixed(y) - (glyph.fAdvanceY >> a
lignShift) | |
| 498 + SK_FixedHalf, //d1g.fHalfSampleY, | |
| 499 fontScaler); | 497 fontScaler); |
| 500 } | 498 } |
| 501 pos += scalarsPerPosition; | 499 pos += scalarsPerPosition; |
| 502 } | 500 } |
| 503 } | 501 } |
| 504 | 502 |
| 505 this->finish(); | 503 this->finish(); |
| 506 } | 504 } |
| OLD | NEW |