blob: a3d0eb2e8881de17b018295b742bf398301b2b5b [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
joshualitt9853cce2014-11-17 14:22:48 -080023 virtual ~GrBitmapTextContext() {}
commit-bot@chromium.org9f94b912014-01-30 15:22:54 +000024
jvanverth@google.comc7a40fa2013-10-16 18:15:34 +000025private:
jvanverth0fedb192014-10-08 09:07:27 -070026 GrTextStrike* fStrike;
joshualittb0a8a372014-09-23 09:50:21 -070027 void* fVertices;
jvanverth294c3262014-10-10 11:36:12 -070028 int fCurrVertex;
jvanverth73f10532014-10-23 11:57:12 -070029 int fAllocVertexCount;
30 int fTotalVertexCount;
jvanverth294c3262014-10-10 11:36:12 -070031 SkRect fVertexBounds;
joshualittb0a8a372014-09-23 09:50:21 -070032 GrTexture* fCurrTexture;
jvanverth294c3262014-10-10 11:36:12 -070033 GrMaskFormat fCurrMaskFormat;
joshualittb0a8a372014-09-23 09:50:21 -070034 SkAutoTUnref<GrGeometryProcessor> fCachedGeometryProcessor;
bsalomon1c63bf62014-07-22 13:09:46 -070035 // Used to check whether fCachedEffect is still valid.
joshualittb0a8a372014-09-23 09:50:21 -070036 uint32_t fEffectTextureUniqueID;
jvanverth0fedb192014-10-08 09:07:27 -070037
jvanverth8c27a182014-10-14 08:45:50 -070038 GrBitmapTextContext(GrContext*, const SkDeviceProperties&);
39
40 virtual bool canDraw(const SkPaint& paint) SK_OVERRIDE;
41
jvanverthaab626c2014-10-16 08:04:39 -070042 virtual void onDrawText(const GrPaint&, const SkPaint&, const char text[], size_t byteLength,
43 SkScalar x, SkScalar y) SK_OVERRIDE;
jvanverth8c27a182014-10-14 08:45:50 -070044 virtual void onDrawPosText(const GrPaint&, const SkPaint&,
45 const char text[], size_t byteLength,
46 const SkScalar pos[], int scalarsPerPosition,
47 const SkPoint& offset) SK_OVERRIDE;
48
jvanverth0fedb192014-10-08 09:07:27 -070049 void init(const GrPaint&, const SkPaint&);
50 void appendGlyph(GrGlyph::PackedID, SkFixed left, SkFixed top, GrFontScaler*);
51 void flush(); // automatically called by destructor
52 void finish();
jvanverth@google.comc7a40fa2013-10-16 18:15:34 +000053};
54
55#endif