2015-07-07 16:43:28 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2015 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "gm.h"
|
|
|
|
#include "SkCanvas.h"
|
|
|
|
#include "SkDrawable.h"
|
2015-08-05 20:57:49 +00:00
|
|
|
#include "SkPath.h"
|
2015-07-07 16:43:28 +00:00
|
|
|
|
|
|
|
struct MyDrawable : public SkDrawable {
|
2015-07-07 17:22:31 +00:00
|
|
|
SkRect onGetBounds() override { return SkRect::MakeWH(50, 100); }
|
2015-07-07 16:43:28 +00:00
|
|
|
|
|
|
|
void onDraw(SkCanvas* canvas) override {
|
|
|
|
SkPath path;
|
|
|
|
path.moveTo(10, 10);
|
|
|
|
path.conicTo(10, 90, 50, 90, 0.9f);
|
|
|
|
|
|
|
|
SkPaint paint;
|
|
|
|
paint.setColor(SK_ColorBLUE);
|
|
|
|
canvas->drawRect(path.getBounds(), paint);
|
|
|
|
|
|
|
|
paint.setAntiAlias(true);
|
|
|
|
paint.setColor(SK_ColorWHITE);
|
|
|
|
canvas->drawPath(path, paint);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-07-07 17:22:31 +00:00
|
|
|
/*
|
|
|
|
* Test calling drawables w/ translate and matrices
|
|
|
|
*/
|
|
|
|
DEF_SIMPLE_GM(drawable, canvas, 180, 275) {
|
|
|
|
SkAutoTUnref<SkDrawable> drawable(new MyDrawable);
|
|
|
|
|
|
|
|
canvas->translate(10, 10);
|
|
|
|
canvas->drawDrawable(drawable);
|
|
|
|
canvas->drawDrawable(drawable, 0, 150);
|
|
|
|
|
|
|
|
SkMatrix m = SkMatrix::MakeScale(1.5f, 0.8f);
|
|
|
|
m.postTranslate(70, 0);
|
|
|
|
canvas->drawDrawable(drawable, &m);
|
|
|
|
|
|
|
|
m.postTranslate(0, 150);
|
|
|
|
canvas->drawDrawable(drawable, &m);
|
2015-07-07 16:43:28 +00:00
|
|
|
}
|