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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
#ifndef _SkTestImageFilters_h
#define _SkTestImageFilters_h
#include "SkImageFilter.h"
#include "SkColorFilter.h"
class SkOffsetImageFilter : public SkImageFilter {
public:
SkOffsetImageFilter(SkScalar dx, SkScalar dy) {
fOffset.set(dx, dy);
}
static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) {
return SkNEW_ARGS(SkOffsetImageFilter, (buffer));
}
protected:
SkOffsetImageFilter(SkFlattenableReadBuffer& buffer);
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
SkBitmap* result, SkIPoint* loc) SK_OVERRIDE;
virtual bool onFilterBounds(const SkIRect&, const SkMatrix&, SkIRect*) SK_OVERRIDE;
// overrides from SkFlattenable
virtual void flatten(SkFlattenableWriteBuffer&) SK_OVERRIDE;
virtual Factory getFactory() SK_OVERRIDE;
private:
SkVector fOffset;
typedef SkImageFilter INHERITED;
};
class SkComposeImageFilter : public SkImageFilter {
public:
SkComposeImageFilter(SkImageFilter* outer, SkImageFilter* inner) {
fOuter = outer;
fInner = inner;
SkSafeRef(outer);
SkSafeRef(inner);
}
virtual ~SkComposeImageFilter();
static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) {
return SkNEW_ARGS(SkComposeImageFilter, (buffer));
}
protected:
SkComposeImageFilter(SkFlattenableReadBuffer& buffer);
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
SkBitmap* result, SkIPoint* loc) SK_OVERRIDE;
virtual bool onFilterBounds(const SkIRect&, const SkMatrix&, SkIRect*) SK_OVERRIDE;
// overrides from SkFlattenable
virtual void flatten(SkFlattenableWriteBuffer&) SK_OVERRIDE;
virtual Factory getFactory() SK_OVERRIDE;
private:
SkImageFilter* fOuter;
SkImageFilter* fInner;
typedef SkImageFilter INHERITED;
};
#include "SkXfermode.h"
class SkMergeImageFilter : public SkImageFilter {
public:
SkMergeImageFilter(SkImageFilter* first, SkImageFilter* second,
SkXfermode::Mode = SkXfermode::kSrcOver_Mode);
SkMergeImageFilter(SkImageFilter* const filters[], int count,
const SkXfermode::Mode modes[] = NULL);
virtual ~SkMergeImageFilter();
static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) {
return SkNEW_ARGS(SkMergeImageFilter, (buffer));
}
protected:
SkMergeImageFilter(SkFlattenableReadBuffer& buffer);
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
SkBitmap* result, SkIPoint* loc) SK_OVERRIDE;
virtual bool onFilterBounds(const SkIRect&, const SkMatrix&, SkIRect*) SK_OVERRIDE;
// overrides from SkFlattenable
virtual void flatten(SkFlattenableWriteBuffer&) SK_OVERRIDE;
virtual Factory getFactory() SK_OVERRIDE;
private:
SkImageFilter** fFilters;
uint8_t* fModes; // SkXfermode::Mode
int fCount;
// private storage, to avoid dynamically allocating storage for our copy
// of the filters and modes (unless fCount is so large we can't fit).
intptr_t fStorage[16];
void initAlloc(int count, bool hasModes);
void init(SkImageFilter* const [], int count, const SkXfermode::Mode []);
typedef SkImageFilter INHERITED;
};
class SkColorFilterImageFilter : public SkImageFilter {
public:
SkColorFilterImageFilter(SkColorFilter* cf) : fColorFilter(cf) {
SkSafeRef(cf);
}
virtual ~SkColorFilterImageFilter();
static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) {
return SkNEW_ARGS(SkColorFilterImageFilter, (buffer));
}
protected:
SkColorFilterImageFilter(SkFlattenableReadBuffer& buffer);
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
SkBitmap* result, SkIPoint* loc) SK_OVERRIDE;
// overrides from SkFlattenable
virtual void flatten(SkFlattenableWriteBuffer&) SK_OVERRIDE;
virtual Factory getFactory() SK_OVERRIDE;
private:
SkColorFilter* fColorFilter;
typedef SkImageFilter INHERITED;
};
///////////////////////////////////////////////////////////////////////////////
// Fun mode that scales down (only) and then scales back up to look pixelated
class SkDownSampleImageFilter : public SkImageFilter {
public:
SkDownSampleImageFilter(SkScalar scale) : fScale(scale) {}
static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) {
return SkNEW_ARGS(SkDownSampleImageFilter, (buffer));
}
protected:
SkDownSampleImageFilter(SkFlattenableReadBuffer& buffer);
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
SkBitmap* result, SkIPoint* loc) SK_OVERRIDE;
// overrides from SkFlattenable
virtual void flatten(SkFlattenableWriteBuffer&) SK_OVERRIDE;
virtual Factory getFactory() SK_OVERRIDE;
private:
SkScalar fScale;
typedef SkImageFilter INHERITED;
};
#endif
|