| 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 2090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2101 break; | 2101 break; |
| 2102 default: | 2102 default: |
| 2103 SkDEBUGFAIL("unknown verb"); | 2103 SkDEBUGFAIL("unknown verb"); |
| 2104 break; | 2104 break; |
| 2105 } | 2105 } |
| 2106 } | 2106 } |
| 2107 } | 2107 } |
| 2108 | 2108 |
| 2109 void SkDraw::drawTextOnPath(const char text[], size_t byteLength, | 2109 void SkDraw::drawTextOnPath(const char text[], size_t byteLength, |
| 2110 const SkPath& follow, const SkMatrix* matrix, | 2110 const SkPath& follow, const SkMatrix* matrix, |
| 2111 const SkPaint& paint) const { | 2111 const SkPaint& origPaint) const { |
| 2112 SkASSERT(byteLength == 0 || text != NULL); | 2112 SkASSERT(byteLength == 0 || text != NULL); |
| 2113 | 2113 |
| 2114 // nothing to draw | 2114 // nothing to draw |
| 2115 if (text == NULL || byteLength == 0 || fRC->isEmpty()) { | 2115 if (text == NULL || byteLength == 0 || fRC->isEmpty()) { |
| 2116 return; | 2116 return; |
| 2117 } | 2117 } |
| 2118 | 2118 |
| 2119 // setup our std paint, in hopes of getting hits in the cache |
| 2120 SkPaint paint(origPaint); |
| 2121 SkScalar textScale = paint.setupForAsPaths(); |
| 2119 SkTextToPathIter iter(text, byteLength, paint, true); | 2122 SkTextToPathIter iter(text, byteLength, paint, true); |
| 2123 |
| 2120 SkPathMeasure meas(follow, false); | 2124 SkPathMeasure meas(follow, false); |
| 2121 SkScalar hOffset = 0; | 2125 SkScalar hOffset = 0; |
| 2122 | 2126 |
| 2123 // need to measure first | 2127 // need to measure first |
| 2124 if (paint.getTextAlign() != SkPaint::kLeft_Align) { | 2128 if (paint.getTextAlign() != SkPaint::kLeft_Align) { |
| 2125 SkScalar pathLen = meas.getLength(); | 2129 SkScalar pathLen = meas.getLength(); |
| 2126 if (paint.getTextAlign() == SkPaint::kCenter_Align) { | 2130 if (paint.getTextAlign() == SkPaint::kCenter_Align) { |
| 2127 pathLen = SkScalarHalf(pathLen); | 2131 pathLen = SkScalarHalf(pathLen); |
| 2128 } | 2132 } |
| 2129 hOffset += pathLen; | 2133 hOffset += pathLen; |
| 2130 } | 2134 } |
| 2131 | 2135 |
| 2132 const SkPath* iterPath; | 2136 SkScalar scale = iter.getPathScale(); |
| 2133 SkScalar xpos; | 2137 SkMatrix scaledMatrix; |
| 2134 SkMatrix scaledMatrix; | 2138 scaledMatrix.setScale(scale * textScale, scale * textScale); |
| 2135 SkScalar scale = iter.getPathScale(); | |
| 2136 | 2139 |
| 2137 scaledMatrix.setScale(scale, scale); | 2140 const SkPath* iterPath; |
| 2138 | 2141 SkScalar xpos; |
| 2139 while (iter.next(&iterPath, &xpos)) { | 2142 while (iter.next(&iterPath, &xpos)) { |
| 2140 if (iterPath) { | 2143 if (iterPath) { |
| 2141 SkPath tmp; | 2144 SkPath tmp; |
| 2142 SkMatrix m(scaledMatrix); | 2145 SkMatrix m(scaledMatrix); |
| 2143 | 2146 |
| 2144 m.postTranslate(xpos + hOffset, 0); | 2147 SkScalar xposScaled = xpos * textScale; |
| 2148 m.postTranslate(xposScaled + hOffset, 0); |
| 2145 if (matrix) { | 2149 if (matrix) { |
| 2146 m.postConcat(*matrix); | 2150 m.postConcat(*matrix); |
| 2147 } | 2151 } |
| 2148 morphpath(&tmp, *iterPath, meas, m); | 2152 morphpath(&tmp, *iterPath, meas, m); |
| 2149 if (fDevice) { | 2153 if (fDevice) { |
| 2150 fDevice->drawPath(*this, tmp, iter.getPaint(), NULL, true); | 2154 fDevice->drawPath(*this, tmp, iter.getPaint(), NULL, true); |
| 2151 } else { | 2155 } else { |
| 2152 this->drawPath(tmp, iter.getPaint(), NULL, true); | 2156 this->drawPath(tmp, iter.getPaint(), NULL, true); |
| 2153 } | 2157 } |
| 2154 } | 2158 } |
| (...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2818 mask->fImage = SkMask::AllocImage(size); | 2822 mask->fImage = SkMask::AllocImage(size); |
| 2819 memset(mask->fImage, 0, mask->computeImageSize()); | 2823 memset(mask->fImage, 0, mask->computeImageSize()); |
| 2820 } | 2824 } |
| 2821 | 2825 |
| 2822 if (SkMask::kJustComputeBounds_CreateMode != mode) { | 2826 if (SkMask::kJustComputeBounds_CreateMode != mode) { |
| 2823 draw_into_mask(*mask, devPath, style); | 2827 draw_into_mask(*mask, devPath, style); |
| 2824 } | 2828 } |
| 2825 | 2829 |
| 2826 return true; | 2830 return true; |
| 2827 } | 2831 } |
| OLD | NEW |