180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/*
280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Copyright 2012 Google Inc.
380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru *
480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Use of this source code is governed by a BSD-style license that can be
580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * found in the LICENSE file.
680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */
780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifndef SkTextToPathIter_DEFINED
980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#define SkTextToPathIter_DEFINED
1080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkAutoKern.h"
1280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkPaint.h"
1380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkGlyphCache;
1580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkTextToPathIter {
1780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querupublic:
1880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkTextToPathIter(const char text[], size_t length, const SkPaint& paint,
1980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                     bool applyStrokeAndPathEffects);
2080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    ~SkTextToPathIter();
2180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
2280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    const SkPaint&  getPaint() const { return fPaint; }
2380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkScalar        getPathScale() const { return fScale; }
2480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
2580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    struct Rec {
2680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        const SkPath*   fPath;  // may be null for "whitespace" glyphs
2780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        SkScalar        fXPos;
2880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    };
2980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
3080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /**
3180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  Returns false when all of the text has been consumed
3280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
3380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool next(const SkPath** path, SkScalar* xpos);
3480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
3580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruprivate:
3680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkGlyphCache*   fCache;
3780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkPaint         fPaint;
3880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkScalar        fScale;
3980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkFixed         fPrevAdvance;
4080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    const char*     fText;
4180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    const char*     fStop;
4280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkMeasureCacheProc fGlyphCacheProc;
4380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
4480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkScalar        fXPos;      // accumulated xpos, returned in next
4580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkAutoKern      fAutoKern;
4680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    int             fXYIndex;   // cache for horizontal -vs- vertical text
4780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru};
4880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
4980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif
50