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" 22 #include "GrPaint.h" 23 #include "GrMatrix.h" 24 25 struct GrGpuTextVertex; 26 class GrContext; 27 class GrTextStrike; 28 class GrFontScaler; 29 class GrDrawTarget; 30 31 class GrTextContext { 32 public: 33 GrTextContext(GrContext*, 34 const GrPaint& paint, 35 const GrMatrix* extMatrix = NULL); 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: 44 GrPaint fPaint; 45 GrVertexLayout fVertexLayout; 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; 63 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 75