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 |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 const SkPaint&, const SkMatrix&
viewMatrix, | 359 const SkPaint&, const SkMatrix&
viewMatrix, |
360 const char text[], size_t byteL
ength, | 360 const char text[], size_t byteL
ength, |
361 const SkScalar pos[], int scala
rsPerPosition, | 361 const SkScalar pos[], int scala
rsPerPosition, |
362 const SkPoint& offset, | 362 const SkPoint& offset, |
363 const SkIRect& regionClipBounds
); | 363 const SkIRect& regionClipBounds
); |
364 | 364 |
365 // Distance field text needs this table to compute a value for use in the fr
agment shader. | 365 // Distance field text needs this table to compute a value for use in the fr
agment shader. |
366 // Because the GrAtlasTextContext can go out of scope before the final flush
, this needs to be | 366 // Because the GrAtlasTextContext can go out of scope before the final flush
, this needs to be |
367 // refcnted and malloced | 367 // refcnted and malloced |
368 struct DistanceAdjustTable : public SkNVRefCnt<DistanceAdjustTable> { | 368 struct DistanceAdjustTable : public SkNVRefCnt<DistanceAdjustTable> { |
369 DistanceAdjustTable(float gamma) { this->buildDistanceAdjustTable(gamma)
; } | 369 DistanceAdjustTable() { this->buildDistanceAdjustTable(); } |
370 ~DistanceAdjustTable() { SkDELETE_ARRAY(fTable); } | 370 ~DistanceAdjustTable() { SkDELETE_ARRAY(fTable); } |
371 | 371 |
372 void buildDistanceAdjustTable(float gamma); | |
373 | |
374 SkScalar& operator[] (int i) { | |
375 return fTable[i]; | |
376 } | |
377 | |
378 const SkScalar& operator[] (int i) const { | 372 const SkScalar& operator[] (int i) const { |
379 return fTable[i]; | 373 return fTable[i]; |
380 } | 374 } |
381 | 375 |
| 376 private: |
| 377 void buildDistanceAdjustTable(); |
| 378 |
382 SkScalar* fTable; | 379 SkScalar* fTable; |
383 }; | 380 }; |
384 | 381 |
385 GrBatchTextStrike* fCurrStrike; | 382 GrBatchTextStrike* fCurrStrike; |
386 GrTextBlobCache* fCache; | 383 GrTextBlobCache* fCache; |
387 SkAutoTUnref<DistanceAdjustTable> fDistanceAdjustTable; | 384 SkAutoTUnref<DistanceAdjustTable> fDistanceAdjustTable; |
388 | 385 |
389 friend class GrTextBlobCache; | 386 friend class GrTextBlobCache; |
390 friend class BitmapTextBatch; | 387 friend class BitmapTextBatch; |
391 | 388 |
392 #ifdef GR_TEST_UTILS | 389 #ifdef GR_TEST_UTILS |
393 BATCH_TEST_FRIEND(TextBlobBatch); | 390 BATCH_TEST_FRIEND(TextBlobBatch); |
394 #endif | 391 #endif |
395 | 392 |
396 typedef GrTextContext INHERITED; | 393 typedef GrTextContext INHERITED; |
397 }; | 394 }; |
398 | 395 |
399 #endif | 396 #endif |
OLD | NEW |