blob: 8b94038b678429b72d31f35457e8ad6264cd3e7f [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.org9f94b912014-01-30 15:22:54 +000024
25 static bool CanDraw(const SkPaint& paint, const SkMatrix& ctm);
commit-bot@chromium.org8128d8c2013-12-19 16:12:25 +000026
jvanverth@google.comd830d132013-11-11 20:54:09 +000027private:
skia.committer@gmail.come5d70152014-01-29 07:01:48 +000028 GrDistanceFieldTextContext(GrContext*, const GrPaint&, const SkPaint&,
commit-bot@chromium.orge8612d92014-01-28 22:02:07 +000029 const SkDeviceProperties&);
commit-bot@chromium.orgcc40f062014-01-24 14:38:27 +000030 virtual ~GrDistanceFieldTextContext();
31 friend class GrTTextContextManager<GrDistanceFieldTextContext>;
32
jvanverth@google.comd830d132013-11-11 20:54:09 +000033 GrTextStrike* fStrike;
34 SkScalar fTextRatio;
35
commit-bot@chromium.orge8612d92014-01-28 22:02:07 +000036 void drawPackedGlyph(GrGlyph::PackedID, GrFixed left, GrFixed top, GrFontScaler*);
jvanverth@google.comd830d132013-11-11 20:54:09 +000037 void flushGlyphs(); // automatically called by destructor
38
39 enum {
40 kMinRequestedGlyphs = 1,
41 kDefaultRequestedGlyphs = 64,
42 kMinRequestedVerts = kMinRequestedGlyphs * 4,
43 kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4,
44 };
45
jvanverth@google.comd830d132013-11-11 20:54:09 +000046 SkPoint* fVertices;
47 int32_t fMaxVertices;
48 GrTexture* fCurrTexture;
49 int fCurrVertex;
50};
51
52#endif