本文整理汇总了C++中SkMatrix::rectStaysRect方法的典型用法代码示例。如果您正苦于以下问题:C++ SkMatrix::rectStaysRect方法的具体用法?C++ SkMatrix::rectStaysRect怎么用?C++ SkMatrix::rectStaysRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkMatrix
的用法示例。
在下文中一共展示了SkMatrix::rectStaysRect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_matrix_recttorect
static void test_matrix_recttorect(skiatest::Reporter* reporter) {
SkRect src, dst;
SkMatrix matrix;
src.set(0, 0, SK_Scalar1*10, SK_Scalar1*10);
dst = src;
matrix.setRectToRect(src, dst, SkMatrix::kFill_ScaleToFit);
REPORTER_ASSERT(reporter, SkMatrix::kIdentity_Mask == matrix.getType());
REPORTER_ASSERT(reporter, matrix.rectStaysRect());
dst.offset(SK_Scalar1, SK_Scalar1);
matrix.setRectToRect(src, dst, SkMatrix::kFill_ScaleToFit);
REPORTER_ASSERT(reporter, SkMatrix::kTranslate_Mask == matrix.getType());
REPORTER_ASSERT(reporter, matrix.rectStaysRect());
dst.fRight += SK_Scalar1;
matrix.setRectToRect(src, dst, SkMatrix::kFill_ScaleToFit);
REPORTER_ASSERT(reporter,
(SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask) == matrix.getType());
REPORTER_ASSERT(reporter, matrix.rectStaysRect());
dst = src;
dst.fRight = src.fRight * 2;
matrix.setRectToRect(src, dst, SkMatrix::kFill_ScaleToFit);
REPORTER_ASSERT(reporter, SkMatrix::kScale_Mask == matrix.getType());
REPORTER_ASSERT(reporter, matrix.rectStaysRect());
}
示例2: shouldDrawAntiAliased
bool shouldDrawAntiAliased(const GraphicsContext* context, const SkRect& destRect)
{
if (!context->shouldAntialias())
return false;
const SkMatrix totalMatrix = context->getTotalMatrix();
// Don't disable anti-aliasing if we're rotated or skewed.
if (!totalMatrix.rectStaysRect())
return true;
// Disable anti-aliasing for scales or n*90 degree rotations.
// Allow to opt out of the optimization though for "hairline" geometry
// images - using the shouldAntialiasHairlineImages() GraphicsContext flag.
if (!context->shouldAntialiasHairlineImages())
return false;
// Check if the dimensions of the destination are "small" (less than one
// device pixel). To prevent sudden drop-outs. Since we know that
// kRectStaysRect_Mask is set, the matrix either has scale and no skew or
// vice versa. We can query the kAffine_Mask flag to determine which case
// it is.
// FIXME: This queries the CTM while drawing, which is generally
// discouraged. Always drawing with AA can negatively impact performance
// though - that's why it's not always on.
SkScalar widthExpansion, heightExpansion;
if (totalMatrix.getType() & SkMatrix::kAffine_Mask)
widthExpansion = totalMatrix[SkMatrix::kMSkewY], heightExpansion = totalMatrix[SkMatrix::kMSkewX];
else
widthExpansion = totalMatrix[SkMatrix::kMScaleX], heightExpansion = totalMatrix[SkMatrix::kMScaleY];
return destRect.width() * fabs(widthExpansion) < 1 || destRect.height() * fabs(heightExpansion) < 1;
}
示例3: memset
void Matrix4::load(const SkMatrix& v) {
memset(data, 0, sizeof(data));
data[kScaleX] = v[SkMatrix::kMScaleX];
data[kSkewX] = v[SkMatrix::kMSkewX];
data[kTranslateX] = v[SkMatrix::kMTransX];
data[kSkewY] = v[SkMatrix::kMSkewY];
data[kScaleY] = v[SkMatrix::kMScaleY];
data[kTranslateY] = v[SkMatrix::kMTransY];
data[kPerspective0] = v[SkMatrix::kMPersp0];
data[kPerspective1] = v[SkMatrix::kMPersp1];
data[kPerspective2] = v[SkMatrix::kMPersp2];
data[kScaleZ] = 1.0f;
// NOTE: The flags are compatible between SkMatrix and this class.
// However, SkMatrix::getType() does not return the flag
// kRectStaysRect. The return value is masked with 0xF
// so we need the extra rectStaysRect() check
mType = v.getType();
if (v.rectStaysRect()) {
mType |= kTypeRectToRect;
}
}
示例4: ShouldUseBicubic
bool GrBicubicEffect::ShouldUseBicubic(const SkMatrix& matrix,
GrTextureParams::FilterMode* filterMode) {
if (matrix.isIdentity()) {
*filterMode = GrTextureParams::kNone_FilterMode;
return false;
}
SkScalar scales[2];
if (!matrix.getMinMaxScales(scales) || scales[0] < SK_Scalar1) {
// Bicubic doesn't handle arbitrary minimization well, as src texels can be skipped
// entirely,
*filterMode = GrTextureParams::kMipMap_FilterMode;
return false;
}
// At this point if scales[1] == SK_Scalar1 then the matrix doesn't do any scaling.
if (scales[1] == SK_Scalar1) {
if (matrix.rectStaysRect() && SkScalarIsInt(matrix.getTranslateX()) &&
SkScalarIsInt(matrix.getTranslateY())) {
*filterMode = GrTextureParams::kNone_FilterMode;
} else {
// Use bilerp to handle rotation or fractional translation.
*filterMode = GrTextureParams::kBilerp_FilterMode;
}
return false;
}
// When we use the bicubic filtering effect each sample is read from the texture using
// nearest neighbor sampling.
*filterMode = GrTextureParams::kNone_FilterMode;
return true;
}
示例5: onDraw
void onDraw(SkCanvas* canvas) override {
static const int kOn = 4;
static const int kOff = 4;
static const int kIntervalLength = kOn + kOff;
static const SkColor gColors[kIntervalLength] = {
SK_ColorRED,
SK_ColorGREEN,
SK_ColorBLUE,
SK_ColorCYAN,
SK_ColorMAGENTA,
SK_ColorYELLOW,
SK_ColorGRAY,
SK_ColorDKGRAY
};
SkPaint paint;
paint.setStyle(SkPaint::kStroke_Style);
paint.setAntiAlias(fDoAA);
SkMatrix rot;
rot.setRotate(90);
SkASSERT(rot.rectStaysRect());
canvas->concat(rot);
int sign; // used to toggle the direction of the lines
int phase = 0;
for (int x = 0; x < 200; x += 10) {
paint.setStrokeWidth(SkIntToScalar(phase+1));
paint.setColor(gColors[phase]);
sign = (x % 20) ? 1 : -1;
drawline(canvas, kOn, kOff, paint,
SkIntToScalar(x), -sign * SkIntToScalar(10003),
SkIntToScalar(phase),
SkIntToScalar(x), sign * SkIntToScalar(10003));
phase = (phase + 1) % kIntervalLength;
}
for (int y = -400; y < 0; y += 10) {
paint.setStrokeWidth(SkIntToScalar(phase+1));
paint.setColor(gColors[phase]);
sign = (y % 20) ? 1 : -1;
drawline(canvas, kOn, kOff, paint,
-sign * SkIntToScalar(10003), SkIntToScalar(y),
SkIntToScalar(phase),
sign * SkIntToScalar(10003), SkIntToScalar(y));
phase = (phase + 1) % kIntervalLength;
}
}
示例6: can_ignore_bilerp_constraint
static bool can_ignore_bilerp_constraint(const GrTextureProducer& producer,
const SkRect& srcRect,
const SkMatrix& srcRectToDeviceSpace,
bool isMSAA) {
if (srcRectToDeviceSpace.rectStaysRect()) {
// sampling is axis-aligned
SkRect transformedRect;
srcRectToDeviceSpace.mapRect(&transformedRect, srcRect);
if (has_aligned_samples(srcRect, transformedRect) ||
!may_color_bleed(srcRect, transformedRect, srcRectToDeviceSpace, isMSAA)) {
return true;
}
}
return false;
}
示例7: FillAANestedRects
void GrAARectRenderer::FillAANestedRects(GrDrawTarget* target,
const GrPipelineBuilder& pipelineBuilder,
GrColor color,
const SkMatrix& viewMatrix,
const SkRect rects[2]) {
SkASSERT(viewMatrix.rectStaysRect());
SkASSERT(!rects[0].isEmpty() && !rects[1].isEmpty());
SkRect devOutside, devInside;
viewMatrix.mapRect(&devOutside, rects[0]);
viewMatrix.mapRect(&devInside, rects[1]);
if (devInside.isEmpty()) {
FillAARect(target, pipelineBuilder, color, viewMatrix, devOutside, devOutside);
return;
}
GeometryStrokeAARect(target, pipelineBuilder, color, viewMatrix, devOutside,
devOutside, devInside, true);
}
示例8: fillAANestedRects
void GrAARectRenderer::fillAANestedRects(GrDrawTarget* target,
GrDrawState* drawState,
GrColor color,
const SkRect rects[2],
const SkMatrix& combinedMatrix) {
SkASSERT(combinedMatrix.rectStaysRect());
SkASSERT(!rects[1].isEmpty());
SkRect devOutside, devOutsideAssist, devInside;
combinedMatrix.mapRect(&devOutside, rects[0]);
// can't call mapRect for devInside since it calls sort
combinedMatrix.mapPoints((SkPoint*)&devInside, (const SkPoint*)&rects[1], 2);
if (devInside.isEmpty()) {
this->fillAARect(target, drawState, color, devOutside, SkMatrix::I(), devOutside);
return;
}
this->geometryStrokeAARect(target, drawState, color, devOutside, devOutsideAssist, devInside,
true);
}
示例9: apply_aa_to_rect
static bool apply_aa_to_rect(GrDrawTarget* target,
GrPipelineBuilder* pipelineBuilder,
SkRect* devBoundRect,
const SkRect& rect,
SkScalar strokeWidth,
const SkMatrix& combinedMatrix,
GrColor color) {
if (pipelineBuilder->getRenderTarget()->isUnifiedMultisampled() ||
!combinedMatrix.preservesAxisAlignment()) {
return false;
}
combinedMatrix.mapRect(devBoundRect, rect);
if (!combinedMatrix.rectStaysRect()) {
return true;
}
if (strokeWidth < 0) {
return !is_irect(*devBoundRect);
}
return true;
}
示例10: apply_aa_to_rect
static bool apply_aa_to_rect(GrDrawTarget* target,
GrPipelineBuilder* pipelineBuilder,
SkRect* devBoundRect,
const SkRect& rect,
SkScalar strokeWidth,
const SkMatrix& combinedMatrix,
GrColor color) {
if (pipelineBuilder->getRenderTarget()->isUnifiedMultisampled()) {
return false;
}
#if defined(SHADER_AA_FILL_RECT) || !defined(IGNORE_ROT_AA_RECT_OPT)
if (strokeWidth >= 0) {
#endif
if (!combinedMatrix.preservesAxisAlignment()) {
return false;
}
#if defined(SHADER_AA_FILL_RECT) || !defined(IGNORE_ROT_AA_RECT_OPT)
} else {
if (!combinedMatrix.preservesRightAngles()) {
return false;
}
}
#endif
combinedMatrix.mapRect(devBoundRect, rect);
if (!combinedMatrix.rectStaysRect()) {
return true;
}
if (strokeWidth < 0) {
return !is_irect(*devBoundRect);
}
return true;
}
示例11: cull_line
// Attempt to trim the line to minimally cover the cull rect (currently
// only works for horizontal and vertical lines).
// Return true if processing should continue; false otherwise.
static bool cull_line(SkPoint* pts, const SkStrokeRec& rec,
const SkMatrix& ctm, const SkRect* cullRect,
const SkScalar intervalLength) {
if (nullptr == cullRect) {
SkASSERT(false); // Shouldn't ever occur in practice
return false;
}
SkScalar dx = pts[1].x() - pts[0].x();
SkScalar dy = pts[1].y() - pts[0].y();
if ((dx && dy) || (!dx && !dy)) {
return false;
}
SkRect bounds = *cullRect;
outset_for_stroke(&bounds, rec);
// cullRect is in device space while pts are in the local coordinate system
// defined by the ctm. We want our answer in the local coordinate system.
SkASSERT(ctm.rectStaysRect());
SkMatrix inv;
if (!ctm.invert(&inv)) {
return false;
}
inv.mapRect(&bounds);
if (dx) {
SkASSERT(dx && !dy);
SkScalar minX = pts[0].fX;
SkScalar maxX = pts[1].fX;
if (dx < 0) {
SkTSwap(minX, maxX);
}
SkASSERT(minX < maxX);
if (maxX <= bounds.fLeft || minX >= bounds.fRight) {
return false;
}
// Now we actually perform the chop, removing the excess to the left and
// right of the bounds (keeping our new line "in phase" with the dash,
// hence the (mod intervalLength).
if (minX < bounds.fLeft) {
minX = bounds.fLeft - SkScalarMod(bounds.fLeft - minX, intervalLength);
}
if (maxX > bounds.fRight) {
maxX = bounds.fRight + SkScalarMod(maxX - bounds.fRight, intervalLength);
}
SkASSERT(maxX > minX);
if (dx < 0) {
SkTSwap(minX, maxX);
}
pts[0].fX = minX;
pts[1].fX = maxX;
} else {
SkASSERT(dy && !dx);
SkScalar minY = pts[0].fY;
SkScalar maxY = pts[1].fY;
if (dy < 0) {
SkTSwap(minY, maxY);
}
SkASSERT(minY < maxY);
if (maxY <= bounds.fTop || minY >= bounds.fBottom) {
return false;
}
// Now we actually perform the chop, removing the excess to the top and
// bottom of the bounds (keeping our new line "in phase" with the dash,
// hence the (mod intervalLength).
if (minY < bounds.fTop) {
minY = bounds.fTop - SkScalarMod(bounds.fTop - minY, intervalLength);
}
if (maxY > bounds.fBottom) {
maxY = bounds.fBottom + SkScalarMod(maxY - bounds.fBottom, intervalLength);
}
SkASSERT(maxY > minY);
if (dy < 0) {
SkTSwap(minY, maxY);
}
pts[0].fY = minY;
pts[1].fY = maxY;
}
return true;
}
示例12: asPoints
// Currently asPoints is more restrictive then it needs to be. In the future
// we need to:
// allow kRound_Cap capping (could allow rotations in the matrix with this)
// allow paths to be returned
bool SkDashPathEffect::asPoints(PointData* results,
const SkPath& src,
const SkStrokeRec& rec,
const SkMatrix& matrix,
const SkRect* cullRect) const {
// width < 0 -> fill && width == 0 -> hairline so requiring width > 0 rules both out
if (fInitialDashLength < 0 || 0 >= rec.getWidth()) {
return false;
}
// TODO: this next test could be eased up. We could allow any number of
// intervals as long as all the ons match and all the offs match.
// Additionally, they do not necessarily need to be integers.
// We cannot allow arbitrary intervals since we want the returned points
// to be uniformly sized.
if (fCount != 2 ||
!SkScalarNearlyEqual(fIntervals[0], fIntervals[1]) ||
!SkScalarIsInt(fIntervals[0]) ||
!SkScalarIsInt(fIntervals[1])) {
return false;
}
SkPoint pts[2];
if (!src.isLine(pts)) {
return false;
}
// TODO: this test could be eased up to allow circles
if (SkPaint::kButt_Cap != rec.getCap()) {
return false;
}
// TODO: this test could be eased up for circles. Rotations could be allowed.
if (!matrix.rectStaysRect()) {
return false;
}
// See if the line can be limited to something plausible.
if (!cull_line(pts, rec, matrix, cullRect, fIntervalLength)) {
return false;
}
SkScalar length = SkPoint::Distance(pts[1], pts[0]);
SkVector tangent = pts[1] - pts[0];
if (tangent.isZero()) {
return false;
}
tangent.scale(SkScalarInvert(length));
// TODO: make this test for horizontal & vertical lines more robust
bool isXAxis = true;
if (SkScalarNearlyEqual(SK_Scalar1, tangent.fX) ||
SkScalarNearlyEqual(-SK_Scalar1, tangent.fX)) {
results->fSize.set(SkScalarHalf(fIntervals[0]), SkScalarHalf(rec.getWidth()));
} else if (SkScalarNearlyEqual(SK_Scalar1, tangent.fY) ||
SkScalarNearlyEqual(-SK_Scalar1, tangent.fY)) {
results->fSize.set(SkScalarHalf(rec.getWidth()), SkScalarHalf(fIntervals[0]));
isXAxis = false;
} else if (SkPaint::kRound_Cap != rec.getCap()) {
// Angled lines don't have axis-aligned boxes.
return false;
}
if (results) {
results->fFlags = 0;
SkScalar clampedInitialDashLength = SkMinScalar(length, fInitialDashLength);
if (SkPaint::kRound_Cap == rec.getCap()) {
results->fFlags |= PointData::kCircles_PointFlag;
}
results->fNumPoints = 0;
SkScalar len2 = length;
if (clampedInitialDashLength > 0 || 0 == fInitialDashIndex) {
SkASSERT(len2 >= clampedInitialDashLength);
if (0 == fInitialDashIndex) {
if (clampedInitialDashLength > 0) {
if (clampedInitialDashLength >= fIntervals[0]) {
++results->fNumPoints; // partial first dash
}
len2 -= clampedInitialDashLength;
}
len2 -= fIntervals[1]; // also skip first space
if (len2 < 0) {
len2 = 0;
}
} else {
len2 -= clampedInitialDashLength; // skip initial partial empty
}
}
int numMidPoints = SkScalarFloorToInt(len2 / fIntervalLength);
results->fNumPoints += numMidPoints;
len2 -= numMidPoints * fIntervalLength;
//.........这里部分代码省略.........
示例13: rectStaysRect
static jboolean rectStaysRect(JNIEnv* env, jobject clazz, jlong objHandle) {
SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle);
return obj->rectStaysRect() ? JNI_TRUE : JNI_FALSE;
}
示例14: TestMatrix
void TestMatrix(skiatest::Reporter* reporter) {
SkMatrix mat, inverse, iden1, iden2;
mat.reset();
mat.setTranslate(SK_Scalar1, SK_Scalar1);
mat.invert(&inverse);
iden1.setConcat(mat, inverse);
REPORTER_ASSERT(reporter, is_identity(iden1));
mat.setScale(SkIntToScalar(2), SkIntToScalar(2));
mat.invert(&inverse);
iden1.setConcat(mat, inverse);
REPORTER_ASSERT(reporter, is_identity(iden1));
test_flatten(reporter, mat);
mat.setScale(SK_Scalar1/2, SK_Scalar1/2);
mat.invert(&inverse);
iden1.setConcat(mat, inverse);
REPORTER_ASSERT(reporter, is_identity(iden1));
test_flatten(reporter, mat);
mat.setScale(SkIntToScalar(3), SkIntToScalar(5), SkIntToScalar(20), 0);
mat.postRotate(SkIntToScalar(25));
REPORTER_ASSERT(reporter, mat.invert(NULL));
mat.invert(&inverse);
iden1.setConcat(mat, inverse);
REPORTER_ASSERT(reporter, is_identity(iden1));
iden2.setConcat(inverse, mat);
REPORTER_ASSERT(reporter, is_identity(iden2));
test_flatten(reporter, mat);
test_flatten(reporter, iden2);
// rectStaysRect test
{
static const struct {
SkScalar m00, m01, m10, m11;
bool mStaysRect;
}
gRectStaysRectSamples[] = {
{ 0, 0, 0, 0, false },
{ 0, 0, 0, SK_Scalar1, false },
{ 0, 0, SK_Scalar1, 0, false },
{ 0, 0, SK_Scalar1, SK_Scalar1, false },
{ 0, SK_Scalar1, 0, 0, false },
{ 0, SK_Scalar1, 0, SK_Scalar1, false },
{ 0, SK_Scalar1, SK_Scalar1, 0, true },
{ 0, SK_Scalar1, SK_Scalar1, SK_Scalar1, false },
{ SK_Scalar1, 0, 0, 0, false },
{ SK_Scalar1, 0, 0, SK_Scalar1, true },
{ SK_Scalar1, 0, SK_Scalar1, 0, false },
{ SK_Scalar1, 0, SK_Scalar1, SK_Scalar1, false },
{ SK_Scalar1, SK_Scalar1, 0, 0, false },
{ SK_Scalar1, SK_Scalar1, 0, SK_Scalar1, false },
{ SK_Scalar1, SK_Scalar1, SK_Scalar1, 0, false },
{ SK_Scalar1, SK_Scalar1, SK_Scalar1, SK_Scalar1, false }
};
for (size_t i = 0; i < SK_ARRAY_COUNT(gRectStaysRectSamples); i++) {
SkMatrix m;
m.reset();
m.set(SkMatrix::kMScaleX, gRectStaysRectSamples[i].m00);
m.set(SkMatrix::kMSkewX, gRectStaysRectSamples[i].m01);
m.set(SkMatrix::kMSkewY, gRectStaysRectSamples[i].m10);
m.set(SkMatrix::kMScaleY, gRectStaysRectSamples[i].m11);
REPORTER_ASSERT(reporter,
m.rectStaysRect() == gRectStaysRectSamples[i].mStaysRect);
}
}
}
示例15: SkIntToScalar
DEF_TEST(Matrix, reporter) {
SkMatrix mat, inverse, iden1, iden2;
mat.reset();
mat.setTranslate(SK_Scalar1, SK_Scalar1);
REPORTER_ASSERT(reporter, mat.invert(&inverse));
iden1.setConcat(mat, inverse);
REPORTER_ASSERT(reporter, is_identity(iden1));
mat.setScale(SkIntToScalar(2), SkIntToScalar(4));
REPORTER_ASSERT(reporter, mat.invert(&inverse));
iden1.setConcat(mat, inverse);
REPORTER_ASSERT(reporter, is_identity(iden1));
test_flatten(reporter, mat);
mat.setScale(SK_Scalar1/2, SkIntToScalar(2));
REPORTER_ASSERT(reporter, mat.invert(&inverse));
iden1.setConcat(mat, inverse);
REPORTER_ASSERT(reporter, is_identity(iden1));
test_flatten(reporter, mat);
mat.setScale(SkIntToScalar(3), SkIntToScalar(5), SkIntToScalar(20), 0);
mat.postRotate(SkIntToScalar(25));
REPORTER_ASSERT(reporter, mat.invert(NULL));
REPORTER_ASSERT(reporter, mat.invert(&inverse));
iden1.setConcat(mat, inverse);
REPORTER_ASSERT(reporter, is_identity(iden1));
iden2.setConcat(inverse, mat);
REPORTER_ASSERT(reporter, is_identity(iden2));
test_flatten(reporter, mat);
test_flatten(reporter, iden2);
mat.setScale(0, SK_Scalar1);
REPORTER_ASSERT(reporter, !mat.invert(NULL));
REPORTER_ASSERT(reporter, !mat.invert(&inverse));
mat.setScale(SK_Scalar1, 0);
REPORTER_ASSERT(reporter, !mat.invert(NULL));
REPORTER_ASSERT(reporter, !mat.invert(&inverse));
// rectStaysRect test
{
static const struct {
SkScalar m00, m01, m10, m11;
bool mStaysRect;
}
gRectStaysRectSamples[] = {
{ 0, 0, 0, 0, false },
{ 0, 0, 0, SK_Scalar1, false },
{ 0, 0, SK_Scalar1, 0, false },
{ 0, 0, SK_Scalar1, SK_Scalar1, false },
{ 0, SK_Scalar1, 0, 0, false },
{ 0, SK_Scalar1, 0, SK_Scalar1, false },
{ 0, SK_Scalar1, SK_Scalar1, 0, true },
{ 0, SK_Scalar1, SK_Scalar1, SK_Scalar1, false },
{ SK_Scalar1, 0, 0, 0, false },
{ SK_Scalar1, 0, 0, SK_Scalar1, true },
{ SK_Scalar1, 0, SK_Scalar1, 0, false },
{ SK_Scalar1, 0, SK_Scalar1, SK_Scalar1, false },
{ SK_Scalar1, SK_Scalar1, 0, 0, false },
{ SK_Scalar1, SK_Scalar1, 0, SK_Scalar1, false },
{ SK_Scalar1, SK_Scalar1, SK_Scalar1, 0, false },
{ SK_Scalar1, SK_Scalar1, SK_Scalar1, SK_Scalar1, false }
};
for (size_t i = 0; i < SK_ARRAY_COUNT(gRectStaysRectSamples); i++) {
SkMatrix m;
m.reset();
m.set(SkMatrix::kMScaleX, gRectStaysRectSamples[i].m00);
m.set(SkMatrix::kMSkewX, gRectStaysRectSamples[i].m01);
m.set(SkMatrix::kMSkewY, gRectStaysRectSamples[i].m10);
m.set(SkMatrix::kMScaleY, gRectStaysRectSamples[i].m11);
REPORTER_ASSERT(reporter,
m.rectStaysRect() == gRectStaysRectSamples[i].mStaysRect);
}
}
mat.reset();
mat.set(SkMatrix::kMScaleX, SkIntToScalar(1));
mat.set(SkMatrix::kMSkewX, SkIntToScalar(2));
mat.set(SkMatrix::kMTransX, SkIntToScalar(3));
mat.set(SkMatrix::kMSkewY, SkIntToScalar(4));
mat.set(SkMatrix::kMScaleY, SkIntToScalar(5));
mat.set(SkMatrix::kMTransY, SkIntToScalar(6));
SkScalar affine[6];
REPORTER_ASSERT(reporter, mat.asAffine(affine));
#define affineEqual(e) affine[SkMatrix::kA##e] == mat.get(SkMatrix::kM##e)
REPORTER_ASSERT(reporter, affineEqual(ScaleX));
REPORTER_ASSERT(reporter, affineEqual(SkewY));
REPORTER_ASSERT(reporter, affineEqual(SkewX));
REPORTER_ASSERT(reporter, affineEqual(ScaleY));
REPORTER_ASSERT(reporter, affineEqual(TransX));
REPORTER_ASSERT(reporter, affineEqual(TransY));
#undef affineEqual
mat.set(SkMatrix::kMPersp1, SkScalarToPersp(SK_Scalar1 / 2));
REPORTER_ASSERT(reporter, !mat.asAffine(affine));
SkMatrix mat2;
//.........这里部分代码省略.........