1/*
2 * Copyright 2012 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SkTextToPathIter_DEFINED
9#define SkTextToPathIter_DEFINED
10
11#include "SkAutoKern.h"
12#include "SkPaint.h"
13
14class SkGlyphCache;
15
16class SkTextToPathIter {
17public:
18    SkTextToPathIter(const char text[], size_t length, const SkPaint& paint,
19                     bool applyStrokeAndPathEffects);
20    ~SkTextToPathIter();
21
22    const SkPaint&  getPaint() const { return fPaint; }
23    SkScalar        getPathScale() const { return fScale; }
24
25    struct Rec {
26        const SkPath*   fPath;  // may be null for "whitespace" glyphs
27        SkScalar        fXPos;
28    };
29
30    /**
31     *  Returns false when all of the text has been consumed
32     */
33    bool next(const SkPath** path, SkScalar* xpos);
34
35private:
36    SkGlyphCache*   fCache;
37    SkPaint         fPaint;
38    SkScalar        fScale;
39    SkFixed         fPrevAdvance;
40    const char*     fText;
41    const char*     fStop;
42    SkMeasureCacheProc fGlyphCacheProc;
43
44    SkScalar        fXPos;      // accumulated xpos, returned in next
45    SkAutoKern      fAutoKern;
46    int             fXYIndex;   // cache for horizontal -vs- vertical text
47};
48
49#endif
50