本文整理汇总了C++中SkMatrix::postRotate方法的典型用法代码示例。如果您正苦于以下问题:C++ SkMatrix::postRotate方法的具体用法?C++ SkMatrix::postRotate怎么用?C++ SkMatrix::postRotate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkMatrix
的用法示例。
在下文中一共展示了SkMatrix::postRotate方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NativePostRotate
void Matrix::NativePostRotate(
/* [in] */ Int64 nObj,
/* [in] */ Float degrees)
{
SkMatrix* obj = reinterpret_cast<SkMatrix*>(nObj);
obj->postRotate(degrees);
}
示例2: draw_anchor
void anchor_handle_renderer::draw_anchor (SkCanvas &canvas, const SkRect &rect, SkPaint &paint) const
{
switch (m_node_type)
{
case handle_type::DIAMOND:
{
canvas.save ();
canvas.translate (rect.centerX (), rect.centerY ());
canvas.rotate (45);
SkRect moved_rect = rect;
moved_rect.offset (-rect.centerX (), -rect.centerY ());
paint.setAntiAlias (true);
canvas.drawRect (moved_rect, paint);
canvas.restore ();
break;
}
case handle_type::SQUARE:
canvas.drawRect (rect, paint);
break;
case handle_type::CIRCLE:
canvas.drawOval (rect, paint);
break;
case handle_type::DOUBLE_HEADED_ARROW:
case handle_type::ROTATE_ARROW:
SkPath path = qt2skia::path (*m_paths.at (m_node_type));
SkMatrix trans;
trans.setIdentity ();
trans.postRotate (m_rotation_angle, 32, 32); // TODO: change all these to use info from path_storage (bounding box and center (possibly should be made 0))
trans.postConcat (qt2skia::matrix (geom::rect2rect (QRectF (0, 0, 64, 64), qt2skia::rect (rect))));
path.transform (trans);
paint.setAntiAlias (true);
canvas.drawPath (path, paint);
break;
}
}
示例3: pathMeasure
void OsmAnd::MapRasterizer_P::rasterizePolylineIcons(
const Context& context,
SkCanvas& canvas,
const SkPath& path,
const MapStyleEvaluationResult& evalResult)
{
bool ok;
QString pathIconName;
ok = evalResult.getStringValue(context.env->styleBuiltinValueDefs->id_OUTPUT_PATH_ICON, pathIconName);
if (!ok || pathIconName.isEmpty())
return;
float pathIconStep = 0.0f;
ok = evalResult.getFloatValue(context.env->styleBuiltinValueDefs->id_OUTPUT_PATH_ICON_STEP, pathIconStep);
if (!ok || pathIconStep <= 0.0f)
return;
std::shared_ptr<const SkBitmap> pathIcon;
ok = context.env->obtainMapIcon(pathIconName, pathIcon);
if (!ok || !pathIcon)
return;
SkMatrix mIconTransform;
mIconTransform.setIdentity();
mIconTransform.setTranslate(-0.5f * pathIcon->width(), -0.5f * pathIcon->height());
mIconTransform.postRotate(90.0f);
SkPathMeasure pathMeasure(path, false);
const auto length = pathMeasure.getLength();
auto iconOffset = 0.5f * pathIconStep;
const auto iconInstancesCount = static_cast<int>((length - iconOffset) / pathIconStep) + 1;
if (iconInstancesCount < 1)
return;
SkMatrix mIconInstanceTransform;
for (auto iconInstanceIdx = 0; iconInstanceIdx < iconInstancesCount; iconInstanceIdx++, iconOffset += pathIconStep)
{
SkMatrix mPinPoint;
ok = pathMeasure.getMatrix(iconOffset, &mPinPoint);
if (!ok)
break;
mIconInstanceTransform.setConcat(mPinPoint, mIconTransform);
canvas.save();
canvas.concat(mIconInstanceTransform);
canvas.drawBitmap(*pathIcon, 0, 0, &_defaultPaint);
canvas.restore();
}
}
示例4:
static void r9(SkLayerRasterizer* rast, SkPaint& p) {
rast->addLayer(p);
SkMatrix lattice;
lattice.setScale(SK_Scalar1, SK_Scalar1*6, 0, 0);
lattice.postRotate(SkIntToScalar(30), 0, 0);
p.setPathEffect(new Line2DPathEffect(SK_Scalar1*2, lattice))->unref();
p.setXfermodeMode(SkXfermode::kClear_Mode);
rast->addLayer(p);
p.setPathEffect(NULL);
p.setXfermode(NULL);
p.setStyle(SkPaint::kStroke_Style);
p.setStrokeWidth(SK_Scalar1);
rast->addLayer(p);
}
示例5:
static void r9(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
rastBuilder->addLayer(p);
SkMatrix lattice;
lattice.setScale(SK_Scalar1, SK_Scalar1*6, 0, 0);
lattice.postRotate(SkIntToScalar(30), 0, 0);
p.setPathEffect(SkLine2DPathEffect::Make(SK_Scalar1*2, lattice));
p.setXfermodeMode(SkXfermode::kClear_Mode);
rastBuilder->addLayer(p);
p.setPathEffect(nullptr);
p.setXfermode(nullptr);
p.setStyle(SkPaint::kStroke_Style);
p.setStrokeWidth(SK_Scalar1);
rastBuilder->addLayer(p);
}
示例6: onOnceBeforeDraw
void onOnceBeforeDraw() override {
const SkRect bounds = SkRect::MakeXYWH(100, 100, 100, 100);
SkPictureRecorder recorder;
draw_something(recorder.beginRecording(bounds), bounds);
fPicture = recorder.finishRecordingAsPicture();
// extract enough just for the oval.
const SkISize size = SkISize::Make(100, 100);
auto srgbColorSpace = SkColorSpace::MakeSRGB();
SkMatrix matrix;
matrix.setTranslate(-100, -100);
fImage0 = SkImage::MakeFromPicture(fPicture, size, &matrix, nullptr,
SkImage::BitDepth::kU8, srgbColorSpace);
matrix.postTranslate(-50, -50);
matrix.postRotate(45);
matrix.postTranslate(50, 50);
fImage1 = SkImage::MakeFromPicture(fPicture, size, &matrix, nullptr,
SkImage::BitDepth::kU8, srgbColorSpace);
}
示例7: test_matrix_homogeneous
static void test_matrix_homogeneous(skiatest::Reporter* reporter) {
SkMatrix mat;
const float kRotation0 = 15.5f;
const float kRotation1 = -50.f;
const float kScale0 = 5000.f;
const int kTripleCount = 1000;
const int kMatrixCount = 1000;
SkRandom rand;
SkScalar randTriples[3*kTripleCount];
for (int i = 0; i < 3*kTripleCount; ++i) {
randTriples[i] = rand.nextRangeF(-3000.f, 3000.f);
}
SkMatrix mats[kMatrixCount];
for (int i = 0; i < kMatrixCount; ++i) {
for (int j = 0; j < 9; ++j) {
mats[i].set(j, rand.nextRangeF(-3000.f, 3000.f));
}
}
// identity
{
mat.reset();
SkScalar dst[3*kTripleCount];
mat.mapHomogeneousPoints(dst, randTriples, kTripleCount);
REPORTER_ASSERT(reporter, scalar_array_nearly_equal_relative(randTriples, dst, kTripleCount*3));
}
// zero matrix
{
mat.setAll(0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f);
SkScalar dst[3*kTripleCount];
mat.mapHomogeneousPoints(dst, randTriples, kTripleCount);
SkScalar zeros[3] = {0.f, 0.f, 0.f};
for (int i = 0; i < kTripleCount; ++i) {
REPORTER_ASSERT(reporter, scalar_array_nearly_equal_relative(&dst[i*3], zeros, 3));
}
}
// zero point
{
SkScalar zeros[3] = {0.f, 0.f, 0.f};
for (int i = 0; i < kMatrixCount; ++i) {
SkScalar dst[3];
mats[i].mapHomogeneousPoints(dst, zeros, 1);
REPORTER_ASSERT(reporter, scalar_array_nearly_equal_relative(dst, zeros, 3));
}
}
// doesn't crash with null dst, src, count == 0
{
mats[0].mapHomogeneousPoints(NULL, NULL, 0);
}
// uniform scale of point
{
mat.setScale(kScale0, kScale0);
SkScalar dst[3];
SkScalar src[3] = {randTriples[0], randTriples[1], 1.f};
SkPoint pnt;
pnt.set(src[0], src[1]);
mat.mapHomogeneousPoints(dst, src, 1);
mat.mapPoints(&pnt, &pnt, 1);
REPORTER_ASSERT(reporter, SkScalarNearlyEqual(dst[0], pnt.fX));
REPORTER_ASSERT(reporter, SkScalarNearlyEqual(dst[1], pnt.fY));
REPORTER_ASSERT(reporter, SkScalarNearlyEqual(dst[2], SK_Scalar1));
}
// rotation of point
{
mat.setRotate(kRotation0);
SkScalar dst[3];
SkScalar src[3] = {randTriples[0], randTriples[1], 1.f};
SkPoint pnt;
pnt.set(src[0], src[1]);
mat.mapHomogeneousPoints(dst, src, 1);
mat.mapPoints(&pnt, &pnt, 1);
REPORTER_ASSERT(reporter, SkScalarNearlyEqual(dst[0], pnt.fX));
REPORTER_ASSERT(reporter, SkScalarNearlyEqual(dst[1], pnt.fY));
REPORTER_ASSERT(reporter, SkScalarNearlyEqual(dst[2], SK_Scalar1));
}
// rotation, scale, rotation of point
{
mat.setRotate(kRotation1);
mat.postScale(kScale0, kScale0);
mat.postRotate(kRotation0);
SkScalar dst[3];
SkScalar src[3] = {randTriples[0], randTriples[1], 1.f};
SkPoint pnt;
pnt.set(src[0], src[1]);
mat.mapHomogeneousPoints(dst, src, 1);
mat.mapPoints(&pnt, &pnt, 1);
REPORTER_ASSERT(reporter, SkScalarNearlyEqual(dst[0], pnt.fX));
REPORTER_ASSERT(reporter, SkScalarNearlyEqual(dst[1], pnt.fY));
REPORTER_ASSERT(reporter, SkScalarNearlyEqual(dst[2], SK_Scalar1));
}
//.........这里部分代码省略.........
示例8: test_matrix_decomposition
static void test_matrix_decomposition(skiatest::Reporter* reporter) {
SkMatrix mat;
SkPoint rotation1, scale, rotation2;
const float kRotation0 = 15.5f;
const float kRotation1 = -50.f;
const float kScale0 = 5000.f;
const float kScale1 = 0.001f;
// identity
mat.reset();
REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, &rotation1, &scale, &rotation2));
REPORTER_ASSERT(reporter, check_matrix_recomposition(mat, rotation1, scale, rotation2));
// make sure it doesn't crash if we pass in NULLs
REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, NULL, NULL, NULL));
// rotation only
mat.setRotate(kRotation0);
REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, &rotation1, &scale, &rotation2));
REPORTER_ASSERT(reporter, check_matrix_recomposition(mat, rotation1, scale, rotation2));
// uniform scale only
mat.setScale(kScale0, kScale0);
REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, &rotation1, &scale, &rotation2));
REPORTER_ASSERT(reporter, check_matrix_recomposition(mat, rotation1, scale, rotation2));
// anisotropic scale only
mat.setScale(kScale1, kScale0);
REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, &rotation1, &scale, &rotation2));
REPORTER_ASSERT(reporter, check_matrix_recomposition(mat, rotation1, scale, rotation2));
// rotation then uniform scale
mat.setRotate(kRotation1);
mat.postScale(kScale0, kScale0);
REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, &rotation1, &scale, &rotation2));
REPORTER_ASSERT(reporter, check_matrix_recomposition(mat, rotation1, scale, rotation2));
// uniform scale then rotation
mat.setScale(kScale0, kScale0);
mat.postRotate(kRotation1);
REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, &rotation1, &scale, &rotation2));
REPORTER_ASSERT(reporter, check_matrix_recomposition(mat, rotation1, scale, rotation2));
// rotation then uniform scale+reflection
mat.setRotate(kRotation0);
mat.postScale(kScale1, -kScale1);
REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, &rotation1, &scale, &rotation2));
REPORTER_ASSERT(reporter, check_matrix_recomposition(mat, rotation1, scale, rotation2));
// uniform scale+reflection, then rotate
mat.setScale(kScale0, -kScale0);
mat.postRotate(kRotation1);
REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, &rotation1, &scale, &rotation2));
REPORTER_ASSERT(reporter, check_matrix_recomposition(mat, rotation1, scale, rotation2));
// rotation then anisotropic scale
mat.setRotate(kRotation1);
mat.postScale(kScale1, kScale0);
REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, &rotation1, &scale, &rotation2));
REPORTER_ASSERT(reporter, check_matrix_recomposition(mat, rotation1, scale, rotation2));
// rotation then anisotropic scale
mat.setRotate(90);
mat.postScale(kScale1, kScale0);
REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, &rotation1, &scale, &rotation2));
REPORTER_ASSERT(reporter, check_matrix_recomposition(mat, rotation1, scale, rotation2));
// anisotropic scale then rotation
mat.setScale(kScale1, kScale0);
mat.postRotate(kRotation0);
REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, &rotation1, &scale, &rotation2));
REPORTER_ASSERT(reporter, check_matrix_recomposition(mat, rotation1, scale, rotation2));
// anisotropic scale then rotation
mat.setScale(kScale1, kScale0);
mat.postRotate(90);
REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, &rotation1, &scale, &rotation2));
REPORTER_ASSERT(reporter, check_matrix_recomposition(mat, rotation1, scale, rotation2));
// rotation, uniform scale, then different rotation
mat.setRotate(kRotation1);
mat.postScale(kScale0, kScale0);
mat.postRotate(kRotation0);
REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, &rotation1, &scale, &rotation2));
REPORTER_ASSERT(reporter, check_matrix_recomposition(mat, rotation1, scale, rotation2));
// rotation, anisotropic scale, then different rotation
mat.setRotate(kRotation0);
mat.postScale(kScale1, kScale0);
mat.postRotate(kRotation1);
REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, &rotation1, &scale, &rotation2));
REPORTER_ASSERT(reporter, check_matrix_recomposition(mat, rotation1, scale, rotation2));
// rotation, anisotropic scale + reflection, then different rotation
mat.setRotate(kRotation0);
mat.postScale(-kScale1, kScale0);
mat.postRotate(kRotation1);
REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, &rotation1, &scale, &rotation2));
REPORTER_ASSERT(reporter, check_matrix_recomposition(mat, rotation1, scale, rotation2));
//.........这里部分代码省略.........
示例9: test_matrix_is_similarity
static void test_matrix_is_similarity(skiatest::Reporter* reporter) {
SkMatrix mat;
// identity
mat.setIdentity();
REPORTER_ASSERT(reporter, mat.isSimilarity());
// translation only
mat.reset();
mat.setTranslate(SkIntToScalar(100), SkIntToScalar(100));
REPORTER_ASSERT(reporter, mat.isSimilarity());
// scale with same size
mat.reset();
mat.setScale(SkIntToScalar(15), SkIntToScalar(15));
REPORTER_ASSERT(reporter, mat.isSimilarity());
// scale with one negative
mat.reset();
mat.setScale(SkIntToScalar(-15), SkIntToScalar(15));
REPORTER_ASSERT(reporter, mat.isSimilarity());
// scale with different size
mat.reset();
mat.setScale(SkIntToScalar(15), SkIntToScalar(20));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// scale with same size at a pivot point
mat.reset();
mat.setScale(SkIntToScalar(15), SkIntToScalar(15),
SkIntToScalar(2), SkIntToScalar(2));
REPORTER_ASSERT(reporter, mat.isSimilarity());
// scale with different size at a pivot point
mat.reset();
mat.setScale(SkIntToScalar(15), SkIntToScalar(20),
SkIntToScalar(2), SkIntToScalar(2));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// skew with same size
mat.reset();
mat.setSkew(SkIntToScalar(15), SkIntToScalar(15));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// skew with different size
mat.reset();
mat.setSkew(SkIntToScalar(15), SkIntToScalar(20));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// skew with same size at a pivot point
mat.reset();
mat.setSkew(SkIntToScalar(15), SkIntToScalar(15),
SkIntToScalar(2), SkIntToScalar(2));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// skew with different size at a pivot point
mat.reset();
mat.setSkew(SkIntToScalar(15), SkIntToScalar(20),
SkIntToScalar(2), SkIntToScalar(2));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// perspective x
mat.reset();
mat.setPerspX(SkScalarToPersp(SK_Scalar1 / 2));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// perspective y
mat.reset();
mat.setPerspY(SkScalarToPersp(SK_Scalar1 / 2));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// rotate
for (int angle = 0; angle < 360; ++angle) {
mat.reset();
mat.setRotate(SkIntToScalar(angle));
REPORTER_ASSERT(reporter, mat.isSimilarity());
}
// see if there are any accumulated precision issues
mat.reset();
for (int i = 1; i < 360; i++) {
mat.postRotate(SkIntToScalar(1));
}
REPORTER_ASSERT(reporter, mat.isSimilarity());
// rotate + translate
mat.reset();
mat.setRotate(SkIntToScalar(30));
mat.postTranslate(SkIntToScalar(10), SkIntToScalar(20));
REPORTER_ASSERT(reporter, mat.isSimilarity());
// rotate + uniform scale
mat.reset();
mat.setRotate(SkIntToScalar(30));
mat.postScale(SkIntToScalar(2), SkIntToScalar(2));
REPORTER_ASSERT(reporter, mat.isSimilarity());
// rotate + non-uniform scale
mat.reset();
mat.setRotate(SkIntToScalar(30));
//.........这里部分代码省略.........
示例10: test_matrix_decomposition
static void test_matrix_decomposition(skiatest::Reporter* reporter) {
SkMatrix mat;
SkScalar rotation0, scaleX, scaleY, rotation1;
const float kRotation0 = 15.5f;
const float kRotation1 = -50.f;
const float kScale0 = 5000.f;
const float kScale1 = 0.001f;
// identity
mat.reset();
REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, &rotation0, &scaleX, &scaleY, &rotation1));
REPORTER_ASSERT(reporter, SkScalarNearlyZero(rotation0));
REPORTER_ASSERT(reporter, SkScalarNearlyEqual(scaleX, SK_Scalar1));
REPORTER_ASSERT(reporter, SkScalarNearlyEqual(scaleY, SK_Scalar1));
REPORTER_ASSERT(reporter, SkScalarNearlyZero(rotation1));
// make sure it doesn't crash if we pass in NULLs
REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, NULL, NULL, NULL, NULL));
// rotation only
mat.setRotate(kRotation0);
REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, &rotation0, &scaleX, &scaleY, &rotation1));
REPORTER_ASSERT(reporter, SkScalarNearlyEqual(rotation0, SkDegreesToRadians(kRotation0)));
REPORTER_ASSERT(reporter, SkScalarNearlyEqual(scaleX, SK_Scalar1));
REPORTER_ASSERT(reporter, SkScalarNearlyEqual(scaleY, SK_Scalar1));
REPORTER_ASSERT(reporter, SkScalarNearlyZero(rotation1));
// uniform scale only
mat.setScale(kScale0, kScale0);
REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, &rotation0, &scaleX, &scaleY, &rotation1));
REPORTER_ASSERT(reporter, SkScalarNearlyZero(rotation0));
REPORTER_ASSERT(reporter, SkScalarNearlyEqual(scaleX, kScale0));
REPORTER_ASSERT(reporter, SkScalarNearlyEqual(scaleY, kScale0));
REPORTER_ASSERT(reporter, SkScalarNearlyZero(rotation1));
// anisotropic scale only
mat.setScale(kScale1, kScale0);
REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, &rotation0, &scaleX, &scaleY, &rotation1));
REPORTER_ASSERT(reporter, SkScalarNearlyZero(rotation0));
REPORTER_ASSERT(reporter, SkScalarNearlyEqual(scaleX, kScale1));
REPORTER_ASSERT(reporter, SkScalarNearlyEqual(scaleY, kScale0));
REPORTER_ASSERT(reporter, SkScalarNearlyZero(rotation1));
// rotation then uniform scale
mat.setRotate(kRotation1);
mat.postScale(kScale0, kScale0);
REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, &rotation0, &scaleX, &scaleY, &rotation1));
REPORTER_ASSERT(reporter, SkScalarNearlyEqual(rotation0, SkDegreesToRadians(kRotation1)));
REPORTER_ASSERT(reporter, SkScalarNearlyEqual(scaleX, kScale0));
REPORTER_ASSERT(reporter, SkScalarNearlyEqual(scaleY, kScale0));
REPORTER_ASSERT(reporter, SkScalarNearlyZero(rotation1));
// uniform scale then rotation
mat.setScale(kScale0, kScale0);
mat.postRotate(kRotation1);
REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, &rotation0, &scaleX, &scaleY, &rotation1));
REPORTER_ASSERT(reporter, SkScalarNearlyEqual(rotation0, SkDegreesToRadians(kRotation1)));
REPORTER_ASSERT(reporter, SkScalarNearlyEqual(scaleX, kScale0));
REPORTER_ASSERT(reporter, SkScalarNearlyEqual(scaleY, kScale0));
REPORTER_ASSERT(reporter, SkScalarNearlyZero(rotation1));
// rotation then uniform scale+reflection
mat.setRotate(kRotation0);
mat.postScale(kScale1, -kScale1);
REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, &rotation0, &scaleX, &scaleY, &rotation1));
REPORTER_ASSERT(reporter, SkScalarNearlyEqual(rotation0, SkDegreesToRadians(kRotation0)));
REPORTER_ASSERT(reporter, SkScalarNearlyEqual(scaleX, kScale1));
REPORTER_ASSERT(reporter, SkScalarNearlyEqual(scaleY, -kScale1));
REPORTER_ASSERT(reporter, SkScalarNearlyZero(rotation1));
// uniform scale+reflection, then rotate
mat.setScale(kScale0, -kScale0);
mat.postRotate(kRotation1);
REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, &rotation0, &scaleX, &scaleY, &rotation1));
REPORTER_ASSERT(reporter, SkScalarNearlyEqual(rotation0, SkDegreesToRadians(-kRotation1)));
REPORTER_ASSERT(reporter, SkScalarNearlyEqual(scaleX, kScale0));
REPORTER_ASSERT(reporter, SkScalarNearlyEqual(scaleY, -kScale0));
REPORTER_ASSERT(reporter, SkScalarNearlyZero(rotation1));
// rotation then anisotropic scale
mat.setRotate(kRotation1);
mat.postScale(kScale1, kScale0);
REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, &rotation0, &scaleX, &scaleY, &rotation1));
REPORTER_ASSERT(reporter, SkScalarNearlyEqual(rotation0, SkDegreesToRadians(kRotation1)));
REPORTER_ASSERT(reporter, SkScalarNearlyEqual(scaleX, kScale1));
REPORTER_ASSERT(reporter, SkScalarNearlyEqual(scaleY, kScale0));
REPORTER_ASSERT(reporter, SkScalarNearlyZero(rotation1));
// anisotropic scale then rotation
mat.setScale(kScale1, kScale0);
mat.postRotate(kRotation0);
REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, &rotation0, &scaleX, &scaleY, &rotation1));
REPORTER_ASSERT(reporter, SkScalarNearlyZero(rotation0));
REPORTER_ASSERT(reporter, SkScalarNearlyEqual(scaleX, kScale1));
REPORTER_ASSERT(reporter, SkScalarNearlyEqual(scaleY, kScale0));
REPORTER_ASSERT(reporter, SkScalarNearlyEqual(rotation1, SkDegreesToRadians(kRotation0)));
// rotation, uniform scale, then different rotation
mat.setRotate(kRotation1);
mat.postScale(kScale0, kScale0);
//.........这里部分代码省略.........
示例11: test_matrix_is_similarity
static void test_matrix_is_similarity(skiatest::Reporter* reporter) {
SkMatrix mat;
// identity
mat.setIdentity();
REPORTER_ASSERT(reporter, mat.isSimilarity());
// translation only
mat.reset();
mat.setTranslate(SkIntToScalar(100), SkIntToScalar(100));
REPORTER_ASSERT(reporter, mat.isSimilarity());
// scale with same size
mat.reset();
mat.setScale(SkIntToScalar(15), SkIntToScalar(15));
REPORTER_ASSERT(reporter, mat.isSimilarity());
// scale with one negative
mat.reset();
mat.setScale(SkIntToScalar(-15), SkIntToScalar(15));
REPORTER_ASSERT(reporter, mat.isSimilarity());
// scale with different size
mat.reset();
mat.setScale(SkIntToScalar(15), SkIntToScalar(20));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// scale with same size at a pivot point
mat.reset();
mat.setScale(SkIntToScalar(15), SkIntToScalar(15),
SkIntToScalar(2), SkIntToScalar(2));
REPORTER_ASSERT(reporter, mat.isSimilarity());
// scale with different size at a pivot point
mat.reset();
mat.setScale(SkIntToScalar(15), SkIntToScalar(20),
SkIntToScalar(2), SkIntToScalar(2));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// skew with same size
mat.reset();
mat.setSkew(SkIntToScalar(15), SkIntToScalar(15));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// skew with different size
mat.reset();
mat.setSkew(SkIntToScalar(15), SkIntToScalar(20));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// skew with same size at a pivot point
mat.reset();
mat.setSkew(SkIntToScalar(15), SkIntToScalar(15),
SkIntToScalar(2), SkIntToScalar(2));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// skew with different size at a pivot point
mat.reset();
mat.setSkew(SkIntToScalar(15), SkIntToScalar(20),
SkIntToScalar(2), SkIntToScalar(2));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// perspective x
mat.reset();
mat.setPerspX(SkScalarToPersp(SK_Scalar1 / 2));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// perspective y
mat.reset();
mat.setPerspY(SkScalarToPersp(SK_Scalar1 / 2));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
#ifdef SK_SCALAR_IS_FLOAT
/* We bypass the following tests for SK_SCALAR_IS_FIXED build.
* The long discussion can be found in this issue:
* http://codereview.appspot.com/5999050/
* In short, we haven't found a perfect way to fix the precision
* issue, i.e. the way we use tolerance in isSimilarityTransformation
* is incorrect. The situation becomes worse in fixed build, so
* we disabled rotation related tests for fixed build.
*/
// rotate
for (int angle = 0; angle < 360; ++angle) {
mat.reset();
mat.setRotate(SkIntToScalar(angle));
REPORTER_ASSERT(reporter, mat.isSimilarity());
}
// see if there are any accumulated precision issues
mat.reset();
for (int i = 1; i < 360; i++) {
mat.postRotate(SkIntToScalar(1));
}
REPORTER_ASSERT(reporter, mat.isSimilarity());
// rotate + translate
mat.reset();
mat.setRotate(SkIntToScalar(30));
mat.postTranslate(SkIntToScalar(10), SkIntToScalar(20));
REPORTER_ASSERT(reporter, mat.isSimilarity());
//.........这里部分代码省略.........
示例12: test_matrix_is_similarity
static void test_matrix_is_similarity(skiatest::Reporter* reporter) {
SkMatrix mat;
// identity
mat.setIdentity();
REPORTER_ASSERT(reporter, mat.isSimilarity());
// translation only
mat.reset();
mat.setTranslate(SkIntToScalar(100), SkIntToScalar(100));
REPORTER_ASSERT(reporter, mat.isSimilarity());
// scale with same size
mat.reset();
mat.setScale(SkIntToScalar(15), SkIntToScalar(15));
REPORTER_ASSERT(reporter, mat.isSimilarity());
// scale with one negative
mat.reset();
mat.setScale(SkIntToScalar(-15), SkIntToScalar(15));
REPORTER_ASSERT(reporter, mat.isSimilarity());
// scale with different size
mat.reset();
mat.setScale(SkIntToScalar(15), SkIntToScalar(20));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// scale with same size at a pivot point
mat.reset();
mat.setScale(SkIntToScalar(15), SkIntToScalar(15),
SkIntToScalar(2), SkIntToScalar(2));
REPORTER_ASSERT(reporter, mat.isSimilarity());
// scale with different size at a pivot point
mat.reset();
mat.setScale(SkIntToScalar(15), SkIntToScalar(20),
SkIntToScalar(2), SkIntToScalar(2));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// skew with same size
mat.reset();
mat.setSkew(SkIntToScalar(15), SkIntToScalar(15));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// skew with different size
mat.reset();
mat.setSkew(SkIntToScalar(15), SkIntToScalar(20));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// skew with same size at a pivot point
mat.reset();
mat.setSkew(SkIntToScalar(15), SkIntToScalar(15),
SkIntToScalar(2), SkIntToScalar(2));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// skew with different size at a pivot point
mat.reset();
mat.setSkew(SkIntToScalar(15), SkIntToScalar(20),
SkIntToScalar(2), SkIntToScalar(2));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// perspective x
mat.reset();
mat.setPerspX(SkScalarToPersp(SK_Scalar1 / 2));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// perspective y
mat.reset();
mat.setPerspY(SkScalarToPersp(SK_Scalar1 / 2));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
// rotate
for (int angle = 0; angle < 360; ++angle) {
mat.reset();
mat.setRotate(SkIntToScalar(angle));
#ifndef SK_CPU_ARM64
REPORTER_ASSERT(reporter, mat.isSimilarity());
#else
// 64-bit ARM devices built with -O2 and -ffp-contract=fast have a loss
// of precision and require that we have a higher tolerance
REPORTER_ASSERT(reporter, mat.isSimilarity(SK_ScalarNearlyZero + 0.00010113f));
#endif
}
// see if there are any accumulated precision issues
mat.reset();
for (int i = 1; i < 360; i++) {
mat.postRotate(SkIntToScalar(1));
}
REPORTER_ASSERT(reporter, mat.isSimilarity());
// rotate + translate
mat.reset();
mat.setRotate(SkIntToScalar(30));
mat.postTranslate(SkIntToScalar(10), SkIntToScalar(20));
REPORTER_ASSERT(reporter, mat.isSimilarity());
// rotate + uniform scale
mat.reset();
mat.setRotate(SkIntToScalar(30));
//.........这里部分代码省略.........
示例13: postRotate__F
static void postRotate__F(JNIEnv* env, jobject clazz, jlong objHandle, jfloat degrees) {
SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle);
obj->postRotate(degrees);
}