Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(454)

Side by Side Diff: src/core/SkPaint.cpp

Issue 284763010: fix the rendering error for drawPosText_asPaths (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: also fix the rendering error for text with path effects Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkDraw.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 978 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 uint32_t flags = this->getFlags(); 989 uint32_t flags = this->getFlags();
990 // clear the flags we don't care about 990 // clear the flags we don't care about
991 flags &= ~TEXT_AS_PATHS_PAINT_FLAGS_TO_IGNORE; 991 flags &= ~TEXT_AS_PATHS_PAINT_FLAGS_TO_IGNORE;
992 // set the flags we do care about 992 // set the flags we do care about
993 flags |= SkPaint::kSubpixelText_Flag; 993 flags |= SkPaint::kSubpixelText_Flag;
994 994
995 this->setFlags(flags); 995 this->setFlags(flags);
996 this->setHinting(SkPaint::kNo_Hinting); 996 this->setHinting(SkPaint::kNo_Hinting);
997 997
998 SkScalar textSize = fTextSize; 998 SkScalar textSize = fTextSize;
999 this->setTextSize(kCanonicalTextSizeForPaths); 999 SkScalar scale = SK_Scalar1;
1000 return textSize / kCanonicalTextSizeForPaths; 1000
1001 // path effect will affects the generation of path for text, don't change
1002 // SkPaint if it exists. If no path effect, text drawing is based on
1003 // canonical text, so textSize and strokeWidth need to be reset. However,
1004 // hairline stroked text is treated as filled to generate its path.
1005 if (NULL == this->getPathEffect()) {
1006 this->setTextSize(kCanonicalTextSizeForPaths);
1007 scale = textSize / kCanonicalTextSizeForPaths;
1008
1009 if (this->getStrokeWidth() > 0 &&
1010 SkPaint::kFill_Style != this->getStyle()) {
1011 this->setStrokeWidth(SkScalarDiv(this->getStrokeWidth(), scale));
1012 } else {
1013 this->setStyle(SkPaint::kFill_Style);
1014 }
1015 }
1016
1017 return scale;
1001 } 1018 }
1002 1019
1003 class SkCanonicalizePaint { 1020 class SkCanonicalizePaint {
1004 public: 1021 public:
1005 SkCanonicalizePaint(const SkPaint& paint) : fPaint(&paint), fScale(0) { 1022 SkCanonicalizePaint(const SkPaint& paint) : fPaint(&paint), fScale(0) {
1006 if (paint.isLinearText() || paint.tooBigToUseCache()) { 1023 if (paint.isLinearText() || paint.tooBigToUseCache()) {
1007 SkPaint* p = fLazy.set(paint); 1024 SkPaint* p = fLazy.set(paint);
1008 fScale = p->setupForAsPaths(); 1025 fScale = p->setupForAsPaths();
1009 fPaint = p; 1026 fPaint = p;
1010 } 1027 }
(...skipping 1725 matching lines...) Expand 10 before | Expand all | Expand 10 after
2736 } 2753 }
2737 #ifdef SK_BUILD_FOR_ANDROID 2754 #ifdef SK_BUILD_FOR_ANDROID
2738 if (dirty & kPaintOptionsAndroid_DirtyBit) { 2755 if (dirty & kPaintOptionsAndroid_DirtyBit) {
2739 SkPaintOptionsAndroid options; 2756 SkPaintOptionsAndroid options;
2740 options.unflatten(buffer); 2757 options.unflatten(buffer);
2741 paint->setPaintOptionsAndroid(options); 2758 paint->setPaintOptionsAndroid(options);
2742 } 2759 }
2743 #endif 2760 #endif
2744 SkASSERT(dirty == paint->fDirtyBits); 2761 SkASSERT(dirty == paint->fDirtyBits);
2745 } 2762 }
OLDNEW
« no previous file with comments | « src/core/SkDraw.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698