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

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

Issue 728673002: remove unused kLCD_MaskFormat (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove associated Gr enum Created 6 years, 1 month 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/SkFontHost_win.cpp ('k') | tests/AAClipTest.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 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 13 matching lines...) Expand all
24 #include "SkScalerContext_win_dw.h" 24 #include "SkScalerContext_win_dw.h"
25 #include "SkTScopedComPtr.h" 25 #include "SkTScopedComPtr.h"
26 #include "SkTypeface_win_dw.h" 26 #include "SkTypeface_win_dw.h"
27 27
28 #include <dwrite.h> 28 #include <dwrite.h>
29 #if SK_HAS_DWRITE_1_H 29 #if SK_HAS_DWRITE_1_H
30 # include <dwrite_1.h> 30 # include <dwrite_1.h>
31 #endif 31 #endif
32 32
33 static bool isLCD(const SkScalerContext::Rec& rec) { 33 static bool isLCD(const SkScalerContext::Rec& rec) {
34 return SkMask::kLCD16_Format == rec.fMaskFormat || 34 return SkMask::kLCD16_Format == rec.fMaskFormat;
35 SkMask::kLCD32_Format == rec.fMaskFormat;
36 } 35 }
37 36
38 static bool is_hinted_without_gasp(DWriteFontTypeface* typeface) { 37 static bool is_hinted_without_gasp(DWriteFontTypeface* typeface) {
39 AutoTDWriteTable<SkOTTableMaximumProfile> maxp(typeface->fDWriteFontFace.get ()); 38 AutoTDWriteTable<SkOTTableMaximumProfile> maxp(typeface->fDWriteFontFace.get ());
40 if (!maxp.fExists) { 39 if (!maxp.fExists) {
41 return false; 40 return false;
42 } 41 }
43 if (maxp.fSize < sizeof(SkOTTableMaximumProfile::Version::TT)) { 42 if (maxp.fSize < sizeof(SkOTTableMaximumProfile::Version::TT)) {
44 return false; 43 return false;
45 } 44 }
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 for (U16CPU i = 0; i < width; i++) { 629 for (U16CPU i = 0; i < width; i++) {
631 U8CPU r = sk_apply_lut_if<APPLY_PREBLEND>(*(src++), tableR); 630 U8CPU r = sk_apply_lut_if<APPLY_PREBLEND>(*(src++), tableR);
632 U8CPU g = sk_apply_lut_if<APPLY_PREBLEND>(*(src++), tableG); 631 U8CPU g = sk_apply_lut_if<APPLY_PREBLEND>(*(src++), tableG);
633 U8CPU b = sk_apply_lut_if<APPLY_PREBLEND>(*(src++), tableB); 632 U8CPU b = sk_apply_lut_if<APPLY_PREBLEND>(*(src++), tableB);
634 dst[i] = SkPack888ToRGB16(r, g, b); 633 dst[i] = SkPack888ToRGB16(r, g, b);
635 } 634 }
636 dst = (uint16_t*)((char*)dst + dstRB); 635 dst = (uint16_t*)((char*)dst + dstRB);
637 } 636 }
638 } 637 }
639 638
640 template<bool APPLY_PREBLEND>
641 static void rgb_to_lcd32(const uint8_t* SK_RESTRICT src, const SkGlyph& glyph,
642 const uint8_t* tableR, const uint8_t* tableG, const uin t8_t* tableB) {
643 const size_t dstRB = glyph.rowBytes();
644 const U16CPU width = glyph.fWidth;
645 SkPMColor* SK_RESTRICT dst = static_cast<SkPMColor*>(glyph.fImage);
646
647 for (U16CPU y = 0; y < glyph.fHeight; y++) {
648 for (U16CPU i = 0; i < width; i++) {
649 U8CPU r = sk_apply_lut_if<APPLY_PREBLEND>(*(src++), tableR);
650 U8CPU g = sk_apply_lut_if<APPLY_PREBLEND>(*(src++), tableG);
651 U8CPU b = sk_apply_lut_if<APPLY_PREBLEND>(*(src++), tableB);
652 dst[i] = SkPackARGB32(0xFF, r, g, b);
653 }
654 dst = (SkPMColor*)((char*)dst + dstRB);
655 }
656 }
657
658 const void* SkScalerContext_DW::drawDWMask(const SkGlyph& glyph, 639 const void* SkScalerContext_DW::drawDWMask(const SkGlyph& glyph,
659 DWRITE_RENDERING_MODE renderingMode, 640 DWRITE_RENDERING_MODE renderingMode,
660 DWRITE_TEXTURE_TYPE textureType) 641 DWRITE_TEXTURE_TYPE textureType)
661 { 642 {
662 int sizeNeeded = glyph.fWidth * glyph.fHeight; 643 int sizeNeeded = glyph.fWidth * glyph.fHeight;
663 if (DWRITE_RENDERING_MODE_ALIASED != renderingMode) { 644 if (DWRITE_RENDERING_MODE_ALIASED != renderingMode) {
664 sizeNeeded *= 3; 645 sizeNeeded *= 3;
665 } 646 }
666 if (sizeNeeded > fBits.count()) { 647 if (sizeNeeded > fBits.count()) {
667 fBits.setCount(sizeNeeded); 648 fBits.setCount(sizeNeeded);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 const uint8_t* src = (const uint8_t*)bits; 716 const uint8_t* src = (const uint8_t*)bits;
736 if (DWRITE_RENDERING_MODE_ALIASED == renderingMode) { 717 if (DWRITE_RENDERING_MODE_ALIASED == renderingMode) {
737 bilevel_to_bw(src, glyph); 718 bilevel_to_bw(src, glyph);
738 const_cast<SkGlyph&>(glyph).fMaskFormat = SkMask::kBW_Format; 719 const_cast<SkGlyph&>(glyph).fMaskFormat = SkMask::kBW_Format;
739 } else if (!isLCD(fRec)) { 720 } else if (!isLCD(fRec)) {
740 if (fPreBlend.isApplicable()) { 721 if (fPreBlend.isApplicable()) {
741 rgb_to_a8<true>(src, glyph, fPreBlend.fG); 722 rgb_to_a8<true>(src, glyph, fPreBlend.fG);
742 } else { 723 } else {
743 rgb_to_a8<false>(src, glyph, fPreBlend.fG); 724 rgb_to_a8<false>(src, glyph, fPreBlend.fG);
744 } 725 }
745 } else if (SkMask::kLCD16_Format == glyph.fMaskFormat) { 726 } else {
727 SkASSERT(SkMask::kLCD16_Format == glyph.fMaskFormat);
746 if (fPreBlend.isApplicable()) { 728 if (fPreBlend.isApplicable()) {
747 rgb_to_lcd16<true>(src, glyph, fPreBlend.fR, fPreBlend.fG, fPreBlend .fB); 729 rgb_to_lcd16<true>(src, glyph, fPreBlend.fR, fPreBlend.fG, fPreBlend .fB);
748 } else { 730 } else {
749 rgb_to_lcd16<false>(src, glyph, fPreBlend.fR, fPreBlend.fG, fPreBlen d.fB); 731 rgb_to_lcd16<false>(src, glyph, fPreBlend.fR, fPreBlend.fG, fPreBlen d.fB);
750 } 732 }
751 } else {
752 SkASSERT(SkMask::kLCD32_Format == glyph.fMaskFormat);
753 if (fPreBlend.isApplicable()) {
754 rgb_to_lcd32<true>(src, glyph, fPreBlend.fR, fPreBlend.fG, fPreBlend .fB);
755 } else {
756 rgb_to_lcd32<false>(src, glyph, fPreBlend.fR, fPreBlend.fG, fPreBlen d.fB);
757 }
758 } 733 }
759 } 734 }
760 735
761 void SkScalerContext_DW::generatePath(const SkGlyph& glyph, SkPath* path) { 736 void SkScalerContext_DW::generatePath(const SkGlyph& glyph, SkPath* path) {
762 SkASSERT(&glyph && path); 737 SkASSERT(&glyph && path);
763 738
764 path->reset(); 739 path->reset();
765 740
766 SkTScopedComPtr<IDWriteGeometrySink> geometryToPath; 741 SkTScopedComPtr<IDWriteGeometrySink> geometryToPath;
767 HRVM(SkDWriteGeometrySink::Create(path, &geometryToPath), 742 HRVM(SkDWriteGeometrySink::Create(path, &geometryToPath),
768 "Could not create geometry to path converter."); 743 "Could not create geometry to path converter.");
769 uint16_t glyphId = glyph.getGlyphID(); 744 uint16_t glyphId = glyph.getGlyphID();
770 //TODO: convert to<->from DIUs? This would make a difference if hinting. 745 //TODO: convert to<->from DIUs? This would make a difference if hinting.
771 //It may not be needed, it appears that DirectWrite only hints at em size. 746 //It may not be needed, it appears that DirectWrite only hints at em size.
772 HRVM(fTypeface->fDWriteFontFace->GetGlyphRunOutline(SkScalarToFloat(fTextSiz eRender), 747 HRVM(fTypeface->fDWriteFontFace->GetGlyphRunOutline(SkScalarToFloat(fTextSiz eRender),
773 &glyphId, 748 &glyphId,
774 NULL, //advances 749 NULL, //advances
775 NULL, //offsets 750 NULL, //offsets
776 1, //num glyphs 751 1, //num glyphs
777 FALSE, //sideways 752 FALSE, //sideways
778 FALSE, //rtl 753 FALSE, //rtl
779 geometryToPath.get()), 754 geometryToPath.get()),
780 "Could not create glyph outline."); 755 "Could not create glyph outline.");
781 756
782 path->transform(fSkXform); 757 path->transform(fSkXform);
783 } 758 }
OLDNEW
« no previous file with comments | « src/ports/SkFontHost_win.cpp ('k') | tests/AAClipTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698