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

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

Issue 152073003: Adding code to calculate Underline Thickness from Font Metrics, this will be useful when Skia is us… (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fixing comments for Underline patch Created 6 years, 10 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
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 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after
1289 if (scale) { 1289 if (scale) {
1290 metrics->fTop = SkScalarMul(metrics->fTop, scale); 1290 metrics->fTop = SkScalarMul(metrics->fTop, scale);
1291 metrics->fAscent = SkScalarMul(metrics->fAscent, scale); 1291 metrics->fAscent = SkScalarMul(metrics->fAscent, scale);
1292 metrics->fDescent = SkScalarMul(metrics->fDescent, scale); 1292 metrics->fDescent = SkScalarMul(metrics->fDescent, scale);
1293 metrics->fBottom = SkScalarMul(metrics->fBottom, scale); 1293 metrics->fBottom = SkScalarMul(metrics->fBottom, scale);
1294 metrics->fLeading = SkScalarMul(metrics->fLeading, scale); 1294 metrics->fLeading = SkScalarMul(metrics->fLeading, scale);
1295 metrics->fAvgCharWidth = SkScalarMul(metrics->fAvgCharWidth, scale); 1295 metrics->fAvgCharWidth = SkScalarMul(metrics->fAvgCharWidth, scale);
1296 metrics->fXMin = SkScalarMul(metrics->fXMin, scale); 1296 metrics->fXMin = SkScalarMul(metrics->fXMin, scale);
1297 metrics->fXMax = SkScalarMul(metrics->fXMax, scale); 1297 metrics->fXMax = SkScalarMul(metrics->fXMax, scale);
1298 metrics->fXHeight = SkScalarMul(metrics->fXHeight, scale); 1298 metrics->fXHeight = SkScalarMul(metrics->fXHeight, scale);
1299 metrics->fUnderlineThickness = SkScalarMul(metrics->fUnderlineThickness, scale);
1300 metrics->fUnderlinePosition = SkScalarMul(metrics->fUnderlinePosition, s cale);
1299 } 1301 }
1300 return metrics->fDescent - metrics->fAscent + metrics->fLeading; 1302 return metrics->fDescent - metrics->fAscent + metrics->fLeading;
1301 } 1303 }
1302 1304
1303 /////////////////////////////////////////////////////////////////////////////// 1305 ///////////////////////////////////////////////////////////////////////////////
1304 1306
1305 static void set_bounds(const SkGlyph& g, SkRect* bounds, SkScalar scale) { 1307 static void set_bounds(const SkGlyph& g, SkRect* bounds, SkScalar scale) {
1306 bounds->set(g.fLeft * scale, 1308 bounds->set(g.fLeft * scale,
1307 g.fTop * scale, 1309 g.fTop * scale,
1308 (g.fLeft + g.fWidth) * scale, 1310 (g.fLeft + g.fWidth) * scale,
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after
2250 this->getMaskFilter()->computeFastBounds(*storage, storage); 2252 this->getMaskFilter()->computeFastBounds(*storage, storage);
2251 } 2253 }
2252 2254
2253 if (this->getImageFilter()) { 2255 if (this->getImageFilter()) {
2254 this->getImageFilter()->computeFastBounds(*storage, storage); 2256 this->getImageFilter()->computeFastBounds(*storage, storage);
2255 } 2257 }
2256 2258
2257 return *storage; 2259 return *storage;
2258 } 2260 }
2259 2261
2262 void SkPaint::FontMetrics::setFontMetricsFlag(FontMetrics::FontMetricsFlags flag )
2263 {
bungeman-skia 2014/02/19 15:39:17 Style nit: we usually put this '{' at the end of t
h.joshi 2014/02/19 17:12:03 Will make changes On 2014/02/19 15:39:17, bungeman
2264 this->fFontMetricsFlag = this->fFontMetricsFlag | flag;
bungeman-skia 2014/02/19 15:39:17 This might be clearer like fFontMetricsFlag |= fl
h.joshi 2014/02/19 17:12:03 Will make changes On 2014/02/19 15:39:17, bungeman
2265 }
2266
2267 void SkPaint::FontMetrics::unsetFontMetricsFlag(FontMetrics::FontMetricsFlags fl ag)
2268 {
2269 this->fFontMetricsFlag = this->fFontMetricsFlag ^ flag;
bungeman-skia 2014/02/19 15:39:17 This will toggle, not unset. Also, since members b
h.joshi 2014/02/19 17:12:03 Will make changes On 2014/02/19 15:39:17, bungeman
2270 }
2271
2272 bool SkPaint::FontMetrics::checkFontMetricsFlag(FontMetrics::FontMetricsFlags fl ag) const
2273 {
2274 return SkToBool(this->fFontMetricsFlag & flag);
2275 }
2276
2260 #ifdef SK_DEVELOPER 2277 #ifdef SK_DEVELOPER
2261 void SkPaint::toString(SkString* str) const { 2278 void SkPaint::toString(SkString* str) const {
2262 str->append("<dl><dt>SkPaint:</dt><dd><dl>"); 2279 str->append("<dl><dt>SkPaint:</dt><dd><dl>");
2263 2280
2264 SkTypeface* typeface = this->getTypeface(); 2281 SkTypeface* typeface = this->getTypeface();
2265 if (NULL != typeface) { 2282 if (NULL != typeface) {
2266 SkDynamicMemoryWStream ostream; 2283 SkDynamicMemoryWStream ostream;
2267 typeface->serialize(&ostream); 2284 typeface->serialize(&ostream);
2268 SkAutoTUnref<SkData> data(ostream.copyToData()); 2285 SkAutoTUnref<SkData> data(ostream.copyToData());
2269 2286
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
2543 case SkXfermode::kPlus_Mode: 2560 case SkXfermode::kPlus_Mode:
2544 return 0 == this->getAlpha(); 2561 return 0 == this->getAlpha();
2545 case SkXfermode::kDst_Mode: 2562 case SkXfermode::kDst_Mode:
2546 return true; 2563 return true;
2547 default: 2564 default:
2548 break; 2565 break;
2549 } 2566 }
2550 } 2567 }
2551 return false; 2568 return false;
2552 } 2569 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698