Chromium Code Reviews| 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 12 matching lines...) Expand all Loading... | |
| 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 static bool CanDraw(const SkPaint&, const SkMatrix&) { return false; } | |
|
reed1
2014/01/29 17:18:56
all of these static-but-appear-to-be-overrides ver
jvanverth1
2014/01/29 19:25:59
I've removed this one. I left the others as static
| |
| 34 | |
| 33 protected: | 35 protected: |
| 34 GrTextContext(GrContext*, const GrPaint&, const SkPaint&, const SkDeviceProp erties&); | 36 GrTextContext(GrContext*, const GrPaint&, const SkPaint&, const SkDeviceProp erties&); |
| 35 | 37 |
| 36 static GrFontScaler* GetGrFontScaler(SkGlyphCache* cache); | 38 static GrFontScaler* GetGrFontScaler(SkGlyphCache* cache); |
| 37 static void MeasureText(SkGlyphCache* cache, SkDrawCacheProc glyphCacheProc, | 39 static void MeasureText(SkGlyphCache* cache, SkDrawCacheProc glyphCacheProc, |
| 38 const char text[], size_t byteLength, SkVector* stop Vector); | 40 const char text[], size_t byteLength, SkVector* stop Vector); |
| 39 | 41 |
| 40 GrContext* fContext; | 42 GrContext* fContext; |
| 41 GrPaint fPaint; | 43 GrPaint fPaint; |
| 42 SkPaint fSkPaint; | 44 SkPaint fSkPaint; |
| 43 SkDeviceProperties fDeviceProperties; | 45 SkDeviceProperties fDeviceProperties; |
| 44 GrDrawTarget* fDrawTarget; | 46 GrDrawTarget* fDrawTarget; |
| 45 | 47 |
| 46 SkIRect fClipRect; | 48 SkIRect fClipRect; |
| 47 }; | 49 }; |
| 48 | 50 |
| 49 /* | 51 /* |
| 50 * These classes wrap the creation of a single text context for a given GPU devi ce. The | 52 * 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. | 53 * assumption is that we'll only be using one text context at a time for that de vice. |
| 52 */ | 54 */ |
| 53 class GrTextContextManager { | 55 class GrTextContextManager { |
| 54 public: | 56 public: |
| 55 virtual ~GrTextContextManager() {} | 57 virtual ~GrTextContextManager() {} |
| 56 virtual GrTextContext* create(GrContext* grContext, const GrPaint& grPaint, | 58 virtual GrTextContext* create(GrContext* grContext, const GrPaint& grPaint, |
| 57 const SkPaint& skPaint, const SkDeviceProperti es& props) = 0; | 59 const SkPaint& skPaint, const SkDeviceProperti es& props) = 0; |
| 60 virtual bool canDraw(const SkPaint& paint, const SkMatrix& ctm) = 0; | |
| 58 }; | 61 }; |
| 59 | 62 |
| 60 template <class TextContextClass> | 63 template <class TextContextClass> |
| 61 class GrTTextContextManager : public GrTextContextManager { | 64 class GrTTextContextManager : public GrTextContextManager { |
| 62 private: | 65 private: |
| 63 class ManagedTextContext : public TextContextClass { | 66 class ManagedTextContext : public TextContextClass { |
| 64 public: | 67 public: |
| 65 virtual ~ManagedTextContext() {} | 68 virtual ~ManagedTextContext() {} |
| 66 | 69 |
| 67 ManagedTextContext(GrContext* grContext, | 70 ManagedTextContext(GrContext* grContext, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 103 SK_OVERRIDE { | 106 SK_OVERRIDE { |
| 104 // add check for usePath here? | 107 // add check for usePath here? |
| 105 SkASSERT(!fUsed); | 108 SkASSERT(!fUsed); |
| 106 ManagedTextContext* obj = SkNEW_PLACEMENT_ARGS(fAllocation, ManagedTextC ontext, | 109 ManagedTextContext* obj = SkNEW_PLACEMENT_ARGS(fAllocation, ManagedTextC ontext, |
| 107 (grContext, grPaint, skPa int, properties, | 110 (grContext, grPaint, skPa int, properties, |
| 108 this)); | 111 this)); |
| 109 fUsed = true; | 112 fUsed = true; |
| 110 return obj; | 113 return obj; |
| 111 } | 114 } |
| 112 | 115 |
| 116 virtual bool canDraw(const SkPaint& paint, const SkMatrix& ctm) SK_OVERRIDE { | |
| 117 return TextContextClass::CanDraw(paint, ctm); | |
| 118 } | |
| 119 | |
| 113 private: | 120 private: |
| 114 void recycle(GrTextContext* textContext) { | 121 void recycle(GrTextContext* textContext) { |
| 115 SkASSERT((void*)textContext == fAllocation); | 122 SkASSERT((void*)textContext == fAllocation); |
| 116 SkASSERT(fUsed); | 123 SkASSERT(fUsed); |
| 117 fUsed = false; | 124 fUsed = false; |
| 118 } | 125 } |
| 119 | 126 |
| 120 void* fAllocation; | 127 void* fAllocation; |
| 121 bool fUsed; | 128 bool fUsed; |
| 122 }; | 129 }; |
| 123 | 130 |
| 124 #endif | 131 #endif |
| OLD | NEW |