1ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com
2ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com/*
3ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Copyright 2006 The Android Open Source Project
4ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com *
5ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Use of this source code is governed by a BSD-style license that can be
6ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * found in the LICENSE file.
7ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com */
8ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com
98a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkDrawText.h"
118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkAnimateMaker.h"
128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkCanvas.h"
138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkPaint.h"
148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comenum SkText_Properties {
168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SK_PROPERTY(length)
178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com};
188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#if SK_USE_CONDENSED_INFO == 0
208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comconst SkMemberInfo SkText::fInfo[] = {
228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SK_MEMBER_PROPERTY(length, Int),
238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SK_MEMBER(text, String),
248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SK_MEMBER(x, Float),
258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SK_MEMBER(y, Float)
268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com};
278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comDEFINE_GET_MEMBER(SkText);
318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comSkText::SkText() : x(0), y(0) {
338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}
348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comSkText::~SkText() {
368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}
378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.combool SkText::draw(SkAnimateMaker& maker) {
398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkBoundableAuto boundable(this, maker);
408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    maker.fCanvas->drawText(text.c_str(), text.size(), x, y, *maker.fPaint);
418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    return false;
428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}
438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifdef SK_DUMP_ENABLED
458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comvoid SkText::dump(SkAnimateMaker* maker) {
468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    INHERITED::dump(maker);
478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}
488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.combool SkText::getProperty(int index, SkScriptValue* value) const {
518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkASSERT(index == SK_PROPERTY(length));
528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    value->fType = SkType_Int;
538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    value->fOperand.fS32 = (int32_t) text.size();
548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    return true;
558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}
56