blob: bffacd52d0b5e2913946c2ce3c97acfde99c5378 [file] [log] [blame]
/*
* Copyright 2013 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrBitmapTextContext_DEFINED
#define GrBitmapTextContext_DEFINED
#include "GrTextContext.h"
class GrGeometryProcessor;
class GrTextStrike;
/*
* This class implements GrTextContext using standard bitmap fonts
*/
class GrBitmapTextContext : public GrTextContext {
public:
static GrBitmapTextContext* Create(GrContext*, const SkDeviceProperties&);
virtual ~GrBitmapTextContext() {}
private:
GrTextStrike* fStrike;
void* fVertices;
int fCurrVertex;
int fAllocVertexCount;
int fTotalVertexCount;
SkRect fVertexBounds;
GrTexture* fCurrTexture;
GrMaskFormat fCurrMaskFormat;
SkAutoTUnref<const GrGeometryProcessor> fCachedGeometryProcessor;
SkAutoTUnref<const GrFragmentProcessor> fCachedTextureProcessor;
// Used to check whether fCachedEffect is still valid.
uint32_t fEffectTextureUniqueID;
SkMatrix fLocalMatrix;
GrBitmapTextContext(GrContext*, const SkDeviceProperties&);
bool canDraw(const SkPaint& paint, const SkMatrix& viewMatrix) SK_OVERRIDE;
virtual void onDrawText(const GrPaint&, const SkPaint&, const SkMatrix& viewMatrix,
const char text[], size_t byteLength,
SkScalar x, SkScalar y) SK_OVERRIDE;
virtual void onDrawPosText(const GrPaint&, const SkPaint&, const SkMatrix& viewMatrix,
const char text[], size_t byteLength,
const SkScalar pos[], int scalarsPerPosition,
const SkPoint& offset) SK_OVERRIDE;
void init(const GrPaint&, const SkPaint&);
void appendGlyph(GrGlyph::PackedID, SkFixed left, SkFixed top, GrFontScaler*);
bool uploadGlyph(GrGlyph*, GrFontScaler*);
void flush(); // automatically called by destructor
void finish();
};
#endif