2 * Copyright 2015 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
10 #include "SkDrawable.h"
13 struct MyDrawable : public SkDrawable {
14 SkRect onGetBounds() override { return SkRect::MakeWH(50, 100); }
16 void onDraw(SkCanvas* canvas) override {
19 path.conicTo(10, 90, 50, 90, 0.9f);
22 paint.setColor(SK_ColorBLUE);
23 canvas->drawRect(path.getBounds(), paint);
25 paint.setAntiAlias(true);
26 paint.setColor(SK_ColorWHITE);
27 canvas->drawPath(path, paint);
32 * Test calling drawables w/ translate and matrices
34 DEF_SIMPLE_GM(drawable, canvas, 180, 275) {
35 sk_sp<SkDrawable> drawable(new MyDrawable);
37 canvas->translate(10, 10);
38 canvas->drawDrawable(drawable.get());
39 canvas->drawDrawable(drawable.get(), 0, 150);
41 SkMatrix m = SkMatrix::MakeScale(1.5f, 0.8f);
42 m.postTranslate(70, 0);
43 canvas->drawDrawable(drawable.get(), &m);
45 m.postTranslate(0, 150);
46 canvas->drawDrawable(drawable.get(), &m);