blob: 4fde6ceef8d8b8dc3e8375c9732d4f14d7211466 [file] [log] [blame]
jvanverth@google.comd830d132013-11-11 20:54:09 +00001/*
2 * Copyright 2013 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 GrDistanceFieldTextContext_DEFINED
9#define GrDistanceFieldTextContext_DEFINED
10
11#include "GrTextContext.h"
12
13class GrTextStrike;
14
15/*
16 * This class implements GrTextContext using distance field fonts
17 */
18class GrDistanceFieldTextContext : public GrTextContext {
19public:
jvanverth@google.comd830d132013-11-11 20:54:09 +000020 virtual void drawPackedGlyph(GrGlyph::PackedID, GrFixed left, GrFixed top,
21 GrFontScaler*) SK_OVERRIDE;
22
commit-bot@chromium.org8128d8c2013-12-19 16:12:25 +000023 void drawText(const char text[], size_t byteLength,
24 SkScalar x, SkScalar y, SkGlyphCache*, GrFontScaler*);
25 void drawPosText(const char text[], size_t byteLength,
26 const SkScalar pos[], SkScalar constY,
27 int scalarsPerPosition,
28 SkGlyphCache* cache, GrFontScaler* fontScaler);
29
30 const SkPaint& getSkPaint() { return fSkPaint; }
31
jvanverth@google.comd830d132013-11-11 20:54:09 +000032private:
commit-bot@chromium.orgcc40f062014-01-24 14:38:27 +000033 GrDistanceFieldTextContext(GrContext*, const GrPaint&, const SkPaint&);
34 virtual ~GrDistanceFieldTextContext();
35 friend class GrTTextContextManager<GrDistanceFieldTextContext>;
36
jvanverth@google.comd830d132013-11-11 20:54:09 +000037 GrTextStrike* fStrike;
38 SkScalar fTextRatio;
39
40 void flushGlyphs(); // automatically called by destructor
41
42 enum {
43 kMinRequestedGlyphs = 1,
44 kDefaultRequestedGlyphs = 64,
45 kMinRequestedVerts = kMinRequestedGlyphs * 4,
46 kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4,
47 };
48
jvanverth@google.comd830d132013-11-11 20:54:09 +000049 SkPoint* fVertices;
50 int32_t fMaxVertices;
51 GrTexture* fCurrTexture;
52 int fCurrVertex;
53};
54
55#endif