blob: 7676fc16482b63e7163e5e661177d15142cd068e [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.org6fcd1ef2014-05-02 12:39:41 +000020 GrDistanceFieldTextContext(GrContext*, const SkDeviceProperties&, bool enable);
commit-bot@chromium.orgcbbc4812014-01-30 22:05:47 +000021 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;
commit-bot@chromium.org609ced42014-04-03 18:25:48 +000035 bool fUseLCDText;
commit-bot@chromium.org6fcd1ef2014-05-02 12:39:41 +000036 bool fEnableDFRendering;
jvanverth2d2a68c2014-06-10 06:42:56 -070037 GrTexture* fGammaTexture;
jvanverth@google.comd830d132013-11-11 20:54:09 +000038
commit-bot@chromium.orgcbbc4812014-01-30 22:05:47 +000039 void init(const GrPaint&, const SkPaint&);
commit-bot@chromium.org972f9cd2014-03-28 17:58:28 +000040 void drawPackedGlyph(GrGlyph::PackedID, SkFixed left, SkFixed top, GrFontScaler*);
jvanverth@google.comd830d132013-11-11 20:54:09 +000041 void flushGlyphs(); // automatically called by destructor
commit-bot@chromium.orgcbbc4812014-01-30 22:05:47 +000042 void finish();
jvanverth@google.comd830d132013-11-11 20:54:09 +000043
44 enum {
45 kMinRequestedGlyphs = 1,
46 kDefaultRequestedGlyphs = 64,
47 kMinRequestedVerts = kMinRequestedGlyphs * 4,
48 kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4,
49 };
50
jvanverthf17bc6c2014-07-25 16:46:53 -070051 void* fVertices;
jvanverth@google.comd830d132013-11-11 20:54:09 +000052 int fCurrVertex;
53};
54
55#endif