aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrTextContext.h
blob: 4cede1dd9dcc62d8dc19f6e0e7c05cb5a047ef45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
 * Copyright 2010 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef GrTextContext_DEFINED
#define GrTextContext_DEFINED

#include "GrPoint.h"
#include "GrGlyph.h"
#include "GrPaint.h"
#include "SkDeviceProperties.h"

#include "SkPostConfig.h"

class GrContext;
class GrDrawTarget;
class GrFontScaler;

/*
 * This class wraps the state for a single text render
 */
class GrTextContext {
public:
    virtual ~GrTextContext() {}
    virtual void drawText(const GrPaint&, const SkPaint&, const char text[], size_t byteLength,
                          SkScalar x, SkScalar y) = 0;
    virtual void drawPosText(const GrPaint&, const SkPaint&,
                             const char text[], size_t byteLength,
                             const SkScalar pos[], SkScalar constY,
                             int scalarsPerPosition) = 0;

    virtual bool canDraw(const SkPaint& paint) = 0;

protected:
    GrTextContext(GrContext*, const SkDeviceProperties&);

    static GrFontScaler* GetGrFontScaler(SkGlyphCache* cache);
    static void MeasureText(SkGlyphCache* cache, SkDrawCacheProc glyphCacheProc,
                            const char text[], size_t byteLength, SkVector* stopVector);

    void init(const GrPaint&, const SkPaint&);
    void finish() { fDrawTarget = NULL; }

    GrContext*         fContext;
    SkDeviceProperties fDeviceProperties;

    GrDrawTarget*      fDrawTarget;
    SkIRect            fClipRect;
    GrPaint            fPaint;
    SkPaint            fSkPaint;
};

#endif