blob: 26208822d9c4b50ff15dfea15941e61379f9775c [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.orgcbbc4812014-01-30 22:05:47 +000020 GrDistanceFieldTextContext(GrContext*, const SkDeviceProperties&);
21 virtual ~GrDistanceFieldTextContext();
22
skia.committer@gmail.com4c18e9f2014-01-31 03:01:59 +000023 virtual void drawText(const GrPaint&, const SkPaint&, const char text[], size_t byteLength,
commit-bot@chromium.orgcbbc4812014-01-30 22:05:47 +000024 SkScalar x, SkScalar y) SK_OVERRIDE;
skia.committer@gmail.com4c18e9f2014-01-31 03:01:59 +000025 virtual void drawPosText(const GrPaint&, const SkPaint&,
commit-bot@chromium.orgcbbc4812014-01-30 22:05:47 +000026 const char text[], size_t byteLength,
commit-bot@chromium.orge8612d92014-01-28 22:02:07 +000027 const SkScalar pos[], SkScalar constY,
28 int scalarsPerPosition) SK_OVERRIDE;
skia.committer@gmail.com4c18e9f2014-01-31 03:01:59 +000029
commit-bot@chromium.orgcbbc4812014-01-30 22:05:47 +000030 virtual bool canDraw(const SkPaint& paint) SK_OVERRIDE;
commit-bot@chromium.org8128d8c2013-12-19 16:12:25 +000031
jvanverth@google.comd830d132013-11-11 20:54:09 +000032private:
33 GrTextStrike* fStrike;
34 SkScalar fTextRatio;
35
commit-bot@chromium.orgcbbc4812014-01-30 22:05:47 +000036 void init(const GrPaint&, const SkPaint&);
commit-bot@chromium.org972f9cd2014-03-28 17:58:28 +000037 void drawPackedGlyph(GrGlyph::PackedID, SkFixed left, SkFixed top, GrFontScaler*);
jvanverth@google.comd830d132013-11-11 20:54:09 +000038 void flushGlyphs(); // automatically called by destructor
commit-bot@chromium.orgcbbc4812014-01-30 22:05:47 +000039 void finish();
jvanverth@google.comd830d132013-11-11 20:54:09 +000040
41 enum {
42 kMinRequestedGlyphs = 1,
43 kDefaultRequestedGlyphs = 64,
44 kMinRequestedVerts = kMinRequestedGlyphs * 4,
45 kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4,
46 };
47
jvanverth@google.comd830d132013-11-11 20:54:09 +000048 SkPoint* fVertices;
49 int32_t fMaxVertices;
50 GrTexture* fCurrTexture;
51 int fCurrVertex;
52};
53
54#endif