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

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

Issue 977623002: Glyph positions maintain 32 bit integer part. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Use Sk48Dot6, do no fixed math. 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
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 "GrBitmapTextContext.h" 8 #include "GrBitmapTextContext.h"
9 #include "GrAtlas.h" 9 #include "GrAtlas.h"
10 #include "GrDefaultGeoProcFactory.h" 10 #include "GrDefaultGeoProcFactory.h"
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 } else { 258 } else {
259 while (text < stop) { 259 while (text < stop) {
260 const char* currentText = text; 260 const char* currentText = text;
261 const SkGlyph& metricGlyph = glyphCacheProc(cache, &text, 0, 0); 261 const SkGlyph& metricGlyph = glyphCacheProc(cache, &text, 0, 0);
262 262
263 if (metricGlyph.fWidth) { 263 if (metricGlyph.fWidth) {
264 SkDEBUGCODE(SkFixed prevAdvX = metricGlyph.fAdvanceX;) 264 SkDEBUGCODE(SkFixed prevAdvX = metricGlyph.fAdvanceX;)
265 SkDEBUGCODE(SkFixed prevAdvY = metricGlyph.fAdvanceY;) 265 SkDEBUGCODE(SkFixed prevAdvY = metricGlyph.fAdvanceY;)
266 SkPoint tmsLoc; 266 SkPoint tmsLoc;
267 tmsProc(pos, &tmsLoc); 267 tmsProc(pos, &tmsLoc);
268 SkIPoint fixedLoc; 268 SkPoint alignLoc;
269 alignProc(tmsLoc, metricGlyph, &fixedLoc); 269 alignProc(tmsLoc, metricGlyph, &alignLoc);
270 270
271 SkFixed fx = fixedLoc.fX + halfSampleX; 271 SkFixed fx = SkScalarToFixed(alignLoc.fX) + halfSampleX;
272 SkFixed fy = fixedLoc.fY + halfSampleY; 272 SkFixed fy = SkScalarToFixed(alignLoc.fY) + halfSampleY;
273 273
274 // have to call again, now that we've been "aligned" 274 // have to call again, now that we've been "aligned"
275 const SkGlyph& glyph = glyphCacheProc(cache, &currentText, 275 const SkGlyph& glyph = glyphCacheProc(cache, &currentText,
276 fx & fxMask, fy & fyMa sk); 276 fx & fxMask, fy & fyMa sk);
277 // the assumption is that the metrics haven't changed 277 // the assumption is that the metrics haven't changed
278 SkASSERT(prevAdvX == glyph.fAdvanceX); 278 SkASSERT(prevAdvX == glyph.fAdvanceX);
279 SkASSERT(prevAdvY == glyph.fAdvanceY); 279 SkASSERT(prevAdvY == glyph.fAdvanceY);
280 SkASSERT(glyph.fWidth); 280 SkASSERT(glyph.fWidth);
281 281
282 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), 282 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(),
(...skipping 30 matching lines...) Expand all
313 } 313 }
314 } else { 314 } else {
315 while (text < stop) { 315 while (text < stop) {
316 // the last 2 parameters are ignored 316 // the last 2 parameters are ignored
317 const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0); 317 const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0);
318 318
319 if (glyph.fWidth) { 319 if (glyph.fWidth) {
320 SkPoint tmsLoc; 320 SkPoint tmsLoc;
321 tmsProc(pos, &tmsLoc); 321 tmsProc(pos, &tmsLoc);
322 322
323 SkIPoint fixedLoc; 323 SkPoint alignLoc;
324 alignProc(tmsLoc, glyph, &fixedLoc); 324 alignProc(tmsLoc, glyph, &alignLoc);
325 325
326 SkFixed fx = fixedLoc.fX + SK_FixedHalf; //halfSampleX; 326 SkFixed fx = SkScalarToFixed(alignLoc.fX) + SK_FixedHalf; // halfSampleX;
327 SkFixed fy = fixedLoc.fY + SK_FixedHalf; //halfSampleY; 327 SkFixed fy = SkScalarToFixed(alignLoc.fY) + SK_FixedHalf; // halfSampleY;
328 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), 328 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(),
329 glyph.getSubXFixed(), 329 glyph.getSubXFixed(),
330 glyph.getSubYFixed()), 330 glyph.getSubYFixed()),
331 SkFixedFloorToFixed(fx), 331 SkFixedFloorToFixed(fx),
332 SkFixedFloorToFixed(fy), 332 SkFixedFloorToFixed(fy),
333 fontScaler); 333 fontScaler);
334 } 334 }
335 pos += scalarsPerPosition; 335 pos += scalarsPerPosition;
336 } 336 }
337 } 337 }
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 } 623 }
624 } 624 }
625 625
626 inline void GrBitmapTextContext::finish() { 626 inline void GrBitmapTextContext::finish() {
627 this->flush(); 627 this->flush();
628 fTotalVertexCount = 0; 628 fTotalVertexCount = 0;
629 629
630 GrTextContext::finish(); 630 GrTextContext::finish();
631 } 631 }
632 632
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698