1cb93a386Sopenharmony_ci// Copyright 2019 Google LLC. 2cb93a386Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. 3cb93a386Sopenharmony_ci#include "tools/fiddle/examples.h" 4cb93a386Sopenharmony_ci// HASH=0e03cd9f154603ed4b21ca56d69dae44 5cb93a386Sopenharmony_ciREG_FIDDLE(Matrix_invert, 256, 128, false, 0) { 6cb93a386Sopenharmony_civoid draw(SkCanvas* canvas) { 7cb93a386Sopenharmony_ci const SkPoint src[] = { { 10, 120}, {120, 120}, {120, 10}, { 10, 10} }; 8cb93a386Sopenharmony_ci const SkPoint dst[] = { {150, 120}, {200, 100}, {240, 30}, { 130, 40} }; 9cb93a386Sopenharmony_ci SkPaint paint; 10cb93a386Sopenharmony_ci paint.setAntiAlias(true); 11cb93a386Sopenharmony_ci SkMatrix matrix; 12cb93a386Sopenharmony_ci matrix.setPolyToPoly(src, dst, 4); 13cb93a386Sopenharmony_ci canvas->drawPoints(SkCanvas::kPolygon_PointMode, 4, src, paint); 14cb93a386Sopenharmony_ci canvas->drawPoints(SkCanvas::kPolygon_PointMode, 4, dst, paint); 15cb93a386Sopenharmony_ci paint.setColor(SK_ColorBLUE); 16cb93a386Sopenharmony_ci paint.setStrokeWidth(3); 17cb93a386Sopenharmony_ci paint.setStrokeCap(SkPaint::kRound_Cap); 18cb93a386Sopenharmony_ci canvas->drawPoints(SkCanvas::kPoints_PointMode, 4, dst, paint); 19cb93a386Sopenharmony_ci if (matrix.invert(&matrix)) { 20cb93a386Sopenharmony_ci canvas->concat(matrix); 21cb93a386Sopenharmony_ci canvas->drawPoints(SkCanvas::kPoints_PointMode, 4, dst, paint); 22cb93a386Sopenharmony_ci } 23cb93a386Sopenharmony_ci} 24cb93a386Sopenharmony_ci} // END FIDDLE 25