blob: a9805cb0fb0c2aa8e833b9c254bd38d6289d671c [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
joshualittb0a8a372014-09-23 09:50:21 -070013class GrGeometryProcessor;
jvanverth@google.comc7a40fa2013-10-16 18:15:34 +000014class GrTextStrike;
15
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
jvanverth0fedb192014-10-08 09:07:27 -070024 virtual bool canDraw(const SkPaint& paint) SK_OVERRIDE;
25
skia.committer@gmail.com4c18e9f2014-01-31 03:01:59 +000026 virtual void drawText(const GrPaint&, const SkPaint&, const char text[], size_t byteLength,
commit-bot@chromium.orgcbbc4812014-01-30 22:05:47 +000027 SkScalar x, SkScalar y) SK_OVERRIDE;
skia.committer@gmail.com4c18e9f2014-01-31 03:01:59 +000028 virtual void drawPosText(const GrPaint&, const SkPaint&,
commit-bot@chromium.orgcbbc4812014-01-30 22:05:47 +000029 const char text[], size_t byteLength,
fmalita05c4a432014-09-29 06:29:53 -070030 const SkScalar pos[], int scalarsPerPosition,
31 const SkPoint& offset) SK_OVERRIDE;
jvanverth@google.comc7a40fa2013-10-16 18:15:34 +000032
33private:
jvanverth@google.comc7a40fa2013-10-16 18:15:34 +000034 enum {
35 kMinRequestedGlyphs = 1,
36 kDefaultRequestedGlyphs = 64,
37 kMinRequestedVerts = kMinRequestedGlyphs * 4,
38 kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4,
39 };
40
jvanverth0fedb192014-10-08 09:07:27 -070041 GrTextStrike* fStrike;
joshualittb0a8a372014-09-23 09:50:21 -070042 void* fVertices;
jvanverth294c3262014-10-10 11:36:12 -070043 int fCurrVertex;
44 int fMaxVertices;
45 SkRect fVertexBounds;
joshualittb0a8a372014-09-23 09:50:21 -070046 GrTexture* fCurrTexture;
jvanverth294c3262014-10-10 11:36:12 -070047 GrMaskFormat fCurrMaskFormat;
joshualittb0a8a372014-09-23 09:50:21 -070048 SkAutoTUnref<GrGeometryProcessor> fCachedGeometryProcessor;
bsalomon1c63bf62014-07-22 13:09:46 -070049 // Used to check whether fCachedEffect is still valid.
joshualittb0a8a372014-09-23 09:50:21 -070050 uint32_t fEffectTextureUniqueID;
jvanverth0fedb192014-10-08 09:07:27 -070051
52 void init(const GrPaint&, const SkPaint&);
53 void appendGlyph(GrGlyph::PackedID, SkFixed left, SkFixed top, GrFontScaler*);
54 void flush(); // automatically called by destructor
55 void finish();
56
jvanverth@google.comc7a40fa2013-10-16 18:15:34 +000057};
58
59#endif