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
This commit is contained in:
tomhudson@google.com 2011-06-06 19:11:19 +00:00
parent 25583a3812
commit 8d430185e0
6 changed files with 15 additions and 22 deletions

View File

@ -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(); }

View File

@ -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;

View File

@ -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];

View File

@ -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();

View File

@ -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();
}

View File

@ -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 {