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

Unified Diff: src/core/SkPaint.cpp

Issue 615053005: avoid extra math work in MackRec (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPaint.cpp
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp
index 34fdf45bc4093c35352fcc0708554028aa78f6c2..7a23566fece108155231987aeaab4392a85ccb28 100644
--- a/src/core/SkPaint.cpp
+++ b/src/core/SkPaint.cpp
@@ -1479,11 +1479,16 @@ static SkColor computeLuminanceColor(const SkPaint& paint) {
#define SK_MAX_SIZE_FOR_LCDTEXT 48
#endif
-static bool tooBigForLCD(const SkScalerContext::Rec& rec) {
- SkScalar area = rec.fPost2x2[0][0] * rec.fPost2x2[1][1] -
- rec.fPost2x2[1][0] * rec.fPost2x2[0][1];
- SkScalar size = SkScalarSqrt(SkScalarAbs(area)) * rec.fTextSize;
- return size > SkIntToScalar(SK_MAX_SIZE_FOR_LCDTEXT);
+const SkScalar gMaxSize2ForLCDText = SK_MAX_SIZE_FOR_LCDTEXT * SK_MAX_SIZE_FOR_LCDTEXT;
+
robertphillips 2014/10/01 19:58:41 too_big_for_lcd ?
+static bool tooBigForLCD(const SkScalerContext::Rec& rec, bool checkPost2x2) {
+ SkScalar size = rec.fTextSize;
+ if (checkPost2x2) {
+ SkScalar area = rec.fPost2x2[0][0] * rec.fPost2x2[1][1] -
+ rec.fPost2x2[1][0] * rec.fPost2x2[0][1];
+ size *= SkScalarAbs(area);
+ }
+ return size > gMaxSize2ForLCDText;
}
/*
@@ -1511,11 +1516,24 @@ void SkScalerContext::MakeRec(const SkPaint& paint,
rec->fPreScaleX = paint.getTextScaleX();
rec->fPreSkewX = paint.getTextSkewX();
+ bool checkPost2x2 = false;
+
if (deviceMatrix) {
- rec->fPost2x2[0][0] = sk_relax(deviceMatrix->getScaleX());
- rec->fPost2x2[0][1] = sk_relax(deviceMatrix->getSkewX());
- rec->fPost2x2[1][0] = sk_relax(deviceMatrix->getSkewY());
- rec->fPost2x2[1][1] = sk_relax(deviceMatrix->getScaleY());
+ const SkMatrix::TypeMask mask = deviceMatrix->getType();
+ if (mask & SkMatrix::kScale_Mask) {
+ rec->fPost2x2[0][0] = sk_relax(deviceMatrix->getScaleX());
+ rec->fPost2x2[1][1] = sk_relax(deviceMatrix->getScaleY());
+ checkPost2x2 = true;
+ } else {
+ rec->fPost2x2[0][0] = rec->fPost2x2[1][1] = SK_Scalar1;
+ }
+ if (mask & SkMatrix::kAffine_Mask) {
+ rec->fPost2x2[0][1] = sk_relax(deviceMatrix->getSkewX());
+ rec->fPost2x2[1][0] = sk_relax(deviceMatrix->getSkewY());
+ checkPost2x2 = true;
+ } else {
+ rec->fPost2x2[0][1] = rec->fPost2x2[1][0] = 0;
+ }
} else {
rec->fPost2x2[0][0] = rec->fPost2x2[1][1] = SK_Scalar1;
rec->fPost2x2[0][1] = rec->fPost2x2[1][0] = 0;
@@ -1566,7 +1584,7 @@ void SkScalerContext::MakeRec(const SkPaint& paint,
rec->fMaskFormat = SkToU8(computeMaskFormat(paint));
if (SkMask::kLCD16_Format == rec->fMaskFormat || SkMask::kLCD32_Format == rec->fMaskFormat) {
- if (tooBigForLCD(*rec)) {
+ if (tooBigForLCD(*rec, checkPost2x2)) {
rec->fMaskFormat = SkMask::kA8_Format;
flags |= SkScalerContext::kGenA8FromLCD_Flag;
} else {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698