blob: dcc3a7537773000de3e3090b974b0fbf4db15267 [file] [log] [blame]
reed@android.com8a1c16f2008-12-17 15:59:43 +00001/* libs/graphics/animator/SkDrawText.cpp
2**
3** Copyright 2006, The Android Open Source Project
4**
5** Licensed under the Apache License, Version 2.0 (the "License");
6** you may not use this file except in compliance with the License.
7** You may obtain a copy of the License at
8**
9** http://www.apache.org/licenses/LICENSE-2.0
10**
11** Unless required by applicable law or agreed to in writing, software
12** distributed under the License is distributed on an "AS IS" BASIS,
13** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14** See the License for the specific language governing permissions and
15** limitations under the License.
16*/
17
18#include "SkDrawText.h"
19#include "SkAnimateMaker.h"
20#include "SkCanvas.h"
21#include "SkPaint.h"
22
23enum SkText_Properties {
24 SK_PROPERTY(length)
25};
26
27#if SK_USE_CONDENSED_INFO == 0
28
29const SkMemberInfo SkText::fInfo[] = {
30 SK_MEMBER_PROPERTY(length, Int),
31 SK_MEMBER(text, String),
32 SK_MEMBER(x, Float),
33 SK_MEMBER(y, Float)
34};
35
36#endif
37
38DEFINE_GET_MEMBER(SkText);
39
40SkText::SkText() : x(0), y(0) {
41}
42
43SkText::~SkText() {
44}
45
46bool SkText::draw(SkAnimateMaker& maker) {
47 SkBoundableAuto boundable(this, maker);
48 maker.fCanvas->drawText(text.c_str(), text.size(), x, y, *maker.fPaint);
49 return false;
50}
51
52#ifdef SK_DUMP_ENABLED
53void SkText::dump(SkAnimateMaker* maker) {
54 INHERITED::dump(maker);
55}
56#endif
57
58bool SkText::getProperty(int index, SkScriptValue* value) const {
59 SkASSERT(index == SK_PROPERTY(length));
60 value->fType = SkType_Int;
61 value->fOperand.fS32 = (int32_t) text.size();
62 return true;
63}
64