blob: a5982517d281ba8fd50f7e086a50e05c71b9d95e [file] [log] [blame]
reed@google.comac10a2d2010-12-22 21:39:39 +00001/*
2 Copyright 2010 Google Inc.
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 */
16
17
18#ifndef GrTextContext_DEFINED
19#define GrTextContext_DEFINED
20
21#include "GrGlyph.h"
bsalomon@google.com86afc2a2011-02-16 16:12:19 +000022#include "GrPaint.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000023
bsalomon@google.com86afc2a2011-02-16 16:12:19 +000024struct GrGpuTextVertex;
25class GrMatrix;
reed@google.comac10a2d2010-12-22 21:39:39 +000026class GrContext;
27class GrTextStrike;
28class GrFontScaler;
bsalomon@google.comffca4002011-02-22 20:34:01 +000029class GrDrawTarget;
reed@google.comac10a2d2010-12-22 21:39:39 +000030
31class GrTextContext {
32public:
bsalomon@google.com5782d712011-01-21 21:03:59 +000033 GrTextContext(GrContext*,
34 const GrPaint& paint,
35 const GrMatrix* extMatrix = NULL);
reed@google.comac10a2d2010-12-22 21:39:39 +000036 ~GrTextContext();
37
38 void drawPackedGlyph(GrGlyph::PackedID, GrFixed left, GrFixed top,
39 GrFontScaler*);
40
41 void flush(); // optional; automatically called by destructor
42
43private:
bsalomon@google.com7d34d2e2011-01-24 17:41:47 +000044 GrPaint fPaint;
45 GrVertexLayout fVertexLayout;
reed@google.comac10a2d2010-12-22 21:39:39 +000046 GrContext* fContext;
47 GrDrawTarget* fDrawTarget;
48
49 GrMatrix fExtMatrix;
50 GrFontScaler* fScaler;
51 GrTextStrike* fStrike;
52
53 inline void flushGlyphs();
54
55 enum {
56 kMinRequestedGlyphs = 1,
57 kDefaultRequestedGlyphs = 64,
58 kMinRequestedVerts = kMinRequestedGlyphs * 4,
59 kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4,
60 };
61
62 GrGpuTextVertex* fVertices;
bsalomon@google.com5782d712011-01-21 21:03:59 +000063
reed@google.comac10a2d2010-12-22 21:39:39 +000064 int32_t fMaxVertices;
65 GrTexture* fCurrTexture;
66 int fCurrVertex;
67
68 GrIRect fClipRect;
69 GrMatrix fOrigViewMatrix; // restore previous viewmatrix
70};
71
72#endif
73
74