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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/src/animator/SkTextToPath.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,47 @@
     1.4 +
     1.5 +/*
     1.6 + * Copyright 2006 The Android Open Source Project
     1.7 + *
     1.8 + * Use of this source code is governed by a BSD-style license that can be
     1.9 + * found in the LICENSE file.
    1.10 + */
    1.11 +
    1.12 +
    1.13 +#include "SkTextToPath.h"
    1.14 +#include "SkAnimateMaker.h"
    1.15 +#include "SkDrawPaint.h"
    1.16 +#include "SkDrawPath.h"
    1.17 +#include "SkDrawText.h"
    1.18 +#include "SkPaint.h"
    1.19 +
    1.20 +#if SK_USE_CONDENSED_INFO == 0
    1.21 +
    1.22 +const SkMemberInfo SkTextToPath::fInfo[] = {
    1.23 +    SK_MEMBER(paint, Paint),
    1.24 +    SK_MEMBER(path, Path),
    1.25 +    SK_MEMBER(text, Text)
    1.26 +};
    1.27 +
    1.28 +#endif
    1.29 +
    1.30 +DEFINE_GET_MEMBER(SkTextToPath);
    1.31 +
    1.32 +SkTextToPath::SkTextToPath() : paint(NULL), path(NULL), text(NULL) {
    1.33 +}
    1.34 +
    1.35 +bool SkTextToPath::draw(SkAnimateMaker& maker) {
    1.36 +    path->draw(maker);
    1.37 +    return false;
    1.38 +}
    1.39 +
    1.40 +void SkTextToPath::onEndElement(SkAnimateMaker& maker) {
    1.41 +    if (paint == NULL || path == NULL || text == NULL) {
    1.42 +        // !!! add error message here
    1.43 +        maker.setErrorCode(SkDisplayXMLParserError::kErrorInAttributeValue);
    1.44 +        return;
    1.45 +    }
    1.46 +    SkPaint realPaint;
    1.47 +    paint->setupPaint(&realPaint);
    1.48 +    realPaint.getTextPath(text->getText(), text->getSize(), text->x,
    1.49 +        text->y, &path->getPath());
    1.50 +}

mercurial