blob: ea089cc766335b96460f27d42bbaadd906cff593 [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
commit-bot@chromium.orge8612d92014-01-28 22:02:07 +000011#include "GrPoint.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000012#include "GrGlyph.h"
tomhudson@google.com375ff852012-06-29 18:37:57 +000013#include "GrPaint.h"
commit-bot@chromium.orge8612d92014-01-28 22:02:07 +000014#include "SkDeviceProperties.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000015
commit-bot@chromium.orgcc40f062014-01-24 14:38:27 +000016#include "SkPostConfig.h"
17
reed@google.comac10a2d2010-12-22 21:39:39 +000018class GrContext;
tomhudson@google.com375ff852012-06-29 18:37:57 +000019class GrDrawTarget;
jvanverth@google.comc7a40fa2013-10-16 18:15:34 +000020class GrFontScaler;
reed@google.comac10a2d2010-12-22 21:39:39 +000021
jvanverth@google.comc7a40fa2013-10-16 18:15:34 +000022/*
23 * This class wraps the state for a single text render
24 */
tomhudson@google.com375ff852012-06-29 18:37:57 +000025class GrTextContext {
bsalomon@google.comf4a9c822012-03-16 14:02:46 +000026public:
commit-bot@chromium.orgcc40f062014-01-24 14:38:27 +000027 virtual ~GrTextContext() {}
commit-bot@chromium.orgcbbc4812014-01-30 22:05:47 +000028 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,
commit-bot@chromium.orge8612d92014-01-28 22:02:07 +000032 const SkScalar pos[], SkScalar constY,
33 int scalarsPerPosition) = 0;
commit-bot@chromium.orgcbbc4812014-01-30 22:05:47 +000034
35 virtual bool canDraw(const SkPaint& paint) = 0;
commit-bot@chromium.org9f94b912014-01-30 15:22:54 +000036
jvanverth@google.comc7a40fa2013-10-16 18:15:34 +000037protected:
commit-bot@chromium.orgcbbc4812014-01-30 22:05:47 +000038 GrTextContext(GrContext*, const SkDeviceProperties&);
reed@google.comfa35e3d2012-06-26 20:16:17 +000039
commit-bot@chromium.orge8612d92014-01-28 22:02:07 +000040 static GrFontScaler* GetGrFontScaler(SkGlyphCache* cache);
41 static void MeasureText(SkGlyphCache* cache, SkDrawCacheProc glyphCacheProc,
42 const char text[], size_t byteLength, SkVector* stopVector);
skia.committer@gmail.come5d70152014-01-29 07:01:48 +000043
commit-bot@chromium.orgcbbc4812014-01-30 22:05:47 +000044 void init(const GrPaint&, const SkPaint&);
45 void finish() { fDrawTarget = NULL; }
46
commit-bot@chromium.orge8612d92014-01-28 22:02:07 +000047 GrContext* fContext;
commit-bot@chromium.orgcbbc4812014-01-30 22:05:47 +000048 SkDeviceProperties fDeviceProperties;
49
50 GrDrawTarget* fDrawTarget;
51 SkIRect fClipRect;
commit-bot@chromium.orge8612d92014-01-28 22:02:07 +000052 GrPaint fPaint;
53 SkPaint fSkPaint;
reed@google.comac10a2d2010-12-22 21:39:39 +000054};
55
56#endif