1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
/*
* 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);
canvas->saveLayer(&bounds, NULL);
paint.setColor(0x80FF0000);
r = bounds;
r.inset(20, 0);
canvas->drawOval(r, paint);
paint.setColor(0x800000FF);
r = bounds;
r.inset(0, 20);
paint.setXfermode(mode);
canvas->drawOval(r, paint);
canvas->restore();
}
class LerpXfermodeGM : public skiagm::GM {
public:
LerpXfermodeGM() {}
protected:
virtual uint32_t onGetFlags() const SK_OVERRIDE {
return kSkipTiled_Flag;
}
virtual SkString onShortName() SK_OVERRIDE {
return SkString("lerpmode");
}
virtual SkISize onISize() SK_OVERRIDE {
return SkISize::Make(240, 120);
}
virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
show_circlelayers(canvas, NULL);
canvas->translate(150, 0);
SkAutoTUnref<SkXfermode> mode(SkLerpXfermode::Create(0.5f));
show_circlelayers(canvas, mode.get());
}
private:
typedef skiagm::GM INHERITED;
};
//////////////////////////////////////////////////////////////////////////////
DEF_GM( return SkNEW(LerpXfermodeGM); )
|