blob: 79058b8bbddb7f9f61866ce3bac5465074262061 [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:
commit-bot@chromium.orge8612d92014-01-28 22:02:07 +000020 virtual void drawText(const char text[], size_t byteLength, SkScalar x, SkScalar y) SK_OVERRIDE;
21 virtual void drawPosText(const char text[], size_t byteLength,
22 const SkScalar pos[], SkScalar constY,
23 int scalarsPerPosition) SK_OVERRIDE;
commit-bot@chromium.org8128d8c2013-12-19 16:12:25 +000024
jvanverth@google.comd830d132013-11-11 20:54:09 +000025private:
commit-bot@chromium.orge8612d92014-01-28 22:02:07 +000026 GrDistanceFieldTextContext(GrContext*, const GrPaint&, const SkPaint&,
27 const SkDeviceProperties&);
commit-bot@chromium.orgcc40f062014-01-24 14:38:27 +000028 virtual ~GrDistanceFieldTextContext();
29 friend class GrTTextContextManager<GrDistanceFieldTextContext>;
30
jvanverth@google.comd830d132013-11-11 20:54:09 +000031 GrTextStrike* fStrike;
32 SkScalar fTextRatio;
33
commit-bot@chromium.orge8612d92014-01-28 22:02:07 +000034 void drawPackedGlyph(GrGlyph::PackedID, GrFixed left, GrFixed top, GrFontScaler*);
jvanverth@google.comd830d132013-11-11 20:54:09 +000035 void flushGlyphs(); // automatically called by destructor
36
37 enum {
38 kMinRequestedGlyphs = 1,
39 kDefaultRequestedGlyphs = 64,
40 kMinRequestedVerts = kMinRequestedGlyphs * 4,
41 kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4,
42 };
43
jvanverth@google.comd830d132013-11-11 20:54:09 +000044 SkPoint* fVertices;
45 int32_t fMaxVertices;
46 GrTexture* fCurrTexture;
47 int fCurrVertex;
48};
49
50#endif