• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* 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 
23 enum SkText_Properties {
24     SK_PROPERTY(length)
25 };
26 
27 #if SK_USE_CONDENSED_INFO == 0
28 
29 const 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 
38 DEFINE_GET_MEMBER(SkText);
39 
SkText()40 SkText::SkText() : x(0), y(0) {
41 }
42 
~SkText()43 SkText::~SkText() {
44 }
45 
draw(SkAnimateMaker & maker)46 bool 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
dump(SkAnimateMaker * maker)53 void SkText::dump(SkAnimateMaker* maker) {
54     INHERITED::dump(maker);
55 }
56 #endif
57 
getProperty(int index,SkScriptValue * value) const58 bool 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 
65