зеркало из https://github.com/mozilla/moz-skia.git
Remove SkCanvas matrix ops return value.
The internal SkMatrix ops can no longer fail -> we can remove the bool return value. R=bsalomon@google.com, reed@google.com, robertphillips@google.com, scroggo@google.com, fmalita@google.com Author: fmalita@chromium.org Review URL: https://codereview.chromium.org/200223008 git-svn-id: http://skia.googlecode.com/svn/trunk@13849 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
Родитель
2077427227
Коммит
92362383a4
|
@ -470,35 +470,30 @@ public:
|
|||
/** Preconcat the current matrix with the specified translation
|
||||
@param dx The distance to translate in X
|
||||
@param dy The distance to translate in Y
|
||||
returns true if the operation succeeded (e.g. did not overflow)
|
||||
*/
|
||||
bool translate(SkScalar dx, SkScalar dy);
|
||||
void translate(SkScalar dx, SkScalar dy);
|
||||
|
||||
/** Preconcat the current matrix with the specified scale.
|
||||
@param sx The amount to scale in X
|
||||
@param sy The amount to scale in Y
|
||||
returns true if the operation succeeded (e.g. did not overflow)
|
||||
*/
|
||||
bool scale(SkScalar sx, SkScalar sy);
|
||||
void scale(SkScalar sx, SkScalar sy);
|
||||
|
||||
/** Preconcat the current matrix with the specified rotation.
|
||||
@param degrees The amount to rotate, in degrees
|
||||
returns true if the operation succeeded (e.g. did not overflow)
|
||||
*/
|
||||
bool rotate(SkScalar degrees);
|
||||
void rotate(SkScalar degrees);
|
||||
|
||||
/** Preconcat the current matrix with the specified skew.
|
||||
@param sx The amount to skew in X
|
||||
@param sy The amount to skew in Y
|
||||
returns true if the operation succeeded (e.g. did not overflow)
|
||||
*/
|
||||
bool skew(SkScalar sx, SkScalar sy);
|
||||
void skew(SkScalar sx, SkScalar sy);
|
||||
|
||||
/** Preconcat the current matrix with the specified matrix.
|
||||
@param matrix The matrix to preconcatenate with the current matrix
|
||||
@return true if the operation succeeded (e.g. did not overflow)
|
||||
*/
|
||||
bool concat(const SkMatrix& matrix);
|
||||
void concat(const SkMatrix& matrix);
|
||||
|
||||
/** Replace the current matrix with a copy of the specified matrix.
|
||||
@param matrix The matrix that will be copied into the current matrix.
|
||||
|
|
|
@ -218,57 +218,57 @@ public:
|
|||
/** Set the matrix to skew by sx and sy.
|
||||
*/
|
||||
void setSkew(SkScalar kx, SkScalar ky);
|
||||
/** Set the matrix to the concatenation of the two specified matrices,
|
||||
returning true if the the result can be represented. Either of the
|
||||
two matrices may also be the target matrix. *this = a * b;
|
||||
/** Set the matrix to the concatenation of the two specified matrices.
|
||||
Either of the two matrices may also be the target matrix.
|
||||
*this = a * b;
|
||||
*/
|
||||
bool setConcat(const SkMatrix& a, const SkMatrix& b);
|
||||
void setConcat(const SkMatrix& a, const SkMatrix& b);
|
||||
|
||||
/** Preconcats the matrix with the specified translation.
|
||||
M' = M * T(dx, dy)
|
||||
*/
|
||||
bool preTranslate(SkScalar dx, SkScalar dy);
|
||||
void preTranslate(SkScalar dx, SkScalar dy);
|
||||
/** Preconcats the matrix with the specified scale.
|
||||
M' = M * S(sx, sy, px, py)
|
||||
*/
|
||||
bool preScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py);
|
||||
void preScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py);
|
||||
/** Preconcats the matrix with the specified scale.
|
||||
M' = M * S(sx, sy)
|
||||
*/
|
||||
bool preScale(SkScalar sx, SkScalar sy);
|
||||
void preScale(SkScalar sx, SkScalar sy);
|
||||
/** Preconcats the matrix with the specified rotation.
|
||||
M' = M * R(degrees, px, py)
|
||||
*/
|
||||
bool preRotate(SkScalar degrees, SkScalar px, SkScalar py);
|
||||
void preRotate(SkScalar degrees, SkScalar px, SkScalar py);
|
||||
/** Preconcats the matrix with the specified rotation.
|
||||
M' = M * R(degrees)
|
||||
*/
|
||||
bool preRotate(SkScalar degrees);
|
||||
void preRotate(SkScalar degrees);
|
||||
/** Preconcats the matrix with the specified skew.
|
||||
M' = M * K(kx, ky, px, py)
|
||||
*/
|
||||
bool preSkew(SkScalar kx, SkScalar ky, SkScalar px, SkScalar py);
|
||||
void preSkew(SkScalar kx, SkScalar ky, SkScalar px, SkScalar py);
|
||||
/** Preconcats the matrix with the specified skew.
|
||||
M' = M * K(kx, ky)
|
||||
*/
|
||||
bool preSkew(SkScalar kx, SkScalar ky);
|
||||
void preSkew(SkScalar kx, SkScalar ky);
|
||||
/** Preconcats the matrix with the specified matrix.
|
||||
M' = M * other
|
||||
*/
|
||||
bool preConcat(const SkMatrix& other);
|
||||
void preConcat(const SkMatrix& other);
|
||||
|
||||
/** Postconcats the matrix with the specified translation.
|
||||
M' = T(dx, dy) * M
|
||||
*/
|
||||
bool postTranslate(SkScalar dx, SkScalar dy);
|
||||
void postTranslate(SkScalar dx, SkScalar dy);
|
||||
/** Postconcats the matrix with the specified scale.
|
||||
M' = S(sx, sy, px, py) * M
|
||||
*/
|
||||
bool postScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py);
|
||||
void postScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py);
|
||||
/** Postconcats the matrix with the specified scale.
|
||||
M' = S(sx, sy) * M
|
||||
*/
|
||||
bool postScale(SkScalar sx, SkScalar sy);
|
||||
void postScale(SkScalar sx, SkScalar sy);
|
||||
/** Postconcats the matrix by dividing it by the specified integers.
|
||||
M' = S(1/divx, 1/divy, 0, 0) * M
|
||||
*/
|
||||
|
@ -276,23 +276,23 @@ public:
|
|||
/** Postconcats the matrix with the specified rotation.
|
||||
M' = R(degrees, px, py) * M
|
||||
*/
|
||||
bool postRotate(SkScalar degrees, SkScalar px, SkScalar py);
|
||||
void postRotate(SkScalar degrees, SkScalar px, SkScalar py);
|
||||
/** Postconcats the matrix with the specified rotation.
|
||||
M' = R(degrees) * M
|
||||
*/
|
||||
bool postRotate(SkScalar degrees);
|
||||
void postRotate(SkScalar degrees);
|
||||
/** Postconcats the matrix with the specified skew.
|
||||
M' = K(kx, ky, px, py) * M
|
||||
*/
|
||||
bool postSkew(SkScalar kx, SkScalar ky, SkScalar px, SkScalar py);
|
||||
void postSkew(SkScalar kx, SkScalar ky, SkScalar px, SkScalar py);
|
||||
/** Postconcats the matrix with the specified skew.
|
||||
M' = K(kx, ky) * M
|
||||
*/
|
||||
bool postSkew(SkScalar kx, SkScalar ky);
|
||||
void postSkew(SkScalar kx, SkScalar ky);
|
||||
/** Postconcats the matrix with the specified matrix.
|
||||
M' = other * M
|
||||
*/
|
||||
bool postConcat(const SkMatrix& other);
|
||||
void postConcat(const SkMatrix& other);
|
||||
|
||||
enum ScaleToFit {
|
||||
/**
|
||||
|
|
|
@ -1275,65 +1275,60 @@ void SkCanvas::didTranslate(SkScalar, SkScalar) {
|
|||
// Do nothing. Subclasses may do something.
|
||||
}
|
||||
|
||||
bool SkCanvas::translate(SkScalar dx, SkScalar dy) {
|
||||
void SkCanvas::translate(SkScalar dx, SkScalar dy) {
|
||||
fDeviceCMDirty = true;
|
||||
fCachedLocalClipBoundsDirty = true;
|
||||
bool res = fMCRec->fMatrix->preTranslate(dx, dy);
|
||||
fMCRec->fMatrix->preTranslate(dx, dy);
|
||||
|
||||
this->didTranslate(dx, dy);
|
||||
return res;
|
||||
}
|
||||
|
||||
void SkCanvas::didScale(SkScalar, SkScalar) {
|
||||
// Do nothing. Subclasses may do something.
|
||||
}
|
||||
|
||||
bool SkCanvas::scale(SkScalar sx, SkScalar sy) {
|
||||
void SkCanvas::scale(SkScalar sx, SkScalar sy) {
|
||||
fDeviceCMDirty = true;
|
||||
fCachedLocalClipBoundsDirty = true;
|
||||
bool res = fMCRec->fMatrix->preScale(sx, sy);
|
||||
fMCRec->fMatrix->preScale(sx, sy);
|
||||
|
||||
this->didScale(sx, sy);
|
||||
return res;
|
||||
}
|
||||
|
||||
void SkCanvas::didRotate(SkScalar) {
|
||||
// Do nothing. Subclasses may do something.
|
||||
}
|
||||
|
||||
bool SkCanvas::rotate(SkScalar degrees) {
|
||||
void SkCanvas::rotate(SkScalar degrees) {
|
||||
fDeviceCMDirty = true;
|
||||
fCachedLocalClipBoundsDirty = true;
|
||||
bool res = fMCRec->fMatrix->preRotate(degrees);
|
||||
fMCRec->fMatrix->preRotate(degrees);
|
||||
|
||||
this->didRotate(degrees);
|
||||
return res;
|
||||
}
|
||||
|
||||
void SkCanvas::didSkew(SkScalar, SkScalar) {
|
||||
// Do nothing. Subclasses may do something.
|
||||
}
|
||||
|
||||
bool SkCanvas::skew(SkScalar sx, SkScalar sy) {
|
||||
void SkCanvas::skew(SkScalar sx, SkScalar sy) {
|
||||
fDeviceCMDirty = true;
|
||||
fCachedLocalClipBoundsDirty = true;
|
||||
bool res = fMCRec->fMatrix->preSkew(sx, sy);
|
||||
fMCRec->fMatrix->preSkew(sx, sy);
|
||||
|
||||
this->didSkew(sx, sy);
|
||||
return res;
|
||||
}
|
||||
|
||||
void SkCanvas::didConcat(const SkMatrix&) {
|
||||
// Do nothing. Subclasses may do something.
|
||||
}
|
||||
|
||||
bool SkCanvas::concat(const SkMatrix& matrix) {
|
||||
void SkCanvas::concat(const SkMatrix& matrix) {
|
||||
fDeviceCMDirty = true;
|
||||
fCachedLocalClipBoundsDirty = true;
|
||||
bool res = fMCRec->fMatrix->preConcat(matrix);
|
||||
fMCRec->fMatrix->preConcat(matrix);
|
||||
|
||||
this->didConcat(matrix);
|
||||
return res;
|
||||
}
|
||||
|
||||
void SkCanvas::didSetMatrix(const SkMatrix&) {
|
||||
|
|
|
@ -1056,10 +1056,7 @@ void SkDraw::drawPath(const SkPath& origSrcPath, const SkPaint& origPaint,
|
|||
pathPtr->transform(*prePathMatrix, result);
|
||||
pathPtr = result;
|
||||
} else {
|
||||
if (!tmpMatrix.setConcat(*matrix, *prePathMatrix)) {
|
||||
// overflow
|
||||
return;
|
||||
}
|
||||
tmpMatrix.setConcat(*matrix, *prePathMatrix);
|
||||
matrix = &tmpMatrix;
|
||||
}
|
||||
}
|
||||
|
@ -1279,9 +1276,7 @@ void SkDraw::drawBitmap(const SkBitmap& bitmap, const SkMatrix& prematrix,
|
|||
paint.setStyle(SkPaint::kFill_Style);
|
||||
|
||||
SkMatrix matrix;
|
||||
if (!matrix.setConcat(*fMatrix, prematrix)) {
|
||||
return;
|
||||
}
|
||||
matrix.setConcat(*fMatrix, prematrix);
|
||||
|
||||
if (clipped_out(matrix, *fRC, bitmap.width(), bitmap.height())) {
|
||||
return;
|
||||
|
@ -2394,7 +2389,8 @@ bool SkTriColorShader::setup(const SkPoint pts[], const SkColor colors[],
|
|||
if (!m.invert(&im)) {
|
||||
return false;
|
||||
}
|
||||
return fDstToUnit.setConcat(im, this->getTotalInverse());
|
||||
fDstToUnit.setConcat(im, this->getTotalInverse());
|
||||
return true;
|
||||
}
|
||||
|
||||
#include "SkColorPriv.h"
|
||||
|
|
|
@ -247,35 +247,36 @@ void SkMatrix::setTranslate(SkScalar dx, SkScalar dy) {
|
|||
}
|
||||
}
|
||||
|
||||
bool SkMatrix::preTranslate(SkScalar dx, SkScalar dy) {
|
||||
void SkMatrix::preTranslate(SkScalar dx, SkScalar dy) {
|
||||
if (!dx && !dy) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->hasPerspective()) {
|
||||
SkMatrix m;
|
||||
m.setTranslate(dx, dy);
|
||||
return this->preConcat(m);
|
||||
}
|
||||
|
||||
if (dx || dy) {
|
||||
this->preConcat(m);
|
||||
} else {
|
||||
fMat[kMTransX] += sdot(fMat[kMScaleX], dx, fMat[kMSkewX], dy);
|
||||
fMat[kMTransY] += sdot(fMat[kMSkewY], dx, fMat[kMScaleY], dy);
|
||||
|
||||
this->setTypeMask(kUnknown_Mask | kOnlyPerspectiveValid_Mask);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SkMatrix::postTranslate(SkScalar dx, SkScalar dy) {
|
||||
void SkMatrix::postTranslate(SkScalar dx, SkScalar dy) {
|
||||
if (!dx && !dy) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->hasPerspective()) {
|
||||
SkMatrix m;
|
||||
m.setTranslate(dx, dy);
|
||||
return this->postConcat(m);
|
||||
}
|
||||
|
||||
if (dx || dy) {
|
||||
this->postConcat(m);
|
||||
} else {
|
||||
fMat[kMTransX] += dx;
|
||||
fMat[kMTransY] += dy;
|
||||
this->setTypeMask(kUnknown_Mask | kOnlyPerspectiveValid_Mask);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -321,15 +322,19 @@ bool SkMatrix::setIDiv(int divx, int divy) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool SkMatrix::preScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py) {
|
||||
void SkMatrix::preScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py) {
|
||||
if (1 == sx && 1 == sy) {
|
||||
return;
|
||||
}
|
||||
|
||||
SkMatrix m;
|
||||
m.setScale(sx, sy, px, py);
|
||||
return this->preConcat(m);
|
||||
this->preConcat(m);
|
||||
}
|
||||
|
||||
bool SkMatrix::preScale(SkScalar sx, SkScalar sy) {
|
||||
void SkMatrix::preScale(SkScalar sx, SkScalar sy) {
|
||||
if (1 == sx && 1 == sy) {
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
// the assumption is that these multiplies are very cheap, and that
|
||||
|
@ -346,25 +351,24 @@ bool SkMatrix::preScale(SkScalar sx, SkScalar sy) {
|
|||
fMat[kMPersp1] *= sy;
|
||||
|
||||
this->orTypeMask(kScale_Mask);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SkMatrix::postScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py) {
|
||||
void SkMatrix::postScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py) {
|
||||
if (1 == sx && 1 == sy) {
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
SkMatrix m;
|
||||
m.setScale(sx, sy, px, py);
|
||||
return this->postConcat(m);
|
||||
this->postConcat(m);
|
||||
}
|
||||
|
||||
bool SkMatrix::postScale(SkScalar sx, SkScalar sy) {
|
||||
void SkMatrix::postScale(SkScalar sx, SkScalar sy) {
|
||||
if (1 == sx && 1 == sy) {
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
SkMatrix m;
|
||||
m.setScale(sx, sy);
|
||||
return this->postConcat(m);
|
||||
this->postConcat(m);
|
||||
}
|
||||
|
||||
// this guy perhaps can go away, if we have a fract/high-precision way to
|
||||
|
@ -436,28 +440,28 @@ void SkMatrix::setRotate(SkScalar degrees) {
|
|||
this->setSinCos(sinV, cosV);
|
||||
}
|
||||
|
||||
bool SkMatrix::preRotate(SkScalar degrees, SkScalar px, SkScalar py) {
|
||||
void SkMatrix::preRotate(SkScalar degrees, SkScalar px, SkScalar py) {
|
||||
SkMatrix m;
|
||||
m.setRotate(degrees, px, py);
|
||||
return this->preConcat(m);
|
||||
this->preConcat(m);
|
||||
}
|
||||
|
||||
bool SkMatrix::preRotate(SkScalar degrees) {
|
||||
void SkMatrix::preRotate(SkScalar degrees) {
|
||||
SkMatrix m;
|
||||
m.setRotate(degrees);
|
||||
return this->preConcat(m);
|
||||
this->preConcat(m);
|
||||
}
|
||||
|
||||
bool SkMatrix::postRotate(SkScalar degrees, SkScalar px, SkScalar py) {
|
||||
void SkMatrix::postRotate(SkScalar degrees, SkScalar px, SkScalar py) {
|
||||
SkMatrix m;
|
||||
m.setRotate(degrees, px, py);
|
||||
return this->postConcat(m);
|
||||
this->postConcat(m);
|
||||
}
|
||||
|
||||
bool SkMatrix::postRotate(SkScalar degrees) {
|
||||
void SkMatrix::postRotate(SkScalar degrees) {
|
||||
SkMatrix m;
|
||||
m.setRotate(degrees);
|
||||
return this->postConcat(m);
|
||||
this->postConcat(m);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -492,28 +496,28 @@ void SkMatrix::setSkew(SkScalar sx, SkScalar sy) {
|
|||
this->setTypeMask(kUnknown_Mask | kOnlyPerspectiveValid_Mask);
|
||||
}
|
||||
|
||||
bool SkMatrix::preSkew(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py) {
|
||||
void SkMatrix::preSkew(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py) {
|
||||
SkMatrix m;
|
||||
m.setSkew(sx, sy, px, py);
|
||||
return this->preConcat(m);
|
||||
this->preConcat(m);
|
||||
}
|
||||
|
||||
bool SkMatrix::preSkew(SkScalar sx, SkScalar sy) {
|
||||
void SkMatrix::preSkew(SkScalar sx, SkScalar sy) {
|
||||
SkMatrix m;
|
||||
m.setSkew(sx, sy);
|
||||
return this->preConcat(m);
|
||||
this->preConcat(m);
|
||||
}
|
||||
|
||||
bool SkMatrix::postSkew(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py) {
|
||||
void SkMatrix::postSkew(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py) {
|
||||
SkMatrix m;
|
||||
m.setSkew(sx, sy, px, py);
|
||||
return this->postConcat(m);
|
||||
this->postConcat(m);
|
||||
}
|
||||
|
||||
bool SkMatrix::postSkew(SkScalar sx, SkScalar sy) {
|
||||
void SkMatrix::postSkew(SkScalar sx, SkScalar sy) {
|
||||
SkMatrix m;
|
||||
m.setSkew(sx, sy);
|
||||
return this->postConcat(m);
|
||||
this->postConcat(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -588,21 +592,12 @@ bool SkMatrix::setRectToRect(const SkRect& src, const SkRect& dst,
|
|||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static inline int fixmuladdmul(float a, float b, float c, float d,
|
||||
float* result) {
|
||||
*result = SkDoubleToFloat((double)a * b + (double)c * d);
|
||||
return true;
|
||||
static inline float muladdmul(float a, float b, float c, float d) {
|
||||
return SkDoubleToFloat((double)a * b + (double)c * d);
|
||||
}
|
||||
|
||||
static inline bool rowcol3(const float row[], const float col[],
|
||||
float* result) {
|
||||
*result = row[0] * col[0] + row[1] * col[3] + row[2] * col[6];
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline int negifaddoverflows(float& result, float a, float b) {
|
||||
result = a + b;
|
||||
return 0;
|
||||
static inline float rowcol3(const float row[], const float col[]) {
|
||||
return row[0] * col[0] + row[1] * col[3] + row[2] * col[6];
|
||||
}
|
||||
|
||||
static void normalize_perspective(SkScalar mat[9]) {
|
||||
|
@ -612,7 +607,7 @@ static void normalize_perspective(SkScalar mat[9]) {
|
|||
}
|
||||
}
|
||||
|
||||
bool SkMatrix::setConcat(const SkMatrix& a, const SkMatrix& b) {
|
||||
void SkMatrix::setConcat(const SkMatrix& a, const SkMatrix& b) {
|
||||
TypeMask aType = a.getPerspectiveTypeMaskOnly();
|
||||
TypeMask bType = b.getPerspectiveTypeMaskOnly();
|
||||
|
||||
|
@ -624,73 +619,52 @@ bool SkMatrix::setConcat(const SkMatrix& a, const SkMatrix& b) {
|
|||
SkMatrix tmp;
|
||||
|
||||
if ((aType | bType) & kPerspective_Mask) {
|
||||
if (!rowcol3(&a.fMat[0], &b.fMat[0], &tmp.fMat[kMScaleX])) {
|
||||
return false;
|
||||
}
|
||||
if (!rowcol3(&a.fMat[0], &b.fMat[1], &tmp.fMat[kMSkewX])) {
|
||||
return false;
|
||||
}
|
||||
if (!rowcol3(&a.fMat[0], &b.fMat[2], &tmp.fMat[kMTransX])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!rowcol3(&a.fMat[3], &b.fMat[0], &tmp.fMat[kMSkewY])) {
|
||||
return false;
|
||||
}
|
||||
if (!rowcol3(&a.fMat[3], &b.fMat[1], &tmp.fMat[kMScaleY])) {
|
||||
return false;
|
||||
}
|
||||
if (!rowcol3(&a.fMat[3], &b.fMat[2], &tmp.fMat[kMTransY])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!rowcol3(&a.fMat[6], &b.fMat[0], &tmp.fMat[kMPersp0])) {
|
||||
return false;
|
||||
}
|
||||
if (!rowcol3(&a.fMat[6], &b.fMat[1], &tmp.fMat[kMPersp1])) {
|
||||
return false;
|
||||
}
|
||||
if (!rowcol3(&a.fMat[6], &b.fMat[2], &tmp.fMat[kMPersp2])) {
|
||||
return false;
|
||||
}
|
||||
tmp.fMat[kMScaleX] = rowcol3(&a.fMat[0], &b.fMat[0]);
|
||||
tmp.fMat[kMSkewX] = rowcol3(&a.fMat[0], &b.fMat[1]);
|
||||
tmp.fMat[kMTransX] = rowcol3(&a.fMat[0], &b.fMat[2]);
|
||||
tmp.fMat[kMSkewY] = rowcol3(&a.fMat[3], &b.fMat[0]);
|
||||
tmp.fMat[kMScaleY] = rowcol3(&a.fMat[3], &b.fMat[1]);
|
||||
tmp.fMat[kMTransY] = rowcol3(&a.fMat[3], &b.fMat[2]);
|
||||
tmp.fMat[kMPersp0] = rowcol3(&a.fMat[6], &b.fMat[0]);
|
||||
tmp.fMat[kMPersp1] = rowcol3(&a.fMat[6], &b.fMat[1]);
|
||||
tmp.fMat[kMPersp2] = rowcol3(&a.fMat[6], &b.fMat[2]);
|
||||
|
||||
normalize_perspective(tmp.fMat);
|
||||
tmp.setTypeMask(kUnknown_Mask);
|
||||
} else { // not perspective
|
||||
if (!fixmuladdmul(a.fMat[kMScaleX], b.fMat[kMScaleX],
|
||||
a.fMat[kMSkewX], b.fMat[kMSkewY], &tmp.fMat[kMScaleX])) {
|
||||
return false;
|
||||
}
|
||||
if (!fixmuladdmul(a.fMat[kMScaleX], b.fMat[kMSkewX],
|
||||
a.fMat[kMSkewX], b.fMat[kMScaleY], &tmp.fMat[kMSkewX])) {
|
||||
return false;
|
||||
}
|
||||
if (!fixmuladdmul(a.fMat[kMScaleX], b.fMat[kMTransX],
|
||||
a.fMat[kMSkewX], b.fMat[kMTransY], &tmp.fMat[kMTransX])) {
|
||||
return false;
|
||||
}
|
||||
if (negifaddoverflows(tmp.fMat[kMTransX], tmp.fMat[kMTransX],
|
||||
a.fMat[kMTransX]) < 0) {
|
||||
return false;
|
||||
}
|
||||
tmp.fMat[kMScaleX] = muladdmul(a.fMat[kMScaleX],
|
||||
b.fMat[kMScaleX],
|
||||
a.fMat[kMSkewX],
|
||||
b.fMat[kMSkewY]);
|
||||
|
||||
if (!fixmuladdmul(a.fMat[kMSkewY], b.fMat[kMScaleX],
|
||||
a.fMat[kMScaleY], b.fMat[kMSkewY], &tmp.fMat[kMSkewY])) {
|
||||
return false;
|
||||
}
|
||||
if (!fixmuladdmul(a.fMat[kMSkewY], b.fMat[kMSkewX],
|
||||
a.fMat[kMScaleY], b.fMat[kMScaleY], &tmp.fMat[kMScaleY])) {
|
||||
return false;
|
||||
}
|
||||
if (!fixmuladdmul(a.fMat[kMSkewY], b.fMat[kMTransX],
|
||||
a.fMat[kMScaleY], b.fMat[kMTransY], &tmp.fMat[kMTransY])) {
|
||||
return false;
|
||||
}
|
||||
if (negifaddoverflows(tmp.fMat[kMTransY], tmp.fMat[kMTransY],
|
||||
a.fMat[kMTransY]) < 0) {
|
||||
return false;
|
||||
}
|
||||
tmp.fMat[kMSkewX] = muladdmul(a.fMat[kMScaleX],
|
||||
b.fMat[kMSkewX],
|
||||
a.fMat[kMSkewX],
|
||||
b.fMat[kMScaleY]);
|
||||
|
||||
tmp.fMat[kMTransX] = muladdmul(a.fMat[kMScaleX],
|
||||
b.fMat[kMTransX],
|
||||
a.fMat[kMSkewX],
|
||||
b.fMat[kMTransY]);
|
||||
|
||||
tmp.fMat[kMTransX] += a.fMat[kMTransX];
|
||||
|
||||
tmp.fMat[kMSkewY] = muladdmul(a.fMat[kMSkewY],
|
||||
b.fMat[kMScaleX],
|
||||
a.fMat[kMScaleY],
|
||||
b.fMat[kMSkewY]);
|
||||
|
||||
tmp.fMat[kMScaleY] = muladdmul(a.fMat[kMSkewY],
|
||||
b.fMat[kMSkewX],
|
||||
a.fMat[kMScaleY],
|
||||
b.fMat[kMScaleY]);
|
||||
|
||||
tmp.fMat[kMTransY] = muladdmul(a.fMat[kMSkewY],
|
||||
b.fMat[kMTransX],
|
||||
a.fMat[kMScaleY],
|
||||
b.fMat[kMTransY]);
|
||||
|
||||
tmp.fMat[kMTransY] += a.fMat[kMTransY];
|
||||
tmp.fMat[kMPersp0] = tmp.fMat[kMPersp1] = 0;
|
||||
tmp.fMat[kMPersp2] = 1;
|
||||
//SkDebugf("Concat mat non-persp type: %d\n", tmp.getType());
|
||||
|
@ -699,19 +673,22 @@ bool SkMatrix::setConcat(const SkMatrix& a, const SkMatrix& b) {
|
|||
}
|
||||
*this = tmp;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SkMatrix::preConcat(const SkMatrix& mat) {
|
||||
void SkMatrix::preConcat(const SkMatrix& mat) {
|
||||
// check for identity first, so we don't do a needless copy of ourselves
|
||||
// to ourselves inside setConcat()
|
||||
return mat.isIdentity() || this->setConcat(*this, mat);
|
||||
if(!mat.isIdentity()) {
|
||||
this->setConcat(*this, mat);
|
||||
}
|
||||
}
|
||||
|
||||
bool SkMatrix::postConcat(const SkMatrix& mat) {
|
||||
void SkMatrix::postConcat(const SkMatrix& mat) {
|
||||
// check for identity first, so we don't do a needless copy of ourselves
|
||||
// to ourselves inside setConcat()
|
||||
return mat.isIdentity() || this->setConcat(mat, *this);
|
||||
if (!mat.isIdentity()) {
|
||||
this->setConcat(mat, *this);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1468,10 +1445,7 @@ bool SkMatrix::setPolyToPoly(const SkPoint src[], const SkPoint dst[],
|
|||
if (!proc(dst, &tempMap, scale)) {
|
||||
return false;
|
||||
}
|
||||
if (!result.setConcat(tempMap, result)) {
|
||||
return false;
|
||||
}
|
||||
*this = result;
|
||||
this->setConcat(tempMap, result);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -62,29 +62,29 @@ public:
|
|||
fMatrix.reset();
|
||||
}
|
||||
|
||||
bool preTranslate(SkScalar dx, SkScalar dy) {
|
||||
void preTranslate(SkScalar dx, SkScalar dy) {
|
||||
fMatrixID = -1;
|
||||
return fMatrix.preTranslate(dx, dy);
|
||||
fMatrix.preTranslate(dx, dy);
|
||||
}
|
||||
|
||||
bool preScale(SkScalar sx, SkScalar sy) {
|
||||
void preScale(SkScalar sx, SkScalar sy) {
|
||||
fMatrixID = -1;
|
||||
return fMatrix.preScale(sx, sy);
|
||||
fMatrix.preScale(sx, sy);
|
||||
}
|
||||
|
||||
bool preRotate(SkScalar degrees) {
|
||||
void preRotate(SkScalar degrees) {
|
||||
fMatrixID = -1;
|
||||
return fMatrix.preRotate(degrees);
|
||||
fMatrix.preRotate(degrees);
|
||||
}
|
||||
|
||||
bool preSkew(SkScalar sx, SkScalar sy) {
|
||||
void preSkew(SkScalar sx, SkScalar sy) {
|
||||
fMatrixID = -1;
|
||||
return fMatrix.preSkew(sx, sy);
|
||||
fMatrix.preSkew(sx, sy);
|
||||
}
|
||||
|
||||
bool preConcat(const SkMatrix& matrix) {
|
||||
void preConcat(const SkMatrix& matrix) {
|
||||
fMatrixID = -1;
|
||||
return fMatrix.preConcat(matrix);
|
||||
fMatrix.preConcat(matrix);
|
||||
}
|
||||
|
||||
void setMatrix(const SkMatrix& matrix) {
|
||||
|
@ -285,29 +285,29 @@ public:
|
|||
|
||||
void restore();
|
||||
|
||||
bool translate(SkScalar dx, SkScalar dy) {
|
||||
void translate(SkScalar dx, SkScalar dy) {
|
||||
this->call(kMatrix_CallType);
|
||||
return fCurMCState->fMatrixInfo->preTranslate(dx, dy);
|
||||
fCurMCState->fMatrixInfo->preTranslate(dx, dy);
|
||||
}
|
||||
|
||||
bool scale(SkScalar sx, SkScalar sy) {
|
||||
void scale(SkScalar sx, SkScalar sy) {
|
||||
this->call(kMatrix_CallType);
|
||||
return fCurMCState->fMatrixInfo->preScale(sx, sy);
|
||||
fCurMCState->fMatrixInfo->preScale(sx, sy);
|
||||
}
|
||||
|
||||
bool rotate(SkScalar degrees) {
|
||||
void rotate(SkScalar degrees) {
|
||||
this->call(kMatrix_CallType);
|
||||
return fCurMCState->fMatrixInfo->preRotate(degrees);
|
||||
fCurMCState->fMatrixInfo->preRotate(degrees);
|
||||
}
|
||||
|
||||
bool skew(SkScalar sx, SkScalar sy) {
|
||||
void skew(SkScalar sx, SkScalar sy) {
|
||||
this->call(kMatrix_CallType);
|
||||
return fCurMCState->fMatrixInfo->preSkew(sx, sy);
|
||||
fCurMCState->fMatrixInfo->preSkew(sx, sy);
|
||||
}
|
||||
|
||||
bool concat(const SkMatrix& matrix) {
|
||||
void concat(const SkMatrix& matrix) {
|
||||
this->call(kMatrix_CallType);
|
||||
return fCurMCState->fMatrixInfo->preConcat(matrix);
|
||||
fCurMCState->fMatrixInfo->preConcat(matrix);
|
||||
}
|
||||
|
||||
void setMatrix(const SkMatrix& matrix) {
|
||||
|
|
|
@ -1696,9 +1696,7 @@ void SkXPSDevice::drawPath(const SkDraw& d,
|
|||
}
|
||||
platonicPath.transform(*prePathMatrix, skeletalPath);
|
||||
} else {
|
||||
if (!matrix.preConcat(*prePathMatrix)) {
|
||||
return;
|
||||
}
|
||||
matrix.preConcat(*prePathMatrix);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -233,12 +233,7 @@ bool SkGradientShaderBase::setContext(const SkBitmap& device,
|
|||
|
||||
const SkMatrix& inverse = this->getTotalInverse();
|
||||
|
||||
if (!fDstToIndex.setConcat(fPtsToUnit, inverse)) {
|
||||
// need to keep our set/end context calls balanced.
|
||||
this->INHERITED::endContext();
|
||||
return false;
|
||||
}
|
||||
|
||||
fDstToIndex.setConcat(fPtsToUnit, inverse);
|
||||
fDstToIndexProc = fDstToIndex.getMapXYProc();
|
||||
fDstToIndexClass = (uint8_t)SkShader::ComputeMatrixClass(fDstToIndex);
|
||||
|
||||
|
|
|
@ -983,10 +983,7 @@ void SkPDFDevice::drawPath(const SkDraw& d, const SkPath& origPath,
|
|||
}
|
||||
origPath.transform(*prePathMatrix, pathPtr);
|
||||
} else {
|
||||
if (!matrix.preConcat(*prePathMatrix)) {
|
||||
// TODO(edisonn): report somehow why we failed?
|
||||
return;
|
||||
}
|
||||
matrix.preConcat(*prePathMatrix);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -312,14 +312,11 @@ TEST_STEP(NAME, NAME##TestStep )
|
|||
// Basic test steps for most virtual methods in SkCanvas that draw or affect
|
||||
// the state of the canvas.
|
||||
|
||||
SIMPLE_TEST_STEP_WITH_ASSERT(Translate,
|
||||
translate(SkIntToScalar(1), SkIntToScalar(2)));
|
||||
SIMPLE_TEST_STEP_WITH_ASSERT(Scale,
|
||||
scale(SkIntToScalar(1), SkIntToScalar(2)));
|
||||
SIMPLE_TEST_STEP_WITH_ASSERT(Rotate, rotate(SkIntToScalar(1)));
|
||||
SIMPLE_TEST_STEP_WITH_ASSERT(Skew,
|
||||
skew(SkIntToScalar(1), SkIntToScalar(2)));
|
||||
SIMPLE_TEST_STEP_WITH_ASSERT(Concat, concat(kTestMatrix));
|
||||
SIMPLE_TEST_STEP(Translate, translate(SkIntToScalar(1), SkIntToScalar(2)));
|
||||
SIMPLE_TEST_STEP(Scale, scale(SkIntToScalar(1), SkIntToScalar(2)));
|
||||
SIMPLE_TEST_STEP(Rotate, rotate(SkIntToScalar(1)));
|
||||
SIMPLE_TEST_STEP(Skew, skew(SkIntToScalar(1), SkIntToScalar(2)));
|
||||
SIMPLE_TEST_STEP(Concat, concat(kTestMatrix));
|
||||
SIMPLE_TEST_STEP(SetMatrix, setMatrix(kTestMatrix));
|
||||
SIMPLE_TEST_STEP(ClipRect, clipRect(kTestRect));
|
||||
SIMPLE_TEST_STEP(ClipPath, clipPath(kTestPath));
|
||||
|
|
Загрузка…
Ссылка в новой задаче