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