Home | History | Annotate | Download | only in gpu
      1 
      2 /*
      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.
      7  */
      8 
      9 
     10 
     11 #ifndef GrTextContext_DEFINED
     12 #define GrTextContext_DEFINED
     13 
     14 #include "GrGlyph.h"
     15 #include "GrPaint.h"
     16 #include "GrMatrix.h"
     17 
     18 struct GrGpuTextVertex;
     19 class GrContext;
     20 class GrTextStrike;
     21 class GrFontScaler;
     22 class GrDrawTarget;
     23 
     24 class GrTextContext {
     25 public:
     26     GrTextContext(GrContext*,
     27                   const GrPaint& paint,
     28                   const GrMatrix* extMatrix = NULL);
     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:
     37     GrPaint         fPaint;
     38     GrVertexLayout  fVertexLayout;
     39     GrContext*      fContext;
     40     GrDrawTarget*   fDrawTarget;
     41 
     42     GrMatrix        fExtMatrix;
     43     GrFontScaler*   fScaler;
     44     GrTextStrike*   fStrike;
     45 
     46     inline void flushGlyphs();
     47     void setupDrawTarget();
     48 
     49     enum {
     50         kMinRequestedGlyphs      = 1,
     51         kDefaultRequestedGlyphs  = 64,
     52         kMinRequestedVerts       = kMinRequestedGlyphs * 4,
     53         kDefaultRequestedVerts   = kDefaultRequestedGlyphs * 4,
     54     };
     55 
     56     GrGpuTextVertex* fVertices;
     57 
     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 
     69