michael@0: /* michael@0: * Copyright 2010 Google Inc. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: #ifndef GrTextContext_DEFINED michael@0: #define GrTextContext_DEFINED michael@0: michael@0: #include "GrPoint.h" michael@0: #include "GrGlyph.h" michael@0: #include "GrPaint.h" michael@0: #include "SkDeviceProperties.h" michael@0: michael@0: #include "SkPostConfig.h" michael@0: michael@0: class GrContext; michael@0: class GrDrawTarget; michael@0: class GrFontScaler; michael@0: michael@0: /* michael@0: * This class wraps the state for a single text render michael@0: */ michael@0: class GrTextContext { michael@0: public: michael@0: virtual ~GrTextContext() {} michael@0: virtual void drawText(const GrPaint&, const SkPaint&, const char text[], size_t byteLength, michael@0: SkScalar x, SkScalar y) = 0; michael@0: virtual void drawPosText(const GrPaint&, const SkPaint&, michael@0: const char text[], size_t byteLength, michael@0: const SkScalar pos[], SkScalar constY, michael@0: int scalarsPerPosition) = 0; michael@0: michael@0: virtual bool canDraw(const SkPaint& paint) = 0; michael@0: michael@0: protected: michael@0: GrTextContext(GrContext*, const SkDeviceProperties&); michael@0: michael@0: static GrFontScaler* GetGrFontScaler(SkGlyphCache* cache); michael@0: static void MeasureText(SkGlyphCache* cache, SkDrawCacheProc glyphCacheProc, michael@0: const char text[], size_t byteLength, SkVector* stopVector); michael@0: michael@0: void init(const GrPaint&, const SkPaint&); michael@0: void finish() { fDrawTarget = NULL; } michael@0: michael@0: GrContext* fContext; michael@0: SkDeviceProperties fDeviceProperties; michael@0: michael@0: GrDrawTarget* fDrawTarget; michael@0: SkIRect fClipRect; michael@0: GrPaint fPaint; michael@0: SkPaint fSkPaint; michael@0: }; michael@0: michael@0: #endif