blob: ad21a2ffda56199c10e7ae4e8211dd782038dd57 [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;
jvanverth0fedb192014-10-08 09:07:27 -070038
jvanverth8c27a182014-10-14 08:45:50 -070039 GrBitmapTextContext(GrContext*, const SkDeviceProperties&);
40
joshualitt5531d512014-12-17 15:50:11 -080041 virtual bool canDraw(const SkPaint& paint, const SkMatrix& viewMatrix) SK_OVERRIDE;
jvanverth8c27a182014-10-14 08:45:50 -070042
joshualitt5531d512014-12-17 15:50:11 -080043 virtual void onDrawText(const GrPaint&, const SkPaint&, const SkMatrix& viewMatrix,
44 const char text[], size_t byteLength,
jvanverthaab626c2014-10-16 08:04:39 -070045 SkScalar x, SkScalar y) SK_OVERRIDE;
joshualitt5531d512014-12-17 15:50:11 -080046 virtual void onDrawPosText(const GrPaint&, const SkPaint&, const SkMatrix& viewMatrix,
jvanverth8c27a182014-10-14 08:45:50 -070047 const char text[], size_t byteLength,
48 const SkScalar pos[], int scalarsPerPosition,
49 const SkPoint& offset) SK_OVERRIDE;
50
jvanverth0fedb192014-10-08 09:07:27 -070051 void init(const GrPaint&, const SkPaint&);
52 void appendGlyph(GrGlyph::PackedID, SkFixed left, SkFixed top, GrFontScaler*);
jvanverth787cdf92014-12-04 10:46:50 -080053 bool uploadGlyph(GrGlyph*, GrFontScaler*);
jvanverth0fedb192014-10-08 09:07:27 -070054 void flush(); // automatically called by destructor
55 void finish();
jvanverth@google.comc7a40fa2013-10-16 18:15:34 +000056};
57
58#endif