Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(277)

Side by Side Diff: src/gpu/GrDistanceFieldTextContext.cpp

Issue 1020593003: Ensure that we use different glyph entries for regular and df text. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/GrBitmapTextContext.cpp ('k') | src/gpu/GrFontCache.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 const char* lastText = text; 312 const char* lastText = text;
313 // the last 2 parameters are ignored 313 // the last 2 parameters are ignored
314 const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0); 314 const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0);
315 315
316 if (glyph.fWidth) { 316 if (glyph.fWidth) {
317 SkScalar x = offset.x() + pos[0]; 317 SkScalar x = offset.x() + pos[0];
318 SkScalar y = offset.y() + (2 == scalarsPerPosition ? pos[1] : 0) ; 318 SkScalar y = offset.y() + (2 == scalarsPerPosition ? pos[1] : 0) ;
319 319
320 if (!this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), 320 if (!this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(),
321 glyph.getSubXFixed(), 321 glyph.getSubXFixed(),
322 glyph.getSubYFixed()), 322 glyph.getSubYFixed(),
323 GrGlyph::kDistance_MaskStyl e),
323 x, y, fontScaler)) { 324 x, y, fontScaler)) {
324 // couldn't append, send to fallback 325 // couldn't append, send to fallback
325 fallbackTxt.push_back_n(SkToInt(text-lastText), lastText); 326 fallbackTxt.push_back_n(SkToInt(text-lastText), lastText);
326 fallbackPos.push_back(pos[0]); 327 fallbackPos.push_back(pos[0]);
327 if (2 == scalarsPerPosition) { 328 if (2 == scalarsPerPosition) {
328 fallbackPos.push_back(pos[1]); 329 fallbackPos.push_back(pos[1]);
329 } 330 }
330 } 331 }
331 } 332 }
332 pos += scalarsPerPosition; 333 pos += scalarsPerPosition;
333 } 334 }
334 } else { 335 } else {
335 SkScalar alignMul = SkPaint::kCenter_Align == fSkPaint.getTextAlign() ? SK_ScalarHalf 336 SkScalar alignMul = SkPaint::kCenter_Align == fSkPaint.getTextAlign() ? SK_ScalarHalf
336 : SK_Scalar1; 337 : SK_Scalar1;
337 while (text < stop) { 338 while (text < stop) {
338 const char* lastText = text; 339 const char* lastText = text;
339 // the last 2 parameters are ignored 340 // the last 2 parameters are ignored
340 const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0); 341 const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0);
341 342
342 if (glyph.fWidth) { 343 if (glyph.fWidth) {
343 SkScalar x = offset.x() + pos[0]; 344 SkScalar x = offset.x() + pos[0];
344 SkScalar y = offset.y() + (2 == scalarsPerPosition ? pos[1] : 0) ; 345 SkScalar y = offset.y() + (2 == scalarsPerPosition ? pos[1] : 0) ;
345 346
346 SkScalar advanceX = SkFixedToScalar(glyph.fAdvanceX)*alignMul*fT extRatio; 347 SkScalar advanceX = SkFixedToScalar(glyph.fAdvanceX)*alignMul*fT extRatio;
347 SkScalar advanceY = SkFixedToScalar(glyph.fAdvanceY)*alignMul*fT extRatio; 348 SkScalar advanceY = SkFixedToScalar(glyph.fAdvanceY)*alignMul*fT extRatio;
348 349
349 if (!this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), 350 if (!this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(),
350 glyph.getSubXFixed(), 351 glyph.getSubXFixed(),
351 glyph.getSubYFixed()), 352 glyph.getSubYFixed(),
353 GrGlyph::kDistance_MaskStyl e),
352 x - advanceX, y - advanceY, fontScaler)) { 354 x - advanceX, y - advanceY, fontScaler)) {
353 // couldn't append, send to fallback 355 // couldn't append, send to fallback
354 fallbackTxt.push_back_n(SkToInt(text-lastText), lastText); 356 fallbackTxt.push_back_n(SkToInt(text-lastText), lastText);
355 fallbackPos.push_back(pos[0]); 357 fallbackPos.push_back(pos[0]);
356 if (2 == scalarsPerPosition) { 358 if (2 == scalarsPerPosition) {
357 fallbackPos.push_back(pos[1]); 359 fallbackPos.push_back(pos[1]);
358 } 360 }
359 } 361 }
360 } 362 }
361 pos += scalarsPerPosition; 363 pos += scalarsPerPosition;
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 // Returns true if this method handled the glyph, false if needs to be passed to fallback 504 // Returns true if this method handled the glyph, false if needs to be passed to fallback
503 // 505 //
504 bool GrDistanceFieldTextContext::appendGlyph(GrGlyph::PackedID packed, 506 bool GrDistanceFieldTextContext::appendGlyph(GrGlyph::PackedID packed,
505 SkScalar sx, SkScalar sy, 507 SkScalar sx, SkScalar sy,
506 GrFontScaler* scaler) { 508 GrFontScaler* scaler) {
507 if (NULL == fDrawTarget) { 509 if (NULL == fDrawTarget) {
508 return true; 510 return true;
509 } 511 }
510 512
511 if (NULL == fStrike) { 513 if (NULL == fStrike) {
512 fStrike = fContext->getFontCache()->getStrike(scaler, true); 514 fStrike = fContext->getFontCache()->getStrike(scaler);
513 } 515 }
514 516
515 GrGlyph* glyph = fStrike->getGlyph(packed, scaler); 517 GrGlyph* glyph = fStrike->getGlyph(packed, scaler);
516 if (NULL == glyph || glyph->fBounds.isEmpty()) { 518 if (NULL == glyph || glyph->fBounds.isEmpty()) {
517 return true; 519 return true;
518 } 520 }
519 521
520 // fallback to color glyph support 522 // fallback to color glyph support
521 if (kA8_GrMaskFormat != glyph->fMaskFormat) { 523 if (kA8_GrMaskFormat != glyph->fMaskFormat) {
522 return false; 524 return false;
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 } 720 }
719 } 721 }
720 722
721 inline void GrDistanceFieldTextContext::finish() { 723 inline void GrDistanceFieldTextContext::finish() {
722 this->flush(); 724 this->flush();
723 fTotalVertexCount = 0; 725 fTotalVertexCount = 0;
724 726
725 GrTextContext::finish(); 727 GrTextContext::finish();
726 } 728 }
727 729
OLDNEW
« no previous file with comments | « src/gpu/GrBitmapTextContext.cpp ('k') | src/gpu/GrFontCache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698