GrTextContext.h revision 4c18e9fbb685cccf23342757e786027a032197da
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 "GrPoint.h" 12#include "GrGlyph.h" 13#include "GrPaint.h" 14#include "SkDeviceProperties.h" 15 16#include "SkPostConfig.h" 17 18class GrContext; 19class GrDrawTarget; 20class GrFontScaler; 21 22/* 23 * This class wraps the state for a single text render 24 */ 25class GrTextContext { 26public: 27 virtual ~GrTextContext() {} 28 virtual void drawText(const GrPaint&, const SkPaint&, const char text[], size_t byteLength, 29 SkScalar x, SkScalar y) = 0; 30 virtual void drawPosText(const GrPaint&, const SkPaint&, 31 const char text[], size_t byteLength, 32 const SkScalar pos[], SkScalar constY, 33 int scalarsPerPosition) = 0; 34 35 virtual bool canDraw(const SkPaint& paint) = 0; 36 37protected: 38 GrTextContext(GrContext*, const SkDeviceProperties&); 39 40 static GrFontScaler* GetGrFontScaler(SkGlyphCache* cache); 41 static void MeasureText(SkGlyphCache* cache, SkDrawCacheProc glyphCacheProc, 42 const char text[], size_t byteLength, SkVector* stopVector); 43 44 void init(const GrPaint&, const SkPaint&); 45 void finish() { fDrawTarget = NULL; } 46 47 GrContext* fContext; 48 SkDeviceProperties fDeviceProperties; 49 50 GrDrawTarget* fDrawTarget; 51 SkIRect fClipRect; 52 GrPaint fPaint; 53 SkPaint fSkPaint; 54}; 55 56#endif 57