Flutter Engine
The Flutter Engine
AutoCanvasRestore_SkCanvas_star.cpp
Go to the documentation of this file.
1// Copyright 2019 Google LLC.
2// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
4REG_FIDDLE(AutoCanvasRestore_SkCanvas_star, 256, 128, false, 0) {
5void draw(SkCanvas* canvas) {
7 paint.setAntiAlias(true);
8 SkFont font(fontMgr->matchFamilyStyle(nullptr, {}), 64);
9 for (SkScalar sx : { -1, 1 } ) {
10 for (SkScalar sy : { -1, 1 } ) {
11 SkAutoCanvasRestore autoRestore(canvas, true);
12 SkMatrix m = SkMatrix::MakeAll(sx, 1, 96, 0, sy, 64, 0, 0, 1);
13 canvas->concat(m);
14 canvas->drawString("R", 0, 0, font, paint);
15 }
16 }
17}
18} // END FIDDLE
REG_FIDDLE(AutoCanvasRestore_SkCanvas_star, 256, 128, false, 0)
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
void concat(const SkMatrix &matrix)
Definition: SkCanvas.cpp:1318
void drawString(const char str[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
Definition: SkCanvas.h:1803
sk_sp< SkTypeface > matchFamilyStyle(const char familyName[], const SkFontStyle &) const
Definition: SkFontMgr.cpp:109
Definition: SkFont.h:35
static SkMatrix MakeAll(SkScalar scaleX, SkScalar skewX, SkScalar transX, SkScalar skewY, SkScalar scaleY, SkScalar transY, SkScalar pers0, SkScalar pers1, SkScalar pers2)
Definition: SkMatrix.h:179
const Paint & paint
Definition: color_source.cc:38
sk_sp< SkFontMgr > fontMgr
Definition: examples.cpp:32
float SkScalar
Definition: extension.cpp:12
font
Font Metadata and Metrics.