180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/* 380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Copyright 2006 The Android Open Source Project 480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * 580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Use of this source code is governed by a BSD-style license that can be 680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * found in the LICENSE file. 780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */ 880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 1080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkDrawText.h" 1180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkAnimateMaker.h" 1280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkCanvas.h" 1380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkPaint.h" 1480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 1580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruenum SkText_Properties { 1680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SK_PROPERTY(length) 1780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru}; 1880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 1980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#if SK_USE_CONDENSED_INFO == 0 2080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 2180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruconst SkMemberInfo SkText::fInfo[] = { 2280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SK_MEMBER_PROPERTY(length, Int), 2380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SK_MEMBER(text, String), 2480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SK_MEMBER(x, Float), 2580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SK_MEMBER(y, Float) 2680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru}; 2780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 2880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 2980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 3080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste QueruDEFINE_GET_MEMBER(SkText); 3180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 3280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste QueruSkText::SkText() : x(0), y(0) { 3380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru} 3480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 3580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste QueruSkText::~SkText() { 3680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru} 3780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 3880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querubool SkText::draw(SkAnimateMaker& maker) { 3980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkBoundableAuto boundable(this, maker); 4080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru maker.fCanvas->drawText(text.c_str(), text.size(), x, y, *maker.fPaint); 4180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru return false; 4280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru} 4380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 4480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifdef SK_DUMP_ENABLED 4580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruvoid SkText::dump(SkAnimateMaker* maker) { 4680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru INHERITED::dump(maker); 4780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru} 4880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 4980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 5080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querubool SkText::getProperty(int index, SkScriptValue* value) const { 5180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkASSERT(index == SK_PROPERTY(length)); 5280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru value->fType = SkType_Int; 5380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru value->fOperand.fS32 = (int32_t) text.size(); 5480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru return true; 5580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru} 56