blob: 6550e3c0793db29ce8cde8b42026f1c205b1c53e [file] [log] [blame]
jvanverth@google.comc7a40fa2013-10-16 18:15:34 +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 GrBitmapTextContext_DEFINED
9#define GrBitmapTextContext_DEFINED
10
11#include "GrTextContext.h"
12
13class GrTextStrike;
14
15/*
16 * This class implements GrTextContext using standard bitmap fonts
17 */
18class GrBitmapTextContext : public GrTextContext {
19public:
commit-bot@chromium.org9f94b912014-01-30 15:22:54 +000020 GrBitmapTextContext(GrContext*, const GrPaint&, const SkPaint&, const SkDeviceProperties&);
21 virtual ~GrBitmapTextContext();
22
commit-bot@chromium.orge8612d92014-01-28 22:02:07 +000023 virtual void drawText(const char text[], size_t byteLength, SkScalar x, SkScalar y) SK_OVERRIDE;
24 virtual void drawPosText(const char text[], size_t byteLength,
25 const SkScalar pos[], SkScalar constY,
26 int scalarsPerPosition) SK_OVERRIDE;
jvanverth@google.comc7a40fa2013-10-16 18:15:34 +000027
commit-bot@chromium.org9f94b912014-01-30 15:22:54 +000028 static bool CanDraw(const SkPaint& paint, const SkMatrix& ctm);
29
jvanverth@google.comc7a40fa2013-10-16 18:15:34 +000030private:
jvanverth@google.comc7a40fa2013-10-16 18:15:34 +000031 GrTextStrike* fStrike;
32
commit-bot@chromium.orge8612d92014-01-28 22:02:07 +000033 void drawPackedGlyph(GrGlyph::PackedID, GrFixed left, GrFixed top, GrFontScaler*);
jvanverth@google.comc7a40fa2013-10-16 18:15:34 +000034 void flushGlyphs(); // automatically called by destructor
35
36 enum {
37 kMinRequestedGlyphs = 1,
38 kDefaultRequestedGlyphs = 64,
39 kMinRequestedVerts = kMinRequestedGlyphs * 4,
40 kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4,
41 };
42
jvanverth@google.comc7a40fa2013-10-16 18:15:34 +000043 SkPoint* fVertices;
44 int32_t fMaxVertices;
45 GrTexture* fCurrTexture;
46 int fCurrVertex;
47};
48
49#endif