blob: 6b28b79efcc0412b5a78e38eb916245336471d58 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
reed@google.comac10a2d2010-12-22 21:39:39 +00002/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00003 * Copyright 2010 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
reed@google.comac10a2d2010-12-22 21:39:39 +00007 */
8
9
epoger@google.comec3ed6a2011-07-28 14:26:00 +000010
reed@google.comac10a2d2010-12-22 21:39:39 +000011#ifndef GrTextContext_DEFINED
12#define GrTextContext_DEFINED
13
bsalomon@google.com858804d2012-10-15 14:25:50 +000014#include "GrContext.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000015#include "GrGlyph.h"
tomhudson@google.com375ff852012-06-29 18:37:57 +000016#include "GrPaint.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000017
tomhudson@google.com375ff852012-06-29 18:37:57 +000018struct GrGpuTextVertex;
reed@google.comac10a2d2010-12-22 21:39:39 +000019class GrContext;
tomhudson@google.com375ff852012-06-29 18:37:57 +000020class GrTextStrike;
reed@google.comac10a2d2010-12-22 21:39:39 +000021class GrFontScaler;
tomhudson@google.com375ff852012-06-29 18:37:57 +000022class GrDrawTarget;
reed@google.comac10a2d2010-12-22 21:39:39 +000023
tomhudson@google.com375ff852012-06-29 18:37:57 +000024class GrTextContext {
bsalomon@google.comf4a9c822012-03-16 14:02:46 +000025public:
bsalomon@google.com0e354aa2012-10-08 20:44:25 +000026 GrTextContext(GrContext*, const GrPaint&);
tomhudson@google.com375ff852012-06-29 18:37:57 +000027 ~GrTextContext();
reed@google.comfa35e3d2012-06-26 20:16:17 +000028
tomhudson@google.com375ff852012-06-29 18:37:57 +000029 void drawPackedGlyph(GrGlyph::PackedID, GrFixed left, GrFixed top,
30 GrFontScaler*);
reed@google.comac10a2d2010-12-22 21:39:39 +000031
tomhudson@google.com375ff852012-06-29 18:37:57 +000032 void flush(); // optional; automatically called by destructor
bsalomon@google.comf4a9c822012-03-16 14:02:46 +000033
34private:
tomhudson@google.com375ff852012-06-29 18:37:57 +000035 GrPaint fPaint;
36 GrVertexLayout fVertexLayout;
37 GrContext* fContext;
38 GrDrawTarget* fDrawTarget;
39
tomhudson@google.com375ff852012-06-29 18:37:57 +000040 GrFontScaler* fScaler;
41 GrTextStrike* fStrike;
42
43 inline void flushGlyphs();
44 void setupDrawTarget();
45
46 enum {
47 kMinRequestedGlyphs = 1,
48 kDefaultRequestedGlyphs = 64,
49 kMinRequestedVerts = kMinRequestedGlyphs * 4,
50 kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4,
51 };
52
bsalomon@google.com858804d2012-10-15 14:25:50 +000053 GrGpuTextVertex* fVertices;
tomhudson@google.com375ff852012-06-29 18:37:57 +000054
bsalomon@google.com858804d2012-10-15 14:25:50 +000055 int32_t fMaxVertices;
56 GrTexture* fCurrTexture;
57 int fCurrVertex;
tomhudson@google.com375ff852012-06-29 18:37:57 +000058
bsalomon@google.com858804d2012-10-15 14:25:50 +000059 GrIRect fClipRect;
60 GrContext::AutoMatrix fAutoMatrix;
reed@google.comac10a2d2010-12-22 21:39:39 +000061};
62
63#endif
tomhudson@google.com375ff852012-06-29 18:37:57 +000064