| 1 |
// Copyright 2020 Google LLC. |
| 2 |
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. |
| 3 |
#include "tools/fiddle/examples.h" |
| 4 |
REG_FIDDLE_ANIMATED(software_bitmap_w_perspective, 256, 256, false, 6, 5) { |
| 5 |
void draw(SkCanvas* canvas) { |
| 6 |
const float width = image->width(); |
| 7 |
const float height = image->height(); |
| 8 |
|
| 9 |
const SkPoint src[] = {{ 0, 0}, {width, 0}, {width * (float)frame, height * (float)frame}, { 0, height}}; |
| 10 |
const SkPoint dst[] = { {0, 0}, {width, 0}, {width, height}, {0, height} }; |
| 11 |
|
| 12 |
const SkMatrix matrix = SkMatrix::PolyToPoly(src, dst).value_or(SkMatrix::I()); |
| 13 |
|
| 14 |
SkAutoCanvasRestore acr(canvas, true); |
| 15 |
canvas->concat(matrix); |
| 16 |
canvas->drawImage(image, 0, 0); |
| 17 |
} |
| 18 |
} // END FIDDLE |