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
|
/*
* Copyright 2013 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkBorder_DEFINED
#define SkBorder_DEFINED
#include "SkColor.h"
#include "SkPaint.h"
#include "SkScalar.h"
#include "SkTArray.h"
// This class provides a concise means of specifying all the geometry/shading
// associated with a CSS-style box/round-rect.
class SkBorder {
public:
enum BorderStyle {
/**
*/
kNone_BorderStyle,
/**
*/
kHidden_BorderStyle,
/**
*/
kDotted_BorderStyle,
/**
*/
kDashed_BorderStyle,
/**
*/
kSolid_BorderStyle,
/**
*/
kDouble_BorderStyle,
/**
*/
kGroove_BorderStyle,
/**
*/
kRidge_BorderStyle,
/**
*/
kInset_BorderStyle,
/**
*/
kOutset_BorderStyle,
};
enum BlurStyle {
kNormal_BlurStyle, //!< fuzzy inside and outside
kInner_BlurStyle, //!< fuzzy inside, nothing outside
};
struct ShadowInfo {
SkScalar fXOffset;
SkScalar fYOffset;
SkScalar fBlurSigma;
SkColor fColor;
BlurStyle fStyle;
};
SkBorder(SkPaint& p, SkScalar width, BorderStyle style);
SkBorder(const SkPaint paints[4], const SkScalar widths[4], const BorderStyle styles[4]);
void setBackground(SkPaint* p) {
if (NULL == p) {
fBackground.reset();
fFlags &= ~kDrawBackground_Flag;
} else {
fBackground = *p;
fFlags |= kDrawBackground_Flag;
}
}
void addShadow(ShadowInfo& info) {
fShadows.push_back(info);
}
private:
enum Flags {
// One paint "fPaints[0]" is applied to all the borders
kOnePaint_Flag = 0x01,
// Use 'fBackground' to draw the background
kDrawBackground_Flag = 0x02,
};
// If kOnePaint_Flag is specified then fBorder[0] is applied to all sides.
// Otherwise the order is: left, top, right, bottom
SkPaint fPaints[4];
// Only valid if kDrawBackground_Flag is set.
SkPaint fBackground;
SkScalar fWidths[4];
BorderStyle fStyles[4];
SkTArray<ShadowInfo> fShadows;
uint32_t fFlags;
};
#endif
|