blob: 6d4ea6d524e255d57e802bbb5c52502c12642625 [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:
jvanverth@google.comc7a40fa2013-10-16 18:15:34 +000033 GrTextStrike* fStrike;
34
commit-bot@chromium.orgcbbc4812014-01-30 22:05:47 +000035 void init(const GrPaint&, const SkPaint&);
commit-bot@chromium.org972f9cd2014-03-28 17:58:28 +000036 void drawPackedGlyph(GrGlyph::PackedID, SkFixed left, SkFixed top, GrFontScaler*);
jvanverth@google.comc7a40fa2013-10-16 18:15:34 +000037 void flushGlyphs(); // automatically called by destructor
commit-bot@chromium.orgcbbc4812014-01-30 22:05:47 +000038 void finish();
jvanverth@google.comc7a40fa2013-10-16 18:15:34 +000039
40 enum {
41 kMinRequestedGlyphs = 1,
42 kDefaultRequestedGlyphs = 64,
43 kMinRequestedVerts = kMinRequestedGlyphs * 4,
44 kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4,
45 };
46
bsalomon8b2fac42014-06-19 14:13:45 -070047 void* fVertices;
jvanverth9bcd23b2014-08-01 14:05:19 -070048 int32_t fMaxVertices;
49 GrTexture* fCurrTexture;
bsalomon83d081a2014-07-08 09:56:10 -070050 SkAutoTUnref<GrEffect> fCachedEffect;
bsalomon1c63bf62014-07-22 13:09:46 -070051 // Used to check whether fCachedEffect is still valid.
52 uint32_t fEffectTextureUniqueID;
bsalomon8b2fac42014-06-19 14:13:45 -070053 int fCurrVertex;
54 SkRect fVertexBounds;
jvanverth@google.comc7a40fa2013-10-16 18:15:34 +000055};
56
57#endif