1 #if 0 // Disabled until updated to use current API.
2 // Copyright 2019 Google LLC.
3 // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
4 #include "tools/fiddle/examples.h"
5 // HASH=17c3070b31b700ea8f52e48af9a66b6e
6 REG_FIDDLE(Matrix_ScaleToFit, 256, 256, false, 0) {
7 void draw(SkCanvas* canvas) {
8 const char* labels[] = { "Fill", "Start", "Center", "End" };
9 SkRect rects[] = {{5, 5, 59, 59}, {5, 74, 59, 108}, {10, 123, 44, 172}, {10, 187, 54, 231}};
11 source.getBounds(&bounds);
13 paint.setAntiAlias(true);
14 for (auto fit : { SkMatrix::kFill_ScaleToFit, SkMatrix::kStart_ScaleToFit,
15 SkMatrix::kCenter_ScaleToFit, SkMatrix::kEnd_ScaleToFit } ) {
16 for (auto rect : rects ) {
17 canvas->drawRect(rect, paint);
19 if (!matrix.setRectToRect(bounds, rect, fit)) {
22 SkAutoCanvasRestore acr(canvas, true);
23 canvas->concat(matrix);
24 canvas->drawBitmap(source, 0, 0);
26 canvas->drawString(labels[fit], 10, 255, paint);
27 canvas->translate(64, 0);
31 #endif // Disabled until updated to use current API.