1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/src/gpu/GrDistanceFieldTextContext.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 GrDistanceFieldTextContext_DEFINED 1.12 +#define GrDistanceFieldTextContext_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 distance field fonts 1.20 + */ 1.21 +class GrDistanceFieldTextContext : public GrTextContext { 1.22 +public: 1.23 + GrDistanceFieldTextContext(GrContext*, const SkDeviceProperties&); 1.24 + virtual ~GrDistanceFieldTextContext(); 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 + SkScalar fTextRatio; 1.38 + 1.39 + void init(const GrPaint&, const SkPaint&); 1.40 + void drawPackedGlyph(GrGlyph::PackedID, GrFixed left, GrFixed top, GrFontScaler*); 1.41 + void flushGlyphs(); // automatically called by destructor 1.42 + void finish(); 1.43 + 1.44 + enum { 1.45 + kMinRequestedGlyphs = 1, 1.46 + kDefaultRequestedGlyphs = 64, 1.47 + kMinRequestedVerts = kMinRequestedGlyphs * 4, 1.48 + kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4, 1.49 + }; 1.50 + 1.51 + SkPoint* fVertices; 1.52 + int32_t fMaxVertices; 1.53 + GrTexture* fCurrTexture; 1.54 + int fCurrVertex; 1.55 +}; 1.56 + 1.57 +#endif