blob: 29ef00743969b5b37cab8979eb96b22042c10477 [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
14#include "GrGlyph.h"
tomhudson@google.com375ff852012-06-29 18:37:57 +000015#include "GrPaint.h"
bsalomon@google.comcc4dac32011-05-10 13:52:42 +000016#include "GrMatrix.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:
tomhudson@google.com375ff852012-06-29 18:37:57 +000026 GrTextContext(GrContext*,
27 const GrPaint& paint,
28 const GrMatrix* extMatrix = NULL);
29 ~GrTextContext();
reed@google.comfa35e3d2012-06-26 20:16:17 +000030
tomhudson@google.com375ff852012-06-29 18:37:57 +000031 void drawPackedGlyph(GrGlyph::PackedID, GrFixed left, GrFixed top,
32 GrFontScaler*);
reed@google.comac10a2d2010-12-22 21:39:39 +000033
tomhudson@google.com375ff852012-06-29 18:37:57 +000034 void flush(); // optional; automatically called by destructor
bsalomon@google.comf4a9c822012-03-16 14:02:46 +000035
36private:
tomhudson@google.com375ff852012-06-29 18:37:57 +000037 GrPaint fPaint;
38 GrVertexLayout fVertexLayout;
39 GrContext* fContext;
40 GrDrawTarget* fDrawTarget;
41
42 GrMatrix fExtMatrix;
43 GrFontScaler* fScaler;
44 GrTextStrike* fStrike;
45
46 inline void flushGlyphs();
47 void setupDrawTarget();
48
49 enum {
50 kMinRequestedGlyphs = 1,
51 kDefaultRequestedGlyphs = 64,
52 kMinRequestedVerts = kMinRequestedGlyphs * 4,
53 kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4,
54 };
55
56 GrGpuTextVertex* fVertices;
57
58 int32_t fMaxVertices;
59 GrTexture* fCurrTexture;
60 int fCurrVertex;
61
62 GrIRect fClipRect;
63 GrMatrix fOrigViewMatrix; // restore previous viewmatrix
reed@google.comac10a2d2010-12-22 21:39:39 +000064};
65
66#endif
tomhudson@google.com375ff852012-06-29 18:37:57 +000067