Add fixes & test for isConfigTexturable and isConfigRenderable
[platform/upstream/libSkiaSharp.git] / gm / drawable.cpp
1 /*
2  * Copyright 2015 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7
8 #include "gm.h"
9 #include "SkCanvas.h"
10 #include "SkDrawable.h"
11 #include "SkPath.h"
12
13 struct MyDrawable : public SkDrawable {
14     SkRect onGetBounds() override { return SkRect::MakeWH(50, 100);  }
15
16     void onDraw(SkCanvas* canvas) override {
17        SkPath path;
18        path.moveTo(10, 10);
19        path.conicTo(10, 90, 50, 90, 0.9f);
20
21        SkPaint paint;
22        paint.setColor(SK_ColorBLUE);
23        canvas->drawRect(path.getBounds(), paint);
24
25        paint.setAntiAlias(true);
26        paint.setColor(SK_ColorWHITE);
27        canvas->drawPath(path, paint);
28     }
29 };
30
31 /*
32  *  Test calling drawables w/ translate and matrices
33  */
34 DEF_SIMPLE_GM(drawable, canvas, 180, 275) {
35     sk_sp<SkDrawable> drawable(new MyDrawable);
36
37     canvas->translate(10, 10);
38     canvas->drawDrawable(drawable.get());
39     canvas->drawDrawable(drawable.get(), 0, 150);
40
41     SkMatrix m = SkMatrix::MakeScale(1.5f, 0.8f);
42     m.postTranslate(70, 0);
43     canvas->drawDrawable(drawable.get(), &m);
44
45     m.postTranslate(0, 150);
46     canvas->drawDrawable(drawable.get(), &m);
47 }