OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "SkPaint.h" | 9 #include "SkPaint.h" |
10 #include "SkAnnotation.h" | 10 #include "SkAnnotation.h" |
(...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
979 // clear the flags we don't care about | 979 // clear the flags we don't care about |
980 flags &= ~TEXT_AS_PATHS_PAINT_FLAGS_TO_IGNORE; | 980 flags &= ~TEXT_AS_PATHS_PAINT_FLAGS_TO_IGNORE; |
981 // set the flags we do care about | 981 // set the flags we do care about |
982 flags |= SkPaint::kSubpixelText_Flag; | 982 flags |= SkPaint::kSubpixelText_Flag; |
983 | 983 |
984 this->setFlags(flags); | 984 this->setFlags(flags); |
985 this->setHinting(SkPaint::kNo_Hinting); | 985 this->setHinting(SkPaint::kNo_Hinting); |
986 | 986 |
987 SkScalar textSize = fTextSize; | 987 SkScalar textSize = fTextSize; |
988 this->setTextSize(kCanonicalTextSizeForPaths); | 988 this->setTextSize(kCanonicalTextSizeForPaths); |
989 return textSize / kCanonicalTextSizeForPaths; | 989 SkScalar scale = textSize / kCanonicalTextSizeForPaths; |
990 this->setStrokeWidth(fWidth / scale); | |
reed1
2013/07/29 14:44:39
Can this be: setStrokeWIdth(fWidth * kCanonical /
bungeman-skia
2013/07/29 14:54:18
Sure, so long as its the same number, doesn't matt
| |
991 //this->setStrokeMiter(fMiterLimit / scale); | |
reed1
2013/07/29 14:44:39
Do we need this line?
bungeman-skia
2013/07/29 14:54:18
Probably? The only reason it's commented out is th
bungeman-skia
2014/05/22 15:06:25
Mike pointed out to me that the miter limit is act
| |
992 return scale; | |
990 } | 993 } |
991 | 994 |
992 class SkCanonicalizePaint { | 995 class SkCanonicalizePaint { |
993 public: | 996 public: |
994 SkCanonicalizePaint(const SkPaint& paint) : fPaint(&paint), fScale(0) { | 997 SkCanonicalizePaint(const SkPaint& paint) : fPaint(&paint), fScale(0) { |
995 if (paint.isLinearText() || paint.tooBigToUseCache()) { | 998 if (paint.isLinearText() || paint.tooBigToUseCache()) { |
996 SkPaint* p = fLazy.set(paint); | 999 SkPaint* p = fLazy.set(paint); |
997 fScale = p->setupForAsPaths(); | 1000 fScale = p->setupForAsPaths(); |
998 fPaint = p; | 1001 fPaint = p; |
999 } | 1002 } |
(...skipping 1494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2494 paint.getStyle() != SkPaint::kFill_Style; | 2497 paint.getStyle() != SkPaint::kFill_Style; |
2495 } | 2498 } |
2496 | 2499 |
2497 SkTextToPathIter::SkTextToPathIter( const char text[], size_t length, | 2500 SkTextToPathIter::SkTextToPathIter( const char text[], size_t length, |
2498 const SkPaint& paint, | 2501 const SkPaint& paint, |
2499 bool applyStrokeAndPathEffects) | 2502 bool applyStrokeAndPathEffects) |
2500 : fPaint(paint) { | 2503 : fPaint(paint) { |
2501 fGlyphCacheProc = paint.getMeasureCacheProc(SkPaint::kForward_TextBufferDire ction, | 2504 fGlyphCacheProc = paint.getMeasureCacheProc(SkPaint::kForward_TextBufferDire ction, |
2502 true); | 2505 true); |
2503 | 2506 |
2504 fPaint.setLinearText(true); | |
2505 fPaint.setMaskFilter(NULL); // don't want this affecting our path-cache lo okup | 2507 fPaint.setMaskFilter(NULL); // don't want this affecting our path-cache lo okup |
2506 | 2508 |
2507 if (fPaint.getPathEffect() == NULL && !has_thick_frame(fPaint)) { | 2509 if (fPaint.getPathEffect() == NULL && !has_thick_frame(fPaint)) { |
2508 applyStrokeAndPathEffects = false; | 2510 applyStrokeAndPathEffects = false; |
2509 } | 2511 } |
2510 | 2512 |
2511 // can't use our canonical size if we need to apply patheffects | 2513 // can't use our canonical size if we need to apply patheffects |
2512 if (fPaint.getPathEffect() == NULL) { | 2514 if (fPaint.isLinearText() && fPaint.getPathEffect() == NULL) { |
2513 fPaint.setTextSize(SkIntToScalar(SkPaint::kCanonicalTextSizeForPaths)); | 2515 fPaint.setTextSize(SkIntToScalar(SkPaint::kCanonicalTextSizeForPaths)); |
2514 fScale = paint.getTextSize() / SkPaint::kCanonicalTextSizeForPaths; | 2516 fScale = paint.getTextSize() / SkPaint::kCanonicalTextSizeForPaths; |
2515 if (has_thick_frame(fPaint)) { | 2517 if (has_thick_frame(fPaint)) { |
2516 fPaint.setStrokeWidth(SkScalarDiv(fPaint.getStrokeWidth(), fScale)); | 2518 fPaint.setStrokeWidth(SkScalarDiv(fPaint.getStrokeWidth(), fScale)); |
2517 } | 2519 } |
2518 } else { | 2520 } else { |
2519 fScale = SK_Scalar1; | 2521 fScale = SK_Scalar1; |
2520 } | 2522 } |
2521 | 2523 |
2522 if (!applyStrokeAndPathEffects) { | 2524 if (!applyStrokeAndPathEffects) { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2602 case SkXfermode::kPlus_Mode: | 2604 case SkXfermode::kPlus_Mode: |
2603 return 0 == this->getAlpha(); | 2605 return 0 == this->getAlpha(); |
2604 case SkXfermode::kDst_Mode: | 2606 case SkXfermode::kDst_Mode: |
2605 return true; | 2607 return true; |
2606 default: | 2608 default: |
2607 break; | 2609 break; |
2608 } | 2610 } |
2609 } | 2611 } |
2610 return false; | 2612 return false; |
2611 } | 2613 } |
OLD | NEW |