diff options
author | 2011-06-06 19:11:19 +0000 | |
---|---|---|
committer | 2011-06-06 19:11:19 +0000 | |
commit | 8d430185e08d2067584837a76b7193b803fee7a0 (patch) | |
tree | d5857dd5c5f14af5cb95a0323f5d4d99facab694 | |
parent | 25583a381252921f2e9d0dc4a30c3834ef677530 (diff) |
Increase use of SkMatrix::hasPerspective(), merge in has_perspective().
Unifies SkMatrix::hasPerspective(), has_perspective(), and manual tests of SkMatrix::getType & kPerspective_Mask.
git-svn-id: http://skia.googlecode.com/svn/trunk@1517 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | src/core/SkCanvas.cpp | 3 | ||||
-rw-r--r-- | src/core/SkDraw.cpp | 6 | ||||
-rw-r--r-- | src/core/SkMatrix.cpp | 20 | ||||
-rw-r--r-- | src/core/SkPaint.cpp | 3 | ||||
-rw-r--r-- | src/core/SkPath.cpp | 3 | ||||
-rw-r--r-- | src/core/SkShader.cpp | 2 |
6 files changed, 15 insertions, 22 deletions
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp index e2d70eede7..7d29f74e9e 100644 --- a/src/core/SkCanvas.cpp +++ b/src/core/SkCanvas.cpp @@ -1064,7 +1064,7 @@ bool SkCanvas::quickReject(const SkRect& rect, EdgeType et) const { return true; } - if (fMCRec->fMatrix->getType() & SkMatrix::kPerspective_Mask) { + if (fMCRec->fMatrix->hasPerspective()) { SkRect dst; fMCRec->fMatrix->mapRect(&dst, rect); SkIRect idst; @@ -1666,4 +1666,3 @@ const SkPaint& SkCanvas::LayerIter::paint() const { const SkRegion& SkCanvas::LayerIter::clip() const { return fImpl->getClip(); } int SkCanvas::LayerIter::x() const { return fImpl->getX(); } int SkCanvas::LayerIter::y() const { return fImpl->getY(); } - diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp index 14e5a803cb..74a30e9c91 100644 --- a/src/core/SkDraw.cpp +++ b/src/core/SkDraw.cpp @@ -864,7 +864,7 @@ static SkScalar fast_len(const SkVector& vec) { // for that we'll transform (0,1) and (1,0), and check that the resulting dot-prod // is nearly one static bool map_radius(const SkMatrix& matrix, SkScalar* value) { - if (matrix.getType() & SkMatrix::kPerspective_Mask) { + if (matrix.hasPerspective()) { return false; } SkVector src[2], dst[2]; @@ -1562,7 +1562,7 @@ void SkDraw::drawText(const char text[], size_t byteLength, } if (/*paint.isLinearText() ||*/ - (fMatrix->getType() & SkMatrix::kPerspective_Mask)) { + (fMatrix->hasPerspective())) { this->drawText_asPaths(text, byteLength, x, y, paint); handle_aftertext(this, paint, underlineWidth, underlineStart); return; @@ -1760,7 +1760,7 @@ void SkDraw::drawPosText(const char text[], size_t byteLength, } if (/*paint.isLinearText() ||*/ - (fMatrix->getType() & SkMatrix::kPerspective_Mask)) { + (fMatrix->hasPerspective())) { // TODO !!!! // this->drawText_asPaths(text, byteLength, x, y, paint); return; diff --git a/src/core/SkMatrix.cpp b/src/core/SkMatrix.cpp index c134b8ffd4..da66a68149 100644 --- a/src/core/SkMatrix.cpp +++ b/src/core/SkMatrix.cpp @@ -46,10 +46,6 @@ void SkMatrix::reset() { this->setTypeMask(kIdentity_Mask | kRectStaysRect_Mask); } -static inline int has_perspective(const SkMatrix& matrix) { - return matrix.getType() & SkMatrix::kPerspective_Mask; -} - // this guy aligns with the masks, so we can compute a mask from a varaible 0/1 enum { kTranslate_Shift, @@ -165,7 +161,7 @@ void SkMatrix::setTranslate(SkScalar dx, SkScalar dy) { } bool SkMatrix::preTranslate(SkScalar dx, SkScalar dy) { - if (has_perspective(*this)) { + if (this->hasPerspective()) { SkMatrix m; m.setTranslate(dx, dy); return this->preConcat(m); @@ -183,7 +179,7 @@ bool SkMatrix::preTranslate(SkScalar dx, SkScalar dy) { } bool SkMatrix::postTranslate(SkScalar dx, SkScalar dy) { - if (has_perspective(*this)) { + if (this->hasPerspective()) { SkMatrix m; m.setTranslate(dx, dy); return this->postConcat(m); @@ -768,7 +764,7 @@ bool SkMatrix::pdfTransform(SkScalar transform[6]) const { SkMatrix identity; const SkMatrix* use = this; bool ret = true; - if (has_perspective(*this)) { + if (this->hasPerspective()) { identity.reset(); use = &identity; ret = false; @@ -783,7 +779,7 @@ bool SkMatrix::pdfTransform(SkScalar transform[6]) const { } bool SkMatrix::invert(SkMatrix* inv) const { - int isPersp = has_perspective(*this); + int isPersp = this->hasPerspective(); int shift; SkDetScalar scale = sk_inv_determinant(fMat, isPersp, &shift); @@ -965,7 +961,7 @@ void SkMatrix::Rot_pts(const SkMatrix& m, SkPoint dst[], void SkMatrix::RotTrans_pts(const SkMatrix& m, SkPoint dst[], const SkPoint src[], int count) { - SkASSERT((m.getType() & kPerspective_Mask) == 0); + SkASSERT(!m.hasPerspective()); if (count > 0) { SkScalar mx = m.fMat[kMScaleX]; @@ -987,7 +983,7 @@ void SkMatrix::RotTrans_pts(const SkMatrix& m, SkPoint dst[], void SkMatrix::Persp_pts(const SkMatrix& m, SkPoint dst[], const SkPoint src[], int count) { - SkASSERT(m.getType() & kPerspective_Mask); + SkASSERT(m.hasPerspective()); #ifdef SK_SCALAR_IS_FIXED SkFixed persp2 = SkFractToFixed(m.fMat[kMPersp2]); @@ -1044,7 +1040,7 @@ void SkMatrix::mapPoints(SkPoint dst[], const SkPoint src[], int count) const { /////////////////////////////////////////////////////////////////////////////// void SkMatrix::mapVectors(SkPoint dst[], const SkPoint src[], int count) const { - if (this->getType() & kPerspective_Mask) { + if (this->hasPerspective()) { SkPoint origin; MapXYProc proc = this->getMapXYProc(); @@ -1099,7 +1095,7 @@ SkScalar SkMatrix::mapRadius(SkScalar radius) const { void SkMatrix::Persp_xy(const SkMatrix& m, SkScalar sx, SkScalar sy, SkPoint* pt) { - SkASSERT(m.getType() & kPerspective_Mask); + SkASSERT(m.hasPerspective()); SkScalar x = SkScalarMul(sx, m.fMat[kMScaleX]) + SkScalarMul(sy, m.fMat[kMSkewX]) + m.fMat[kMTransX]; diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp index c023dbf206..b7b6a34e1d 100644 --- a/src/core/SkPaint.cpp +++ b/src/core/SkPaint.cpp @@ -1232,8 +1232,7 @@ static SkScalar sk_relax(SkScalar x) { void SkScalerContext::MakeRec(const SkPaint& paint, const SkMatrix* deviceMatrix, Rec* rec) { - SkASSERT(deviceMatrix == NULL || - (deviceMatrix->getType() & SkMatrix::kPerspective_Mask) == 0); + SkASSERT(deviceMatrix == NULL || !deviceMatrix->hasPerspective()); rec->fFontID = SkTypeface::UniqueID(paint.getTypeface()); rec->fTextSize = paint.getTextSize(); diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp index ca57237a53..b88b20f90c 100644 --- a/src/core/SkPath.cpp +++ b/src/core/SkPath.cpp @@ -949,7 +949,7 @@ void SkPath::transform(const SkMatrix& matrix, SkPath* dst) const { dst = (SkPath*)this; } - if (matrix.getType() & SkMatrix::kPerspective_Mask) { + if (matrix.hasPerspective()) { SkPath tmp; tmp.fFillType = fFillType; @@ -1532,4 +1532,3 @@ SkPath::Convexity SkPath::ComputeConvexity(const SkPath& path) { } return state.getConvexity(); } - diff --git a/src/core/SkShader.cpp b/src/core/SkShader.cpp index 7b469533be..b51705e6e6 100644 --- a/src/core/SkShader.cpp +++ b/src/core/SkShader.cpp @@ -185,7 +185,7 @@ void SkShader::shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) { SkShader::MatrixClass SkShader::ComputeMatrixClass(const SkMatrix& mat) { MatrixClass mc = kLinear_MatrixClass; - if (mat.getType() & SkMatrix::kPerspective_Mask) { + if (mat.hasPerspective()) { if (mat.fixedStepInX(0, NULL, NULL)) { mc = kFixedStepInX_MatrixClass; } else { |