blob: 7a93820a167e2042470544181b13d4d06f4af049 [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:
jvanverth8c27a182014-10-14 08:45:50 -070021 static GrBitmapTextContext* Create(GrContext*, const SkDeviceProperties&);
22
commit-bot@chromium.org9f94b912014-01-30 15:22:54 +000023 virtual ~GrBitmapTextContext();
24
jvanverth@google.comc7a40fa2013-10-16 18:15:34 +000025private:
jvanverth@google.comc7a40fa2013-10-16 18:15:34 +000026 enum {
27 kMinRequestedGlyphs = 1,
28 kDefaultRequestedGlyphs = 64,
29 kMinRequestedVerts = kMinRequestedGlyphs * 4,
30 kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4,
31 };
32
jvanverth0fedb192014-10-08 09:07:27 -070033 GrTextStrike* fStrike;
joshualittb0a8a372014-09-23 09:50:21 -070034 void* fVertices;
jvanverth294c3262014-10-10 11:36:12 -070035 int fCurrVertex;
36 int fMaxVertices;
37 SkRect fVertexBounds;
joshualittb0a8a372014-09-23 09:50:21 -070038 GrTexture* fCurrTexture;
jvanverth294c3262014-10-10 11:36:12 -070039 GrMaskFormat fCurrMaskFormat;
joshualittb0a8a372014-09-23 09:50:21 -070040 SkAutoTUnref<GrGeometryProcessor> fCachedGeometryProcessor;
bsalomon1c63bf62014-07-22 13:09:46 -070041 // Used to check whether fCachedEffect is still valid.
joshualittb0a8a372014-09-23 09:50:21 -070042 uint32_t fEffectTextureUniqueID;
jvanverth0fedb192014-10-08 09:07:27 -070043
jvanverth8c27a182014-10-14 08:45:50 -070044 GrBitmapTextContext(GrContext*, const SkDeviceProperties&);
45
46 virtual bool canDraw(const SkPaint& paint) SK_OVERRIDE;
47
48 virtual void onDrawText(const GrPaint&, const SkPaint&, const char text[], size_t byteLength,
49 SkScalar x, SkScalar y) SK_OVERRIDE;
50 virtual void onDrawPosText(const GrPaint&, const SkPaint&,
51 const char text[], size_t byteLength,
52 const SkScalar pos[], int scalarsPerPosition,
53 const SkPoint& offset) SK_OVERRIDE;
54
jvanverth0fedb192014-10-08 09:07:27 -070055 void init(const GrPaint&, const SkPaint&);
56 void appendGlyph(GrGlyph::PackedID, SkFixed left, SkFixed top, GrFontScaler*);
57 void flush(); // automatically called by destructor
58 void finish();
59
jvanverth@google.comc7a40fa2013-10-16 18:15:34 +000060};
61
62#endif