summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhaas@google.com <jhaas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-21 20:45:23 +0000
committerjhaas@google.com <jhaas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-21 20:45:23 +0000
commit9451fde471832f8da5026dcf47a341bb5c88d53e (patch)
treeb1153ebf089e4aee5dbf1ac4c13b5cb42dcf1557
parent77b2868b86b268178c28d3f267b9c3f1fde72cad (diff)
downloadchromium_src-9451fde471832f8da5026dcf47a341bb5c88d53e.zip
chromium_src-9451fde471832f8da5026dcf47a341bb5c88d53e.tar.gz
chromium_src-9451fde471832f8da5026dcf47a341bb5c88d53e.tar.bz2
Fixed bug #1251296
This is a regression that is causing me to wonder why it ever worked in the first place. The underflow bug was getting tripped by a very small scaling matrix being improperly treated as a zero matrix, and also, the scaling code was getting bitten by a bug in Skia's edge comparison function which caused incorrect results to be returned when the difference between two values exceeded the maximum signed integer. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1180 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--skia/corecg/SkMatrix.cpp5
-rw-r--r--skia/sgl/SkScan_Path.cpp2
-rw-r--r--webkit/port/platform/graphics/SkiaUtils.cpp15
3 files changed, 13 insertions, 9 deletions
diff --git a/skia/corecg/SkMatrix.cpp b/skia/corecg/SkMatrix.cpp
index d5b64ec..4c9a087 100644
--- a/skia/corecg/SkMatrix.cpp
+++ b/skia/corecg/SkMatrix.cpp
@@ -667,9 +667,12 @@ bool SkMatrix::postConcat(const SkMatrix& mat) {
det = (double)mat[SkMatrix::kMScaleX] * mat[SkMatrix::kMScaleY] - (double)mat[SkMatrix::kMSkewX] * mat[SkMatrix::kMSkewY];
}
- if (SkScalarNearlyZero((float)det)) {
+ // Since the determinant is on the order of the square of the matrix members,
+ // compare to the square of the default nearly-zero constant
+ if (SkScalarNearlyZero((float)det, SK_ScalarNearlyZero * SK_ScalarNearlyZero)) {
return 0;
}
+
return (float)(1.0 / det);
}
#else
diff --git a/skia/sgl/SkScan_Path.cpp b/skia/sgl/SkScan_Path.cpp
index 81b0233..4e58518 100644
--- a/skia/sgl/SkScan_Path.cpp
+++ b/skia/sgl/SkScan_Path.cpp
@@ -368,7 +368,7 @@ extern "C" {
valuea = edgea->fX;
valueb = edgeb->fX;
}
- return valuea - valueb;
+ return valuea > valueb ? 1 : valuea < valueb ? -1 : 0;
}
}
diff --git a/webkit/port/platform/graphics/SkiaUtils.cpp b/webkit/port/platform/graphics/SkiaUtils.cpp
index 89e6998..27779c7 100644
--- a/webkit/port/platform/graphics/SkiaUtils.cpp
+++ b/webkit/port/platform/graphics/SkiaUtils.cpp
@@ -211,14 +211,15 @@ bool SkPathContainsPoint(SkPath* orig_path, WebCore::FloatPoint point, SkPath::F
orig_path->setFillType(ft);
- // Skia has trouble with coordinates greater than +/- 2^15... if we have
- // those, we need to scale
+ // Skia has trouble with coordinates close to the max signed 16-bit values
+ // If we have those, we need to scale.
+ //
+ // TODO: remove this code once Skia is patched to work properly with large
+ // values
const SkScalar kMaxCoordinate = SkIntToScalar(1<<15);
- SkScalar biggest_coord = 0;
- biggest_coord = -bounds.fLeft > biggest_coord ? -bounds.fLeft : biggest_coord;
- biggest_coord = -bounds.fTop > biggest_coord ? -bounds.fTop : biggest_coord;
- biggest_coord = bounds.fRight > biggest_coord ? bounds.fRight : biggest_coord;
- biggest_coord = bounds.fBottom > biggest_coord ? bounds.fBottom : biggest_coord;
+ SkScalar biggest_coord = std::max(std::max(std::max(
+ bounds.fRight, bounds.fBottom), -bounds.fLeft), -bounds.fTop);
+
if (biggest_coord > kMaxCoordinate) {
scale = SkScalarCeil(SkScalarDiv(biggest_coord, kMaxCoordinate));