Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #if defined(SK_BUILD_FOR_WIN32) | 9 #if defined(SK_BUILD_FOR_WIN32) |
| 10 | 10 |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 } | 205 } |
| 206 | 206 |
| 207 SkScalerContext_DW::SkScalerContext_DW(DWriteFontTypeface* typeface, | 207 SkScalerContext_DW::SkScalerContext_DW(DWriteFontTypeface* typeface, |
| 208 const SkScalerContextEffects& effects, | 208 const SkScalerContextEffects& effects, |
| 209 const SkDescriptor* desc) | 209 const SkDescriptor* desc) |
| 210 : SkScalerContext(typeface, effects, desc) | 210 : SkScalerContext(typeface, effects, desc) |
| 211 , fTypeface(SkRef(typeface)) | 211 , fTypeface(SkRef(typeface)) |
| 212 , fGlyphCount(-1) { | 212 , fGlyphCount(-1) { |
| 213 | 213 |
| 214 #if SK_HAS_DWRITE_2_H | 214 #if SK_HAS_DWRITE_2_H |
| 215 fTypeface->fFactory->QueryInterface<IDWriteFactory2>(&fFactory2); | 215 fIsColorFont = fTypeface->fFactory2 && |
| 216 | 216 fTypeface->fDWriteFontFace2 && |
| 217 SkTScopedComPtr<IDWriteFontFace2> fontFace2; | 217 fTypeface->fDWriteFontFace2->IsColorFont(); |
| 218 fTypeface->fDWriteFontFace->QueryInterface<IDWriteFontFace2>(&fontFace2); | |
| 219 fIsColorFont = fFactory2.get() && fontFace2.get() && fontFace2->IsColorFont( ); | |
| 220 #endif | 218 #endif |
| 221 | 219 |
| 222 // In general, all glyphs should use CLEARTYPE_NATURAL_SYMMETRIC | 220 // In general, all glyphs should use CLEARTYPE_NATURAL_SYMMETRIC |
| 223 // except when bi-level rendering is requested or there are embedded | 221 // except when bi-level rendering is requested or there are embedded |
| 224 // bi-level bitmaps (and the embedded bitmap flag is set and no rotation). | 222 // bi-level bitmaps (and the embedded bitmap flag is set and no rotation). |
| 225 // | 223 // |
| 226 // DirectWrite's IDWriteFontFace::GetRecommendedRenderingMode does not do | 224 // DirectWrite's IDWriteFontFace::GetRecommendedRenderingMode does not do |
| 227 // this. As a result, determine the actual size of the text and then see if | 225 // this. As a result, determine the actual size of the text and then see if |
| 228 // there are any embedded bi-level bitmaps of that size. If there are, then | 226 // there are any embedded bi-level bitmaps of that size. If there are, then |
| 229 // force bitmaps by requesting bi-level rendering. | 227 // force bitmaps by requesting bi-level rendering. |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 317 | 315 |
| 318 // The normal case is to use natural symmetric rendering and linear metrics. | 316 // The normal case is to use natural symmetric rendering and linear metrics. |
| 319 } else { | 317 } else { |
| 320 fTextSizeRender = realTextSize; | 318 fTextSizeRender = realTextSize; |
| 321 fRenderingMode = DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC; | 319 fRenderingMode = DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC; |
| 322 fTextureType = DWRITE_TEXTURE_CLEARTYPE_3x1; | 320 fTextureType = DWRITE_TEXTURE_CLEARTYPE_3x1; |
| 323 fTextSizeMeasure = realTextSize; | 321 fTextSizeMeasure = realTextSize; |
| 324 fMeasuringMode = DWRITE_MEASURING_MODE_NATURAL; | 322 fMeasuringMode = DWRITE_MEASURING_MODE_NATURAL; |
| 325 } | 323 } |
| 326 | 324 |
| 325 // DirectWrite2 allows for grayscale hinting. | |
| 326 #if SK_HAS_DWRITE_2_H | |
| 327 fAntiAliasMode = DWRITE_TEXT_ANTIALIAS_MODE_CLEARTYPE; | |
| 328 #ifndef SK_IGNORE_DW_GRAY_FIX | |
| 329 if (fTypeface->fFactory2 && fTypeface->fDWriteFontFace2 && | |
| 330 !isLCD(fRec) && !(fRec.fFlags & SkScalerContext::kGenA8FromLCD_Flag)) | |
| 331 { | |
| 332 // DWRITE_TEXTURE_ALIASED_1x1 is now misnamed, it must also be used with grayscale. | |
| 333 fTextureType = DWRITE_TEXTURE_ALIASED_1x1; | |
| 334 fAntiAliasMode = DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE; | |
| 335 } | |
| 336 #endif | |
| 337 #endif | |
| 338 | |
| 339 // DirectWrite2 allows hinting to be disabled. | |
| 340 #if SK_HAS_DWRITE_2_H | |
| 341 fGridFitMode = DWRITE_GRID_FIT_MODE_ENABLED; | |
| 342 if (fTypeface->fFactory2 && fTypeface->fDWriteFontFace2 && | |
| 343 fRec.getHinting() == SkPaint::kNo_Hinting) | |
| 344 { | |
| 345 fGridFitMode = DWRITE_GRID_FIT_MODE_DISABLED; | |
| 346 } | |
| 347 #endif | |
| 348 | |
| 327 if (this->isSubpixel()) { | 349 if (this->isSubpixel()) { |
| 328 fTextSizeMeasure = realTextSize; | 350 fTextSizeMeasure = realTextSize; |
| 329 fMeasuringMode = DWRITE_MEASURING_MODE_NATURAL; | 351 fMeasuringMode = DWRITE_MEASURING_MODE_NATURAL; |
| 330 } | 352 } |
| 331 } | 353 } |
| 332 | 354 |
| 333 SkScalerContext_DW::~SkScalerContext_DW() { | 355 SkScalerContext_DW::~SkScalerContext_DW() { |
| 334 } | 356 } |
| 335 | 357 |
| 336 unsigned SkScalerContext_DW::generateGlyphCount() { | 358 unsigned SkScalerContext_DW::generateGlyphCount() { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 425 run.fontFace = fTypeface->fDWriteFontFace.get(); | 447 run.fontFace = fTypeface->fDWriteFontFace.get(); |
| 426 run.fontEmSize = SkScalarToFloat(fTextSizeRender); | 448 run.fontEmSize = SkScalarToFloat(fTextSizeRender); |
| 427 run.bidiLevel = 0; | 449 run.bidiLevel = 0; |
| 428 run.glyphIndices = &glyphId; | 450 run.glyphIndices = &glyphId; |
| 429 run.isSideways = FALSE; | 451 run.isSideways = FALSE; |
| 430 run.glyphOffsets = &offset; | 452 run.glyphOffsets = &offset; |
| 431 | 453 |
| 432 SkTScopedComPtr<IDWriteGlyphRunAnalysis> glyphRunAnalysis; | 454 SkTScopedComPtr<IDWriteGlyphRunAnalysis> glyphRunAnalysis; |
| 433 { | 455 { |
| 434 SkAutoExclusive l(DWriteFactoryMutex); | 456 SkAutoExclusive l(DWriteFactoryMutex); |
| 435 HRM(fTypeface->fFactory->CreateGlyphRunAnalysis( | 457 if (fTypeface->fFactory2) { |
| 436 &run, | 458 #if SK_HAS_DWRITE_2_H |
| 437 1.0f, // pixelsPerDip, | 459 HRNM(fTypeface->fFactory2->CreateGlyphRunAnalysis( |
| 438 &fXform, | 460 &run, |
| 439 renderingMode, | 461 &fXform, |
| 440 fMeasuringMode, | 462 renderingMode, |
| 441 0.0f, // baselineOriginX, | 463 fMeasuringMode, |
| 442 0.0f, // baselineOriginY, | 464 fGridFitMode, |
| 443 &glyphRunAnalysis), | 465 fAntiAliasMode, |
| 444 "Could not create glyph run analysis."); | 466 0.0f, // baselineOriginX, |
| 467 0.0f, // baselineOriginY, | |
| 468 &glyphRunAnalysis), | |
| 469 "Could not create DW2 glyph run analysis."); | |
|
mtklein
2016/06/16 15:19:29
<top of file>
#if !SK_HAS_DWRITE_2_H
#pragma .
bungeman-skia
2016/06/16 17:04:58
Done.
| |
| 470 #else | |
| 471 # pragma message("No dwrite_2.h is available, pixel antialiased glyph quality m ay be affected.") | |
| 472 #endif | |
| 473 } else { | |
| 474 HRNM(fTypeface->fFactory->CreateGlyphRunAnalysis(&run, | |
| 475 1.0f, // pixelsPerDip, | |
| 476 &fXform, | |
| 477 renderingMode, | |
| 478 fMeasuringMode, | |
| 479 0.0f, // baselineOriginX, | |
| 480 0.0f, // baselineOriginY, | |
| 481 &glyphRunAnalysis), | |
| 482 "Could not create glyph run analysis."); | |
| 483 } | |
| 445 } | 484 } |
| 446 { | 485 { |
| 447 Shared l(DWriteFactoryMutex); | 486 Shared l(DWriteFactoryMutex); |
| 448 HRM(glyphRunAnalysis->GetAlphaTextureBounds(textureType, bbox), | 487 HRM(glyphRunAnalysis->GetAlphaTextureBounds(textureType, bbox), |
| 449 "Could not get texture bounds."); | 488 "Could not get texture bounds."); |
| 450 } | 489 } |
| 451 return S_OK; | 490 return S_OK; |
| 452 } | 491 } |
| 453 | 492 |
| 454 /** GetAlphaTextureBounds succeeds but sometimes returns empty bounds like | 493 /** GetAlphaTextureBounds succeeds but sometimes returns empty bounds like |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 491 DWRITE_GLYPH_RUN run; | 530 DWRITE_GLYPH_RUN run; |
| 492 run.glyphCount = 1; | 531 run.glyphCount = 1; |
| 493 run.glyphAdvances = &advance; | 532 run.glyphAdvances = &advance; |
| 494 run.fontFace = fTypeface->fDWriteFontFace.get(); | 533 run.fontFace = fTypeface->fDWriteFontFace.get(); |
| 495 run.fontEmSize = SkScalarToFloat(fTextSizeRender); | 534 run.fontEmSize = SkScalarToFloat(fTextSizeRender); |
| 496 run.bidiLevel = 0; | 535 run.bidiLevel = 0; |
| 497 run.glyphIndices = &glyphId; | 536 run.glyphIndices = &glyphId; |
| 498 run.isSideways = FALSE; | 537 run.isSideways = FALSE; |
| 499 run.glyphOffsets = &offset; | 538 run.glyphOffsets = &offset; |
| 500 | 539 |
| 501 HRESULT hr = fFactory2->TranslateColorGlyphRun( | 540 HRESULT hr = fTypeface->fFactory2->TranslateColorGlyphRun( |
| 502 0, 0, &run, nullptr, fMeasuringMode, &fXform, 0, colorGlyph); | 541 0, 0, &run, nullptr, fMeasuringMode, &fXform, 0, colorGlyph); |
| 503 if (hr == DWRITE_E_NOCOLOR) { | 542 if (hr == DWRITE_E_NOCOLOR) { |
| 504 return false; | 543 return false; |
| 505 } | 544 } |
| 506 HRBM(hr, "Failed to translate color glyph run"); | 545 HRBM(hr, "Failed to translate color glyph run"); |
| 507 return true; | 546 return true; |
| 508 } | 547 } |
| 509 #endif | 548 #endif |
| 510 | 549 |
| 511 void SkScalerContext_DW::generateMetrics(SkGlyph* glyph) { | 550 void SkScalerContext_DW::generateMetrics(SkGlyph* glyph) { |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 649 mask >>= 1; | 688 mask >>= 1; |
| 650 } | 689 } |
| 651 dst[byteCount] = byte; | 690 dst[byteCount] = byte; |
| 652 } | 691 } |
| 653 src += bitCount; | 692 src += bitCount; |
| 654 dst += dstRB; | 693 dst += dstRB; |
| 655 } | 694 } |
| 656 } | 695 } |
| 657 | 696 |
| 658 template<bool APPLY_PREBLEND> | 697 template<bool APPLY_PREBLEND> |
| 698 static void grayscale_to_a8(const uint8_t* SK_RESTRICT src, const SkGlyph& glyph , | |
| 699 const uint8_t* table8) { | |
| 700 const size_t dstRB = glyph.rowBytes(); | |
| 701 const U16CPU width = glyph.fWidth; | |
| 702 uint8_t* SK_RESTRICT dst = static_cast<uint8_t*>(glyph.fImage); | |
| 703 | |
| 704 for (U16CPU y = 0; y < glyph.fHeight; y++) { | |
| 705 for (U16CPU i = 0; i < width; i++) { | |
| 706 U8CPU a = *(src++); | |
| 707 dst[i] = sk_apply_lut_if<APPLY_PREBLEND>(a, table8); | |
| 708 } | |
| 709 dst = SkTAddOffset<uint8_t>(dst, dstRB); | |
| 710 } | |
| 711 } | |
| 712 | |
| 713 template<bool APPLY_PREBLEND> | |
| 659 static void rgb_to_a8(const uint8_t* SK_RESTRICT src, const SkGlyph& glyph, cons t uint8_t* table8) { | 714 static void rgb_to_a8(const uint8_t* SK_RESTRICT src, const SkGlyph& glyph, cons t uint8_t* table8) { |
| 660 const size_t dstRB = glyph.rowBytes(); | 715 const size_t dstRB = glyph.rowBytes(); |
| 661 const U16CPU width = glyph.fWidth; | 716 const U16CPU width = glyph.fWidth; |
| 662 uint8_t* SK_RESTRICT dst = static_cast<uint8_t*>(glyph.fImage); | 717 uint8_t* SK_RESTRICT dst = static_cast<uint8_t*>(glyph.fImage); |
| 663 | 718 |
| 664 for (U16CPU y = 0; y < glyph.fHeight; y++) { | 719 for (U16CPU y = 0; y < glyph.fHeight; y++) { |
| 665 for (U16CPU i = 0; i < width; i++) { | 720 for (U16CPU i = 0; i < width; i++) { |
| 666 U8CPU r = *(src++); | 721 U8CPU r = *(src++); |
| 667 U8CPU g = *(src++); | 722 U8CPU g = *(src++); |
| 668 U8CPU b = *(src++); | 723 U8CPU b = *(src++); |
| 669 dst[i] = sk_apply_lut_if<APPLY_PREBLEND>((r + g + b) / 3, table8); | 724 dst[i] = sk_apply_lut_if<APPLY_PREBLEND>((r + g + b) / 3, table8); |
| 670 } | 725 } |
| 671 dst = (uint8_t*)((char*)dst + dstRB); | 726 dst = SkTAddOffset<uint8_t>(dst, dstRB); |
| 672 } | 727 } |
| 673 } | 728 } |
| 674 | 729 |
| 675 template<bool APPLY_PREBLEND, bool RGB> | 730 template<bool APPLY_PREBLEND, bool RGB> |
| 676 static void rgb_to_lcd16(const uint8_t* SK_RESTRICT src, const SkGlyph& glyph, | 731 static void rgb_to_lcd16(const uint8_t* SK_RESTRICT src, const SkGlyph& glyph, |
| 677 const uint8_t* tableR, const uint8_t* tableG, const uin t8_t* tableB) { | 732 const uint8_t* tableR, const uint8_t* tableG, const uin t8_t* tableB) { |
| 678 const size_t dstRB = glyph.rowBytes(); | 733 const size_t dstRB = glyph.rowBytes(); |
| 679 const U16CPU width = glyph.fWidth; | 734 const U16CPU width = glyph.fWidth; |
| 680 uint16_t* SK_RESTRICT dst = static_cast<uint16_t*>(glyph.fImage); | 735 uint16_t* SK_RESTRICT dst = static_cast<uint16_t*>(glyph.fImage); |
| 681 | 736 |
| 682 for (U16CPU y = 0; y < glyph.fHeight; y++) { | 737 for (U16CPU y = 0; y < glyph.fHeight; y++) { |
| 683 for (U16CPU i = 0; i < width; i++) { | 738 for (U16CPU i = 0; i < width; i++) { |
| 684 U8CPU r, g, b; | 739 U8CPU r, g, b; |
| 685 if (RGB) { | 740 if (RGB) { |
| 686 r = sk_apply_lut_if<APPLY_PREBLEND>(*(src++), tableR); | 741 r = sk_apply_lut_if<APPLY_PREBLEND>(*(src++), tableR); |
| 687 g = sk_apply_lut_if<APPLY_PREBLEND>(*(src++), tableG); | 742 g = sk_apply_lut_if<APPLY_PREBLEND>(*(src++), tableG); |
| 688 b = sk_apply_lut_if<APPLY_PREBLEND>(*(src++), tableB); | 743 b = sk_apply_lut_if<APPLY_PREBLEND>(*(src++), tableB); |
| 689 } else { | 744 } else { |
| 690 b = sk_apply_lut_if<APPLY_PREBLEND>(*(src++), tableB); | 745 b = sk_apply_lut_if<APPLY_PREBLEND>(*(src++), tableB); |
| 691 g = sk_apply_lut_if<APPLY_PREBLEND>(*(src++), tableG); | 746 g = sk_apply_lut_if<APPLY_PREBLEND>(*(src++), tableG); |
| 692 r = sk_apply_lut_if<APPLY_PREBLEND>(*(src++), tableR); | 747 r = sk_apply_lut_if<APPLY_PREBLEND>(*(src++), tableR); |
| 693 } | 748 } |
| 694 dst[i] = SkPack888ToRGB16(r, g, b); | 749 dst[i] = SkPack888ToRGB16(r, g, b); |
| 695 } | 750 } |
| 696 dst = (uint16_t*)((char*)dst + dstRB); | 751 dst = SkTAddOffset<uint16_t>(dst, dstRB); |
| 697 } | 752 } |
| 698 } | 753 } |
| 699 | 754 |
| 700 const void* SkScalerContext_DW::drawDWMask(const SkGlyph& glyph, | 755 const void* SkScalerContext_DW::drawDWMask(const SkGlyph& glyph, |
| 701 DWRITE_RENDERING_MODE renderingMode, | 756 DWRITE_RENDERING_MODE renderingMode, |
| 702 DWRITE_TEXTURE_TYPE textureType) | 757 DWRITE_TEXTURE_TYPE textureType) |
| 703 { | 758 { |
| 704 int sizeNeeded = glyph.fWidth * glyph.fHeight; | 759 int sizeNeeded = glyph.fWidth * glyph.fHeight; |
| 705 if (DWRITE_RENDERING_MODE_ALIASED != renderingMode) { | 760 if (DWRITE_TEXTURE_CLEARTYPE_3x1 == textureType) { |
| 706 sizeNeeded *= 3; | 761 sizeNeeded *= 3; |
| 707 } | 762 } |
| 708 if (sizeNeeded > fBits.count()) { | 763 if (sizeNeeded > fBits.count()) { |
| 709 fBits.setCount(sizeNeeded); | 764 fBits.setCount(sizeNeeded); |
| 710 } | 765 } |
| 711 | 766 |
| 712 // erase | 767 // erase |
| 713 memset(fBits.begin(), 0, sizeNeeded); | 768 memset(fBits.begin(), 0, sizeNeeded); |
| 714 | 769 |
| 715 fXform.dx = SkFixedToFloat(glyph.getSubXFixed()); | 770 fXform.dx = SkFixedToFloat(glyph.getSubXFixed()); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 726 DWRITE_GLYPH_RUN run; | 781 DWRITE_GLYPH_RUN run; |
| 727 run.glyphCount = 1; | 782 run.glyphCount = 1; |
| 728 run.glyphAdvances = &advance; | 783 run.glyphAdvances = &advance; |
| 729 run.fontFace = fTypeface->fDWriteFontFace.get(); | 784 run.fontFace = fTypeface->fDWriteFontFace.get(); |
| 730 run.fontEmSize = SkScalarToFloat(fTextSizeRender); | 785 run.fontEmSize = SkScalarToFloat(fTextSizeRender); |
| 731 run.bidiLevel = 0; | 786 run.bidiLevel = 0; |
| 732 run.glyphIndices = &index; | 787 run.glyphIndices = &index; |
| 733 run.isSideways = FALSE; | 788 run.isSideways = FALSE; |
| 734 run.glyphOffsets = &offset; | 789 run.glyphOffsets = &offset; |
| 735 { | 790 { |
| 736 | |
| 737 SkTScopedComPtr<IDWriteGlyphRunAnalysis> glyphRunAnalysis; | 791 SkTScopedComPtr<IDWriteGlyphRunAnalysis> glyphRunAnalysis; |
| 738 { | 792 { |
| 739 SkAutoExclusive l(DWriteFactoryMutex); | 793 SkAutoExclusive l(DWriteFactoryMutex); |
| 740 HRNM(fTypeface->fFactory->CreateGlyphRunAnalysis(&run, | 794 if (fTypeface->fFactory2) { |
| 741 1.0f, // pixelsPerDip, | 795 #if SK_HAS_DWRITE_2_H |
| 742 &fXform, | 796 HRNM(fTypeface->fFactory2->CreateGlyphRunAnalysis(&run, |
| 743 renderingMode, | 797 &fXform, |
| 744 fMeasuringMode, | 798 renderingMode, |
| 745 0.0f, // baselineOriginX, | 799 fMeasuringMode, |
| 746 0.0f, // baselineOriginY, | 800 fGridFitMode, |
| 747 &glyphRunAnalysis), | 801 fAntiAliasMode, |
| 748 "Could not create glyph run analysis."); | 802 0.0f, // baselineOriginX, |
| 803 0.0f, // baselineOriginY, | |
| 804 &glyphRunAnalysis), | |
| 805 "Could not create DW2 glyph run analysis."); | |
| 806 #else | |
| 807 # pragma message("No dwrite_2.h is available, pixel antialiased glyph quality m ay be affected.") | |
| 808 #endif | |
| 809 } else { | |
| 810 HRNM(fTypeface->fFactory->CreateGlyphRunAnalysis(&run, | |
| 811 1.0f, // pixelsPerDip, | |
| 812 &fXform, | |
| 813 renderingMode, | |
| 814 fMeasuringMode, | |
| 815 0.0f, // baselineOriginX, | |
| 816 0.0f, // baselineOriginY, | |
| 817 &glyphRunAnalysis), | |
| 818 "Could not create glyph run analysis."); | |
| 819 } | |
| 749 } | 820 } |
| 750 //NOTE: this assumes that the glyph has already been measured | 821 //NOTE: this assumes that the glyph has already been measured |
| 751 //with an exact same glyph run analysis. | 822 //with an exact same glyph run analysis. |
| 752 RECT bbox; | 823 RECT bbox; |
| 753 bbox.left = glyph.fLeft; | 824 bbox.left = glyph.fLeft; |
| 754 bbox.top = glyph.fTop; | 825 bbox.top = glyph.fTop; |
| 755 bbox.right = glyph.fLeft + glyph.fWidth; | 826 bbox.right = glyph.fLeft + glyph.fWidth; |
| 756 bbox.bottom = glyph.fTop + glyph.fHeight; | 827 bbox.bottom = glyph.fTop + glyph.fHeight; |
| 757 { | 828 { |
| 758 Shared l(DWriteFactoryMutex); | 829 Shared l(DWriteFactoryMutex); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 858 sk_bzero(glyph.fImage, glyph.computeImageSize()); | 929 sk_bzero(glyph.fImage, glyph.computeImageSize()); |
| 859 return; | 930 return; |
| 860 } | 931 } |
| 861 | 932 |
| 862 //Copy the mask into the glyph. | 933 //Copy the mask into the glyph. |
| 863 const uint8_t* src = (const uint8_t*)bits; | 934 const uint8_t* src = (const uint8_t*)bits; |
| 864 if (DWRITE_RENDERING_MODE_ALIASED == renderingMode) { | 935 if (DWRITE_RENDERING_MODE_ALIASED == renderingMode) { |
| 865 bilevel_to_bw(src, glyph); | 936 bilevel_to_bw(src, glyph); |
| 866 const_cast<SkGlyph&>(glyph).fMaskFormat = SkMask::kBW_Format; | 937 const_cast<SkGlyph&>(glyph).fMaskFormat = SkMask::kBW_Format; |
| 867 } else if (!isLCD(fRec)) { | 938 } else if (!isLCD(fRec)) { |
| 868 if (fPreBlend.isApplicable()) { | 939 if (textureType == DWRITE_TEXTURE_ALIASED_1x1) { |
| 869 rgb_to_a8<true>(src, glyph, fPreBlend.fG); | 940 if (fPreBlend.isApplicable()) { |
| 941 grayscale_to_a8<true>(src, glyph, fPreBlend.fG); | |
| 942 } else { | |
| 943 grayscale_to_a8<false>(src, glyph, fPreBlend.fG); | |
| 944 } | |
| 870 } else { | 945 } else { |
| 871 rgb_to_a8<false>(src, glyph, fPreBlend.fG); | 946 if (fPreBlend.isApplicable()) { |
| 947 rgb_to_a8<true>(src, glyph, fPreBlend.fG); | |
| 948 } else { | |
| 949 rgb_to_a8<false>(src, glyph, fPreBlend.fG); | |
| 950 } | |
| 872 } | 951 } |
| 873 } else { | 952 } else { |
| 874 SkASSERT(SkMask::kLCD16_Format == glyph.fMaskFormat); | 953 SkASSERT(SkMask::kLCD16_Format == glyph.fMaskFormat); |
| 875 if (fPreBlend.isApplicable()) { | 954 if (fPreBlend.isApplicable()) { |
| 876 if (fRec.fFlags & SkScalerContext::kLCD_BGROrder_Flag) { | 955 if (fRec.fFlags & SkScalerContext::kLCD_BGROrder_Flag) { |
| 877 rgb_to_lcd16<true, false>(src, glyph, fPreBlend.fR, fPreBlend.fG , fPreBlend.fB); | 956 rgb_to_lcd16<true, false>(src, glyph, fPreBlend.fR, fPreBlend.fG , fPreBlend.fB); |
| 878 } else { | 957 } else { |
| 879 rgb_to_lcd16<true, true>(src, glyph, fPreBlend.fR, fPreBlend.fG, fPreBlend.fB); | 958 rgb_to_lcd16<true, true>(src, glyph, fPreBlend.fR, fPreBlend.fG, fPreBlend.fB); |
| 880 } | 959 } |
| 881 } else { | 960 } else { |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 909 FALSE, //sideways | 988 FALSE, //sideways |
| 910 FALSE, //rtl | 989 FALSE, //rtl |
| 911 geometryToPath.get()), | 990 geometryToPath.get()), |
| 912 "Could not create glyph outline."); | 991 "Could not create glyph outline."); |
| 913 } | 992 } |
| 914 | 993 |
| 915 path->transform(fSkXform); | 994 path->transform(fSkXform); |
| 916 } | 995 } |
| 917 | 996 |
| 918 #endif//defined(SK_BUILD_FOR_WIN32) | 997 #endif//defined(SK_BUILD_FOR_WIN32) |
| OLD | NEW |