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 | 8 |
9 #include "SkDraw.h" | 9 #include "SkDraw.h" |
10 #include "SkBlitter.h" | 10 #include "SkBlitter.h" |
(...skipping 1843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1854 ////////////////////////////////////////////////////////////////////////////// | 1854 ////////////////////////////////////////////////////////////////////////////// |
1855 | 1855 |
1856 void SkDraw::drawPosText_asPaths(const char text[], size_t byteLength, | 1856 void SkDraw::drawPosText_asPaths(const char text[], size_t byteLength, |
1857 const SkScalar pos[], SkScalar constY, | 1857 const SkScalar pos[], SkScalar constY, |
1858 int scalarsPerPosition, | 1858 int scalarsPerPosition, |
1859 const SkPaint& origPaint) const { | 1859 const SkPaint& origPaint) const { |
1860 // setup our std paint, in hopes of getting hits in the cache | 1860 // setup our std paint, in hopes of getting hits in the cache |
1861 SkPaint paint(origPaint); | 1861 SkPaint paint(origPaint); |
1862 SkScalar matrixScale = paint.setupForAsPaths(); | 1862 SkScalar matrixScale = paint.setupForAsPaths(); |
1863 | 1863 |
1864 SkDraw draw(*this); | 1864 SkMatrix matrix; |
1865 | 1865 matrix.setScale(matrixScale, matrixScale); |
1866 // Now modify our matrix to account for the canonical text size | |
1867 SkMatrix matrix = *fMatrix; | |
1868 matrix.preScale(matrixScale, matrixScale); | |
1869 const SkScalar posScale = SkScalarInvert(matrixScale); | |
1870 | 1866 |
1871 SkDrawCacheProc glyphCacheProc = paint.getDrawCacheProc(); | 1867 SkDrawCacheProc glyphCacheProc = paint.getDrawCacheProc(); |
1872 SkAutoGlyphCache autoCache(paint, NULL, NULL); | 1868 SkAutoGlyphCache autoCache(paint, NULL, NULL); |
1873 SkGlyphCache* cache = autoCache.getCache(); | 1869 SkGlyphCache* cache = autoCache.getCache(); |
1874 | 1870 |
1875 const char* stop = text + byteLength; | 1871 const char* stop = text + byteLength; |
1876 AlignProc alignProc = pick_align_proc(paint.getTextAlign()); | 1872 AlignProc alignProc = pick_align_proc(paint.getTextAlign()); |
1877 TextMapState tms(SkMatrix::I(), constY); | 1873 TextMapState tms(SkMatrix::I(), constY); |
1878 TextMapState::Proc tmsProc = tms.pickProc(scalarsPerPosition); | 1874 TextMapState::Proc tmsProc = tms.pickProc(scalarsPerPosition); |
1879 | 1875 |
1880 while (text < stop) { | 1876 while (text < stop) { |
1881 const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0); | 1877 const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0); |
1882 if (glyph.fWidth) { | 1878 if (glyph.fWidth) { |
1883 const SkPath* path = cache->findPath(glyph); | 1879 const SkPath* path = cache->findPath(glyph); |
1884 if (path) { | 1880 if (path) { |
1885 tmsProc(tms, pos); | 1881 tmsProc(tms, pos); |
1886 SkIPoint fixedLoc; | 1882 SkIPoint fixedLoc; |
1887 alignProc(tms.fLoc, glyph, &fixedLoc); | 1883 alignProc(tms.fLoc, glyph, &fixedLoc); |
1888 | 1884 |
1889 SkMatrix localMatrix = matrix; | 1885 matrix[SkMatrix::kMTransX] = SkFixedToScalar(fixedLoc.fX); |
1890 localMatrix.preTranslate(SkFixedToScalar(fixedLoc.fX) * posScale
, | 1886 matrix[SkMatrix::kMTransY] = SkFixedToScalar(fixedLoc.fY); |
1891 SkFixedToScalar(fixedLoc.fY) * posScale
); | 1887 if (fDevice) { |
1892 draw.fMatrix = &localMatrix; | 1888 fDevice->drawPath(*this, *path, paint, &matrix, false); |
1893 draw.drawPath(*path, paint); | 1889 } else { |
| 1890 this->drawPath(*path, paint, &matrix, false); |
| 1891 } |
1894 } | 1892 } |
1895 } | 1893 } |
1896 pos += scalarsPerPosition; | 1894 pos += scalarsPerPosition; |
1897 } | 1895 } |
1898 } | 1896 } |
1899 | 1897 |
1900 void SkDraw::drawPosText(const char text[], size_t byteLength, | 1898 void SkDraw::drawPosText(const char text[], size_t byteLength, |
1901 const SkScalar pos[], SkScalar constY, | 1899 const SkScalar pos[], SkScalar constY, |
1902 int scalarsPerPosition, const SkPaint& paint) const { | 1900 int scalarsPerPosition, const SkPaint& paint) const { |
1903 SkASSERT(byteLength == 0 || text != NULL); | 1901 SkASSERT(byteLength == 0 || text != NULL); |
(...skipping 930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2834 mask->fImage = SkMask::AllocImage(size); | 2832 mask->fImage = SkMask::AllocImage(size); |
2835 memset(mask->fImage, 0, mask->computeImageSize()); | 2833 memset(mask->fImage, 0, mask->computeImageSize()); |
2836 } | 2834 } |
2837 | 2835 |
2838 if (SkMask::kJustComputeBounds_CreateMode != mode) { | 2836 if (SkMask::kJustComputeBounds_CreateMode != mode) { |
2839 draw_into_mask(*mask, devPath, style); | 2837 draw_into_mask(*mask, devPath, style); |
2840 } | 2838 } |
2841 | 2839 |
2842 return true; | 2840 return true; |
2843 } | 2841 } |
OLD | NEW |