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

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

Issue 1011403005: Revert of Ensure that we use different glyph entries for regular and df text. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 | « no previous file | src/gpu/GrDistanceFieldTextContext.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 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 } 164 }
165 165
166 while (text < stop) { 166 while (text < stop) {
167 const SkGlyph& glyph = glyphCacheProc(cache, &text, fx & fxMask, fy & fy Mask); 167 const SkGlyph& glyph = glyphCacheProc(cache, &text, fx & fxMask, fy & fy Mask);
168 168
169 fx += autokern.adjust(glyph); 169 fx += autokern.adjust(glyph);
170 170
171 if (glyph.fWidth) { 171 if (glyph.fWidth) {
172 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), 172 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(),
173 glyph.getSubXFixed(), 173 glyph.getSubXFixed(),
174 glyph.getSubYFixed(), 174 glyph.getSubYFixed()),
175 GrGlyph::kCoverage_MaskStyle),
176 Sk48Dot16FloorToInt(fx), 175 Sk48Dot16FloorToInt(fx),
177 Sk48Dot16FloorToInt(fy), 176 Sk48Dot16FloorToInt(fy),
178 fontScaler); 177 fontScaler);
179 } 178 }
180 179
181 fx += glyph.fAdvanceX; 180 fx += glyph.fAdvanceX;
182 fy += glyph.fAdvanceY; 181 fy += glyph.fAdvanceY;
183 } 182 }
184 183
185 this->finish(); 184 this->finish();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 tmsProc(pos, &tmsLoc); 241 tmsProc(pos, &tmsLoc);
243 Sk48Dot16 fx = SkScalarTo48Dot16(tmsLoc.fX + halfSampleX); 242 Sk48Dot16 fx = SkScalarTo48Dot16(tmsLoc.fX + halfSampleX);
244 Sk48Dot16 fy = SkScalarTo48Dot16(tmsLoc.fY + halfSampleY); 243 Sk48Dot16 fy = SkScalarTo48Dot16(tmsLoc.fY + halfSampleY);
245 244
246 const SkGlyph& glyph = glyphCacheProc(cache, &text, 245 const SkGlyph& glyph = glyphCacheProc(cache, &text,
247 fx & fxMask, fy & fyMask); 246 fx & fxMask, fy & fyMask);
248 247
249 if (glyph.fWidth) { 248 if (glyph.fWidth) {
250 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), 249 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(),
251 glyph.getSubXFixed(), 250 glyph.getSubXFixed(),
252 glyph.getSubYFixed(), 251 glyph.getSubYFixed()),
253 GrGlyph::kCoverage_MaskStyle ),
254 Sk48Dot16FloorToInt(fx), 252 Sk48Dot16FloorToInt(fx),
255 Sk48Dot16FloorToInt(fy), 253 Sk48Dot16FloorToInt(fy),
256 fontScaler); 254 fontScaler);
257 } 255 }
258 pos += scalarsPerPosition; 256 pos += scalarsPerPosition;
259 } 257 }
260 } else { 258 } else {
261 while (text < stop) { 259 while (text < stop) {
262 const char* currentText = text; 260 const char* currentText = text;
263 const SkGlyph& metricGlyph = glyphCacheProc(cache, &text, 0, 0); 261 const SkGlyph& metricGlyph = glyphCacheProc(cache, &text, 0, 0);
(...skipping 12 matching lines...) Expand all
276 // have to call again, now that we've been "aligned" 274 // have to call again, now that we've been "aligned"
277 const SkGlyph& glyph = glyphCacheProc(cache, &currentText, 275 const SkGlyph& glyph = glyphCacheProc(cache, &currentText,
278 fx & fxMask, fy & fyMa sk); 276 fx & fxMask, fy & fyMa sk);
279 // the assumption is that the metrics haven't changed 277 // the assumption is that the metrics haven't changed
280 SkASSERT(prevAdvX == glyph.fAdvanceX); 278 SkASSERT(prevAdvX == glyph.fAdvanceX);
281 SkASSERT(prevAdvY == glyph.fAdvanceY); 279 SkASSERT(prevAdvY == glyph.fAdvanceY);
282 SkASSERT(glyph.fWidth); 280 SkASSERT(glyph.fWidth);
283 281
284 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), 282 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(),
285 glyph.getSubXFixed(), 283 glyph.getSubXFixed(),
286 glyph.getSubYFixed(), 284 glyph.getSubYFixed()),
287 GrGlyph::kCoverage_MaskStyle ),
288 Sk48Dot16FloorToInt(fx), 285 Sk48Dot16FloorToInt(fx),
289 Sk48Dot16FloorToInt(fy), 286 Sk48Dot16FloorToInt(fy),
290 fontScaler); 287 fontScaler);
291 } 288 }
292 pos += scalarsPerPosition; 289 pos += scalarsPerPosition;
293 } 290 }
294 } 291 }
295 } else { // not subpixel 292 } else { // not subpixel
296 293
297 if (SkPaint::kLeft_Align == fSkPaint.getTextAlign()) { 294 if (SkPaint::kLeft_Align == fSkPaint.getTextAlign()) {
298 while (text < stop) { 295 while (text < stop) {
299 // the last 2 parameters are ignored 296 // the last 2 parameters are ignored
300 const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0); 297 const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0);
301 298
302 if (glyph.fWidth) { 299 if (glyph.fWidth) {
303 SkPoint tmsLoc; 300 SkPoint tmsLoc;
304 tmsProc(pos, &tmsLoc); 301 tmsProc(pos, &tmsLoc);
305 302
306 Sk48Dot16 fx = SkScalarTo48Dot16(tmsLoc.fX + SK_ScalarHalf); //halfSampleX; 303 Sk48Dot16 fx = SkScalarTo48Dot16(tmsLoc.fX + SK_ScalarHalf); //halfSampleX;
307 Sk48Dot16 fy = SkScalarTo48Dot16(tmsLoc.fY + SK_ScalarHalf); //halfSampleY; 304 Sk48Dot16 fy = SkScalarTo48Dot16(tmsLoc.fY + SK_ScalarHalf); //halfSampleY;
308 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), 305 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(),
309 glyph.getSubXFixed(), 306 glyph.getSubXFixed(),
310 glyph.getSubYFixed(), 307 glyph.getSubYFixed()),
311 GrGlyph::kCoverage_MaskStyle ),
312 Sk48Dot16FloorToInt(fx), 308 Sk48Dot16FloorToInt(fx),
313 Sk48Dot16FloorToInt(fy), 309 Sk48Dot16FloorToInt(fy),
314 fontScaler); 310 fontScaler);
315 } 311 }
316 pos += scalarsPerPosition; 312 pos += scalarsPerPosition;
317 } 313 }
318 } else { 314 } else {
319 while (text < stop) { 315 while (text < stop) {
320 // the last 2 parameters are ignored 316 // the last 2 parameters are ignored
321 const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0); 317 const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0);
322 318
323 if (glyph.fWidth) { 319 if (glyph.fWidth) {
324 SkPoint tmsLoc; 320 SkPoint tmsLoc;
325 tmsProc(pos, &tmsLoc); 321 tmsProc(pos, &tmsLoc);
326 322
327 SkPoint alignLoc; 323 SkPoint alignLoc;
328 alignProc(tmsLoc, glyph, &alignLoc); 324 alignProc(tmsLoc, glyph, &alignLoc);
329 325
330 Sk48Dot16 fx = SkScalarTo48Dot16(alignLoc.fX + SK_ScalarHalf ); //halfSampleX; 326 Sk48Dot16 fx = SkScalarTo48Dot16(alignLoc.fX + SK_ScalarHalf ); //halfSampleX;
331 Sk48Dot16 fy = SkScalarTo48Dot16(alignLoc.fY + SK_ScalarHalf ); //halfSampleY; 327 Sk48Dot16 fy = SkScalarTo48Dot16(alignLoc.fY + SK_ScalarHalf ); //halfSampleY;
332 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), 328 this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(),
333 glyph.getSubXFixed(), 329 glyph.getSubXFixed(),
334 glyph.getSubYFixed(), 330 glyph.getSubYFixed()),
335 GrGlyph::kCoverage_MaskStyle ),
336 Sk48Dot16FloorToInt(fx), 331 Sk48Dot16FloorToInt(fx),
337 Sk48Dot16FloorToInt(fy), 332 Sk48Dot16FloorToInt(fy),
338 fontScaler); 333 fontScaler);
339 } 334 }
340 pos += scalarsPerPosition; 335 pos += scalarsPerPosition;
341 } 336 }
342 } 337 }
343 } 338 }
344 339
345 this->finish(); 340 this->finish();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 } 405 }
411 406
412 void GrBitmapTextContext::appendGlyph(GrGlyph::PackedID packed, 407 void GrBitmapTextContext::appendGlyph(GrGlyph::PackedID packed,
413 int vx, int vy, 408 int vx, int vy,
414 GrFontScaler* scaler) { 409 GrFontScaler* scaler) {
415 if (NULL == fDrawTarget) { 410 if (NULL == fDrawTarget) {
416 return; 411 return;
417 } 412 }
418 413
419 if (NULL == fStrike) { 414 if (NULL == fStrike) {
420 fStrike = fContext->getFontCache()->getStrike(scaler); 415 fStrike = fContext->getFontCache()->getStrike(scaler, false);
421 } 416 }
422 417
423 GrGlyph* glyph = fStrike->getGlyph(packed, scaler); 418 GrGlyph* glyph = fStrike->getGlyph(packed, scaler);
424 if (NULL == glyph || glyph->fBounds.isEmpty()) { 419 if (NULL == glyph || glyph->fBounds.isEmpty()) {
425 return; 420 return;
426 } 421 }
427 422
428 int x = vx + glyph->fBounds.fLeft; 423 int x = vx + glyph->fBounds.fLeft;
429 int y = vy + glyph->fBounds.fTop; 424 int y = vy + glyph->fBounds.fTop;
430 425
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 } 620 }
626 } 621 }
627 622
628 inline void GrBitmapTextContext::finish() { 623 inline void GrBitmapTextContext::finish() {
629 this->flush(); 624 this->flush();
630 fTotalVertexCount = 0; 625 fTotalVertexCount = 0;
631 626
632 GrTextContext::finish(); 627 GrTextContext::finish();
633 } 628 }
634 629
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrDistanceFieldTextContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698