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
|
/*
* Copyright 2006 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.
*/
#include "SkDrawRectangle.h"
#include "SkAnimateMaker.h"
#include "SkCanvas.h"
#include "SkMatrixParts.h"
#include "SkPaint.h"
#include "SkScript.h"
enum SkRectangle_Properties {
SK_PROPERTY(height),
SK_PROPERTY(needsRedraw),
SK_PROPERTY(width)
};
#if SK_USE_CONDENSED_INFO == 0
const SkMemberInfo SkDrawRect::fInfo[] = {
SK_MEMBER_ALIAS(bottom, fRect.fBottom, Float),
SK_MEMBER_PROPERTY(height, Float),
SK_MEMBER_ALIAS(left, fRect.fLeft, Float),
SK_MEMBER_PROPERTY(needsRedraw, Boolean),
SK_MEMBER_ALIAS(right, fRect.fRight, Float),
SK_MEMBER_ALIAS(top, fRect.fTop, Float),
SK_MEMBER_PROPERTY(width, Float)
};
#endif
DEFINE_GET_MEMBER(SkDrawRect);
SkDrawRect::SkDrawRect() : fParent(NULL) {
fRect.setEmpty();
}
void SkDrawRect::dirty() {
if (fParent)
fParent->dirty();
}
bool SkDrawRect::draw(SkAnimateMaker& maker) {
SkBoundableAuto boundable(this, maker);
maker.fCanvas->drawRect(fRect, *maker.fPaint);
return false;
}
#ifdef SK_DUMP_ENABLED
void SkDrawRect::dump(SkAnimateMaker* maker) {
dumpBase(maker);
SkDebugf("left=\"%g\" top=\"%g\" right=\"%g\" bottom=\"%g\" />\n",
SkScalarToFloat(fRect.fLeft), SkScalarToFloat(fRect.fTop), SkScalarToFloat(fRect.fRight),
SkScalarToFloat(fRect.fBottom));
}
#endif
SkDisplayable* SkDrawRect::getParent() const {
return fParent;
}
bool SkDrawRect::getProperty(int index, SkScriptValue* value) const {
SkScalar result;
switch (index) {
case SK_PROPERTY(height):
result = fRect.height();
break;
case SK_PROPERTY(needsRedraw):
value->fType = SkType_Boolean;
value->fOperand.fS32 = fBounds.isEmpty() == false;
return true;
case SK_PROPERTY(width):
result = fRect.width();
break;
default:
SkASSERT(0);
return false;
}
value->fType = SkType_Float;
value->fOperand.fScalar = result;
return true;
}
bool SkDrawRect::setParent(SkDisplayable* parent) {
fParent = parent;
return false;
}
bool SkDrawRect::setProperty(int index, SkScriptValue& value) {
SkScalar scalar = value.fOperand.fScalar;
switch (index) {
case SK_PROPERTY(height):
SkASSERT(value.fType == SkType_Float);
fRect.fBottom = scalar + fRect.fTop;
return true;
case SK_PROPERTY(needsRedraw):
return false;
case SK_PROPERTY(width):
SkASSERT(value.fType == SkType_Float);
fRect.fRight = scalar + fRect.fLeft;
return true;
default:
SkASSERT(0);
}
return false;
}
#if SK_USE_CONDENSED_INFO == 0
const SkMemberInfo SkRoundRect::fInfo[] = {
SK_MEMBER_INHERITED,
SK_MEMBER(rx, Float),
SK_MEMBER(ry, Float),
};
#endif
DEFINE_GET_MEMBER(SkRoundRect);
SkRoundRect::SkRoundRect() : rx(0), ry(0) {
}
bool SkRoundRect::draw(SkAnimateMaker& maker) {
SkBoundableAuto boundable(this, maker);
maker.fCanvas->drawRoundRect(fRect, rx, ry, *maker.fPaint);
return false;
}
#ifdef SK_DUMP_ENABLED
void SkRoundRect::dump(SkAnimateMaker* maker) {
dumpBase(maker);
SkDebugf("left=\"%g\" top=\"%g\" right=\"%g\" bottom=\"%g\" rx=\"%g\" ry=\"%g\" />\n",
SkScalarToFloat(fRect.fLeft), SkScalarToFloat(fRect.fTop), SkScalarToFloat(fRect.fRight),
SkScalarToFloat(fRect.fBottom), SkScalarToFloat(rx), SkScalarToFloat(ry));
}
#endif
|