| Index: src/core/SkBitmapProcState.cpp
|
| diff --git a/src/core/SkBitmapProcState.cpp b/src/core/SkBitmapProcState.cpp
|
| index f04379cf20d035112533937fce5d77d03faf2778..26ee82e28fe954b840926dc2917a21367389583e 100644
|
| --- a/src/core/SkBitmapProcState.cpp
|
| +++ b/src/core/SkBitmapProcState.cpp
|
| @@ -62,9 +62,9 @@ SkBitmapProcInfo::~SkBitmapProcInfo() {
|
|
|
| ///////////////////////////////////////////////////////////////////////////////
|
|
|
| -// true iff the matrix contains, at most, scale and translate elements
|
| +// true iff the matrix has a scale and no more than an optional translate.
|
| static bool matrix_only_scale_translate(const SkMatrix& m) {
|
| - return m.getType() <= (SkMatrix::kScale_Mask | SkMatrix::kTranslate_Mask);
|
| + return (m.getType() & ~SkMatrix::kTranslate_Mask) == SkMatrix::kScale_Mask;
|
| }
|
|
|
| /**
|
| @@ -74,44 +74,32 @@ static bool matrix_only_scale_translate(const SkMatrix& m) {
|
| static bool just_trans_clamp(const SkMatrix& matrix, const SkPixmap& pixmap) {
|
| SkASSERT(matrix_only_scale_translate(matrix));
|
|
|
| - if (matrix.getType() & SkMatrix::kScale_Mask) {
|
| - SkRect dst;
|
| - SkRect src = SkRect::Make(pixmap.bounds());
|
| -
|
| - // Can't call mapRect(), since that will fix up inverted rectangles,
|
| - // e.g. when scale is negative, and we don't want to return true for
|
| - // those.
|
| - matrix.mapPoints(SkTCast<SkPoint*>(&dst),
|
| - SkTCast<const SkPoint*>(&src),
|
| - 2);
|
| -
|
| - // Now round all 4 edges to device space, and then compare the device
|
| - // width/height to the original. Note: we must map all 4 and subtract
|
| - // rather than map the "width" and compare, since we care about the
|
| - // phase (in pixel space) that any translate in the matrix might impart.
|
| - SkIRect idst;
|
| - dst.round(&idst);
|
| - return idst.width() == pixmap.width() && idst.height() == pixmap.height();
|
| - }
|
| - // if we got here, we're either kTranslate_Mask or identity
|
| - return true;
|
| + SkRect dst;
|
| + SkRect src = SkRect::Make(pixmap.bounds());
|
| +
|
| + // Can't call mapRect(), since that will fix up inverted rectangles,
|
| + // e.g. when scale is negative, and we don't want to return true for
|
| + // those.
|
| + matrix.mapPoints(SkTCast<SkPoint*>(&dst),
|
| + SkTCast<const SkPoint*>(&src),
|
| + 2);
|
| +
|
| + // Now round all 4 edges to device space, and then compare the device
|
| + // width/height to the original. Note: we must map all 4 and subtract
|
| + // rather than map the "width" and compare, since we care about the
|
| + // phase (in pixel space) that any translate in the matrix might impart.
|
| + SkIRect idst;
|
| + dst.round(&idst);
|
| + return idst.width() == pixmap.width() && idst.height() == pixmap.height();
|
| }
|
|
|
| static bool just_trans_general(const SkMatrix& matrix) {
|
| SkASSERT(matrix_only_scale_translate(matrix));
|
|
|
| - if (matrix.getType() & SkMatrix::kScale_Mask) {
|
| - const SkScalar tol = SK_Scalar1 / 32768;
|
| + const SkScalar tol = SK_Scalar1 / 32768;
|
|
|
| - if (!SkScalarNearlyZero(matrix[SkMatrix::kMScaleX] - SK_Scalar1, tol)) {
|
| - return false;
|
| - }
|
| - if (!SkScalarNearlyZero(matrix[SkMatrix::kMScaleY] - SK_Scalar1, tol)) {
|
| - return false;
|
| - }
|
| - }
|
| - // if we got here, treat us as either kTranslate_Mask or identity
|
| - return true;
|
| + return SkScalarNearlyZero(matrix[SkMatrix::kMScaleX] - SK_Scalar1, tol)
|
| + && SkScalarNearlyZero(matrix[SkMatrix::kMScaleY] - SK_Scalar1, tol);
|
| }
|
|
|
| static bool valid_for_filtering(unsigned dimension) {
|
|
|