| 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 "GrAtlasTextBlob.h" | 13 #include "GrAtlasTextBlob.h" |
| 14 #include "GrDistanceFieldAdjustTable.h" |
| 14 #include "GrGeometryProcessor.h" | 15 #include "GrGeometryProcessor.h" |
| 15 #include "SkTextBlobRunIterator.h" | 16 #include "SkTextBlobRunIterator.h" |
| 16 | 17 |
| 17 #ifdef GR_TEST_UTILS | 18 #ifdef GR_TEST_UTILS |
| 18 #include "GrBatchTest.h" | 19 #include "GrBatchTest.h" |
| 19 #endif | 20 #endif |
| 20 | 21 |
| 21 class GrDrawBatch; | 22 class GrDrawBatch; |
| 22 class GrDrawContext; | 23 class GrDrawContext; |
| 23 class GrDrawTarget; | 24 class GrDrawTarget; |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 const char text[], size_t byteLen
gth, | 142 const char text[], size_t byteLen
gth, |
| 142 SkScalar x, SkScalar y, | 143 SkScalar x, SkScalar y, |
| 143 const SkIRect& regionClipBounds); | 144 const SkIRect& regionClipBounds); |
| 144 inline GrAtlasTextBlob* createDrawPosTextBlob(const GrClip&, const GrPaint&, | 145 inline GrAtlasTextBlob* createDrawPosTextBlob(const GrClip&, const GrPaint&, |
| 145 const SkPaint&, const SkMatrix
& viewMatrix, | 146 const SkPaint&, const SkMatrix
& viewMatrix, |
| 146 const char text[], size_t byte
Length, | 147 const char text[], size_t byte
Length, |
| 147 const SkScalar pos[], int scal
arsPerPosition, | 148 const SkScalar pos[], int scal
arsPerPosition, |
| 148 const SkPoint& offset, | 149 const SkPoint& offset, |
| 149 const SkIRect& regionClipBound
s); | 150 const SkIRect& regionClipBound
s); |
| 150 | 151 |
| 151 // Distance field text needs this table to compute a value for use in the fr
agment shader. | |
| 152 // Because the GrAtlasTextContext can go out of scope before the final flush
, this needs to be | |
| 153 // refcnted and malloced | |
| 154 struct DistanceAdjustTable : public SkNVRefCnt<DistanceAdjustTable> { | |
| 155 DistanceAdjustTable() { this->buildDistanceAdjustTable(); } | |
| 156 ~DistanceAdjustTable() { delete[] fTable; } | |
| 157 | |
| 158 const SkScalar& operator[] (int i) const { | |
| 159 return fTable[i]; | |
| 160 } | |
| 161 | |
| 162 private: | |
| 163 void buildDistanceAdjustTable(); | |
| 164 | |
| 165 SkScalar* fTable; | |
| 166 }; | |
| 167 | |
| 168 GrBatchTextStrike* fCurrStrike; | 152 GrBatchTextStrike* fCurrStrike; |
| 169 GrTextBlobCache* fCache; | 153 GrTextBlobCache* fCache; |
| 170 SkAutoTUnref<const DistanceAdjustTable> fDistanceAdjustTable; | 154 SkAutoTUnref<const GrDistanceFieldAdjustTable> fDistanceAdjustTable; |
| 171 | |
| 172 friend class GrTextBlobCache; | |
| 173 friend class GrAtlasTextBatch; | |
| 174 | 155 |
| 175 #ifdef GR_TEST_UTILS | 156 #ifdef GR_TEST_UTILS |
| 176 DRAW_BATCH_TEST_FRIEND(TextBlobBatch); | 157 DRAW_BATCH_TEST_FRIEND(TextBlobBatch); |
| 177 #endif | 158 #endif |
| 178 | 159 |
| 179 typedef GrTextContext INHERITED; | 160 typedef GrTextContext INHERITED; |
| 180 }; | 161 }; |
| 181 | 162 |
| 182 #endif | 163 #endif |
| OLD | NEW |