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

Side by Side Diff: src/core/SkFindAndPlaceGlyph.h

Issue 1438893002: Increment text pointer when the width is zero in the subpixel with center and right alignment. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add test cases for code. Created 5 years, 1 month 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 | « no previous file | tests/DrawTextTest.cpp » ('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 2015 Google Inc. 2 * Copyright 2015 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 #ifndef SkFindAndPositionGlyph_DEFINED 8 #ifndef SkFindAndPositionGlyph_DEFINED
9 #define SkFindAndPositionGlyph_DEFINED 9 #define SkFindAndPositionGlyph_DEFINED
10 10
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 void findAndPositionGlyph(const char** text, SkPoint position, 301 void findAndPositionGlyph(const char** text, SkPoint position,
302 ProcessOneGlyph&& processOneGlyph) override { 302 ProcessOneGlyph&& processOneGlyph) override {
303 SkPoint finalPosition = position; 303 SkPoint finalPosition = position;
304 if (kTextAlignment != SkPaint::kLeft_Align) { 304 if (kTextAlignment != SkPaint::kLeft_Align) {
305 // Get the width of an un-sub-pixel positioned glyph for calcula ting the alignment. 305 // Get the width of an un-sub-pixel positioned glyph for calcula ting the alignment.
306 // This is not needed for kLeftAlign because its adjustment is a lways {0, 0}. 306 // This is not needed for kLeftAlign because its adjustment is a lways {0, 0}.
307 const char* tempText = *text; 307 const char* tempText = *text;
308 const SkGlyph &metricGlyph = fGlyphCacheProc(fCache, &tempText, 0, 0); 308 const SkGlyph &metricGlyph = fGlyphCacheProc(fCache, &tempText, 0, 0);
309 309
310 if (metricGlyph.fWidth <= 0) { 310 if (metricGlyph.fWidth <= 0) {
311 // Exiting early, be sure to update text pointer.
312 *text = tempText;
311 return; 313 return;
312 } 314 }
313 315
314 // Adjust the final position by the alignment adjustment. 316 // Adjust the final position by the alignment adjustment.
315 finalPosition -= TextAlignmentAdjustment(kTextAlignment, metricG lyph); 317 finalPosition -= TextAlignmentAdjustment(kTextAlignment, metricG lyph);
316 } 318 }
317 319
318 // Find the glyph. 320 // Find the glyph.
319 SkIPoint lookupPosition = SubpixelAlignment(kAxisAlignment, finalPos ition); 321 SkIPoint lookupPosition = SubpixelAlignment(kAxisAlignment, finalPos ition);
320 const SkGlyph& renderGlyph = fGlyphCacheProc( 322 const SkGlyph& renderGlyph = fGlyphCacheProc(
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 positioner.Positioner::findAndPositionGlyph( 516 positioner.Positioner::findAndPositionGlyph(
515 &cursor, mappedPoint, skstd::forward<ProcessOneGlyph>(processOne Glyph)); 517 &cursor, mappedPoint, skstd::forward<ProcessOneGlyph>(processOne Glyph));
516 } 518 }
517 return true; 519 return true;
518 } 520 }
519 return false; 521 return false;
520 } 522 }
521 523
522 524
523 #endif // SkFindAndPositionGlyph_DEFINED 525 #endif // SkFindAndPositionGlyph_DEFINED
OLDNEW
« no previous file with comments | « no previous file | tests/DrawTextTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698