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

Unified Diff: src/core/SkScalerContext.cpp

Issue 770383002: Replace use of deprecated CG methods. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Remove no longer required include. Created 6 years 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 | src/ports/SkFontHost_mac.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkScalerContext.cpp
diff --git a/src/core/SkScalerContext.cpp b/src/core/SkScalerContext.cpp
index 4d22fbec62c154671d62ca69a64a1920da3f5702..5cfa814ae9e14ce069aafe469d80156bb29469d0 100644
--- a/src/core/SkScalerContext.cpp
+++ b/src/core/SkScalerContext.cpp
@@ -735,6 +735,27 @@ void SkScalerContextRec::computeMatrices(PreMatrixScale preMatrixScale, SkVector
*A_out = A;
}
+ // If the 'total' matrix is singular, set the 'scale' to something finite and zero the matrices.
+ // All underlying ports have issues with zero text size, so use the matricies to zero.
+
+ // Map the vectors [1,1] and [1,-1] (the EM) through the 'total' matrix.
+ // If the length of one of these vectors is less than 1/256 then an EM filling square will
+ // never affect any pixels.
+ SkVector diag[2] = { { A.getScaleX() + A.getSkewX(), A.getScaleY() + A.getSkewY() },
+ { A.getScaleX() - A.getSkewX(), A.getScaleY() - A.getSkewY() }, };
+ if (diag[0].lengthSqd() < SK_ScalarNearlyZero || diag[1].lengthSqd() < SK_ScalarNearlyZero) {
reed1 2014/12/10 16:45:16 1. most often when we look at len^2, we compare it
bungeman-skia 2014/12/10 17:06:16 Done and done.
+ s->fX = SK_Scalar1;
+ s->fY = SK_Scalar1;
+ sA->setScale(0, 0);
+ if (GsA) {
+ GsA->setScale(0, 0);
+ }
+ if (G_inv) {
+ G_inv->reset();
+ }
+ return;
+ }
+
// GA is the matrix A with rotation removed.
SkMatrix GA;
bool skewedOrFlipped = A.getSkewX() || A.getSkewY() || A.getScaleX() < 0 || A.getScaleY() < 0;
@@ -789,12 +810,18 @@ void SkScalerContextRec::computeMatrices(PreMatrixScale preMatrixScale, SkVector
}
// The 'remaining' matrix sA is the total matrix A without the scale.
- if (!skewedOrFlipped && kFull_PreMatrixScale == preMatrixScale) {
+ if (!skewedOrFlipped && (
+ (kFull_PreMatrixScale == preMatrixScale) ||
+ (kVertical_PreMatrixScale == preMatrixScale && A.getScaleX() == A.getScaleY())))
+ {
// If GA == A and kFull_PreMatrixScale, sA is identity.
+ // If GA == A and kVertical_PreMatrixScale and A.scaleX == A.scaleY, sA is identity.
+ sA->reset();
+ } else if (!skewedOrFlipped && kVertical_PreMatrixScale == preMatrixScale) {
+ // If GA == A and kVertical_PreMatrixScale, sA.scaleY is SK_Scalar1.
sA->reset();
+ sA->setScaleX(A.getScaleX() / s->fY);
} else {
- // TODO: If GA == A and kVertical_PreMatrixScale, sA.scaleY is SK_Scalar1.
- // TODO: If GA == A and kVertical_PreMatrixScale and A.scaleX == A.scaleY, sA is identity.
// TODO: like kVertical_PreMatrixScale, kVerticalInteger_PreMatrixScale with int scales.
*sA = A;
sA->preScale(SkScalarInvert(s->fX), SkScalarInvert(s->fY));
« no previous file with comments | « no previous file | src/ports/SkFontHost_mac.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698