| 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 2261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2272 morphpath(&tmp, *iterPath, meas, m); | 2272 morphpath(&tmp, *iterPath, meas, m); |
| 2273 if (fDevice) { | 2273 if (fDevice) { |
| 2274 fDevice->drawPath(*this, tmp, iter.getPaint(), NULL, true); | 2274 fDevice->drawPath(*this, tmp, iter.getPaint(), NULL, true); |
| 2275 } else { | 2275 } else { |
| 2276 this->drawPath(tmp, iter.getPaint(), NULL, true); | 2276 this->drawPath(tmp, iter.getPaint(), NULL, true); |
| 2277 } | 2277 } |
| 2278 } | 2278 } |
| 2279 } | 2279 } |
| 2280 } | 2280 } |
| 2281 | 2281 |
| 2282 #ifdef SK_BUILD_FOR_ANDROID | |
| 2283 void SkDraw::drawPosTextOnPath(const char text[], size_t byteLength, | |
| 2284 const SkPoint pos[], const SkPaint& paint, | |
| 2285 const SkPath& path, const SkMatrix* matrix) const
{ | |
| 2286 // nothing to draw | |
| 2287 if (text == NULL || byteLength == 0 || fRC->isEmpty()) { | |
| 2288 return; | |
| 2289 } | |
| 2290 | |
| 2291 SkMatrix scaledMatrix; | |
| 2292 SkPathMeasure meas(path, false); | |
| 2293 | |
| 2294 SkMeasureCacheProc glyphCacheProc = paint.getMeasureCacheProc( | |
| 2295 SkPaint::kForward_TextBufferDirection, true); | |
| 2296 | |
| 2297 // Copied (modified) from SkTextToPathIter constructor to setup paint | |
| 2298 SkPaint tempPaint(paint); | |
| 2299 | |
| 2300 tempPaint.setLinearText(true); | |
| 2301 tempPaint.setMaskFilter(NULL); // don't want this affecting our path-cache l
ookup | |
| 2302 | |
| 2303 if (tempPaint.getPathEffect() == NULL && !(tempPaint.getStrokeWidth() > 0 | |
| 2304 && tempPaint.getStyle() != SkPaint::kFill_Style)) { | |
| 2305 tempPaint.setStyle(SkPaint::kFill_Style); | |
| 2306 tempPaint.setPathEffect(NULL); | |
| 2307 } | |
| 2308 // End copied from SkTextToPathIter constructor | |
| 2309 | |
| 2310 // detach cache | |
| 2311 SkGlyphCache* cache = tempPaint.detachCache(NULL, NULL); | |
| 2312 | |
| 2313 // Must set scale, even if 1 | |
| 2314 SkScalar scale = SK_Scalar1; | |
| 2315 scaledMatrix.setScale(scale, scale); | |
| 2316 | |
| 2317 // Loop over all glyph ids | |
| 2318 for (const char* stop = text + byteLength; text < stop; pos++) { | |
| 2319 | |
| 2320 const SkGlyph& glyph = glyphCacheProc(cache, &text); | |
| 2321 SkPath tmp; | |
| 2322 | |
| 2323 const SkPath* glyphPath = cache->findPath(glyph); | |
| 2324 if (glyphPath == NULL) { | |
| 2325 continue; | |
| 2326 } | |
| 2327 | |
| 2328 SkMatrix m(scaledMatrix); | |
| 2329 m.postTranslate(pos->fX, 0); | |
| 2330 | |
| 2331 if (matrix) { | |
| 2332 m.postConcat(*matrix); | |
| 2333 } | |
| 2334 | |
| 2335 morphpath(&tmp, *glyphPath, meas, m); | |
| 2336 this->drawPath(tmp, tempPaint); | |
| 2337 | |
| 2338 } | |
| 2339 | |
| 2340 // re-attach cache | |
| 2341 SkGlyphCache::AttachCache(cache); | |
| 2342 } | |
| 2343 #endif | |
| 2344 | |
| 2345 /////////////////////////////////////////////////////////////////////////////// | 2282 /////////////////////////////////////////////////////////////////////////////// |
| 2346 | 2283 |
| 2347 struct VertState { | 2284 struct VertState { |
| 2348 int f0, f1, f2; | 2285 int f0, f1, f2; |
| 2349 | 2286 |
| 2350 VertState(int vCount, const uint16_t indices[], int indexCount) | 2287 VertState(int vCount, const uint16_t indices[], int indexCount) |
| 2351 : fIndices(indices) { | 2288 : fIndices(indices) { |
| 2352 fCurrIndex = 0; | 2289 fCurrIndex = 0; |
| 2353 if (indices) { | 2290 if (indices) { |
| 2354 fCount = indexCount; | 2291 fCount = indexCount; |
| (...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2942 mask->fImage = SkMask::AllocImage(size); | 2879 mask->fImage = SkMask::AllocImage(size); |
| 2943 memset(mask->fImage, 0, mask->computeImageSize()); | 2880 memset(mask->fImage, 0, mask->computeImageSize()); |
| 2944 } | 2881 } |
| 2945 | 2882 |
| 2946 if (SkMask::kJustComputeBounds_CreateMode != mode) { | 2883 if (SkMask::kJustComputeBounds_CreateMode != mode) { |
| 2947 draw_into_mask(*mask, devPath, style); | 2884 draw_into_mask(*mask, devPath, style); |
| 2948 } | 2885 } |
| 2949 | 2886 |
| 2950 return true; | 2887 return true; |
| 2951 } | 2888 } |
| OLD | NEW |