1 /* 2 * Copyright 2010 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 GrTextContext_DEFINED 9 #define GrTextContext_DEFINED 10 11 #include "GrContext.h" 12 #include "GrGlyph.h" 13 #include "GrPaint.h" 14 15 class GrContext; 16 class GrTextStrike; 17 class GrFontScaler; 18 class GrDrawTarget; 19 20 class GrTextContext { 21 public: 22 GrTextContext(GrContext*, const GrPaint&); 23 ~GrTextContext(); 24 25 void drawPackedGlyph(GrGlyph::PackedID, GrFixed left, GrFixed top, 26 GrFontScaler*); 27 28 void flush(); // optional; automatically called by destructor 29 30 private: 31 GrPaint fPaint; 32 GrContext* fContext; 33 GrDrawTarget* fDrawTarget; 34 35 GrFontScaler* fScaler; 36 GrTextStrike* fStrike; 37 38 inline void flushGlyphs(); 39 void setupDrawTarget(); 40 41 enum { 42 kMinRequestedGlyphs = 1, 43 kDefaultRequestedGlyphs = 64, 44 kMinRequestedVerts = kMinRequestedGlyphs * 4, 45 kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4, 46 }; 47 48 SkPoint* fVertices; 49 int32_t fMaxVertices; 50 GrTexture* fCurrTexture; 51 int fCurrVertex; 52 53 SkIRect fClipRect; 54 GrContext::AutoMatrix fAutoMatrix; 55 }; 56 57 #endif 58