OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2015 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 GrBitmapTextContext_DEFINED | 8 #ifndef GrAtlasTextContext_DEFINED |
9 #define GrBitmapTextContext_DEFINED | 9 #define GrAtlasTextContext_DEFINED |
10 | 10 |
11 #include "GrTextContext.h" | 11 #include "GrTextContext.h" |
12 | 12 |
13 #include "GrGeometryProcessor.h" | 13 #include "GrGeometryProcessor.h" |
14 #include "GrMemoryPool.h" | |
15 #include "SkDescriptor.h" | 14 #include "SkDescriptor.h" |
16 #include "SkTHash.h" | 15 #include "SkTHash.h" |
17 | 16 |
18 class GrBatchTextStrike; | 17 class GrBatchTextStrike; |
19 class GrPipelineBuilder; | 18 class GrPipelineBuilder; |
20 | 19 |
21 /* | 20 /* |
22 * This class implements GrTextContext using standard bitmap fonts, and can also
process textblobs. | 21 * This class implements GrTextContext using standard bitmap fonts, and can also
process textblobs. |
23 * TODO replace GrBitmapTextContext | 22 * TODO replace GrBitmapTextContext |
24 */ | 23 */ |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 | 172 |
174 // TODO use real cache | 173 // TODO use real cache |
175 static void ClearCacheEntry(uint32_t key, BitmapTextBlob**); | 174 static void ClearCacheEntry(uint32_t key, BitmapTextBlob**); |
176 SkTHashMap<uint32_t, BitmapTextBlob*, BitmapTextBlob::Hash> fCache; | 175 SkTHashMap<uint32_t, BitmapTextBlob*, BitmapTextBlob::Hash> fCache; |
177 | 176 |
178 friend class BitmapTextBatch; | 177 friend class BitmapTextBatch; |
179 | 178 |
180 typedef GrTextContext INHERITED; | 179 typedef GrTextContext INHERITED; |
181 }; | 180 }; |
182 | 181 |
183 class GrTextStrike; | |
184 | |
185 /* | |
186 * This class implements GrTextContext using standard bitmap fonts | |
187 */ | |
188 class GrBitmapTextContext : public GrTextContext { | |
189 public: | |
190 static GrBitmapTextContext* Create(GrContext*, SkGpuDevice*, const SkDevice
Properties&); | |
191 | |
192 virtual ~GrBitmapTextContext() {} | |
193 | |
194 private: | |
195 GrTextStrike* fStrike; | |
196 void* fVertices; | |
197 int fCurrVertex; | |
198 int fAllocVertexCount; | |
199 int fTotalVertexCount; | |
200 SkRect fVertexBounds; | |
201 GrTexture* fCurrTexture; | |
202 GrMaskFormat fCurrMaskFormat; | |
203 SkAutoTUnref<const GrGeometryProcessor> fCachedGeometryProcessor; | |
204 // Used to check whether fCachedEffect is still valid. | |
205 uint32_t fEffectTextureUniqueID; | |
206 SkMatrix fLocalMatrix; | |
207 | |
208 GrBitmapTextContext(GrContext*, SkGpuDevice*, const SkDeviceProperties&); | |
209 | |
210 bool canDraw(const GrRenderTarget*, const GrClip&, const GrPaint&, | |
211 const SkPaint&, const SkMatrix& viewMatrix) override; | |
212 | |
213 void onDrawText(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPain
t&, | |
214 const SkMatrix& viewMatrix, const char text[], size_t byteLe
ngth, | |
215 SkScalar x, SkScalar y, const SkIRect& regionClipBounds) ove
rride; | |
216 void onDrawPosText(GrRenderTarget*, const GrClip&, const GrPaint&, const SkP
aint&, | |
217 const SkMatrix& viewMatrix, | |
218 const char text[], size_t byteLength, | |
219 const SkScalar pos[], int scalarsPerPosition, | |
220 const SkPoint& offset, const SkIRect& regionClipBounds) o
verride; | |
221 | |
222 void init(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint&, | |
223 const SkIRect& regionClipBounds); | |
224 void appendGlyph(GrGlyph::PackedID, SkFixed left, SkFixed top, GrFontScaler*
); | |
225 bool uploadGlyph(GrGlyph*, GrFontScaler*); | |
226 void flush(); // automatically called by destructor | |
227 void finish(); | |
228 }; | |
229 | |
230 #endif | 182 #endif |
OLD | NEW |