blob: 51193c82f99d507d0261cf275d6af32db03a7bb0 [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;
commit-bot@chromium.org7801faa2014-05-14 15:14:51 +000014class GrAtlasMgr;
jvanverth@google.comc7a40fa2013-10-16 18:15:34 +000015
16/*
17 * This class implements GrTextContext using standard bitmap fonts
18 */
19class GrBitmapTextContext : public GrTextContext {
20public:
commit-bot@chromium.orgcbbc4812014-01-30 22:05:47 +000021 GrBitmapTextContext(GrContext*, const SkDeviceProperties&);
commit-bot@chromium.org9f94b912014-01-30 15:22:54 +000022 virtual ~GrBitmapTextContext();
23
skia.committer@gmail.com4c18e9f2014-01-31 03:01:59 +000024 virtual void drawText(const GrPaint&, const SkPaint&, const char text[], size_t byteLength,
commit-bot@chromium.orgcbbc4812014-01-30 22:05:47 +000025 SkScalar x, SkScalar y) SK_OVERRIDE;
skia.committer@gmail.com4c18e9f2014-01-31 03:01:59 +000026 virtual void drawPosText(const GrPaint&, const SkPaint&,
commit-bot@chromium.orgcbbc4812014-01-30 22:05:47 +000027 const char text[], size_t byteLength,
commit-bot@chromium.orge8612d92014-01-28 22:02:07 +000028 const SkScalar pos[], SkScalar constY,
29 int scalarsPerPosition) SK_OVERRIDE;
jvanverth@google.comc7a40fa2013-10-16 18:15:34 +000030
commit-bot@chromium.orgcbbc4812014-01-30 22:05:47 +000031 virtual bool canDraw(const SkPaint& paint) SK_OVERRIDE;
skia.committer@gmail.com4c18e9f2014-01-31 03:01:59 +000032
jvanverth@google.comc7a40fa2013-10-16 18:15:34 +000033private:
jvanverth@google.comc7a40fa2013-10-16 18:15:34 +000034 GrTextStrike* fStrike;
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.comc7a40fa2013-10-16 18:15:34 +000038 void flushGlyphs(); // automatically called by destructor
commit-bot@chromium.orgcbbc4812014-01-30 22:05:47 +000039 void finish();
jvanverth@google.comc7a40fa2013-10-16 18:15:34 +000040
41 enum {
42 kMinRequestedGlyphs = 1,
43 kDefaultRequestedGlyphs = 64,
44 kMinRequestedVerts = kMinRequestedGlyphs * 4,
45 kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4,
46 };
47
bsalomon594069f2014-06-06 06:16:34 -070048 void* fVertices;
jvanverth@google.comc7a40fa2013-10-16 18:15:34 +000049 int32_t fMaxVertices;
50 GrTexture* fCurrTexture;
51 int fCurrVertex;
commit-bot@chromium.org3ae0e6c2014-02-11 18:24:25 +000052 SkRect fVertexBounds;
jvanverth@google.comc7a40fa2013-10-16 18:15:34 +000053};
54
55#endif