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 | |
bsalomon@google.com | 858804d | 2012-10-15 14:25:50 +0000 | [diff] [blame^] | 14 | #include "GrContext.h" |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 15 | #include "GrGlyph.h" |
tomhudson@google.com | 375ff85 | 2012-06-29 18:37:57 +0000 | [diff] [blame] | 16 | #include "GrPaint.h" |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 17 | |
tomhudson@google.com | 375ff85 | 2012-06-29 18:37:57 +0000 | [diff] [blame] | 18 | struct GrGpuTextVertex; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 19 | class GrContext; |
tomhudson@google.com | 375ff85 | 2012-06-29 18:37:57 +0000 | [diff] [blame] | 20 | class GrTextStrike; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 21 | class GrFontScaler; |
tomhudson@google.com | 375ff85 | 2012-06-29 18:37:57 +0000 | [diff] [blame] | 22 | class GrDrawTarget; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 23 | |
tomhudson@google.com | 375ff85 | 2012-06-29 18:37:57 +0000 | [diff] [blame] | 24 | class GrTextContext { |
bsalomon@google.com | f4a9c82 | 2012-03-16 14:02:46 +0000 | [diff] [blame] | 25 | public: |
bsalomon@google.com | 0e354aa | 2012-10-08 20:44:25 +0000 | [diff] [blame] | 26 | GrTextContext(GrContext*, const GrPaint&); |
tomhudson@google.com | 375ff85 | 2012-06-29 18:37:57 +0000 | [diff] [blame] | 27 | ~GrTextContext(); |
reed@google.com | fa35e3d | 2012-06-26 20:16:17 +0000 | [diff] [blame] | 28 | |
tomhudson@google.com | 375ff85 | 2012-06-29 18:37:57 +0000 | [diff] [blame] | 29 | void drawPackedGlyph(GrGlyph::PackedID, GrFixed left, GrFixed top, |
| 30 | GrFontScaler*); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 31 | |
tomhudson@google.com | 375ff85 | 2012-06-29 18:37:57 +0000 | [diff] [blame] | 32 | void flush(); // optional; automatically called by destructor |
bsalomon@google.com | f4a9c82 | 2012-03-16 14:02:46 +0000 | [diff] [blame] | 33 | |
| 34 | private: |
tomhudson@google.com | 375ff85 | 2012-06-29 18:37:57 +0000 | [diff] [blame] | 35 | GrPaint fPaint; |
| 36 | GrVertexLayout fVertexLayout; |
| 37 | GrContext* fContext; |
| 38 | GrDrawTarget* fDrawTarget; |
| 39 | |
tomhudson@google.com | 375ff85 | 2012-06-29 18:37:57 +0000 | [diff] [blame] | 40 | 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.com | 858804d | 2012-10-15 14:25:50 +0000 | [diff] [blame^] | 53 | GrGpuTextVertex* fVertices; |
tomhudson@google.com | 375ff85 | 2012-06-29 18:37:57 +0000 | [diff] [blame] | 54 | |
bsalomon@google.com | 858804d | 2012-10-15 14:25:50 +0000 | [diff] [blame^] | 55 | int32_t fMaxVertices; |
| 56 | GrTexture* fCurrTexture; |
| 57 | int fCurrVertex; |
tomhudson@google.com | 375ff85 | 2012-06-29 18:37:57 +0000 | [diff] [blame] | 58 | |
bsalomon@google.com | 858804d | 2012-10-15 14:25:50 +0000 | [diff] [blame^] | 59 | GrIRect fClipRect; |
| 60 | GrContext::AutoMatrix fAutoMatrix; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 61 | }; |
| 62 | |
| 63 | #endif |
tomhudson@google.com | 375ff85 | 2012-06-29 18:37:57 +0000 | [diff] [blame] | 64 | |