2 * Copyright 2013 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #ifndef GrBitmapTextContext_DEFINED
9 #define GrBitmapTextContext_DEFINED
11 #include "GrTextContext.h"
13 #include "GrGeometryProcessor.h"
18 * This class implements GrTextContext using standard bitmap fonts
20 class GrBitmapTextContext : public GrTextContext {
22 static GrBitmapTextContext* Create(GrContext*, SkGpuDevice*, const SkDeviceProperties&);
24 virtual ~GrBitmapTextContext() {}
27 GrTextStrike* fStrike;
30 int fAllocVertexCount;
31 int fTotalVertexCount;
33 GrTexture* fCurrTexture;
34 GrMaskFormat fCurrMaskFormat;
35 SkAutoTUnref<const GrGeometryProcessor> fCachedGeometryProcessor;
36 // Used to check whether fCachedEffect is still valid.
37 uint32_t fEffectTextureUniqueID;
38 SkMatrix fLocalMatrix;
40 GrBitmapTextContext(GrContext*, SkGpuDevice*, const SkDeviceProperties&);
42 bool canDraw(const GrRenderTarget*, const GrClip&, const GrPaint&,
43 const SkPaint&, const SkMatrix& viewMatrix) SK_OVERRIDE;
45 void onDrawText(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint&,
46 const SkMatrix& viewMatrix, const char text[], size_t byteLength,
47 SkScalar x, SkScalar y, const SkIRect& regionClipBounds) SK_OVERRIDE;
48 void onDrawPosText(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint&,
49 const SkMatrix& viewMatrix,
50 const char text[], size_t byteLength,
51 const SkScalar pos[], int scalarsPerPosition,
52 const SkPoint& offset, const SkIRect& regionClipBounds) SK_OVERRIDE;
54 void init(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint&,
55 const SkIRect& regionClipBounds);
56 void appendGlyph(GrGlyph::PackedID, SkFixed left, SkFixed top, GrFontScaler*);
57 bool uploadGlyph(GrGlyph*, GrFontScaler*);
58 void flush(); // automatically called by destructor