epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame^] | 1 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 2 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame^] | 3 | * 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.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame^] | 10 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 11 | #ifndef GrTextContext_DEFINED |
| 12 | #define GrTextContext_DEFINED |
| 13 | |
| 14 | #include "GrGlyph.h" |
bsalomon@google.com | 86afc2a | 2011-02-16 16:12:19 +0000 | [diff] [blame] | 15 | #include "GrPaint.h" |
bsalomon@google.com | cc4dac3 | 2011-05-10 13:52:42 +0000 | [diff] [blame] | 16 | #include "GrMatrix.h" |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 17 | |
bsalomon@google.com | 86afc2a | 2011-02-16 16:12:19 +0000 | [diff] [blame] | 18 | struct GrGpuTextVertex; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 19 | class GrContext; |
| 20 | class GrTextStrike; |
| 21 | class GrFontScaler; |
bsalomon@google.com | ffca400 | 2011-02-22 20:34:01 +0000 | [diff] [blame] | 22 | class GrDrawTarget; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 23 | |
| 24 | class GrTextContext { |
| 25 | public: |
bsalomon@google.com | 5782d71 | 2011-01-21 21:03:59 +0000 | [diff] [blame] | 26 | GrTextContext(GrContext*, |
| 27 | const GrPaint& paint, |
| 28 | const GrMatrix* extMatrix = NULL); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 29 | ~GrTextContext(); |
| 30 | |
| 31 | void drawPackedGlyph(GrGlyph::PackedID, GrFixed left, GrFixed top, |
| 32 | GrFontScaler*); |
| 33 | |
| 34 | void flush(); // optional; automatically called by destructor |
| 35 | |
| 36 | private: |
bsalomon@google.com | 7d34d2e | 2011-01-24 17:41:47 +0000 | [diff] [blame] | 37 | GrPaint fPaint; |
| 38 | GrVertexLayout fVertexLayout; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 39 | GrContext* fContext; |
| 40 | GrDrawTarget* fDrawTarget; |
| 41 | |
| 42 | GrMatrix fExtMatrix; |
| 43 | GrFontScaler* fScaler; |
| 44 | GrTextStrike* fStrike; |
| 45 | |
| 46 | inline void flushGlyphs(); |
bsalomon@google.com | 3914958 | 2011-06-13 21:55:32 +0000 | [diff] [blame] | 47 | void setupDrawTarget(); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 48 | |
| 49 | enum { |
| 50 | kMinRequestedGlyphs = 1, |
| 51 | kDefaultRequestedGlyphs = 64, |
| 52 | kMinRequestedVerts = kMinRequestedGlyphs * 4, |
| 53 | kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4, |
| 54 | }; |
| 55 | |
| 56 | GrGpuTextVertex* fVertices; |
bsalomon@google.com | 5782d71 | 2011-01-21 21:03:59 +0000 | [diff] [blame] | 57 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 58 | 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 | |