blob: 5204da4b01efa4f022a9fe47403dc0a6dfc409bb [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
bsalomon@google.com858804d2012-10-15 14:25:50 +000011#include "GrContext.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"
reed@google.comac10a2d2010-12-22 21:39:39 +000014
15class GrContext;
tomhudson@google.com375ff852012-06-29 18:37:57 +000016class GrTextStrike;
reed@google.comac10a2d2010-12-22 21:39:39 +000017class GrFontScaler;
tomhudson@google.com375ff852012-06-29 18:37:57 +000018class GrDrawTarget;
reed@google.comac10a2d2010-12-22 21:39:39 +000019
tomhudson@google.com375ff852012-06-29 18:37:57 +000020class GrTextContext {
bsalomon@google.comf4a9c822012-03-16 14:02:46 +000021public:
bsalomon@google.com0e354aa2012-10-08 20:44:25 +000022 GrTextContext(GrContext*, const GrPaint&);
tomhudson@google.com375ff852012-06-29 18:37:57 +000023 ~GrTextContext();
reed@google.comfa35e3d2012-06-26 20:16:17 +000024
tomhudson@google.com375ff852012-06-29 18:37:57 +000025 void drawPackedGlyph(GrGlyph::PackedID, GrFixed left, GrFixed top,
26 GrFontScaler*);
reed@google.comac10a2d2010-12-22 21:39:39 +000027
tomhudson@google.com375ff852012-06-29 18:37:57 +000028 void flush(); // optional; automatically called by destructor
bsalomon@google.comf4a9c822012-03-16 14:02:46 +000029
30private:
tomhudson@google.com375ff852012-06-29 18:37:57 +000031 GrPaint fPaint;
tomhudson@google.com375ff852012-06-29 18:37:57 +000032 GrContext* fContext;
33 GrDrawTarget* fDrawTarget;
34
tomhudson@google.com375ff852012-06-29 18:37:57 +000035 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
bsalomon@google.com85983282013-02-07 22:00:29 +000048 SkPoint* fVertices;
bsalomon@google.com858804d2012-10-15 14:25:50 +000049 int32_t fMaxVertices;
50 GrTexture* fCurrTexture;
51 int fCurrVertex;
tomhudson@google.com375ff852012-06-29 18:37:57 +000052
commit-bot@chromium.orgfd03d4a2013-07-17 21:39:42 +000053 SkIRect fClipRect;
bsalomon@google.com858804d2012-10-15 14:25:50 +000054 GrContext::AutoMatrix fAutoMatrix;
reed@google.comac10a2d2010-12-22 21:39:39 +000055};
56
57#endif