| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 const SkScalar pos[], int scalarsPerPosition, | 48 const SkScalar pos[], int scalarsPerPosition, |
| 49 const SkPoint& offset, const SkIRect& regionClipBounds) o
verride; | 49 const SkPoint& offset, const SkIRect& regionClipBounds) o
verride; |
| 50 void drawTextBlob(GrDrawContext*, const GrClip&, const SkPaint&, | 50 void drawTextBlob(GrDrawContext*, const GrClip&, const SkPaint&, |
| 51 const SkMatrix& viewMatrix, const SkTextBlob*, SkScalar x,
SkScalar y, | 51 const SkMatrix& viewMatrix, const SkTextBlob*, SkScalar x,
SkScalar y, |
| 52 SkDrawFilter*, const SkIRect& clipBounds) override; | 52 SkDrawFilter*, const SkIRect& clipBounds) override; |
| 53 | 53 |
| 54 typedef GrAtlasTextBlob::Run Run; | 54 typedef GrAtlasTextBlob::Run Run; |
| 55 typedef Run::SubRunInfo PerSubRunInfo; | 55 typedef Run::SubRunInfo PerSubRunInfo; |
| 56 | 56 |
| 57 inline bool canDrawAsDistanceFields(const SkPaint&, const SkMatrix& viewMatr
ix); | 57 inline bool canDrawAsDistanceFields(const SkPaint&, const SkMatrix& viewMatr
ix); |
| 58 GrAtlasTextBlob* setupDFBlob(int glyphCount, const SkPaint& origPaint, | |
| 59 const SkMatrix& viewMatrix, SkPaint* dfPaint, | |
| 60 SkScalar* textRatio); | |
| 61 void bmpAppendGlyph(GrAtlasTextBlob*, int runIndex, const SkGlyph&, int left
, int top, | |
| 62 GrColor color, GrFontScaler*); | |
| 63 bool dfAppendGlyph(GrAtlasTextBlob*, int runIndex, const SkGlyph&, SkScalar
sx, SkScalar sy, | 58 bool dfAppendGlyph(GrAtlasTextBlob*, int runIndex, const SkGlyph&, SkScalar
sx, SkScalar sy, |
| 64 GrColor color, GrFontScaler*, SkScalar textRatio, | 59 GrColor color, GrFontScaler*, SkScalar textRatio, |
| 65 const SkMatrix& viewMatrix); | 60 const SkMatrix& viewMatrix); |
| 66 | 61 |
| 67 // A helper for drawing BitmapText in a run of distance fields | 62 // A helper for drawing BitmapText in a run of distance fields |
| 68 inline void fallbackDrawPosText(GrAtlasTextBlob*, int runIndex, | 63 inline void fallbackDrawPosText(GrAtlasTextBlob*, int runIndex, |
| 69 GrColor color, | 64 GrColor color, |
| 70 const SkPaint&, const SkMatrix& viewMatrix, | 65 const SkPaint&, const SkMatrix& viewMatrix, |
| 71 const SkTDArray<char>& fallbackTxt, | 66 const SkTDArray<char>& fallbackTxt, |
| 72 const SkTDArray<SkScalar>& fallbackPos, | 67 const SkTDArray<SkScalar>& fallbackPos, |
| 73 int scalarsPerPosition, | 68 int scalarsPerPosition, |
| 74 const SkPoint& offset); | 69 const SkPoint& offset); |
| 75 | 70 |
| 76 void internalDrawDFText(GrAtlasTextBlob*, int runIndex, | 71 void internalDrawDFText(GrAtlasTextBlob*, int runIndex, |
| 77 const SkPaint&, | 72 const SkPaint&, |
| 78 GrColor color, const SkMatrix& viewMatrix, | 73 GrColor color, const SkMatrix& viewMatrix, |
| 79 const char text[], size_t byteLength, | 74 const char text[], size_t byteLength, |
| 80 SkScalar x, SkScalar y, | 75 SkScalar x, SkScalar y); |
| 81 SkScalar textRatio, const SkPaint& origPaint); | |
| 82 void internalDrawDFPosText(GrAtlasTextBlob*, int runIndex, | 76 void internalDrawDFPosText(GrAtlasTextBlob*, int runIndex, |
| 83 const SkPaint&, | 77 const SkPaint&, |
| 84 GrColor color, const SkMatrix& viewMatrix, | 78 GrColor color, const SkMatrix& viewMatrix, |
| 85 const char text[], size_t byteLength, | 79 const char text[], size_t byteLength, |
| 86 const SkScalar pos[], int scalarsPerPosition, | 80 const SkScalar pos[], int scalarsPerPosition, |
| 87 const SkPoint& offset, | 81 const SkPoint& offset); |
| 88 SkScalar textRatio, | |
| 89 const SkPaint& origPaint); | |
| 90 | 82 |
| 91 // sets up the descriptor on the blob and returns a detached cache. Client
must attach | 83 // sets up the descriptor on the blob and returns a detached cache. Client
must attach |
| 92 inline static GrColor ComputeCanonicalColor(const SkPaint&, bool lcd); | 84 inline static GrColor ComputeCanonicalColor(const SkPaint&, bool lcd); |
| 93 void regenerateTextBlob(GrAtlasTextBlob* bmp, const SkPaint& skPaint, GrColo
r, | 85 void regenerateTextBlob(GrAtlasTextBlob* bmp, const SkPaint& skPaint, GrColo
r, |
| 94 const SkMatrix& viewMatrix, | 86 const SkMatrix& viewMatrix, |
| 95 const SkTextBlob* blob, SkScalar x, SkScalar y, | 87 const SkTextBlob* blob, SkScalar x, SkScalar y, |
| 96 SkDrawFilter* drawFilter, | 88 SkDrawFilter* drawFilter); |
| 97 const GrClip&); | |
| 98 inline static bool HasLCD(const SkTextBlob*); | 89 inline static bool HasLCD(const SkTextBlob*); |
| 99 inline void initDistanceFieldPaint(GrAtlasTextBlob*, SkPaint*, SkScalar* tex
tRatio, | 90 inline void initDistanceFieldPaint(GrAtlasTextBlob*, SkPaint*, SkScalar* tex
tRatio, |
| 100 const SkMatrix&); | 91 const SkMatrix&); |
| 101 | 92 |
| 102 // Test methods | 93 // Test methods |
| 103 // TODO this is really ugly. It'd be much nicer if positioning could be mov
ed to batch | 94 // TODO this is really ugly. It'd be much nicer if positioning could be mov
ed to batch |
| 104 inline GrAtlasTextBlob* createDrawTextBlob(const GrPaint&, | 95 inline GrAtlasTextBlob* createDrawTextBlob(const GrPaint&, |
| 105 const SkPaint&, const SkMatrix& v
iewMatrix, | 96 const SkPaint&, const SkMatrix& v
iewMatrix, |
| 106 const char text[], size_t byteLen
gth, | 97 const char text[], size_t byteLen
gth, |
| 107 SkScalar x, SkScalar y); | 98 SkScalar x, SkScalar y); |
| 108 inline GrAtlasTextBlob* createDrawPosTextBlob(const GrPaint&, | 99 inline GrAtlasTextBlob* createDrawPosTextBlob(const GrPaint&, |
| 109 const SkPaint&, const SkMatrix
& viewMatrix, | 100 const SkPaint&, const SkMatrix
& viewMatrix, |
| 110 const char text[], size_t byte
Length, | 101 const char text[], size_t byte
Length, |
| 111 const SkScalar pos[], int scal
arsPerPosition, | 102 const SkScalar pos[], int scal
arsPerPosition, |
| 112 const SkPoint& offset); | 103 const SkPoint& offset); |
| 113 const GrDistanceFieldAdjustTable* dfAdjustTable() const { return fDistanceAd
justTable; } | 104 const GrDistanceFieldAdjustTable* dfAdjustTable() const { return fDistanceAd
justTable; } |
| 114 | 105 |
| 115 GrBatchTextStrike* fCurrStrike; | 106 GrBatchTextStrike* fCurrStrike; |
| 116 GrTextBlobCache* fCache; | 107 GrTextBlobCache* fCache; |
| 117 SkAutoTUnref<const GrDistanceFieldAdjustTable> fDistanceAdjustTable; | 108 SkAutoTUnref<const GrDistanceFieldAdjustTable> fDistanceAdjustTable; |
| 118 | 109 |
| 119 #ifdef GR_TEST_UTILS | 110 #ifdef GR_TEST_UTILS |
| 120 DRAW_BATCH_TEST_FRIEND(TextBlobBatch); | 111 DRAW_BATCH_TEST_FRIEND(TextBlobBatch); |
| 121 #endif | 112 #endif |
| 122 | 113 |
| 123 typedef GrTextContext INHERITED; | 114 typedef GrTextContext INHERITED; |
| 124 }; | 115 }; |
| 125 | 116 |
| 126 #endif | 117 #endif |
| OLD | NEW |