OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 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 GrAtlasTextContext_DEFINED | 8 #ifndef GrAtlasTextContext_DEFINED |
9 #define GrAtlasTextContext_DEFINED | 9 #define GrAtlasTextContext_DEFINED |
10 | 10 |
11 #include "GrTextContext.h" | 11 #include "GrTextContext.h" |
12 | 12 |
13 #include "GrBatchAtlas.h" | 13 #include "GrBatchAtlas.h" |
14 #include "GrBatchFontCache.h" | 14 #include "GrBatchFontCache.h" |
15 #include "GrGeometryProcessor.h" | 15 #include "GrGeometryProcessor.h" |
16 #include "SkDescriptor.h" | 16 #include "SkDescriptor.h" |
17 #include "GrMemoryPool.h" | 17 #include "GrMemoryPool.h" |
18 #include "SkMaskFilter.h" | 18 #include "SkMaskFilter.h" |
19 #include "SkTextBlob.h" | 19 #include "SkTextBlob.h" |
20 #include "SkTInternalLList.h" | 20 #include "SkTInternalLList.h" |
21 | 21 |
| 22 #ifdef GR_TEST_UTILS |
| 23 #include "GrBatchTest.h" |
| 24 #endif |
| 25 |
| 26 class BitmapTextBatch; |
22 class GrPipelineBuilder; | 27 class GrPipelineBuilder; |
23 class GrTextBlobCache; | 28 class GrTextBlobCache; |
24 | 29 |
25 /* | 30 /* |
26 * This class implements GrTextContext using standard bitmap fonts, and can also
process textblobs. | 31 * This class implements GrTextContext using standard bitmap fonts, and can also
process textblobs. |
27 * TODO replace GrBitmapTextContext | 32 * TODO replace GrBitmapTextContext |
28 */ | 33 */ |
29 class GrAtlasTextContext : public GrTextContext { | 34 class GrAtlasTextContext : public GrTextContext { |
30 public: | 35 public: |
31 static GrAtlasTextContext* Create(GrContext*, SkGpuDevice*, const SkDevicePr
operties&, | 36 static GrAtlasTextContext* Create(GrContext*, SkGpuDevice*, const SkDevicePr
operties&, |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 inline void appendGlyphPath(BitmapTextBlob* blob, GrGlyph* glyph, | 263 inline void appendGlyphPath(BitmapTextBlob* blob, GrGlyph* glyph, |
259 GrFontScaler* scaler, int x, int y); | 264 GrFontScaler* scaler, int x, int y); |
260 inline void appendGlyphCommon(BitmapTextBlob*, Run*, Run::SubRunInfo*, | 265 inline void appendGlyphCommon(BitmapTextBlob*, Run*, Run::SubRunInfo*, |
261 const SkRect& positions, GrColor color, | 266 const SkRect& positions, GrColor color, |
262 size_t vertexStride, bool useVertexColor, | 267 size_t vertexStride, bool useVertexColor, |
263 GrGlyph*); | 268 GrGlyph*); |
264 | 269 |
265 inline void flushRunAsPaths(const SkTextBlob::RunIterator&, const SkPaint&,
SkDrawFilter*, | 270 inline void flushRunAsPaths(const SkTextBlob::RunIterator&, const SkPaint&,
SkDrawFilter*, |
266 const SkMatrix& viewMatrix, const SkIRect& clipB
ounds, SkScalar x, | 271 const SkMatrix& viewMatrix, const SkIRect& clipB
ounds, SkScalar x, |
267 SkScalar y); | 272 SkScalar y); |
| 273 inline BitmapTextBatch* createBatch(BitmapTextBlob*, const PerSubRunInfo&, |
| 274 int glyphCount, int run, int subRun, |
| 275 GrColor, SkScalar transX, SkScalar trans
Y, |
| 276 const SkPaint&); |
268 inline void flushRun(GrDrawTarget*, GrPipelineBuilder*, BitmapTextBlob*, int
run, GrColor, | 277 inline void flushRun(GrDrawTarget*, GrPipelineBuilder*, BitmapTextBlob*, int
run, GrColor, |
269 SkScalar transX, SkScalar transY, const SkPaint&); | 278 SkScalar transX, SkScalar transY, const SkPaint&); |
270 inline void flushBigGlyphs(BitmapTextBlob* cacheBlob, GrRenderTarget* rt, | 279 inline void flushBigGlyphs(BitmapTextBlob* cacheBlob, GrRenderTarget* rt, |
271 const GrPaint& grPaint, const GrClip& clip, | 280 const GrPaint& grPaint, const GrClip& clip, |
272 SkScalar transX, SkScalar transY); | 281 SkScalar transX, SkScalar transY); |
273 | 282 |
274 // We have to flush SkTextBlobs differently from drawText / drawPosText | 283 // We have to flush SkTextBlobs differently from drawText / drawPosText |
275 void flush(GrDrawTarget*, const SkTextBlob*, BitmapTextBlob*, GrRenderTarget
*, const SkPaint&, | 284 void flush(GrDrawTarget*, const SkTextBlob*, BitmapTextBlob*, GrRenderTarget
*, const SkPaint&, |
276 const GrPaint&, SkDrawFilter*, const GrClip&, const SkMatrix& vie
wMatrix, | 285 const GrPaint&, SkDrawFilter*, const GrClip&, const SkMatrix& vie
wMatrix, |
277 const SkIRect& clipBounds, SkScalar x, SkScalar y, SkScalar trans
X, SkScalar transY); | 286 const SkIRect& clipBounds, SkScalar x, SkScalar y, SkScalar trans
X, SkScalar transY); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 const SkMatrix& viewMatrix, SkScalar x
, SkScalar y); | 334 const SkMatrix& viewMatrix, SkScalar x
, SkScalar y); |
326 void regenerateTextBlob(BitmapTextBlob* bmp, const SkPaint& skPaint, GrColor
, | 335 void regenerateTextBlob(BitmapTextBlob* bmp, const SkPaint& skPaint, GrColor
, |
327 const SkMatrix& viewMatrix, | 336 const SkMatrix& viewMatrix, |
328 const SkTextBlob* blob, SkScalar x, SkScalar y, | 337 const SkTextBlob* blob, SkScalar x, SkScalar y, |
329 SkDrawFilter* drawFilter, const SkIRect& clipRect, G
rRenderTarget*, | 338 SkDrawFilter* drawFilter, const SkIRect& clipRect, G
rRenderTarget*, |
330 const GrClip&, const GrPaint&); | 339 const GrClip&, const GrPaint&); |
331 inline static bool HasLCD(const SkTextBlob*); | 340 inline static bool HasLCD(const SkTextBlob*); |
332 inline void initDistanceFieldPaint(BitmapTextBlob*, SkPaint*, SkScalar* text
Ratio, | 341 inline void initDistanceFieldPaint(BitmapTextBlob*, SkPaint*, SkScalar* text
Ratio, |
333 const SkMatrix&); | 342 const SkMatrix&); |
334 | 343 |
| 344 // Test methods |
| 345 // TODO this is really ugly. It'd be much nicer if positioning could be mov
ed to batch |
| 346 inline BitmapTextBlob* createDrawTextBlob(GrRenderTarget*, const GrClip&, co
nst GrPaint&, |
| 347 const SkPaint&, const SkMatrix& vi
ewMatrix, |
| 348 const char text[], size_t byteLeng
th, |
| 349 SkScalar x, SkScalar y, |
| 350 const SkIRect& regionClipBounds); |
| 351 inline BitmapTextBlob* createDrawPosTextBlob(GrRenderTarget*, const GrClip&,
const GrPaint&, |
| 352 const SkPaint&, const SkMatrix&
viewMatrix, |
| 353 const char text[], size_t byteL
ength, |
| 354 const SkScalar pos[], int scala
rsPerPosition, |
| 355 const SkPoint& offset, |
| 356 const SkIRect& regionClipBounds
); |
| 357 |
335 // Distance field text needs this table to compute a value for use in the fr
agment shader. | 358 // Distance field text needs this table to compute a value for use in the fr
agment shader. |
336 // Because the GrAtlasTextContext can go out of scope before the final flush
, this needs to be | 359 // Because the GrAtlasTextContext can go out of scope before the final flush
, this needs to be |
337 // refcnted and malloced | 360 // refcnted and malloced |
338 struct DistanceAdjustTable : public SkNVRefCnt<DistanceAdjustTable> { | 361 struct DistanceAdjustTable : public SkNVRefCnt<DistanceAdjustTable> { |
339 DistanceAdjustTable(float gamma) { this->buildDistanceAdjustTable(gamma)
; } | 362 DistanceAdjustTable(float gamma) { this->buildDistanceAdjustTable(gamma)
; } |
340 ~DistanceAdjustTable() { SkDELETE_ARRAY(fTable); } | 363 ~DistanceAdjustTable() { SkDELETE_ARRAY(fTable); } |
341 | 364 |
342 void buildDistanceAdjustTable(float gamma); | 365 void buildDistanceAdjustTable(float gamma); |
343 | 366 |
344 SkScalar& operator[] (int i) { | 367 SkScalar& operator[] (int i) { |
345 return fTable[i]; | 368 return fTable[i]; |
346 } | 369 } |
347 | 370 |
348 const SkScalar& operator[] (int i) const { | 371 const SkScalar& operator[] (int i) const { |
349 return fTable[i]; | 372 return fTable[i]; |
350 } | 373 } |
351 | 374 |
352 SkScalar* fTable; | 375 SkScalar* fTable; |
353 }; | 376 }; |
354 | 377 |
355 GrBatchTextStrike* fCurrStrike; | 378 GrBatchTextStrike* fCurrStrike; |
356 GrTextBlobCache* fCache; | 379 GrTextBlobCache* fCache; |
357 bool fEnableDFRendering; | 380 bool fEnableDFRendering; |
358 SkAutoTUnref<DistanceAdjustTable> fDistanceAdjustTable; | 381 SkAutoTUnref<DistanceAdjustTable> fDistanceAdjustTable; |
359 | 382 |
360 friend class GrTextBlobCache; | 383 friend class GrTextBlobCache; |
361 friend class BitmapTextBatch; | 384 friend class BitmapTextBatch; |
362 | 385 |
| 386 #ifdef GR_TEST_UTILS |
| 387 BATCH_TEST_FRIEND(TextBlob); |
| 388 #endif |
| 389 |
363 typedef GrTextContext INHERITED; | 390 typedef GrTextContext INHERITED; |
364 }; | 391 }; |
365 | 392 |
366 #endif | 393 #endif |
OLD | NEW |