| Index: src/core/SkMatrix.cpp
|
| diff --git a/src/core/SkMatrix.cpp b/src/core/SkMatrix.cpp
|
| index 95662fc4cd42bca1edfb286e94089494b6e5a206..81115620810ef147ca0c06036a13e9a6ac47b319 100644
|
| --- a/src/core/SkMatrix.cpp
|
| +++ b/src/core/SkMatrix.cpp
|
| @@ -1638,6 +1638,32 @@ void SkMatrix::toString(SkString* str) const {
|
|
|
| #include "SkMatrixUtils.h"
|
|
|
| +bool SkRectIsOnGrid(int width, int height, const SkRect& r, unsigned subpixelBits) {
|
| + const int lowBitsMask = (1 << subpixelBits) - 1;
|
| + const SkScalar scale = 1 << subpixelBits;
|
| +
|
| + const int dL = SkScalarRoundToInt(r.fLeft * scale);
|
| + const int dT = SkScalarRoundToInt(r.fTop * scale);
|
| + const int dR = SkScalarRoundToInt(r.fRight * scale);
|
| + const int dB = SkScalarRoundToInt(r.fBottom * scale);
|
| +
|
| + if (subpixelBits) {
|
| + // we only check the low-bits for gridding if we have subpixelBits
|
| + const int merge = dL | dT | dR | dB;
|
| + if (merge & lowBitsMask) {
|
| + return false;
|
| + }
|
| + }
|
| +
|
| + // Now we know we're integral, just need to check our width/height
|
| + const int dW = (dR - dL);
|
| + const int dH = (dB - dT);
|
| + if (dW != (width << subpixelBits) || dH != (height << subpixelBits)) {
|
| + return false;
|
| + }
|
| + return true;
|
| +}
|
| +
|
| bool SkTreatAsSprite(const SkMatrix& mat, int width, int height,
|
| unsigned subpixelBits) {
|
| // quick reject on affine or perspective
|
| @@ -1664,6 +1690,7 @@ bool SkTreatAsSprite(const SkMatrix& mat, int width, int height,
|
| mat.mapRect(&dst, src);
|
| }
|
|
|
| +#if 0
|
| // just apply the translate to isrc
|
| isrc.offset(SkScalarRoundToInt(mat.getTranslateX()),
|
| SkScalarRoundToInt(mat.getTranslateY()));
|
| @@ -1684,6 +1711,9 @@ bool SkTreatAsSprite(const SkMatrix& mat, int width, int height,
|
| SkIRect idst;
|
| dst.round(&idst);
|
| return isrc == idst;
|
| +#else
|
| + return SkRectIsOnGrid(width, height, dst, subpixelBits);
|
| +#endif
|
| }
|
|
|
| // A square matrix M can be decomposed (via polar decomposition) into two matrices --
|
|
|