blob: c139e222959c344944bdf2d66bc37c2aa3bee4d5 [file] [log] [blame]
reed@google.comac10a2d2010-12-22 21:39:39 +00001/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00002 * 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.
reed@google.comac10a2d2010-12-22 21:39:39 +00006 */
7
reed@google.comac10a2d2010-12-22 21:39:39 +00008#ifndef GrTextContext_DEFINED
9#define GrTextContext_DEFINED
10
11#include "GrGlyph.h"
tomhudson@google.com375ff852012-06-29 18:37:57 +000012#include "GrPaint.h"
commit-bot@chromium.orge8612d92014-01-28 22:02:07 +000013#include "SkDeviceProperties.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000014
commit-bot@chromium.orgcc40f062014-01-24 14:38:27 +000015#include "SkPostConfig.h"
16
reed@google.comac10a2d2010-12-22 21:39:39 +000017class GrContext;
tomhudson@google.com375ff852012-06-29 18:37:57 +000018class GrDrawTarget;
jvanverth@google.comc7a40fa2013-10-16 18:15:34 +000019class GrFontScaler;
reed@google.comac10a2d2010-12-22 21:39:39 +000020
jvanverth@google.comc7a40fa2013-10-16 18:15:34 +000021/*
22 * This class wraps the state for a single text render
23 */
tomhudson@google.com375ff852012-06-29 18:37:57 +000024class GrTextContext {
bsalomon@google.comf4a9c822012-03-16 14:02:46 +000025public:
commit-bot@chromium.orgcc40f062014-01-24 14:38:27 +000026 virtual ~GrTextContext() {}
skia.committer@gmail.com4c18e9f2014-01-31 03:01:59 +000027 virtual void drawText(const GrPaint&, const SkPaint&, const char text[], size_t byteLength,
commit-bot@chromium.orgcbbc4812014-01-30 22:05:47 +000028 SkScalar x, SkScalar y) = 0;
29 virtual void drawPosText(const GrPaint&, const SkPaint&,
30 const char text[], size_t byteLength,
robertphillipsd46b8d22014-09-29 04:48:52 -070031 const SkScalar pos[], SkScalar constY,
32 int scalarsPerPosition) = 0;
commit-bot@chromium.orgcbbc4812014-01-30 22:05:47 +000033
34 virtual bool canDraw(const SkPaint& paint) = 0;
skia.committer@gmail.com4c18e9f2014-01-31 03:01:59 +000035
jvanverth@google.comc7a40fa2013-10-16 18:15:34 +000036protected:
commit-bot@chromium.orgcbbc4812014-01-30 22:05:47 +000037 GrTextContext(GrContext*, const SkDeviceProperties&);
reed@google.comfa35e3d2012-06-26 20:16:17 +000038
commit-bot@chromium.orge8612d92014-01-28 22:02:07 +000039 static GrFontScaler* GetGrFontScaler(SkGlyphCache* cache);
40 static void MeasureText(SkGlyphCache* cache, SkDrawCacheProc glyphCacheProc,
41 const char text[], size_t byteLength, SkVector* stopVector);
skia.committer@gmail.come5d70152014-01-29 07:01:48 +000042
commit-bot@chromium.orgcbbc4812014-01-30 22:05:47 +000043 void init(const GrPaint&, const SkPaint&);
44 void finish() { fDrawTarget = NULL; }
45
commit-bot@chromium.orge8612d92014-01-28 22:02:07 +000046 GrContext* fContext;
commit-bot@chromium.orgcbbc4812014-01-30 22:05:47 +000047 SkDeviceProperties fDeviceProperties;
48
49 GrDrawTarget* fDrawTarget;
50 SkIRect fClipRect;
commit-bot@chromium.orge8612d92014-01-28 22:02:07 +000051 GrPaint fPaint;
52 SkPaint fSkPaint;
reed@google.comac10a2d2010-12-22 21:39:39 +000053};
54
55#endif