Flutter Engine
The Flutter Engine
Canvas_drawDrawable_2.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(Canvas_drawDrawable_2, 256, 100, false, 0) {
5struct MyDrawable : public SkDrawable {
6 SkRect onGetBounds() override { return SkRect::MakeWH(50, 100); }
7 void onDraw(SkCanvas* canvas) override {
9 path.conicTo(10, 90, 50, 90, 0.9f);
11 paint.setColor(SK_ColorBLUE);
12 canvas->drawRect(path.getBounds(), paint);
13 paint.setAntiAlias(true);
14 paint.setColor(SK_ColorWHITE);
15 canvas->drawPath(path, paint);
16 }
17};
18
19void draw(SkCanvas* canvas) {
20 sk_sp<SkDrawable> drawable(new MyDrawable);
21 canvas->drawDrawable(drawable.get(), 10, 10);
22}
23} // END FIDDLE
REG_FIDDLE(Canvas_drawDrawable_2, 256, 100, false, 0)
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void drawDrawable(SkDrawable *drawable, const SkMatrix *matrix=nullptr)
Definition: SkCanvas.cpp:2574
void drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747
Definition: SkPath.h:59
T * get() const
Definition: SkRefCnt.h:303
const Paint & paint
Definition: color_source.cc:38
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57
void onDraw(SkCanvas *canvas) override
Definition: drawable.cpp:21
SkRect onGetBounds() override
Definition: drawable.cpp:19
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609