blob: 24ee7e8cfe7c9da8794fe5c293018404c34af210 [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.orgcbbc4812014-01-30 22:05:47 +000020 GrBitmapTextContext(GrContext*, const SkDeviceProperties&);
commit-bot@chromium.org9f94b912014-01-30 15:22:54 +000021 virtual ~GrBitmapTextContext();
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;
jvanverth@google.comc7a40fa2013-10-16 18:15:34 +000029
commit-bot@chromium.orgcbbc4812014-01-30 22:05:47 +000030 virtual bool canDraw(const SkPaint& paint) SK_OVERRIDE;
skia.committer@gmail.com4c18e9f2014-01-31 03:01:59 +000031
jvanverth@google.comc7a40fa2013-10-16 18:15:34 +000032private:
commit-bot@chromium.orgcbbc4812014-01-30 22:05:47 +000033 void init(const GrPaint&, const SkPaint&);
jvanverth63b9dc82014-08-28 10:39:40 -070034 void allocateVertices(const char text[], size_t byteLength);
commit-bot@chromium.org972f9cd2014-03-28 17:58:28 +000035 void drawPackedGlyph(GrGlyph::PackedID, SkFixed left, SkFixed top, GrFontScaler*);
jvanverth@google.comc7a40fa2013-10-16 18:15:34 +000036 void flushGlyphs(); // automatically called by destructor
commit-bot@chromium.orgcbbc4812014-01-30 22:05:47 +000037 void finish();
jvanverth@google.comc7a40fa2013-10-16 18:15:34 +000038
39 enum {
40 kMinRequestedGlyphs = 1,
41 kDefaultRequestedGlyphs = 64,
42 kMinRequestedVerts = kMinRequestedGlyphs * 4,
43 kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4,
44 };
45
jvanverth63b9dc82014-08-28 10:39:40 -070046 GrTextStrike* fStrike;
bsalomon83d081a2014-07-08 09:56:10 -070047 SkAutoTUnref<GrEffect> fCachedEffect;
bsalomon1c63bf62014-07-22 13:09:46 -070048 // Used to check whether fCachedEffect is still valid.
49 uint32_t fEffectTextureUniqueID;
jvanverth63b9dc82014-08-28 10:39:40 -070050
51 void* fVertices;
52 int fVertexCount;
bsalomon8b2fac42014-06-19 14:13:45 -070053 int fCurrVertex;
54 SkRect fVertexBounds;
jvanverth@google.comc7a40fa2013-10-16 18:15:34 +000055};
56
57#endif