aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-09-06 21:02:36 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-09-06 21:02:36 +0000
commitf244f901a9b76b75447e74cefd077ccf16eb8f40 (patch)
treef1084eed611b6bc7ffb005b2a34988cd9a6fdcfc
parent867c0eaf9515820d65ad281c2a4f7f25dae27719 (diff)
detect when scale is really 1.0, and don't mis-mark our flags to kScale
git-svn-id: http://skia.googlecode.com/svn/trunk@2230 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--src/core/SkMatrix.cpp50
1 files changed, 34 insertions, 16 deletions
diff --git a/src/core/SkMatrix.cpp b/src/core/SkMatrix.cpp
index 30005330dc..a525f11a01 100644
--- a/src/core/SkMatrix.cpp
+++ b/src/core/SkMatrix.cpp
@@ -200,28 +200,36 @@ bool SkMatrix::postTranslate(SkScalar dx, SkScalar dy) {
///////////////////////////////////////////////////////////////////////////////
void SkMatrix::setScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py) {
- fMat[kMScaleX] = sx;
- fMat[kMScaleY] = sy;
- fMat[kMTransX] = px - SkScalarMul(sx, px);
- fMat[kMTransY] = py - SkScalarMul(sy, py);
- fMat[kMPersp2] = kMatrix22Elem;
+ if (SK_Scalar1 == sx && SK_Scalar1 == sy) {
+ this->reset();
+ } else {
+ fMat[kMScaleX] = sx;
+ fMat[kMScaleY] = sy;
+ fMat[kMTransX] = px - SkScalarMul(sx, px);
+ fMat[kMTransY] = py - SkScalarMul(sy, py);
+ fMat[kMPersp2] = kMatrix22Elem;
- fMat[kMSkewX] = fMat[kMSkewY] =
- fMat[kMPersp0] = fMat[kMPersp1] = 0;
-
- this->setTypeMask(kScale_Mask | kTranslate_Mask | kRectStaysRect_Mask);
+ fMat[kMSkewX] = fMat[kMSkewY] =
+ fMat[kMPersp0] = fMat[kMPersp1] = 0;
+
+ this->setTypeMask(kScale_Mask | kTranslate_Mask | kRectStaysRect_Mask);
+ }
}
void SkMatrix::setScale(SkScalar sx, SkScalar sy) {
- fMat[kMScaleX] = sx;
- fMat[kMScaleY] = sy;
- fMat[kMPersp2] = kMatrix22Elem;
+ if (SK_Scalar1 == sx && SK_Scalar1 == sy) {
+ this->reset();
+ } else {
+ fMat[kMScaleX] = sx;
+ fMat[kMScaleY] = sy;
+ fMat[kMPersp2] = kMatrix22Elem;
- fMat[kMTransX] = fMat[kMTransY] =
- fMat[kMSkewX] = fMat[kMSkewY] =
- fMat[kMPersp0] = fMat[kMPersp1] = 0;
+ fMat[kMTransX] = fMat[kMTransY] =
+ fMat[kMSkewX] = fMat[kMSkewY] =
+ fMat[kMPersp0] = fMat[kMPersp1] = 0;
- this->setTypeMask(kScale_Mask | kRectStaysRect_Mask);
+ this->setTypeMask(kScale_Mask | kRectStaysRect_Mask);
+ }
}
bool SkMatrix::setIDiv(int divx, int divy) {
@@ -239,6 +247,10 @@ bool SkMatrix::preScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py) {
}
bool SkMatrix::preScale(SkScalar sx, SkScalar sy) {
+ if (SK_Scalar1 == sx && SK_Scalar1 == sy) {
+ return true;
+ }
+
#ifdef SK_SCALAR_IS_FIXED
SkMatrix m;
m.setScale(sx, sy);
@@ -263,12 +275,18 @@ bool SkMatrix::preScale(SkScalar sx, SkScalar sy) {
}
bool SkMatrix::postScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py) {
+ if (SK_Scalar1 == sx && SK_Scalar1 == sy) {
+ return true;
+ }
SkMatrix m;
m.setScale(sx, sy, px, py);
return this->postConcat(m);
}
bool SkMatrix::postScale(SkScalar sx, SkScalar sy) {
+ if (SK_Scalar1 == sx && SK_Scalar1 == sy) {
+ return true;
+ }
SkMatrix m;
m.setScale(sx, sy);
return this->postConcat(m);