Chromium Code Reviews| 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 "GrBitmapTextContext.h" |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 299 | 299 |
| 300 if (glyph.fWidth) { | 300 if (glyph.fWidth) { |
| 301 SkScalar x = offset.x() + pos[0]; | 301 SkScalar x = offset.x() + pos[0]; |
| 302 SkScalar y = offset.y() + (2 == scalarsPerPosition ? pos[1] : 0) ; | 302 SkScalar y = offset.y() + (2 == scalarsPerPosition ? pos[1] : 0) ; |
| 303 | 303 |
| 304 if (!this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), | 304 if (!this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), |
| 305 glyph.getSubXFixed(), | 305 glyph.getSubXFixed(), |
| 306 glyph.getSubYFixed()), | 306 glyph.getSubYFixed()), |
| 307 x, y, fontScaler)) { | 307 x, y, fontScaler)) { |
| 308 // couldn't append, send to fallback | 308 // couldn't append, send to fallback |
| 309 fallbackTxt.push_back_n(text-lastText, lastText); | 309 fallbackTxt.push_back_n(SkToU32(text-lastText), lastText); |
|
reed1
2014/12/11 20:56:26
SkToInt ?
bsalomon
2014/12/11 21:08:47
Imminent CL will fix the casts that should have be
| |
| 310 fallbackPos.push_back(pos[0]); | 310 fallbackPos.push_back(pos[0]); |
| 311 if (2 == scalarsPerPosition) { | 311 if (2 == scalarsPerPosition) { |
| 312 fallbackPos.push_back(pos[1]); | 312 fallbackPos.push_back(pos[1]); |
| 313 } | 313 } |
| 314 } | 314 } |
| 315 } | 315 } |
| 316 pos += scalarsPerPosition; | 316 pos += scalarsPerPosition; |
| 317 } | 317 } |
| 318 } else { | 318 } else { |
| 319 SkScalar alignMul = SkPaint::kCenter_Align == fSkPaint.getTextAlign() ? SK_ScalarHalf | 319 SkScalar alignMul = SkPaint::kCenter_Align == fSkPaint.getTextAlign() ? SK_ScalarHalf |
| 320 : SK_Scalar1; | 320 : SK_Scalar1; |
| 321 while (text < stop) { | 321 while (text < stop) { |
| 322 const char* lastText = text; | 322 const char* lastText = text; |
| 323 // the last 2 parameters are ignored | 323 // the last 2 parameters are ignored |
| 324 const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0); | 324 const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0); |
| 325 | 325 |
| 326 if (glyph.fWidth) { | 326 if (glyph.fWidth) { |
| 327 SkScalar x = offset.x() + pos[0]; | 327 SkScalar x = offset.x() + pos[0]; |
| 328 SkScalar y = offset.y() + (2 == scalarsPerPosition ? pos[1] : 0) ; | 328 SkScalar y = offset.y() + (2 == scalarsPerPosition ? pos[1] : 0) ; |
| 329 | 329 |
| 330 SkScalar advanceX = SkFixedToScalar(glyph.fAdvanceX)*alignMul*fT extRatio; | 330 SkScalar advanceX = SkFixedToScalar(glyph.fAdvanceX)*alignMul*fT extRatio; |
| 331 SkScalar advanceY = SkFixedToScalar(glyph.fAdvanceY)*alignMul*fT extRatio; | 331 SkScalar advanceY = SkFixedToScalar(glyph.fAdvanceY)*alignMul*fT extRatio; |
| 332 | 332 |
| 333 if (!this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), | 333 if (!this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), |
| 334 glyph.getSubXFixed(), | 334 glyph.getSubXFixed(), |
| 335 glyph.getSubYFixed()), | 335 glyph.getSubYFixed()), |
| 336 x - advanceX, y - advanceY, fontScaler)) { | 336 x - advanceX, y - advanceY, fontScaler)) { |
| 337 // couldn't append, send to fallback | 337 // couldn't append, send to fallback |
| 338 fallbackTxt.push_back_n(text-lastText, lastText); | 338 fallbackTxt.push_back_n(SkToU32(text-lastText), lastText); |
| 339 fallbackPos.push_back(pos[0]); | 339 fallbackPos.push_back(pos[0]); |
| 340 if (2 == scalarsPerPosition) { | 340 if (2 == scalarsPerPosition) { |
| 341 fallbackPos.push_back(pos[1]); | 341 fallbackPos.push_back(pos[1]); |
| 342 } | 342 } |
| 343 } | 343 } |
| 344 } | 344 } |
| 345 pos += scalarsPerPosition; | 345 pos += scalarsPerPosition; |
| 346 } | 346 } |
| 347 } | 347 } |
| 348 | 348 |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 673 } | 673 } |
| 674 } | 674 } |
| 675 | 675 |
| 676 inline void GrDistanceFieldTextContext::finish() { | 676 inline void GrDistanceFieldTextContext::finish() { |
| 677 this->flush(); | 677 this->flush(); |
| 678 fTotalVertexCount = 0; | 678 fTotalVertexCount = 0; |
| 679 | 679 |
| 680 GrTextContext::finish(); | 680 GrTextContext::finish(); |
| 681 } | 681 } |
| 682 | 682 |
| OLD | NEW |