OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
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 "SkDraw.h" | 8 #include "SkDraw.h" |
9 #include "SkBlitter.h" | 9 #include "SkBlitter.h" |
10 #include "SkBounder.h" | 10 #include "SkBounder.h" |
(...skipping 1662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1673 | 1673 |
1674 // SkScalarRec doesn't currently have a way of representing hairline stroke
and | 1674 // SkScalarRec doesn't currently have a way of representing hairline stroke
and |
1675 // will fill if its frame-width is 0. | 1675 // will fill if its frame-width is 0. |
1676 if (ShouldDrawTextAsPaths(paint, *fMatrix)) { | 1676 if (ShouldDrawTextAsPaths(paint, *fMatrix)) { |
1677 this->drawText_asPaths(text, byteLength, x, y, paint); | 1677 this->drawText_asPaths(text, byteLength, x, y, paint); |
1678 return; | 1678 return; |
1679 } | 1679 } |
1680 | 1680 |
1681 SkDrawCacheProc glyphCacheProc = paint.getDrawCacheProc(); | 1681 SkDrawCacheProc glyphCacheProc = paint.getDrawCacheProc(); |
1682 | 1682 |
1683 SkAutoGlyphCache autoCache(paint, &fDevice->fLeakyProperties, fMatrix); | 1683 const SkMatrix* ctm = fMatrix; |
| 1684 const SkPaint* paintRef = &paint; |
| 1685 SkPaint paintCopy; |
| 1686 uint32_t procFlags = fProcs ? fProcs->fFlags : 0; |
| 1687 if (procFlags & SkDrawProcs::kUseScaledGlyphs_Flag) { |
| 1688 paintCopy = paint; |
| 1689 paintCopy.setTextSize(32); |
| 1690 paintCopy.setLCDRenderText(false); |
| 1691 paintRef = &paintCopy; |
| 1692 } |
| 1693 if (procFlags & SkDrawProcs::kSkipBakedGlyphTransform_Flag) { |
| 1694 ctm = NULL; |
| 1695 } |
| 1696 SkAutoGlyphCache autoCache(*paintRef, &fDevice->fLeakyProperties, ctm); |
1684 SkGlyphCache* cache = autoCache.getCache(); | 1697 SkGlyphCache* cache = autoCache.getCache(); |
1685 | 1698 |
1686 // transform our starting point | 1699 // transform our starting point |
1687 { | 1700 if (!(procFlags & SkDrawProcs::kSkipBakedGlyphTransform_Flag)) { |
1688 SkPoint loc; | 1701 SkPoint loc; |
1689 fMatrix->mapXY(x, y, &loc); | 1702 fMatrix->mapXY(x, y, &loc); |
1690 x = loc.fX; | 1703 x = loc.fX; |
1691 y = loc.fY; | 1704 y = loc.fY; |
1692 } | 1705 } |
1693 | 1706 |
1694 // need to measure first | 1707 // need to measure first |
1695 if (paint.getTextAlign() != SkPaint::kLeft_Align) { | 1708 if (paint.getTextAlign() != SkPaint::kLeft_Align) { |
1696 SkVector stop; | 1709 SkVector stop; |
1697 | 1710 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1735 d1g.fHalfSampleY = SK_FixedHalf; | 1748 d1g.fHalfSampleY = SK_FixedHalf; |
1736 } else if (kY_SkAxisAlignment == baseline) { | 1749 } else if (kY_SkAxisAlignment == baseline) { |
1737 fxMask = 0; | 1750 fxMask = 0; |
1738 d1g.fHalfSampleX = SK_FixedHalf; | 1751 d1g.fHalfSampleX = SK_FixedHalf; |
1739 } | 1752 } |
1740 } | 1753 } |
1741 | 1754 |
1742 SkFixed fx = SkScalarToFixed(x) + d1g.fHalfSampleX; | 1755 SkFixed fx = SkScalarToFixed(x) + d1g.fHalfSampleX; |
1743 SkFixed fy = SkScalarToFixed(y) + d1g.fHalfSampleY; | 1756 SkFixed fy = SkScalarToFixed(y) + d1g.fHalfSampleY; |
1744 | 1757 |
| 1758 SkFixed fscale; |
| 1759 if (procFlags & SkDrawProcs::kUseScaledGlyphs_Flag) { |
| 1760 SkScalar sscale = paint.getTextSize()/32.f; |
| 1761 fscale = SkScalarToFixed(sscale); |
| 1762 } |
1745 while (text < stop) { | 1763 while (text < stop) { |
1746 const SkGlyph& glyph = glyphCacheProc(cache, &text, fx & fxMask, fy & fy
Mask); | 1764 const SkGlyph& glyph = glyphCacheProc(cache, &text, fx & fxMask, fy & fy
Mask); |
1747 | 1765 |
1748 fx += autokern.adjust(glyph); | 1766 if (procFlags & SkDrawProcs::kUseScaledGlyphs_Flag) { |
| 1767 fx += SkFixedMul_portable(autokern.adjust(glyph), fscale); |
| 1768 } else { |
| 1769 fx += autokern.adjust(glyph); |
| 1770 } |
1749 | 1771 |
1750 if (glyph.fWidth) { | 1772 if (glyph.fWidth) { |
1751 proc(d1g, fx, fy, glyph); | 1773 proc(d1g, fx, fy, glyph); |
1752 } | 1774 } |
1753 fx += glyph.fAdvanceX; | 1775 |
1754 fy += glyph.fAdvanceY; | 1776 if (procFlags & SkDrawProcs::kUseScaledGlyphs_Flag) { |
| 1777 fx += SkFixedMul_portable(glyph.fAdvanceX, fscale); |
| 1778 fy += SkFixedMul_portable(glyph.fAdvanceY, fscale); |
| 1779 } else { |
| 1780 fx += glyph.fAdvanceX; |
| 1781 fy += glyph.fAdvanceY; |
| 1782 } |
1755 } | 1783 } |
1756 } | 1784 } |
1757 | 1785 |
1758 // last parameter is interpreted as SkFixed [x, y] | 1786 // last parameter is interpreted as SkFixed [x, y] |
1759 // return the fixed position, which may be rounded or not by the caller | 1787 // return the fixed position, which may be rounded or not by the caller |
1760 // e.g. subpixel doesn't round | 1788 // e.g. subpixel doesn't round |
1761 typedef void (*AlignProc)(const SkPoint&, const SkGlyph&, SkIPoint*); | 1789 typedef void (*AlignProc)(const SkPoint&, const SkGlyph&, SkIPoint*); |
1762 | 1790 |
1763 static void leftAlignProc(const SkPoint& loc, const SkGlyph& glyph, | 1791 static void leftAlignProc(const SkPoint& loc, const SkGlyph& glyph, |
1764 SkIPoint* dst) { | 1792 SkIPoint* dst) { |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1902 return; | 1930 return; |
1903 } | 1931 } |
1904 | 1932 |
1905 if (ShouldDrawTextAsPaths(paint, *fMatrix)) { | 1933 if (ShouldDrawTextAsPaths(paint, *fMatrix)) { |
1906 this->drawPosText_asPaths(text, byteLength, pos, constY, | 1934 this->drawPosText_asPaths(text, byteLength, pos, constY, |
1907 scalarsPerPosition, paint); | 1935 scalarsPerPosition, paint); |
1908 return; | 1936 return; |
1909 } | 1937 } |
1910 | 1938 |
1911 SkDrawCacheProc glyphCacheProc = paint.getDrawCacheProc(); | 1939 SkDrawCacheProc glyphCacheProc = paint.getDrawCacheProc(); |
1912 SkAutoGlyphCache autoCache(paint, &fDevice->fLeakyProperties, fMatrix); | 1940 const SkMatrix* ctm = fMatrix; |
| 1941 const SkPaint* paintRef = &paint; |
| 1942 SkPaint paintCopy; |
| 1943 uint32_t procFlags = fProcs ? fProcs->fFlags : 0; |
| 1944 if (procFlags & SkDrawProcs::kUseScaledGlyphs_Flag) { |
| 1945 paintCopy = paint; |
| 1946 paintCopy.setTextSize(32); |
| 1947 paintRef = &paintCopy; |
| 1948 } |
| 1949 if (procFlags & SkDrawProcs::kSkipBakedGlyphTransform_Flag) { |
| 1950 ctm = NULL; |
| 1951 } |
| 1952 SkAutoGlyphCache autoCache(*paintRef, &fDevice->fLeakyProperties, ctm); |
1913 SkGlyphCache* cache = autoCache.getCache(); | 1953 SkGlyphCache* cache = autoCache.getCache(); |
1914 | 1954 |
1915 SkAAClipBlitterWrapper wrapper; | 1955 SkAAClipBlitterWrapper wrapper; |
1916 SkAutoBlitterChoose blitterChooser; | 1956 SkAutoBlitterChoose blitterChooser; |
1917 SkBlitter* blitter = NULL; | 1957 SkBlitter* blitter = NULL; |
1918 if (needsRasterTextBlit(*this)) { | 1958 if (needsRasterTextBlit(*this)) { |
1919 blitterChooser.choose(*fBitmap, *fMatrix, paint); | 1959 blitterChooser.choose(*fBitmap, *fMatrix, paint); |
1920 blitter = blitterChooser.get(); | 1960 blitter = blitterChooser.get(); |
1921 if (fRC->isAA()) { | 1961 if (fRC->isAA()) { |
1922 wrapper.init(*fRC, blitter); | 1962 wrapper.init(*fRC, blitter); |
(...skipping 21 matching lines...) Expand all Loading... |
1944 #endif | 1984 #endif |
1945 } else if (kY_SkAxisAlignment == baseline) { | 1985 } else if (kY_SkAxisAlignment == baseline) { |
1946 fxMask = 0; | 1986 fxMask = 0; |
1947 #ifndef SK_IGNORE_SUBPIXEL_AXIS_ALIGN_FIX | 1987 #ifndef SK_IGNORE_SUBPIXEL_AXIS_ALIGN_FIX |
1948 d1g.fHalfSampleX = SK_FixedHalf; | 1988 d1g.fHalfSampleX = SK_FixedHalf; |
1949 #endif | 1989 #endif |
1950 } | 1990 } |
1951 | 1991 |
1952 if (SkPaint::kLeft_Align == paint.getTextAlign()) { | 1992 if (SkPaint::kLeft_Align == paint.getTextAlign()) { |
1953 while (text < stop) { | 1993 while (text < stop) { |
1954 tmsProc(tms, pos); | 1994 if (procFlags & SkDrawProcs::kSkipBakedGlyphTransform_Flag) { |
| 1995 tms.fLoc.fX = *pos; |
| 1996 tms.fLoc.fY = *(pos+1); |
| 1997 } else { |
| 1998 tmsProc(tms, pos); |
| 1999 } |
1955 | 2000 |
1956 SkFixed fx = SkScalarToFixed(tms.fLoc.fX) + d1g.fHalfSampleX; | 2001 SkFixed fx = SkScalarToFixed(tms.fLoc.fX) + d1g.fHalfSampleX; |
1957 SkFixed fy = SkScalarToFixed(tms.fLoc.fY) + d1g.fHalfSampleY; | 2002 SkFixed fy = SkScalarToFixed(tms.fLoc.fY) + d1g.fHalfSampleY; |
1958 | 2003 |
1959 const SkGlyph& glyph = glyphCacheProc(cache, &text, | 2004 const SkGlyph& glyph = glyphCacheProc(cache, &text, |
1960 fx & fxMask, fy & fyMask); | 2005 fx & fxMask, fy & fyMask); |
1961 | 2006 |
1962 if (glyph.fWidth) { | 2007 if (glyph.fWidth) { |
1963 proc(d1g, fx, fy, glyph); | 2008 proc(d1g, fx, fy, glyph); |
1964 } | 2009 } |
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2826 mask->fImage = SkMask::AllocImage(size); | 2871 mask->fImage = SkMask::AllocImage(size); |
2827 memset(mask->fImage, 0, mask->computeImageSize()); | 2872 memset(mask->fImage, 0, mask->computeImageSize()); |
2828 } | 2873 } |
2829 | 2874 |
2830 if (SkMask::kJustComputeBounds_CreateMode != mode) { | 2875 if (SkMask::kJustComputeBounds_CreateMode != mode) { |
2831 draw_into_mask(*mask, devPath, style); | 2876 draw_into_mask(*mask, devPath, style); |
2832 } | 2877 } |
2833 | 2878 |
2834 return true; | 2879 return true; |
2835 } | 2880 } |
OLD | NEW |