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 #undef GetGlyphIndices | 9 #undef GetGlyphIndices |
10 | 10 |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 for (U16CPU i = 0; i < width; i++) { | 584 for (U16CPU i = 0; i < width; i++) { |
585 U8CPU r = *(src++); | 585 U8CPU r = *(src++); |
586 U8CPU g = *(src++); | 586 U8CPU g = *(src++); |
587 U8CPU b = *(src++); | 587 U8CPU b = *(src++); |
588 dst[i] = sk_apply_lut_if<APPLY_PREBLEND>((r + g + b) / 3, table8); | 588 dst[i] = sk_apply_lut_if<APPLY_PREBLEND>((r + g + b) / 3, table8); |
589 } | 589 } |
590 dst = (uint8_t*)((char*)dst + dstRB); | 590 dst = (uint8_t*)((char*)dst + dstRB); |
591 } | 591 } |
592 } | 592 } |
593 | 593 |
594 template<bool APPLY_PREBLEND> | 594 template<bool APPLY_PREBLEND, bool RGB> |
595 static void rgb_to_lcd16(const uint8_t* SK_RESTRICT src, const SkGlyph& glyph, | 595 static void rgb_to_lcd16(const uint8_t* SK_RESTRICT src, const SkGlyph& glyph, |
596 const uint8_t* tableR, const uint8_t* tableG, const uin
t8_t* tableB) { | 596 const uint8_t* tableR, const uint8_t* tableG, const uin
t8_t* tableB) { |
597 const size_t dstRB = glyph.rowBytes(); | 597 const size_t dstRB = glyph.rowBytes(); |
598 const U16CPU width = glyph.fWidth; | 598 const U16CPU width = glyph.fWidth; |
599 uint16_t* SK_RESTRICT dst = static_cast<uint16_t*>(glyph.fImage); | 599 uint16_t* SK_RESTRICT dst = static_cast<uint16_t*>(glyph.fImage); |
600 | 600 |
601 for (U16CPU y = 0; y < glyph.fHeight; y++) { | 601 for (U16CPU y = 0; y < glyph.fHeight; y++) { |
602 for (U16CPU i = 0; i < width; i++) { | 602 for (U16CPU i = 0; i < width; i++) { |
603 U8CPU r = sk_apply_lut_if<APPLY_PREBLEND>(*(src++), tableR); | 603 U8CPU r, g, b; |
604 U8CPU g = sk_apply_lut_if<APPLY_PREBLEND>(*(src++), tableG); | 604 if (RGB) { |
605 U8CPU b = sk_apply_lut_if<APPLY_PREBLEND>(*(src++), tableB); | 605 r = sk_apply_lut_if<APPLY_PREBLEND>(*(src++), tableR); |
| 606 g = sk_apply_lut_if<APPLY_PREBLEND>(*(src++), tableG); |
| 607 b = sk_apply_lut_if<APPLY_PREBLEND>(*(src++), tableB); |
| 608 } else { |
| 609 b = sk_apply_lut_if<APPLY_PREBLEND>(*(src++), tableB); |
| 610 g = sk_apply_lut_if<APPLY_PREBLEND>(*(src++), tableG); |
| 611 r = sk_apply_lut_if<APPLY_PREBLEND>(*(src++), tableR); |
| 612 } |
606 dst[i] = SkPack888ToRGB16(r, g, b); | 613 dst[i] = SkPack888ToRGB16(r, g, b); |
607 } | 614 } |
608 dst = (uint16_t*)((char*)dst + dstRB); | 615 dst = (uint16_t*)((char*)dst + dstRB); |
609 } | 616 } |
610 } | 617 } |
611 | 618 |
612 const void* SkScalerContext_DW::drawDWMask(const SkGlyph& glyph, | 619 const void* SkScalerContext_DW::drawDWMask(const SkGlyph& glyph, |
613 DWRITE_RENDERING_MODE renderingMode, | 620 DWRITE_RENDERING_MODE renderingMode, |
614 DWRITE_TEXTURE_TYPE textureType) | 621 DWRITE_TEXTURE_TYPE textureType) |
615 { | 622 { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 const_cast<SkGlyph&>(glyph).fMaskFormat = SkMask::kBW_Format; | 699 const_cast<SkGlyph&>(glyph).fMaskFormat = SkMask::kBW_Format; |
693 } else if (!isLCD(fRec)) { | 700 } else if (!isLCD(fRec)) { |
694 if (fPreBlend.isApplicable()) { | 701 if (fPreBlend.isApplicable()) { |
695 rgb_to_a8<true>(src, glyph, fPreBlend.fG); | 702 rgb_to_a8<true>(src, glyph, fPreBlend.fG); |
696 } else { | 703 } else { |
697 rgb_to_a8<false>(src, glyph, fPreBlend.fG); | 704 rgb_to_a8<false>(src, glyph, fPreBlend.fG); |
698 } | 705 } |
699 } else { | 706 } else { |
700 SkASSERT(SkMask::kLCD16_Format == glyph.fMaskFormat); | 707 SkASSERT(SkMask::kLCD16_Format == glyph.fMaskFormat); |
701 if (fPreBlend.isApplicable()) { | 708 if (fPreBlend.isApplicable()) { |
702 rgb_to_lcd16<true>(src, glyph, fPreBlend.fR, fPreBlend.fG, fPreBlend
.fB); | 709 if (fRec.fFlags & SkScalerContext::kLCD_BGROrder_Flag) { |
| 710 rgb_to_lcd16<true, false>(src, glyph, fPreBlend.fR, fPreBlend.fG
, fPreBlend.fB); |
| 711 } else { |
| 712 rgb_to_lcd16<true, true>(src, glyph, fPreBlend.fR, fPreBlend.fG,
fPreBlend.fB); |
| 713 } |
703 } else { | 714 } else { |
704 rgb_to_lcd16<false>(src, glyph, fPreBlend.fR, fPreBlend.fG, fPreBlen
d.fB); | 715 if (fRec.fFlags & SkScalerContext::kLCD_BGROrder_Flag) { |
| 716 rgb_to_lcd16<false, false>(src, glyph, fPreBlend.fR, fPreBlend.f
G, fPreBlend.fB); |
| 717 } else { |
| 718 rgb_to_lcd16<false, true>(src, glyph, fPreBlend.fR, fPreBlend.fG
, fPreBlend.fB); |
| 719 } |
705 } | 720 } |
706 } | 721 } |
707 } | 722 } |
708 | 723 |
709 void SkScalerContext_DW::generatePath(const SkGlyph& glyph, SkPath* path) { | 724 void SkScalerContext_DW::generatePath(const SkGlyph& glyph, SkPath* path) { |
710 SkASSERT(&glyph && path); | 725 SkASSERT(&glyph && path); |
711 | 726 |
712 path->reset(); | 727 path->reset(); |
713 | 728 |
714 SkTScopedComPtr<IDWriteGeometrySink> geometryToPath; | 729 SkTScopedComPtr<IDWriteGeometrySink> geometryToPath; |
715 HRVM(SkDWriteGeometrySink::Create(path, &geometryToPath), | 730 HRVM(SkDWriteGeometrySink::Create(path, &geometryToPath), |
716 "Could not create geometry to path converter."); | 731 "Could not create geometry to path converter."); |
717 uint16_t glyphId = glyph.getGlyphID(); | 732 uint16_t glyphId = glyph.getGlyphID(); |
718 //TODO: convert to<->from DIUs? This would make a difference if hinting. | 733 //TODO: convert to<->from DIUs? This would make a difference if hinting. |
719 //It may not be needed, it appears that DirectWrite only hints at em size. | 734 //It may not be needed, it appears that DirectWrite only hints at em size. |
720 HRVM(fTypeface->fDWriteFontFace->GetGlyphRunOutline(SkScalarToFloat(fTextSiz
eRender), | 735 HRVM(fTypeface->fDWriteFontFace->GetGlyphRunOutline(SkScalarToFloat(fTextSiz
eRender), |
721 &glyphId, | 736 &glyphId, |
722 NULL, //advances | 737 NULL, //advances |
723 NULL, //offsets | 738 NULL, //offsets |
724 1, //num glyphs | 739 1, //num glyphs |
725 FALSE, //sideways | 740 FALSE, //sideways |
726 FALSE, //rtl | 741 FALSE, //rtl |
727 geometryToPath.get()), | 742 geometryToPath.get()), |
728 "Could not create glyph outline."); | 743 "Could not create glyph outline."); |
729 | 744 |
730 path->transform(fSkXform); | 745 path->transform(fSkXform); |
731 } | 746 } |
OLD | NEW |