blob: bffacd52d0b5e2913946c2ce3c97acfde99c5378 [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;
joshualitt2e3b3e32014-12-09 13:31:14 -080034 SkAutoTUnref<const GrGeometryProcessor> fCachedGeometryProcessor;
35 SkAutoTUnref<const GrFragmentProcessor> fCachedTextureProcessor;
bsalomon1c63bf62014-07-22 13:09:46 -070036 // Used to check whether fCachedEffect is still valid.
joshualittb0a8a372014-09-23 09:50:21 -070037 uint32_t fEffectTextureUniqueID;
joshualitt8fc6c2d2014-12-22 15:27:05 -080038 SkMatrix fLocalMatrix;
jvanverth0fedb192014-10-08 09:07:27 -070039
jvanverth8c27a182014-10-14 08:45:50 -070040 GrBitmapTextContext(GrContext*, const SkDeviceProperties&);
41
mtklein72c9faa2015-01-09 10:06:39 -080042 bool canDraw(const SkPaint& paint, const SkMatrix& viewMatrix) SK_OVERRIDE;
jvanverth8c27a182014-10-14 08:45:50 -070043
joshualitt5531d512014-12-17 15:50:11 -080044 virtual void onDrawText(const GrPaint&, const SkPaint&, const SkMatrix& viewMatrix,
45 const char text[], size_t byteLength,
jvanverthaab626c2014-10-16 08:04:39 -070046 SkScalar x, SkScalar y) SK_OVERRIDE;
joshualitt5531d512014-12-17 15:50:11 -080047 virtual void onDrawPosText(const GrPaint&, const SkPaint&, const SkMatrix& viewMatrix,
jvanverth8c27a182014-10-14 08:45:50 -070048 const char text[], size_t byteLength,
49 const SkScalar pos[], int scalarsPerPosition,
50 const SkPoint& offset) SK_OVERRIDE;
51
jvanverth0fedb192014-10-08 09:07:27 -070052 void init(const GrPaint&, const SkPaint&);
53 void appendGlyph(GrGlyph::PackedID, SkFixed left, SkFixed top, GrFontScaler*);
jvanverth787cdf92014-12-04 10:46:50 -080054 bool uploadGlyph(GrGlyph*, GrFontScaler*);
jvanverth0fedb192014-10-08 09:07:27 -070055 void flush(); // automatically called by destructor
56 void finish();
jvanverth@google.comc7a40fa2013-10-16 18:15:34 +000057};
58
59#endif