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}};
10     SkRect bounds;
11     source.getBounds(&bounds);
12     SkPaint paint;
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);
18             SkMatrix matrix;
19             if (!matrix.setRectToRect(bounds, rect, fit)) {
20                 continue;
21             }
22             SkAutoCanvasRestore acr(canvas, true);
23             canvas->concat(matrix);
24             canvas->drawBitmap(source, 0, 0);
25         }
26         canvas->drawString(labels[fit], 10, 255, paint);
27         canvas->translate(64, 0);
28     }
29 }
30 }  // END FIDDLE
31 #endif  // Disabled until updated to use current API.
32