1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/src/gpu/GrBitmapTextContext.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,54 @@ 1.4 +/* 1.5 + * Copyright 2013 Google Inc. 1.6 + * 1.7 + * Use of this source code is governed by a BSD-style license that can be 1.8 + * found in the LICENSE file. 1.9 + */ 1.10 + 1.11 +#ifndef GrBitmapTextContext_DEFINED 1.12 +#define GrBitmapTextContext_DEFINED 1.13 + 1.14 +#include "GrTextContext.h" 1.15 + 1.16 +class GrTextStrike; 1.17 + 1.18 +/* 1.19 + * This class implements GrTextContext using standard bitmap fonts 1.20 + */ 1.21 +class GrBitmapTextContext : public GrTextContext { 1.22 +public: 1.23 + GrBitmapTextContext(GrContext*, const SkDeviceProperties&); 1.24 + virtual ~GrBitmapTextContext(); 1.25 + 1.26 + virtual void drawText(const GrPaint&, const SkPaint&, const char text[], size_t byteLength, 1.27 + SkScalar x, SkScalar y) SK_OVERRIDE; 1.28 + virtual void drawPosText(const GrPaint&, const SkPaint&, 1.29 + const char text[], size_t byteLength, 1.30 + const SkScalar pos[], SkScalar constY, 1.31 + int scalarsPerPosition) SK_OVERRIDE; 1.32 + 1.33 + virtual bool canDraw(const SkPaint& paint) SK_OVERRIDE; 1.34 + 1.35 +private: 1.36 + GrTextStrike* fStrike; 1.37 + 1.38 + void init(const GrPaint&, const SkPaint&); 1.39 + void drawPackedGlyph(GrGlyph::PackedID, GrFixed left, GrFixed top, GrFontScaler*); 1.40 + void flushGlyphs(); // automatically called by destructor 1.41 + void finish(); 1.42 + 1.43 + enum { 1.44 + kMinRequestedGlyphs = 1, 1.45 + kDefaultRequestedGlyphs = 64, 1.46 + kMinRequestedVerts = kMinRequestedGlyphs * 4, 1.47 + kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4, 1.48 + }; 1.49 + 1.50 + SkPoint* fVertices; 1.51 + int32_t fMaxVertices; 1.52 + GrTexture* fCurrTexture; 1.53 + int fCurrVertex; 1.54 + SkRect fVertexBounds; 1.55 +}; 1.56 + 1.57 +#endif