blob: 3e00ff2477c4f91be0a793eeab540289b28776cc [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.org8128d8c2013-12-19 16:12:25 +000020 GrDistanceFieldTextContext(GrContext*, const GrPaint&, const SkPaint&);
jvanverth@google.comd830d132013-11-11 20:54:09 +000021 virtual ~GrDistanceFieldTextContext();
22
23 virtual void drawPackedGlyph(GrGlyph::PackedID, GrFixed left, GrFixed top,
24 GrFontScaler*) SK_OVERRIDE;
25
commit-bot@chromium.org8128d8c2013-12-19 16:12:25 +000026 void drawText(const char text[], size_t byteLength,
27 SkScalar x, SkScalar y, SkGlyphCache*, GrFontScaler*);
28 void drawPosText(const char text[], size_t byteLength,
29 const SkScalar pos[], SkScalar constY,
30 int scalarsPerPosition,
31 SkGlyphCache* cache, GrFontScaler* fontScaler);
32
33 const SkPaint& getSkPaint() { return fSkPaint; }
34
jvanverth@google.comd830d132013-11-11 20:54:09 +000035private:
36 GrTextStrike* fStrike;
37 SkScalar fTextRatio;
38
39 void flushGlyphs(); // automatically called by destructor
40
41 enum {
42 kMinRequestedGlyphs = 1,
43 kDefaultRequestedGlyphs = 64,
44 kMinRequestedVerts = kMinRequestedGlyphs * 4,
45 kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4,
46 };
47
commit-bot@chromium.org8128d8c2013-12-19 16:12:25 +000048 SkPaint fSkPaint;
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