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

Side by Side Diff: src/ports/SkScalerContext_win_dw.cpp

Issue 504343007: DirectWrite to use aliased if ClearType is empty. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 3 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/ports/SkScalerContext_win_dw.h ('k') | no next file » | 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 2011 Google Inc. 2 * Copyright 2011 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 "SkTypes.h" 8 #include "SkTypes.h"
9 #undef GetGlyphIndices 9 #undef GetGlyphIndices
10 10
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 vecs[0].fX = SkScalarRoundToScalar(advanceX); 391 vecs[0].fX = SkScalarRoundToScalar(advanceX);
392 fG_inv.mapVectors(vecs, SK_ARRAY_COUNT(vecs)); 392 fG_inv.mapVectors(vecs, SK_ARRAY_COUNT(vecs));
393 } else { 393 } else {
394 fSkXform.mapVectors(vecs, SK_ARRAY_COUNT(vecs)); 394 fSkXform.mapVectors(vecs, SK_ARRAY_COUNT(vecs));
395 } 395 }
396 396
397 glyph->fAdvanceX = SkScalarToFixed(vecs[0].fX); 397 glyph->fAdvanceX = SkScalarToFixed(vecs[0].fX);
398 glyph->fAdvanceY = SkScalarToFixed(vecs[0].fY); 398 glyph->fAdvanceY = SkScalarToFixed(vecs[0].fY);
399 } 399 }
400 400
401 void SkScalerContext_DW::generateMetrics(SkGlyph* glyph) { 401 void SkScalerContext_DW::getBoundingBox(SkGlyph* glyph,
402 glyph->fWidth = 0; 402 DWRITE_RENDERING_MODE renderingMode,
403 403 DWRITE_TEXTURE_TYPE textureType,
404 this->generateAdvance(glyph); 404 RECT* bbox)
405 405 {
406 //Measure raster size. 406 //Measure raster size.
407 fXform.dx = SkFixedToFloat(glyph->getSubXFixed()); 407 fXform.dx = SkFixedToFloat(glyph->getSubXFixed());
408 fXform.dy = SkFixedToFloat(glyph->getSubYFixed()); 408 fXform.dy = SkFixedToFloat(glyph->getSubYFixed());
409 409
410 FLOAT advance = 0; 410 FLOAT advance = 0;
411 411
412 UINT16 glyphId = glyph->getGlyphID(); 412 UINT16 glyphId = glyph->getGlyphID();
413 413
414 DWRITE_GLYPH_OFFSET offset; 414 DWRITE_GLYPH_OFFSET offset;
415 offset.advanceOffset = 0.0f; 415 offset.advanceOffset = 0.0f;
416 offset.ascenderOffset = 0.0f; 416 offset.ascenderOffset = 0.0f;
417 417
418 DWRITE_GLYPH_RUN run; 418 DWRITE_GLYPH_RUN run;
419 run.glyphCount = 1; 419 run.glyphCount = 1;
420 run.glyphAdvances = &advance; 420 run.glyphAdvances = &advance;
421 run.fontFace = fTypeface->fDWriteFontFace.get(); 421 run.fontFace = fTypeface->fDWriteFontFace.get();
422 run.fontEmSize = SkScalarToFloat(fTextSizeRender); 422 run.fontEmSize = SkScalarToFloat(fTextSizeRender);
423 run.bidiLevel = 0; 423 run.bidiLevel = 0;
424 run.glyphIndices = &glyphId; 424 run.glyphIndices = &glyphId;
425 run.isSideways = FALSE; 425 run.isSideways = FALSE;
426 run.glyphOffsets = &offset; 426 run.glyphOffsets = &offset;
427 427
428 SkTScopedComPtr<IDWriteGlyphRunAnalysis> glyphRunAnalysis; 428 SkTScopedComPtr<IDWriteGlyphRunAnalysis> glyphRunAnalysis;
429 HRVM(fTypeface->fFactory->CreateGlyphRunAnalysis( 429 HRVM(fTypeface->fFactory->CreateGlyphRunAnalysis(
430 &run, 430 &run,
431 1.0f, // pixelsPerDip, 431 1.0f, // pixelsPerDip,
432 &fXform, 432 &fXform,
433 fRenderingMode, 433 renderingMode,
434 fMeasuringMode, 434 fMeasuringMode,
435 0.0f, // baselineOriginX, 435 0.0f, // baselineOriginX,
436 0.0f, // baselineOriginY, 436 0.0f, // baselineOriginY,
437 &glyphRunAnalysis), 437 &glyphRunAnalysis),
438 "Could not create glyph run analysis."); 438 "Could not create glyph run analysis.");
439 439
440 HRVM(glyphRunAnalysis->GetAlphaTextureBounds(textureType, bbox),
441 "Could not get texture bounds.");
442 }
443
444 void SkScalerContext_DW::generateMetrics(SkGlyph* glyph) {
445 glyph->fWidth = 0;
446
447 this->generateAdvance(glyph);
448
440 RECT bbox; 449 RECT bbox;
441 HRVM(glyphRunAnalysis->GetAlphaTextureBounds(fTextureType, &bbox), 450 this->getBoundingBox(glyph, fRenderingMode, fTextureType, &bbox);
442 "Could not get texture bounds."); 451
452 if (bbox.left == bbox.right || bbox.top == bbox.bottom) {
453 if (DWRITE_TEXTURE_CLEARTYPE_3x1 == fTextureType) {
454 this->getBoundingBox(glyph,
455 DWRITE_RENDERING_MODE_ALIASED,
456 DWRITE_TEXTURE_ALIASED_1x1,
457 &bbox);
458 if (bbox.left != bbox.right && bbox.top != bbox.bottom) {
reed1 2014/08/27 22:07:33 I'd add a comment inside the if... // We concede
459 fTextureType = DWRITE_TEXTURE_ALIASED_1x1;
460 fRenderingMode = DWRITE_RENDERING_MODE_ALIASED;
461 }
462 }
463 }
443 464
444 glyph->fWidth = SkToU16(bbox.right - bbox.left); 465 glyph->fWidth = SkToU16(bbox.right - bbox.left);
445 glyph->fHeight = SkToU16(bbox.bottom - bbox.top); 466 glyph->fHeight = SkToU16(bbox.bottom - bbox.top);
446 glyph->fLeft = SkToS16(bbox.left); 467 glyph->fLeft = SkToS16(bbox.left);
447 glyph->fTop = SkToS16(bbox.top); 468 glyph->fTop = SkToS16(bbox.top);
448 } 469 }
449 470
450 void SkScalerContext_DW::generateFontMetrics(SkPaint::FontMetrics* metrics) { 471 void SkScalerContext_DW::generateFontMetrics(SkPaint::FontMetrics* metrics) {
451 if (NULL == metrics) { 472 if (NULL == metrics) {
452 return; 473 return;
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 NULL, //advances 733 NULL, //advances
713 NULL, //offsets 734 NULL, //offsets
714 1, //num glyphs 735 1, //num glyphs
715 FALSE, //sideways 736 FALSE, //sideways
716 FALSE, //rtl 737 FALSE, //rtl
717 geometryToPath.get()), 738 geometryToPath.get()),
718 "Could not create glyph outline."); 739 "Could not create glyph outline.");
719 740
720 path->transform(fSkXform); 741 path->transform(fSkXform);
721 } 742 }
OLDNEW
« no previous file with comments | « src/ports/SkScalerContext_win_dw.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698