diff options
author | mtklein <mtklein@chromium.org> | 2015-07-07 09:43:28 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-07-07 09:43:28 -0700 |
commit | d2baa9093876357c8fbf4bc74d10d68b4c026c6f (patch) | |
tree | 1fdcef82745f3993d32f8e93c2d8d58132c1551c /gm/drawable.cpp | |
parent | 1c8a587120fd33854974457cf2a795ead98183a9 (diff) |
Make sp- via support SkDrawables; add a GM to test it.
BUG=skia:
Review URL: https://codereview.chromium.org/1212363005
Diffstat (limited to 'gm/drawable.cpp')
-rw-r--r-- | gm/drawable.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/gm/drawable.cpp b/gm/drawable.cpp new file mode 100644 index 0000000000..375ce73cbe --- /dev/null +++ b/gm/drawable.cpp @@ -0,0 +1,35 @@ +/* + * 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" + +struct MyDrawable : public SkDrawable { + SkRect onGetBounds() override { + return SkRect::MakeWH(640, 480); + } + + 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); + } +}; + +DEF_SIMPLE_GM(Drawables, canvas, 640, 480) { + SkAutoTUnref<SkDrawable> d(new MyDrawable); + canvas->drawDrawable(d); +} |