1 /* libs/graphics/animator/SkTextToPath.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 "SkTextToPath.h" 19 #include "SkAnimateMaker.h" 20 #include "SkDrawPaint.h" 21 #include "SkDrawPath.h" 22 #include "SkDrawText.h" 23 #include "SkPaint.h" 24 25 #if SK_USE_CONDENSED_INFO == 0 26 27 const SkMemberInfo SkTextToPath::fInfo[] = { 28 SK_MEMBER(paint, Paint), 29 SK_MEMBER(path, Path), 30 SK_MEMBER(text, Text) 31 }; 32 33 #endif 34 35 DEFINE_GET_MEMBER(SkTextToPath); 36 37 SkTextToPath::SkTextToPath() : paint(NULL), path(NULL), text(NULL) { 38 } 39 40 bool SkTextToPath::draw(SkAnimateMaker& maker) { 41 path->draw(maker); 42 return false; 43 } 44 45 void SkTextToPath::onEndElement(SkAnimateMaker& maker) { 46 if (paint == NULL || path == NULL || text == NULL) { 47 // !!! add error message here 48 maker.setErrorCode(SkDisplayXMLParserError::kErrorInAttributeValue); 49 return; 50 } 51 SkPaint realPaint; 52 paint->setupPaint(&realPaint); 53 realPaint.getTextPath(text->getText(), text->getSize(), text->x, 54 text->y, &path->getPath()); 55 } 56 57