gfx/skia/trunk/src/animator/SkDrawTextBox.cpp

Thu, 15 Jan 2015 15:55:04 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:55:04 +0100
branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
permissions
-rw-r--r--

Back out 97036ab72558 which inappropriately compared turds to third parties.

michael@0 1
michael@0 2 /*
michael@0 3 * Copyright 2006 The Android Open Source Project
michael@0 4 *
michael@0 5 * Use of this source code is governed by a BSD-style license that can be
michael@0 6 * found in the LICENSE file.
michael@0 7 */
michael@0 8
michael@0 9
michael@0 10 #include "SkDrawTextBox.h"
michael@0 11 #include "SkAnimateMaker.h"
michael@0 12 #include "SkCanvas.h"
michael@0 13 #include "SkPaint.h"
michael@0 14
michael@0 15 enum SkDrawTextBox_Properties {
michael@0 16 foo = 100,
michael@0 17 SK_PROPERTY(spacingAlign),
michael@0 18 SK_PROPERTY(mode)
michael@0 19 };
michael@0 20
michael@0 21
michael@0 22 #if SK_USE_CONDENSED_INFO == 0
michael@0 23
michael@0 24 const SkMemberInfo SkDrawTextBox::fInfo[] = {
michael@0 25 SK_MEMBER_INHERITED,
michael@0 26 SK_MEMBER(mode, TextBoxMode),
michael@0 27 SK_MEMBER_ALIAS(spacingAdd, fSpacingAdd, Float),
michael@0 28 SK_MEMBER(spacingAlign, TextBoxAlign),
michael@0 29 SK_MEMBER_ALIAS(spacingMul, fSpacingMul, Float),
michael@0 30 SK_MEMBER_ALIAS(text, fText, String)
michael@0 31 };
michael@0 32
michael@0 33 #endif
michael@0 34
michael@0 35 DEFINE_GET_MEMBER(SkDrawTextBox);
michael@0 36
michael@0 37 SkDrawTextBox::SkDrawTextBox()
michael@0 38 {
michael@0 39 fSpacingMul = SK_Scalar1;
michael@0 40 fSpacingAdd = 0;
michael@0 41 spacingAlign = SkTextBox::kStart_SpacingAlign;
michael@0 42 mode = SkTextBox::kLineBreak_Mode;
michael@0 43 }
michael@0 44
michael@0 45 #ifdef SK_DUMP_ENABLED
michael@0 46 void SkDrawTextBox::dump(SkAnimateMaker* maker)
michael@0 47 {
michael@0 48 dumpBase(maker);
michael@0 49 dumpAttrs(maker);
michael@0 50 if (mode == 0)
michael@0 51 SkDebugf("mode=\"oneLine\" ");
michael@0 52 if (spacingAlign == 1)
michael@0 53 SkDebugf("spacingAlign=\"center\" ");
michael@0 54 else if (spacingAlign == 2)
michael@0 55 SkDebugf("spacingAlign=\"end\" ");
michael@0 56 SkDebugf("/>\n");
michael@0 57 }
michael@0 58 #endif
michael@0 59
michael@0 60 bool SkDrawTextBox::getProperty(int index, SkScriptValue* value) const
michael@0 61 {
michael@0 62 return this->INHERITED::getProperty(index, value);
michael@0 63 }
michael@0 64
michael@0 65 bool SkDrawTextBox::setProperty(int index, SkScriptValue& scriptValue)
michael@0 66 {
michael@0 67 return this->INHERITED::setProperty(index, scriptValue);
michael@0 68 }
michael@0 69
michael@0 70 bool SkDrawTextBox::draw(SkAnimateMaker& maker)
michael@0 71 {
michael@0 72 SkTextBox box;
michael@0 73 box.setMode((SkTextBox::Mode) mode);
michael@0 74 box.setSpacingAlign((SkTextBox::SpacingAlign) spacingAlign);
michael@0 75 box.setBox(fRect);
michael@0 76 box.setSpacing(fSpacingMul, fSpacingAdd);
michael@0 77 SkBoundableAuto boundable(this, maker);
michael@0 78 box.draw(maker.fCanvas, fText.c_str(), fText.size(), *maker.fPaint);
michael@0 79 return false;
michael@0 80 }

mercurial