blob: 7a73b7b10951bac9090cc1052af66f5d2dd18596 [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
jvanverth8c27a182014-10-14 08:45:50 -070048 virtual void onDrawPosText(const GrPaint&, const SkPaint&,
49 const char text[], size_t byteLength,
50 const SkScalar pos[], int scalarsPerPosition,
51 const SkPoint& offset) SK_OVERRIDE;
52
jvanverth0fedb192014-10-08 09:07:27 -070053 void init(const GrPaint&, const SkPaint&);
54 void appendGlyph(GrGlyph::PackedID, SkFixed left, SkFixed top, GrFontScaler*);
55 void flush(); // automatically called by destructor
56 void finish();
57
jvanverth@google.comc7a40fa2013-10-16 18:15:34 +000058};
59
60#endif