reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 1 | /* |
| 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.com | 86afc2a | 2011-02-16 16:12:19 +0000 | [diff] [blame] | 22 | #include "GrPaint.h" |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 23 | |
bsalomon@google.com | 86afc2a | 2011-02-16 16:12:19 +0000 | [diff] [blame] | 24 | struct GrGpuTextVertex; |
| 25 | class GrMatrix; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 26 | class GrContext; |
| 27 | class GrTextStrike; |
| 28 | class GrFontScaler; |
bsalomon@google.com | ffca400 | 2011-02-22 20:34:01 +0000 | [diff] [blame^] | 29 | class GrDrawTarget; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 30 | |
| 31 | class GrTextContext { |
| 32 | public: |
bsalomon@google.com | 5782d71 | 2011-01-21 21:03:59 +0000 | [diff] [blame] | 33 | GrTextContext(GrContext*, |
| 34 | const GrPaint& paint, |
| 35 | const GrMatrix* extMatrix = NULL); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 36 | ~GrTextContext(); |
| 37 | |
| 38 | void drawPackedGlyph(GrGlyph::PackedID, GrFixed left, GrFixed top, |
| 39 | GrFontScaler*); |
| 40 | |
| 41 | void flush(); // optional; automatically called by destructor |
| 42 | |
| 43 | private: |
bsalomon@google.com | 7d34d2e | 2011-01-24 17:41:47 +0000 | [diff] [blame] | 44 | GrPaint fPaint; |
| 45 | GrVertexLayout fVertexLayout; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 46 | 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.com | 5782d71 | 2011-01-21 21:03:59 +0000 | [diff] [blame] | 63 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 64 | 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 | |