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
|
/*
* Copyright 2012 The Android Open Source Project
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkMorphologyImageFilter_DEFINED
#define SkMorphologyImageFilter_DEFINED
#include "SkColor.h"
#include "SkImageFilter.h"
#include "SkSize.h"
class SK_API SkMorphologyImageFilter : public SkImageFilter {
public:
void computeFastBounds(const SkRect& src, SkRect* dst) const SK_OVERRIDE;
bool onFilterBounds(const SkIRect& src, const SkMatrix& ctm, SkIRect* dst) const SK_OVERRIDE;
/**
* All morphology procs have the same signature: src is the source buffer, dst the
* destination buffer, radius is the morphology radius, width and height are the bounds
* of the destination buffer (in pixels), and srcStride and dstStride are the
* number of pixels per row in each buffer. All buffers are 8888.
*/
typedef void (*Proc)(const SkPMColor* src, SkPMColor* dst, int radius,
int width, int height, int srcStride, int dstStride);
protected:
SkMorphologyImageFilter(int radiusX, int radiusY, SkImageFilter* input,
const CropRect* cropRect, uint32_t uniqueID);
bool filterImageGeneric(Proc procX, Proc procY,
Proxy*, const SkBitmap& src, const Context&,
SkBitmap* result, SkIPoint* offset) const;
void flatten(SkWriteBuffer&) const SK_OVERRIDE;
#if SK_SUPPORT_GPU
bool canFilterImageGPU() const SK_OVERRIDE { return true; }
bool filterImageGPUGeneric(bool dilate, Proxy* proxy, const SkBitmap& src,
const Context& ctm, SkBitmap* result,
SkIPoint* offset) const;
#endif
SkISize radius() const { return fRadius; }
private:
SkISize fRadius;
typedef SkImageFilter INHERITED;
};
class SK_API SkDilateImageFilter : public SkMorphologyImageFilter {
public:
static SkDilateImageFilter* Create(int radiusX, int radiusY,
SkImageFilter* input = NULL,
const CropRect* cropRect = NULL,
uint32_t uniqueID = 0) {
if (radiusX < 0 || radiusY < 0) {
return NULL;
}
return SkNEW_ARGS(SkDilateImageFilter, (radiusX, radiusY, input, cropRect, uniqueID));
}
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE;
#if SK_SUPPORT_GPU
virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context&,
SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE;
#endif
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDilateImageFilter)
protected:
SkDilateImageFilter(int radiusX, int radiusY, SkImageFilter* input, const CropRect* cropRect, uint32_t uniqueID)
: INHERITED(radiusX, radiusY, input, cropRect, uniqueID) {}
private:
typedef SkMorphologyImageFilter INHERITED;
};
class SK_API SkErodeImageFilter : public SkMorphologyImageFilter {
public:
static SkErodeImageFilter* Create(int radiusX, int radiusY,
SkImageFilter* input = NULL,
const CropRect* cropRect = NULL,
uint32_t uniqueID = 0) {
if (radiusX < 0 || radiusY < 0) {
return NULL;
}
return SkNEW_ARGS(SkErodeImageFilter, (radiusX, radiusY, input, cropRect, uniqueID));
}
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE;
#if SK_SUPPORT_GPU
virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context&,
SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE;
#endif
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkErodeImageFilter)
protected:
SkErodeImageFilter(int radiusX, int radiusY, SkImageFilter* input, const CropRect* cropRect, uint32_t uniqueID)
: INHERITED(radiusX, radiusY, input, cropRect, uniqueID) {}
private:
typedef SkMorphologyImageFilter INHERITED;
};
#endif
|