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 1878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1889 const SkScalar pos[], SkScalar constY, | 1889 const SkScalar pos[], SkScalar constY, |
1890 int scalarsPerPosition, | 1890 int scalarsPerPosition, |
1891 const SkPaint& origPaint) const { | 1891 const SkPaint& origPaint) const { |
1892 // setup our std paint, in hopes of getting hits in the cache | 1892 // setup our std paint, in hopes of getting hits in the cache |
1893 SkPaint paint(origPaint); | 1893 SkPaint paint(origPaint); |
1894 SkScalar matrixScale = paint.setupForAsPaths(); | 1894 SkScalar matrixScale = paint.setupForAsPaths(); |
1895 | 1895 |
1896 SkMatrix matrix; | 1896 SkMatrix matrix; |
1897 matrix.setScale(matrixScale, matrixScale); | 1897 matrix.setScale(matrixScale, matrixScale); |
1898 | 1898 |
| 1899 // Temporarily jam in kFill, so we only ever ask for the raw outline from th
e cache. |
| 1900 paint.setStyle(SkPaint::kFill_Style); |
| 1901 paint.setPathEffect(NULL); |
| 1902 |
1899 SkDrawCacheProc glyphCacheProc = paint.getDrawCacheProc(); | 1903 SkDrawCacheProc glyphCacheProc = paint.getDrawCacheProc(); |
1900 SkAutoGlyphCache autoCache(paint, NULL, NULL); | 1904 SkAutoGlyphCache autoCache(paint, NULL, NULL); |
1901 SkGlyphCache* cache = autoCache.getCache(); | 1905 SkGlyphCache* cache = autoCache.getCache(); |
1902 | 1906 |
1903 const char* stop = text + byteLength; | 1907 const char* stop = text + byteLength; |
1904 AlignProc_scalar alignProc = pick_align_proc_scalar(paint.getTextAlign()); | 1908 AlignProc_scalar alignProc = pick_align_proc_scalar(paint.getTextAlign()); |
1905 TextMapState tms(SkMatrix::I(), constY); | 1909 TextMapState tms(SkMatrix::I(), constY); |
1906 TextMapState::Proc tmsProc = tms.pickProc(scalarsPerPosition); | 1910 TextMapState::Proc tmsProc = tms.pickProc(scalarsPerPosition); |
1907 | 1911 |
| 1912 // Now restore the original settings, so we "draw" with whatever style/strok
ing. |
| 1913 paint.setStyle(origPaint.getStyle()); |
| 1914 paint.setPathEffect(origPaint.getPathEffect()); |
| 1915 |
1908 while (text < stop) { | 1916 while (text < stop) { |
1909 const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0); | 1917 const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0); |
1910 if (glyph.fWidth) { | 1918 if (glyph.fWidth) { |
1911 const SkPath* path = cache->findPath(glyph); | 1919 const SkPath* path = cache->findPath(glyph); |
1912 if (path) { | 1920 if (path) { |
1913 tmsProc(tms, pos); | 1921 tmsProc(tms, pos); |
1914 SkPoint loc; | 1922 SkPoint loc; |
1915 alignProc(tms.fLoc, glyph, &loc); | 1923 alignProc(tms.fLoc, glyph, &loc); |
1916 | 1924 |
1917 matrix[SkMatrix::kMTransX] = loc.fX; | 1925 matrix[SkMatrix::kMTransX] = loc.fX; |
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2828 mask->fImage = SkMask::AllocImage(size); | 2836 mask->fImage = SkMask::AllocImage(size); |
2829 memset(mask->fImage, 0, mask->computeImageSize()); | 2837 memset(mask->fImage, 0, mask->computeImageSize()); |
2830 } | 2838 } |
2831 | 2839 |
2832 if (SkMask::kJustComputeBounds_CreateMode != mode) { | 2840 if (SkMask::kJustComputeBounds_CreateMode != mode) { |
2833 draw_into_mask(*mask, devPath, style); | 2841 draw_into_mask(*mask, devPath, style); |
2834 } | 2842 } |
2835 | 2843 |
2836 return true; | 2844 return true; |
2837 } | 2845 } |
OLD | NEW |