2013-05-21 21:33:11 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2013 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 "SkLerpXfermode.h"
|
|
|
|
|
|
|
|
static void show_circlelayers(SkCanvas* canvas, SkXfermode* mode) {
|
|
|
|
SkPaint paint;
|
|
|
|
paint.setAntiAlias(true);
|
|
|
|
SkRect r, bounds = { 10, 10, 110, 110 };
|
|
|
|
|
|
|
|
r = bounds;
|
|
|
|
r.fRight = bounds.centerX();
|
|
|
|
canvas->drawRect(r, paint);
|
|
|
|
|
2015-08-27 14:41:13 +00:00
|
|
|
canvas->saveLayer(&bounds, nullptr);
|
2013-05-22 07:01:13 +00:00
|
|
|
|
2013-05-21 21:33:11 +00:00
|
|
|
paint.setColor(0x80FF0000);
|
|
|
|
r = bounds;
|
|
|
|
r.inset(20, 0);
|
|
|
|
canvas->drawOval(r, paint);
|
2013-05-22 07:01:13 +00:00
|
|
|
|
2013-05-21 21:33:11 +00:00
|
|
|
paint.setColor(0x800000FF);
|
|
|
|
r = bounds;
|
|
|
|
r.inset(0, 20);
|
|
|
|
paint.setXfermode(mode);
|
|
|
|
canvas->drawOval(r, paint);
|
2013-05-22 07:01:13 +00:00
|
|
|
|
2013-05-21 21:33:11 +00:00
|
|
|
canvas->restore();
|
|
|
|
}
|
|
|
|
|
2015-09-09 15:16:41 +00:00
|
|
|
DEF_SIMPLE_GM(lerpmode, canvas, 240, 120) {
|
2015-08-27 14:41:13 +00:00
|
|
|
show_circlelayers(canvas, nullptr);
|
2013-05-21 21:33:11 +00:00
|
|
|
canvas->translate(150, 0);
|
|
|
|
SkAutoTUnref<SkXfermode> mode(SkLerpXfermode::Create(0.5f));
|
|
|
|
show_circlelayers(canvas, mode.get());
|
2015-09-09 15:16:41 +00:00
|
|
|
}
|