blob: 5983e358c896a65b4678a1cb6b765311e89d4de9 [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"
bsalomon@google.com86afc2a2011-02-16 16:12:19 +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
bsalomon@google.com86afc2a2011-02-16 16:12:19 +000018struct GrGpuTextVertex;
reed@google.comac10a2d2010-12-22 21:39:39 +000019class GrContext;
20class GrTextStrike;
21class GrFontScaler;
bsalomon@google.comffca4002011-02-22 20:34:01 +000022class GrDrawTarget;
reed@google.comac10a2d2010-12-22 21:39:39 +000023
24class GrTextContext {
25public:
bsalomon@google.com5782d712011-01-21 21:03:59 +000026 GrTextContext(GrContext*,
27 const GrPaint& paint,
28 const GrMatrix* extMatrix = NULL);
reed@google.comac10a2d2010-12-22 21:39:39 +000029 ~GrTextContext();
30
31 void drawPackedGlyph(GrGlyph::PackedID, GrFixed left, GrFixed top,
32 GrFontScaler*);
33
34 void flush(); // optional; automatically called by destructor
35
36private:
bsalomon@google.com7d34d2e2011-01-24 17:41:47 +000037 GrPaint fPaint;
38 GrVertexLayout fVertexLayout;
reed@google.comac10a2d2010-12-22 21:39:39 +000039 GrContext* fContext;
40 GrDrawTarget* fDrawTarget;
41
42 GrMatrix fExtMatrix;
43 GrFontScaler* fScaler;
44 GrTextStrike* fStrike;
45
46 inline void flushGlyphs();
bsalomon@google.com39149582011-06-13 21:55:32 +000047 void setupDrawTarget();
reed@google.comac10a2d2010-12-22 21:39:39 +000048
49 enum {
50 kMinRequestedGlyphs = 1,
51 kDefaultRequestedGlyphs = 64,
52 kMinRequestedVerts = kMinRequestedGlyphs * 4,
53 kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4,
54 };
55
56 GrGpuTextVertex* fVertices;
bsalomon@google.com5782d712011-01-21 21:03:59 +000057
reed@google.comac10a2d2010-12-22 21:39:39 +000058 int32_t fMaxVertices;
59 GrTexture* fCurrTexture;
60 int fCurrVertex;
61
62 GrIRect fClipRect;
63 GrMatrix fOrigViewMatrix; // restore previous viewmatrix
64};
65
66#endif
67
68