skia2/gm/drawable.cpp
Hal Canary cefc43112c gm: s/SkAutoTUnref/sk_sp/
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4434

Change-Id: Ib2bea321617a17012190b33f2c7c439a5b6b3025
Reviewed-on: https://skia-review.googlesource.com/4434
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
2016-11-07 15:22:49 +00:00

48 lines
1.2 KiB
C++

/*
* 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"
#include "SkPath.h"
struct MyDrawable : public SkDrawable {
SkRect onGetBounds() override { return SkRect::MakeWH(50, 100); }
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);
}
};
/*
* Test calling drawables w/ translate and matrices
*/
DEF_SIMPLE_GM(drawable, canvas, 180, 275) {
sk_sp<SkDrawable> drawable(new MyDrawable);
canvas->translate(10, 10);
canvas->drawDrawable(drawable.get());
canvas->drawDrawable(drawable.get(), 0, 150);
SkMatrix m = SkMatrix::MakeScale(1.5f, 0.8f);
m.postTranslate(70, 0);
canvas->drawDrawable(drawable.get(), &m);
m.postTranslate(0, 150);
canvas->drawDrawable(drawable.get(), &m);
}