aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrStencilAndCoverTextContext.h
blob: 2e79f5c9b7e43f59dcf5234bd780eb81de6e5616 (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
/*
 * Copyright 2014 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef GrStencilAndCoverTextContext_DEFINED
#define GrStencilAndCoverTextContext_DEFINED

#include "GrTextContext.h"
#include "GrDrawState.h"
#include "SkStrokeRec.h"

class GrTextStrike;
class GrPath;

/*
 * This class implements text rendering using stencil and cover path rendering
 * (by the means of GrDrawTarget::drawPath).
 * This class exposes the functionality through GrTextContext interface.
 */
class GrStencilAndCoverTextContext : public GrTextContext {
public:
    GrStencilAndCoverTextContext(GrContext*, const SkDeviceProperties&);
    virtual ~GrStencilAndCoverTextContext();

    virtual void drawText(const GrPaint&, const SkPaint&, const char text[],
                          size_t byteLength,
                          SkScalar x, SkScalar y) SK_OVERRIDE;
    virtual void drawPosText(const GrPaint&, const SkPaint&,
                             const char text[], size_t byteLength,
                             const SkScalar pos[], SkScalar constY,
                             int scalarsPerPosition) SK_OVERRIDE;

    virtual bool canDraw(const SkPaint& paint) SK_OVERRIDE;

private:
    void init(const GrPaint&, const SkPaint&, size_t textByteLength);
    void appendGlyph(GrGlyph::PackedID, const SkPoint&,
                     GrTextStrike*, GrFontScaler*);
    void finish();

    GrDrawState::AutoRestoreEffects fStateRestore;
    SkScalar fTextRatio;
    SkStrokeRec fStroke;
    SkTDArray<const GrPath*> fPaths;
    SkTDArray<SkMatrix> fTransforms;
    SkPath fTmpPath;
    SkMatrix fGlyphTransform;
    bool fNeedsDeviceSpaceGlyphs;
};

#endif