| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * Copyright 2010 Google Inc. | 2  * Copyright 2010 Google Inc. | 
| 3  * | 3  * | 
| 4  * Use of this source code is governed by a BSD-style license that can be | 4  * Use of this source code is governed by a BSD-style license that can be | 
| 5  * found in the LICENSE file. | 5  * found in the LICENSE file. | 
| 6  */ | 6  */ | 
| 7 | 7 | 
| 8 #ifndef GrTextContext_DEFINED | 8 #ifndef GrTextContext_DEFINED | 
| 9 #define GrTextContext_DEFINED | 9 #define GrTextContext_DEFINED | 
| 10 | 10 | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
| 22 /* | 22 /* | 
| 23  * This class wraps the state for a single text render | 23  * This class wraps the state for a single text render | 
| 24  */ | 24  */ | 
| 25 class GrTextContext { | 25 class GrTextContext { | 
| 26 public: | 26 public: | 
| 27     virtual ~GrTextContext() {} | 27     virtual ~GrTextContext() {} | 
| 28     virtual void drawText(const char text[], size_t byteLength, SkScalar x, SkSc
     alar y) = 0; | 28     virtual void drawText(const char text[], size_t byteLength, SkScalar x, SkSc
     alar y) = 0; | 
| 29     virtual void drawPosText(const char text[], size_t byteLength, | 29     virtual void drawPosText(const char text[], size_t byteLength, | 
| 30                              const SkScalar pos[], SkScalar constY, | 30                              const SkScalar pos[], SkScalar constY, | 
| 31                              int scalarsPerPosition) = 0; | 31                              int scalarsPerPosition) = 0; | 
| 32 | 32 | 
| 33 protected: | 33 protected: | 
| 34     GrTextContext(GrContext*, const GrPaint&, const SkPaint&, const SkDeviceProp
     erties&); | 34     GrTextContext(GrContext*, const GrPaint&, const SkPaint&, const SkDeviceProp
     erties&); | 
| 35 | 35 | 
| 36     static GrFontScaler* GetGrFontScaler(SkGlyphCache* cache); | 36     static GrFontScaler* GetGrFontScaler(SkGlyphCache* cache); | 
| 37     static void MeasureText(SkGlyphCache* cache, SkDrawCacheProc glyphCacheProc, | 37     static void MeasureText(SkGlyphCache* cache, SkDrawCacheProc glyphCacheProc, | 
| 38                             const char text[], size_t byteLength, SkVector* stop
     Vector); | 38                             const char text[], size_t byteLength, SkVector* stop
     Vector); | 
| 39 | 39 | 
| 40     GrContext*         fContext; | 40     GrContext*         fContext; | 
| 41     GrPaint            fPaint; | 41     GrPaint            fPaint; | 
| 42     SkPaint            fSkPaint; | 42     SkPaint            fSkPaint; | 
| 43     SkDeviceProperties fDeviceProperties; | 43     SkDeviceProperties fDeviceProperties; | 
| 44     GrDrawTarget*      fDrawTarget; | 44     GrDrawTarget*      fDrawTarget; | 
| 45 | 45 | 
| 46     SkIRect            fClipRect; | 46     SkIRect            fClipRect; | 
| 47 }; | 47 }; | 
| 48 | 48 | 
| 49 /* | 49 /* | 
| 50  * These classes wrap the creation of a single text context for a given GPU devi
     ce. The | 50  * These classes wrap the creation of a single text context for a given GPU devi
     ce. The | 
| 51  * assumption is that we'll only be using one text context at a time for that de
     vice. | 51  * assumption is that we'll only be using one text context at a time for that de
     vice. | 
| 52  */ | 52  */ | 
| 53 class GrTextContextManager { | 53 class GrTextContextManager { | 
| 54 public: | 54 public: | 
| 55     virtual ~GrTextContextManager() {} | 55     virtual ~GrTextContextManager() {} | 
| 56     virtual GrTextContext* create(GrContext* grContext, const GrPaint& grPaint, | 56     virtual GrTextContext* create(GrContext* grContext, const GrPaint& grPaint, | 
| 57                                   const SkPaint& skPaint, const SkDeviceProperti
     es& props) = 0; | 57                                   const SkPaint& skPaint, const SkDeviceProperti
     es& props) = 0; | 
|  | 58     virtual bool canDraw(const SkPaint& paint, const SkMatrix& ctm) = 0; | 
| 58 }; | 59 }; | 
| 59 | 60 | 
| 60 template <class TextContextClass> | 61 template <class TextContextClass> | 
| 61 class GrTTextContextManager : public GrTextContextManager { | 62 class GrTTextContextManager : public GrTextContextManager { | 
| 62 private: | 63 private: | 
| 63     class ManagedTextContext : public TextContextClass { | 64     class ManagedTextContext : public TextContextClass { | 
| 64     public: | 65     public: | 
| 65         virtual ~ManagedTextContext() {} | 66         virtual ~ManagedTextContext() {} | 
| 66 | 67 | 
| 67         ManagedTextContext(GrContext* grContext, | 68         ManagedTextContext(GrContext* grContext, | 
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 103                                  SK_OVERRIDE { | 104                                  SK_OVERRIDE { | 
| 104         // add check for usePath here? | 105         // add check for usePath here? | 
| 105         SkASSERT(!fUsed); | 106         SkASSERT(!fUsed); | 
| 106         ManagedTextContext* obj = SkNEW_PLACEMENT_ARGS(fAllocation, ManagedTextC
     ontext, | 107         ManagedTextContext* obj = SkNEW_PLACEMENT_ARGS(fAllocation, ManagedTextC
     ontext, | 
| 107                                                        (grContext, grPaint, skPa
     int, properties, | 108                                                        (grContext, grPaint, skPa
     int, properties, | 
| 108                                                         this)); | 109                                                         this)); | 
| 109         fUsed = true; | 110         fUsed = true; | 
| 110         return obj; | 111         return obj; | 
| 111     } | 112     } | 
| 112 | 113 | 
|  | 114     virtual bool canDraw(const SkPaint& paint, const SkMatrix& ctm) SK_OVERRIDE 
     { | 
|  | 115         return TextContextClass::CanDraw(paint, ctm); | 
|  | 116     } | 
|  | 117 | 
| 113 private: | 118 private: | 
| 114     void recycle(GrTextContext* textContext) { | 119     void recycle(GrTextContext* textContext) { | 
| 115         SkASSERT((void*)textContext == fAllocation); | 120         SkASSERT((void*)textContext == fAllocation); | 
| 116         SkASSERT(fUsed); | 121         SkASSERT(fUsed); | 
| 117         fUsed = false; | 122         fUsed = false; | 
| 118     } | 123     } | 
| 119 | 124 | 
| 120     void* fAllocation; | 125     void* fAllocation; | 
| 121     bool  fUsed; | 126     bool  fUsed; | 
| 122 }; | 127 }; | 
| 123 | 128 | 
| 124 #endif | 129 #endif | 
| OLD | NEW | 
|---|