| 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 "GrAtlasTextBlob.h" |
| 14 #include "GrBatchFontCache.h" | |
| 15 #include "GrGeometryProcessor.h" | 14 #include "GrGeometryProcessor.h" |
| 16 #include "SkDescriptor.h" | |
| 17 #include "GrMemoryPool.h" | |
| 18 #include "SkMaskFilter.h" | |
| 19 #include "SkTextBlob.h" | 15 #include "SkTextBlob.h" |
| 20 #include "SkTInternalLList.h" | |
| 21 | 16 |
| 22 #ifdef GR_TEST_UTILS | 17 #ifdef GR_TEST_UTILS |
| 23 #include "GrBatchTest.h" | 18 #include "GrBatchTest.h" |
| 24 #endif | 19 #endif |
| 25 | 20 |
| 26 class BitmapTextBatch; | 21 class BitmapTextBatch; |
| 27 class GrDrawContext; | 22 class GrDrawContext; |
| 28 class GrDrawTarget; | 23 class GrDrawTarget; |
| 29 class GrPipelineBuilder; | 24 class GrPipelineBuilder; |
| 30 class GrTextBlobCache; | 25 class GrTextBlobCache; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 49 SkScalar x, SkScalar y, const SkIRect& regionClipBounds) ove
rride; | 44 SkScalar x, SkScalar y, const SkIRect& regionClipBounds) ove
rride; |
| 50 void onDrawPosText(GrRenderTarget*, const GrClip&, const GrPaint&, | 45 void onDrawPosText(GrRenderTarget*, const GrClip&, const GrPaint&, |
| 51 const SkPaint&, const SkMatrix& viewMatrix, | 46 const SkPaint&, const SkMatrix& viewMatrix, |
| 52 const char text[], size_t byteLength, | 47 const char text[], size_t byteLength, |
| 53 const SkScalar pos[], int scalarsPerPosition, | 48 const SkScalar pos[], int scalarsPerPosition, |
| 54 const SkPoint& offset, const SkIRect& regionClipBounds) o
verride; | 49 const SkPoint& offset, const SkIRect& regionClipBounds) o
verride; |
| 55 void drawTextBlob(GrRenderTarget*, const GrClip&, const SkPaint&, | 50 void drawTextBlob(GrRenderTarget*, const GrClip&, const SkPaint&, |
| 56 const SkMatrix& viewMatrix, const SkTextBlob*, SkScalar x,
SkScalar y, | 51 const SkMatrix& viewMatrix, const SkTextBlob*, SkScalar x,
SkScalar y, |
| 57 SkDrawFilter*, const SkIRect& clipBounds) override; | 52 SkDrawFilter*, const SkIRect& clipBounds) override; |
| 58 | 53 |
| 59 /* | 54 typedef GrAtlasTextBlob::Run Run; |
| 60 * A BitmapTextBlob contains a fully processed SkTextBlob, suitable for near
ly immediate drawing | |
| 61 * on the GPU. These are initially created with valid positions and colors,
but invalid | |
| 62 * texture coordinates. The BitmapTextBlob itself has a few Blob-wide prope
rties, and also | |
| 63 * consists of a number of runs. Runs inside a blob are flushed individuall
y so they can be | |
| 64 * reordered. | |
| 65 * | |
| 66 * The only thing(aside from a memcopy) required to flush a BitmapTextBlob i
s to ensure that | |
| 67 * the GrAtlas will not evict anything the Blob needs. | |
| 68 */ | |
| 69 struct BitmapTextBlob : public SkRefCnt { | |
| 70 SK_DECLARE_INTERNAL_LLIST_INTERFACE(BitmapTextBlob); | |
| 71 | |
| 72 /* | |
| 73 * Each Run inside of the blob can have its texture coordinates regenera
ted if required. | |
| 74 * To determine if regeneration is necessary, fAtlasGeneration is used.
If there have been | |
| 75 * any evictions inside of the atlas, then we will simply regenerate Run
s. We could track | |
| 76 * this at a more fine grained level, but its not clear if this is worth
it, as evictions | |
| 77 * should be fairly rare. | |
| 78 * | |
| 79 * One additional point, each run can contain glyphs with any of the thr
ee mask formats. | |
| 80 * We call these SubRuns. Because a subrun must be a contiguous range,
we have to create | |
| 81 * a new subrun each time the mask format changes in a run. In theory,
a run can have as | |
| 82 * many SubRuns as it has glyphs, ie if a run alternates between color e
moji and A8. In | |
| 83 * practice, the vast majority of runs have only a single subrun. | |
| 84 * | |
| 85 * Finally, for runs where the entire thing is too large for the GrAtlas
TextContext to | |
| 86 * handle, we have a bit to mark the run as flusahable via rendering as
paths. It is worth | |
| 87 * pointing. It would be a bit expensive to figure out ahead of time whe
ther or not a run | |
| 88 * can flush in this manner, so we always allocate vertices for the run,
regardless of | |
| 89 * whether or not it is too large. The benefit of this strategy is that
we can always reuse | |
| 90 * a blob allocation regardless of viewmatrix changes. We could store p
ositions for these | |
| 91 * glyphs. However, its not clear if this is a win because we'd still h
ave to either go the | |
| 92 * glyph cache to get the path at flush time, or hold onto the path in t
he cache, which | |
| 93 * would greatly increase the memory of these cached items. | |
| 94 */ | |
| 95 struct Run { | |
| 96 Run() | |
| 97 : fColor(GrColor_ILLEGAL) | |
| 98 , fInitialized(false) | |
| 99 , fDrawAsPaths(false) { | |
| 100 fVertexBounds.setLargestInverted(); | |
| 101 // To ensure we always have one subrun, we push back a fresh run
here | |
| 102 fSubRunInfo.push_back(); | |
| 103 } | |
| 104 struct SubRunInfo { | |
| 105 SubRunInfo() | |
| 106 : fAtlasGeneration(GrBatchAtlas::kInvalidAtlasGeneration) | |
| 107 , fVertexStartIndex(0) | |
| 108 , fVertexEndIndex(0) | |
| 109 , fGlyphStartIndex(0) | |
| 110 , fGlyphEndIndex(0) | |
| 111 , fDrawAsDistanceFields(false) {} | |
| 112 // Distance field text cannot draw coloremoji, and so has to fal
l back. However, | |
| 113 // though the distance field text and the coloremoji may share t
he same run, they | |
| 114 // will have different descriptors. If fOverrideDescriptor is n
on-NULL, then it | |
| 115 // will be used in place of the run's descriptor to regen textur
e coords | |
| 116 // TODO we could have a descriptor cache, it would reduce the si
ze of these blobs | |
| 117 // significantly, and then the subrun could just have a refed po
inter to the | |
| 118 // correct descriptor. | |
| 119 GrBatchAtlas::BulkUseTokenUpdater fBulkUseToken; | |
| 120 uint64_t fAtlasGeneration; | |
| 121 size_t fVertexStartIndex; | |
| 122 size_t fVertexEndIndex; | |
| 123 uint32_t fGlyphStartIndex; | |
| 124 uint32_t fGlyphEndIndex; | |
| 125 SkScalar fTextRatio; // df property | |
| 126 GrMaskFormat fMaskFormat; | |
| 127 bool fDrawAsDistanceFields; // df property | |
| 128 bool fUseLCDText; // df property | |
| 129 }; | |
| 130 | |
| 131 SubRunInfo& push_back() { | |
| 132 // Forward glyph / vertex information to seed the new sub run | |
| 133 SubRunInfo& prevSubRun = fSubRunInfo.back(); | |
| 134 SubRunInfo& newSubRun = fSubRunInfo.push_back(); | |
| 135 newSubRun.fGlyphStartIndex = prevSubRun.fGlyphEndIndex; | |
| 136 newSubRun.fGlyphEndIndex = prevSubRun.fGlyphEndIndex; | |
| 137 | |
| 138 newSubRun.fVertexStartIndex = prevSubRun.fVertexEndIndex; | |
| 139 newSubRun.fVertexEndIndex = prevSubRun.fVertexEndIndex; | |
| 140 return newSubRun; | |
| 141 } | |
| 142 static const int kMinSubRuns = 1; | |
| 143 SkAutoTUnref<GrBatchTextStrike> fStrike; | |
| 144 SkAutoTUnref<SkTypeface> fTypeface; | |
| 145 SkRect fVertexBounds; | |
| 146 SkSTArray<kMinSubRuns, SubRunInfo> fSubRunInfo; | |
| 147 SkAutoDescriptor fDescriptor; | |
| 148 SkAutoTDelete<SkAutoDescriptor> fOverrideDescriptor; // df propertie
s | |
| 149 GrColor fColor; | |
| 150 bool fInitialized; | |
| 151 bool fDrawAsPaths; | |
| 152 }; | |
| 153 | |
| 154 struct BigGlyph { | |
| 155 BigGlyph(const SkPath& path, SkScalar vx, SkScalar vy) | |
| 156 : fPath(path) | |
| 157 , fVx(vx) | |
| 158 , fVy(vy) {} | |
| 159 SkPath fPath; | |
| 160 SkScalar fVx; | |
| 161 SkScalar fVy; | |
| 162 }; | |
| 163 | |
| 164 struct Key { | |
| 165 Key() { | |
| 166 sk_bzero(this, sizeof(Key)); | |
| 167 } | |
| 168 uint32_t fUniqueID; | |
| 169 // Color may affect the gamma of the mask we generate, but in a fair
ly limited way. | |
| 170 // Each color is assigned to on of a fixed number of buckets based o
n its | |
| 171 // luminance. For each luminance bucket there is a "canonical color"
that | |
| 172 // represents the bucket. This functionality is currently only supp
orted for A8 | |
| 173 SkColor fCanonicalColor; | |
| 174 SkPaint::Style fStyle; | |
| 175 SkPixelGeometry fPixelGeometry; | |
| 176 bool fHasBlur; | |
| 177 | |
| 178 bool operator==(const Key& other) const { | |
| 179 return 0 == memcmp(this, &other, sizeof(Key)); | |
| 180 } | |
| 181 }; | |
| 182 | |
| 183 struct StrokeInfo { | |
| 184 SkScalar fFrameWidth; | |
| 185 SkScalar fMiterLimit; | |
| 186 SkPaint::Join fJoin; | |
| 187 }; | |
| 188 | |
| 189 enum TextType { | |
| 190 kHasDistanceField_TextType = 0x1, | |
| 191 kHasBitmap_TextType = 0x2, | |
| 192 }; | |
| 193 | |
| 194 // all glyph / vertex offsets are into these pools. | |
| 195 unsigned char* fVertices; | |
| 196 GrGlyph** fGlyphs; | |
| 197 Run* fRuns; | |
| 198 GrMemoryPool* fPool; | |
| 199 SkMaskFilter::BlurRec fBlurRec; | |
| 200 StrokeInfo fStrokeInfo; | |
| 201 SkTArray<BigGlyph> fBigGlyphs; | |
| 202 Key fKey; | |
| 203 SkMatrix fViewMatrix; | |
| 204 SkColor fPaintColor; | |
| 205 SkScalar fX; | |
| 206 SkScalar fY; | |
| 207 | |
| 208 // We can reuse distance field text, but only if the new viewmatrix woul
d not result in | |
| 209 // a mip change. Because there can be multiple runs in a blob, we track
the overall | |
| 210 // maximum minimum scale, and minimum maximum scale, we can support befo
re we need to regen | |
| 211 SkScalar fMaxMinScale; | |
| 212 SkScalar fMinMaxScale; | |
| 213 int fRunCount; | |
| 214 uint8_t fTextType; | |
| 215 | |
| 216 BitmapTextBlob() | |
| 217 : fMaxMinScale(-SK_ScalarMax) | |
| 218 , fMinMaxScale(SK_ScalarMax) | |
| 219 , fTextType(0) {} | |
| 220 | |
| 221 ~BitmapTextBlob() override { | |
| 222 for (int i = 0; i < fRunCount; i++) { | |
| 223 fRuns[i].~Run(); | |
| 224 } | |
| 225 } | |
| 226 | |
| 227 static const Key& GetKey(const BitmapTextBlob& blob) { | |
| 228 return blob.fKey; | |
| 229 } | |
| 230 | |
| 231 static uint32_t Hash(const Key& key) { | |
| 232 return SkChecksum::Murmur3(&key, sizeof(Key)); | |
| 233 } | |
| 234 | |
| 235 void operator delete(void* p) { | |
| 236 BitmapTextBlob* blob = reinterpret_cast<BitmapTextBlob*>(p); | |
| 237 blob->fPool->release(p); | |
| 238 } | |
| 239 void* operator new(size_t) { | |
| 240 SkFAIL("All blobs are created by placement new."); | |
| 241 return sk_malloc_throw(0); | |
| 242 } | |
| 243 | |
| 244 void* operator new(size_t, void* p) { return p; } | |
| 245 void operator delete(void* target, void* placement) { | |
| 246 ::operator delete(target, placement); | |
| 247 } | |
| 248 | |
| 249 bool hasDistanceField() const { return SkToBool(fTextType & kHasDistance
Field_TextType); } | |
| 250 bool hasBitmap() const { return SkToBool(fTextType & kHasBitmap_TextType
); } | |
| 251 void setHasDistanceField() { fTextType |= kHasDistanceField_TextType; } | |
| 252 void setHasBitmap() { fTextType |= kHasBitmap_TextType; } | |
| 253 }; | |
| 254 | |
| 255 typedef BitmapTextBlob::Run Run; | |
| 256 typedef Run::SubRunInfo PerSubRunInfo; | 55 typedef Run::SubRunInfo PerSubRunInfo; |
| 257 | 56 |
| 258 inline bool canDrawAsDistanceFields(const SkPaint&, const SkMatrix& viewMatr
ix); | 57 inline bool canDrawAsDistanceFields(const SkPaint&, const SkMatrix& viewMatr
ix); |
| 259 BitmapTextBlob* setupDFBlob(int glyphCount, const SkPaint& origPaint, | 58 GrAtlasTextBlob* setupDFBlob(int glyphCount, const SkPaint& origPaint, |
| 260 const SkMatrix& viewMatrix, SkGlyphCache** cache
, | 59 const SkMatrix& viewMatrix, SkGlyphCache** cache
, |
| 261 SkPaint* dfPaint, SkScalar* textRatio); | 60 SkPaint* dfPaint, SkScalar* textRatio); |
| 262 void bmpAppendGlyph(BitmapTextBlob*, int runIndex, GrGlyph::PackedID, int le
ft, int top, | 61 void bmpAppendGlyph(GrAtlasTextBlob*, int runIndex, GrGlyph::PackedID, int l
eft, int top, |
| 263 GrColor color, GrFontScaler*, const SkIRect& clipRect); | 62 GrColor color, GrFontScaler*, const SkIRect& clipRect); |
| 264 bool dfAppendGlyph(BitmapTextBlob*, int runIndex, GrGlyph::PackedID, SkScala
r sx, SkScalar sy, | 63 bool dfAppendGlyph(GrAtlasTextBlob*, int runIndex, GrGlyph::PackedID, SkScal
ar sx, SkScalar sy, |
| 265 GrColor color, GrFontScaler*, const SkIRect& clipRect, Sk
Scalar textRatio, | 64 GrColor color, GrFontScaler*, const SkIRect& clipRect, Sk
Scalar textRatio, |
| 266 const SkMatrix& viewMatrix); | 65 const SkMatrix& viewMatrix); |
| 267 inline void appendGlyphPath(BitmapTextBlob* blob, GrGlyph* glyph, | 66 inline void appendGlyphPath(GrAtlasTextBlob* blob, GrGlyph* glyph, |
| 268 GrFontScaler* scaler, SkScalar x, SkScalar y); | 67 GrFontScaler* scaler, SkScalar x, SkScalar y); |
| 269 inline void appendGlyphCommon(BitmapTextBlob*, Run*, Run::SubRunInfo*, | 68 inline void appendGlyphCommon(GrAtlasTextBlob*, Run*, Run::SubRunInfo*, |
| 270 const SkRect& positions, GrColor color, | 69 const SkRect& positions, GrColor color, |
| 271 size_t vertexStride, bool useVertexColor, | 70 size_t vertexStride, bool useVertexColor, |
| 272 GrGlyph*); | 71 GrGlyph*); |
| 273 | 72 |
| 274 inline void flushRunAsPaths(GrRenderTarget*, | 73 inline void flushRunAsPaths(GrRenderTarget*, |
| 275 const SkTextBlob::RunIterator&, const GrClip& cl
ip, | 74 const SkTextBlob::RunIterator&, const GrClip& cl
ip, |
| 276 const SkPaint&, SkDrawFilter*, | 75 const SkPaint&, SkDrawFilter*, |
| 277 const SkMatrix& viewMatrix, const SkIRect& clipB
ounds, SkScalar x, | 76 const SkMatrix& viewMatrix, const SkIRect& clipB
ounds, SkScalar x, |
| 278 SkScalar y); | 77 SkScalar y); |
| 279 inline BitmapTextBatch* createBatch(BitmapTextBlob*, const PerSubRunInfo&, | 78 inline BitmapTextBatch* createBatch(GrAtlasTextBlob*, const PerSubRunInfo&, |
| 280 int glyphCount, int run, int subRun, | 79 int glyphCount, int run, int subRun, |
| 281 GrColor, SkScalar transX, SkScalar trans
Y, | 80 GrColor, SkScalar transX, SkScalar trans
Y, |
| 282 const SkPaint&); | 81 const SkPaint&); |
| 283 inline void flushRun(GrPipelineBuilder*, BitmapTextBlob*, int run, GrColor, | 82 inline void flushRun(GrPipelineBuilder*, GrAtlasTextBlob*, int run, GrColor, |
| 284 SkScalar transX, SkScalar transY, const SkPaint&); | 83 SkScalar transX, SkScalar transY, const SkPaint&); |
| 285 inline void flushBigGlyphs(BitmapTextBlob* cacheBlob, GrRenderTarget*, | 84 inline void flushBigGlyphs(GrAtlasTextBlob* cacheBlob, GrRenderTarget*, |
| 286 const GrClip& clip, const SkPaint& skPaint, | 85 const GrClip& clip, const SkPaint& skPaint, |
| 287 SkScalar transX, SkScalar transY, const SkIRect&
clipBounds); | 86 SkScalar transX, SkScalar transY, const SkIRect&
clipBounds); |
| 288 | 87 |
| 289 // We have to flush SkTextBlobs differently from drawText / drawPosText | 88 // We have to flush SkTextBlobs differently from drawText / drawPosText |
| 290 void flush(const SkTextBlob*, BitmapTextBlob*, GrRenderTarget*, | 89 void flush(const SkTextBlob*, GrAtlasTextBlob*, GrRenderTarget*, |
| 291 const SkPaint&, const GrPaint&, SkDrawFilter*, const GrClip&, | 90 const SkPaint&, const GrPaint&, SkDrawFilter*, const GrClip&, |
| 292 const SkMatrix& viewMatrix, const SkIRect& clipBounds, SkScalar x
, SkScalar y, | 91 const SkMatrix& viewMatrix, const SkIRect& clipBounds, SkScalar x
, SkScalar y, |
| 293 SkScalar transX, SkScalar transY); | 92 SkScalar transX, SkScalar transY); |
| 294 void flush(BitmapTextBlob*, GrRenderTarget*, const SkPaint&, | 93 void flush(GrAtlasTextBlob*, GrRenderTarget*, const SkPaint&, |
| 295 const GrPaint&, const GrClip&, const SkIRect& clipBounds); | 94 const GrPaint&, const GrClip&, const SkIRect& clipBounds); |
| 296 | 95 |
| 297 // A helper for drawing BitmapText in a run of distance fields | 96 // A helper for drawing BitmapText in a run of distance fields |
| 298 inline void fallbackDrawPosText(BitmapTextBlob*, int runIndex, | 97 inline void fallbackDrawPosText(GrAtlasTextBlob*, int runIndex, |
| 299 GrRenderTarget*, const GrClip&, | 98 GrRenderTarget*, const GrClip&, |
| 300 const GrPaint&, | 99 const GrPaint&, |
| 301 const SkPaint&, const SkMatrix& viewMatrix, | 100 const SkPaint&, const SkMatrix& viewMatrix, |
| 302 const SkTDArray<char>& fallbackTxt, | 101 const SkTDArray<char>& fallbackTxt, |
| 303 const SkTDArray<SkScalar>& fallbackPos, | 102 const SkTDArray<SkScalar>& fallbackPos, |
| 304 int scalarsPerPosition, | 103 int scalarsPerPosition, |
| 305 const SkPoint& offset, | 104 const SkPoint& offset, |
| 306 const SkIRect& clipRect); | 105 const SkIRect& clipRect); |
| 307 | 106 |
| 308 void internalDrawBMPText(BitmapTextBlob*, int runIndex, SkGlyphCache*, const
SkPaint&, | 107 void internalDrawBMPText(GrAtlasTextBlob*, int runIndex, SkGlyphCache*, cons
t SkPaint&, |
| 309 GrColor color, const SkMatrix& viewMatrix, | 108 GrColor color, const SkMatrix& viewMatrix, |
| 310 const char text[], size_t byteLength, | 109 const char text[], size_t byteLength, |
| 311 SkScalar x, SkScalar y, const SkIRect& clipRect); | 110 SkScalar x, SkScalar y, const SkIRect& clipRect); |
| 312 void internalDrawBMPPosText(BitmapTextBlob*, int runIndex, SkGlyphCache*, co
nst SkPaint&, | 111 void internalDrawBMPPosText(GrAtlasTextBlob*, int runIndex, SkGlyphCache*, c
onst SkPaint&, |
| 313 GrColor color, const SkMatrix& viewMatrix, | 112 GrColor color, const SkMatrix& viewMatrix, |
| 314 const char text[], size_t byteLength, | 113 const char text[], size_t byteLength, |
| 315 const SkScalar pos[], int scalarsPerPosition, | 114 const SkScalar pos[], int scalarsPerPosition, |
| 316 const SkPoint& offset, const SkIRect& clipRect); | 115 const SkPoint& offset, const SkIRect& clipRect); |
| 317 | 116 |
| 318 void internalDrawDFText(BitmapTextBlob*, int runIndex, SkGlyphCache*, const
SkPaint&, | 117 void internalDrawDFText(GrAtlasTextBlob*, int runIndex, SkGlyphCache*, const
SkPaint&, |
| 319 GrColor color, const SkMatrix& viewMatrix, | 118 GrColor color, const SkMatrix& viewMatrix, |
| 320 const char text[], size_t byteLength, | 119 const char text[], size_t byteLength, |
| 321 SkScalar x, SkScalar y, const SkIRect& clipRect, | 120 SkScalar x, SkScalar y, const SkIRect& clipRect, |
| 322 SkScalar textRatio, | 121 SkScalar textRatio, |
| 323 SkTDArray<char>* fallbackTxt, | 122 SkTDArray<char>* fallbackTxt, |
| 324 SkTDArray<SkScalar>* fallbackPos, | 123 SkTDArray<SkScalar>* fallbackPos, |
| 325 SkPoint* offset, const SkPaint& origPaint); | 124 SkPoint* offset, const SkPaint& origPaint); |
| 326 void internalDrawDFPosText(BitmapTextBlob*, int runIndex, SkGlyphCache*, con
st SkPaint&, | 125 void internalDrawDFPosText(GrAtlasTextBlob*, int runIndex, SkGlyphCache*, co
nst SkPaint&, |
| 327 GrColor color, const SkMatrix& viewMatrix, | 126 GrColor color, const SkMatrix& viewMatrix, |
| 328 const char text[], size_t byteLength, | 127 const char text[], size_t byteLength, |
| 329 const SkScalar pos[], int scalarsPerPosition, | 128 const SkScalar pos[], int scalarsPerPosition, |
| 330 const SkPoint& offset, const SkIRect& clipRect, | 129 const SkPoint& offset, const SkIRect& clipRect, |
| 331 SkScalar textRatio, | 130 SkScalar textRatio, |
| 332 SkTDArray<char>* fallbackTxt, | 131 SkTDArray<char>* fallbackTxt, |
| 333 SkTDArray<SkScalar>* fallbackPos); | 132 SkTDArray<SkScalar>* fallbackPos); |
| 334 | 133 |
| 335 // sets up the descriptor on the blob and returns a detached cache. Client
must attach | 134 // sets up the descriptor on the blob and returns a detached cache. Client
must attach |
| 336 inline static GrColor ComputeCanonicalColor(const SkPaint&, bool lcd); | 135 inline static GrColor ComputeCanonicalColor(const SkPaint&, bool lcd); |
| 337 inline SkGlyphCache* setupCache(Run*, const SkPaint&, const SkMatrix* viewMa
trix, bool noGamma); | 136 inline SkGlyphCache* setupCache(Run*, const SkPaint&, const SkMatrix* viewMa
trix, bool noGamma); |
| 338 static inline bool MustRegenerateBlob(SkScalar* outTransX, SkScalar* outTran
sY, | 137 static inline bool MustRegenerateBlob(SkScalar* outTransX, SkScalar* outTran
sY, |
| 339 const BitmapTextBlob&, const SkPaint&, | 138 const GrAtlasTextBlob&, const SkPaint&
, |
| 340 const SkMaskFilter::BlurRec&, | 139 const SkMaskFilter::BlurRec&, |
| 341 const SkMatrix& viewMatrix, SkScalar x
, SkScalar y); | 140 const SkMatrix& viewMatrix, SkScalar x
, SkScalar y); |
| 342 void regenerateTextBlob(BitmapTextBlob* bmp, const SkPaint& skPaint, GrColor
, | 141 void regenerateTextBlob(GrAtlasTextBlob* bmp, const SkPaint& skPaint, GrColo
r, |
| 343 const SkMatrix& viewMatrix, | 142 const SkMatrix& viewMatrix, |
| 344 const SkTextBlob* blob, SkScalar x, SkScalar y, | 143 const SkTextBlob* blob, SkScalar x, SkScalar y, |
| 345 SkDrawFilter* drawFilter, const SkIRect& clipRect, G
rRenderTarget*, | 144 SkDrawFilter* drawFilter, const SkIRect& clipRect, G
rRenderTarget*, |
| 346 const GrClip&, const GrPaint&); | 145 const GrClip&, const GrPaint&); |
| 347 inline static bool HasLCD(const SkTextBlob*); | 146 inline static bool HasLCD(const SkTextBlob*); |
| 348 inline void initDistanceFieldPaint(BitmapTextBlob*, SkPaint*, SkScalar* text
Ratio, | 147 inline void initDistanceFieldPaint(GrAtlasTextBlob*, SkPaint*, SkScalar* tex
tRatio, |
| 349 const SkMatrix&); | 148 const SkMatrix&); |
| 350 | 149 |
| 351 // Test methods | 150 // Test methods |
| 352 // TODO this is really ugly. It'd be much nicer if positioning could be mov
ed to batch | 151 // TODO this is really ugly. It'd be much nicer if positioning could be mov
ed to batch |
| 353 inline BitmapTextBlob* createDrawTextBlob(GrRenderTarget*, const GrClip&, co
nst GrPaint&, | 152 inline GrAtlasTextBlob* createDrawTextBlob(GrRenderTarget*, const GrClip&, c
onst GrPaint&, |
| 354 const SkPaint&, const SkMatrix& vi
ewMatrix, | 153 const SkPaint&, const SkMatrix& vi
ewMatrix, |
| 355 const char text[], size_t byteLeng
th, | 154 const char text[], size_t byteLeng
th, |
| 356 SkScalar x, SkScalar y, | 155 SkScalar x, SkScalar y, |
| 357 const SkIRect& regionClipBounds); | 156 const SkIRect& regionClipBounds); |
| 358 inline BitmapTextBlob* createDrawPosTextBlob(GrRenderTarget*, const GrClip&,
const GrPaint&, | 157 inline GrAtlasTextBlob* createDrawPosTextBlob(GrRenderTarget*, const GrClip&
, const GrPaint&, |
| 359 const SkPaint&, const SkMatrix&
viewMatrix, | 158 const SkPaint&, const SkMatrix&
viewMatrix, |
| 360 const char text[], size_t byteL
ength, | 159 const char text[], size_t byteL
ength, |
| 361 const SkScalar pos[], int scala
rsPerPosition, | 160 const SkScalar pos[], int scala
rsPerPosition, |
| 362 const SkPoint& offset, | 161 const SkPoint& offset, |
| 363 const SkIRect& regionClipBounds
); | 162 const SkIRect& regionClipBounds
); |
| 364 | 163 |
| 365 // Distance field text needs this table to compute a value for use in the fr
agment shader. | 164 // 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 | 165 // Because the GrAtlasTextContext can go out of scope before the final flush
, this needs to be |
| 367 // refcnted and malloced | 166 // refcnted and malloced |
| 368 struct DistanceAdjustTable : public SkNVRefCnt<DistanceAdjustTable> { | 167 struct DistanceAdjustTable : public SkNVRefCnt<DistanceAdjustTable> { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 387 friend class BitmapTextBatch; | 186 friend class BitmapTextBatch; |
| 388 | 187 |
| 389 #ifdef GR_TEST_UTILS | 188 #ifdef GR_TEST_UTILS |
| 390 BATCH_TEST_FRIEND(TextBlobBatch); | 189 BATCH_TEST_FRIEND(TextBlobBatch); |
| 391 #endif | 190 #endif |
| 392 | 191 |
| 393 typedef GrTextContext INHERITED; | 192 typedef GrTextContext INHERITED; |
| 394 }; | 193 }; |
| 395 | 194 |
| 396 #endif | 195 #endif |
| OLD | NEW |