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 16 matching lines...) Expand all Loading... |
27 class GrDrawContext; | 27 class GrDrawContext; |
28 class GrPipelineBuilder; | 28 class GrPipelineBuilder; |
29 class GrTextBlobCache; | 29 class GrTextBlobCache; |
30 | 30 |
31 /* | 31 /* |
32 * This class implements GrTextContext using standard bitmap fonts, and can also
process textblobs. | 32 * This class implements GrTextContext using standard bitmap fonts, and can also
process textblobs. |
33 * TODO replace GrBitmapTextContext | 33 * TODO replace GrBitmapTextContext |
34 */ | 34 */ |
35 class GrAtlasTextContext : public GrTextContext { | 35 class GrAtlasTextContext : public GrTextContext { |
36 public: | 36 public: |
37 static GrAtlasTextContext* Create(GrContext*, SkGpuDevice*, const SkDevicePr
operties&, | 37 static GrAtlasTextContext* Create(GrContext*, const SkDeviceProperties&, |
38 bool enableDistanceFields); | 38 bool enableDistanceFields); |
39 | 39 |
40 private: | 40 private: |
41 GrAtlasTextContext(GrContext*, SkGpuDevice*, const SkDeviceProperties&, | 41 GrAtlasTextContext(GrContext*, const SkDeviceProperties&, bool enableDistanc
eFields); |
42 bool enableDistanceFields); | |
43 ~GrAtlasTextContext() override {} | 42 ~GrAtlasTextContext() override {} |
44 | 43 |
45 bool canDraw(const GrRenderTarget*, const GrClip&, const GrPaint&, | 44 bool canDraw(const GrRenderTarget*, const GrClip&, const GrPaint&, |
46 const SkPaint&, const SkMatrix& viewMatrix) override; | 45 const SkPaint&, const SkMatrix& viewMatrix) override; |
47 | 46 |
48 void onDrawText(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPain
t&, | 47 void onDrawText(GrDrawContext*, GrRenderTarget*, const GrClip&, const GrPain
t&, const SkPaint&, |
49 const SkMatrix& viewMatrix, const char text[], size_t byteLe
ngth, | 48 const SkMatrix& viewMatrix, const char text[], size_t byteLe
ngth, |
50 SkScalar x, SkScalar y, const SkIRect& regionClipBounds) ove
rride; | 49 SkScalar x, SkScalar y, const SkIRect& regionClipBounds) ove
rride; |
51 void onDrawPosText(GrRenderTarget*, const GrClip&, const GrPaint&, const SkP
aint&, | 50 void onDrawPosText(GrDrawContext*, GrRenderTarget*, const GrClip&, const GrP
aint&, |
52 const SkMatrix& viewMatrix, | 51 const SkPaint&, const SkMatrix& viewMatrix, |
53 const char text[], size_t byteLength, | 52 const char text[], size_t byteLength, |
54 const SkScalar pos[], int scalarsPerPosition, | 53 const SkScalar pos[], int scalarsPerPosition, |
55 const SkPoint& offset, const SkIRect& regionClipBounds) o
verride; | 54 const SkPoint& offset, const SkIRect& regionClipBounds) o
verride; |
56 void drawTextBlob(GrRenderTarget*, const GrClip&, const SkPaint&, | 55 void drawTextBlob(SkGpuDevice*, GrRenderTarget*, const GrClip&, const SkPain
t&, |
57 const SkMatrix& viewMatrix, const SkTextBlob*, SkScalar x,
SkScalar y, | 56 const SkMatrix& viewMatrix, const SkTextBlob*, SkScalar x,
SkScalar y, |
58 SkDrawFilter*, const SkIRect& clipBounds) override; | 57 SkDrawFilter*, const SkIRect& clipBounds) override; |
59 | 58 |
60 /* | 59 /* |
61 * A BitmapTextBlob contains a fully processed SkTextBlob, suitable for near
ly immediate drawing | 60 * A BitmapTextBlob contains a fully processed SkTextBlob, suitable for near
ly immediate drawing |
62 * on the GPU. These are initially created with valid positions and colors,
but invalid | 61 * on the GPU. These are initially created with valid positions and colors,
but invalid |
63 * texture coordinates. The BitmapTextBlob itself has a few Blob-wide prope
rties, and also | 62 * texture coordinates. The BitmapTextBlob itself has a few Blob-wide prope
rties, and also |
64 * consists of a number of runs. Runs inside a blob are flushed individuall
y so they can be | 63 * consists of a number of runs. Runs inside a blob are flushed individuall
y so they can be |
65 * reordered. | 64 * reordered. |
66 * | 65 * |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 bool dfAppendGlyph(BitmapTextBlob*, int runIndex, GrGlyph::PackedID, SkScala
r sx, SkScalar sy, | 264 bool dfAppendGlyph(BitmapTextBlob*, int runIndex, GrGlyph::PackedID, SkScala
r sx, SkScalar sy, |
266 GrColor color, GrFontScaler*, const SkIRect& clipRect, Sk
Scalar textRatio, | 265 GrColor color, GrFontScaler*, const SkIRect& clipRect, Sk
Scalar textRatio, |
267 const SkMatrix& viewMatrix); | 266 const SkMatrix& viewMatrix); |
268 inline void appendGlyphPath(BitmapTextBlob* blob, GrGlyph* glyph, | 267 inline void appendGlyphPath(BitmapTextBlob* blob, GrGlyph* glyph, |
269 GrFontScaler* scaler, SkScalar x, SkScalar y); | 268 GrFontScaler* scaler, SkScalar x, SkScalar y); |
270 inline void appendGlyphCommon(BitmapTextBlob*, Run*, Run::SubRunInfo*, | 269 inline void appendGlyphCommon(BitmapTextBlob*, Run*, Run::SubRunInfo*, |
271 const SkRect& positions, GrColor color, | 270 const SkRect& positions, GrColor color, |
272 size_t vertexStride, bool useVertexColor, | 271 size_t vertexStride, bool useVertexColor, |
273 GrGlyph*); | 272 GrGlyph*); |
274 | 273 |
275 inline void flushRunAsPaths(const SkTextBlob::RunIterator&, const SkPaint&,
SkDrawFilter*, | 274 inline void flushRunAsPaths(SkGpuDevice*, GrDrawContext*, GrRenderTarget*, |
| 275 const SkTextBlob::RunIterator&, const GrClip& cl
ip, |
| 276 const SkPaint&, SkDrawFilter*, |
276 const SkMatrix& viewMatrix, const SkIRect& clipB
ounds, SkScalar x, | 277 const SkMatrix& viewMatrix, const SkIRect& clipB
ounds, SkScalar x, |
277 SkScalar y); | 278 SkScalar y); |
278 inline BitmapTextBatch* createBatch(BitmapTextBlob*, const PerSubRunInfo&, | 279 inline BitmapTextBatch* createBatch(BitmapTextBlob*, const PerSubRunInfo&, |
279 int glyphCount, int run, int subRun, | 280 int glyphCount, int run, int subRun, |
280 GrColor, SkScalar transX, SkScalar trans
Y, | 281 GrColor, SkScalar transX, SkScalar trans
Y, |
281 const SkPaint&); | 282 const SkPaint&); |
282 inline void flushRun(GrDrawContext*, GrPipelineBuilder*, BitmapTextBlob*, in
t run, GrColor, | 283 inline void flushRun(GrDrawContext*, GrPipelineBuilder*, BitmapTextBlob*, in
t run, GrColor, |
283 SkScalar transX, SkScalar transY, const SkPaint&); | 284 SkScalar transX, SkScalar transY, const SkPaint&); |
284 inline void flushBigGlyphs(BitmapTextBlob* cacheBlob, GrRenderTarget* rt, | 285 inline void flushBigGlyphs(BitmapTextBlob* cacheBlob, GrDrawContext*, GrRend
erTarget*, |
285 const SkPaint& skPaint, | 286 const GrClip& clip, const SkPaint& skPaint, |
286 SkScalar transX, SkScalar transY, const SkIRect&
clipBounds); | 287 SkScalar transX, SkScalar transY, const SkIRect&
clipBounds); |
287 | 288 |
288 // We have to flush SkTextBlobs differently from drawText / drawPosText | 289 // We have to flush SkTextBlobs differently from drawText / drawPosText |
289 void flush(GrDrawContext*, const SkTextBlob*, BitmapTextBlob*, GrRenderTarge
t*, const SkPaint&, | 290 void flush(SkGpuDevice*, GrDrawContext*, const SkTextBlob*, BitmapTextBlob*,
GrRenderTarget*, |
290 const GrPaint&, SkDrawFilter*, const GrClip&, const SkMatrix& vie
wMatrix, | 291 const SkPaint&, const GrPaint&, SkDrawFilter*, const GrClip&, |
291 const SkIRect& clipBounds, SkScalar x, SkScalar y, SkScalar trans
X, SkScalar transY); | 292 const SkMatrix& viewMatrix, const SkIRect& clipBounds, SkScalar x
, SkScalar y, |
| 293 SkScalar transX, SkScalar transY); |
292 void flush(GrDrawContext*, BitmapTextBlob*, GrRenderTarget*, const SkPaint&, | 294 void flush(GrDrawContext*, BitmapTextBlob*, GrRenderTarget*, const SkPaint&, |
293 const GrPaint&, const GrClip&, const SkIRect& clipBounds); | 295 const GrPaint&, const GrClip&, const SkIRect& clipBounds); |
294 | 296 |
295 // A helper for drawing BitmapText in a run of distance fields | 297 // A helper for drawing BitmapText in a run of distance fields |
296 inline void fallbackDrawPosText(BitmapTextBlob*, int runIndex, | 298 inline void fallbackDrawPosText(BitmapTextBlob*, int runIndex, |
297 GrRenderTarget*, const GrClip&, | 299 GrRenderTarget*, const GrClip&, |
298 const GrPaint&, | 300 const GrPaint&, |
299 const SkPaint&, const SkMatrix& viewMatrix, | 301 const SkPaint&, const SkMatrix& viewMatrix, |
300 const SkTDArray<char>& fallbackTxt, | 302 const SkTDArray<char>& fallbackTxt, |
301 const SkTDArray<SkScalar>& fallbackPos, | 303 const SkTDArray<SkScalar>& fallbackPos, |
(...skipping 28 matching lines...) Expand all Loading... |
330 SkTDArray<char>* fallbackTxt, | 332 SkTDArray<char>* fallbackTxt, |
331 SkTDArray<SkScalar>* fallbackPos); | 333 SkTDArray<SkScalar>* fallbackPos); |
332 | 334 |
333 // sets up the descriptor on the blob and returns a detached cache. Client
must attach | 335 // sets up the descriptor on the blob and returns a detached cache. Client
must attach |
334 inline static GrColor ComputeCanonicalColor(const SkPaint&, bool lcd); | 336 inline static GrColor ComputeCanonicalColor(const SkPaint&, bool lcd); |
335 inline SkGlyphCache* setupCache(Run*, const SkPaint&, const SkMatrix* viewMa
trix, bool noGamma); | 337 inline SkGlyphCache* setupCache(Run*, const SkPaint&, const SkMatrix* viewMa
trix, bool noGamma); |
336 static inline bool MustRegenerateBlob(SkScalar* outTransX, SkScalar* outTran
sY, | 338 static inline bool MustRegenerateBlob(SkScalar* outTransX, SkScalar* outTran
sY, |
337 const BitmapTextBlob&, const SkPaint&, | 339 const BitmapTextBlob&, const SkPaint&, |
338 const SkMaskFilter::BlurRec&, | 340 const SkMaskFilter::BlurRec&, |
339 const SkMatrix& viewMatrix, SkScalar x
, SkScalar y); | 341 const SkMatrix& viewMatrix, SkScalar x
, SkScalar y); |
340 void regenerateTextBlob(BitmapTextBlob* bmp, const SkPaint& skPaint, GrColor
, | 342 void regenerateTextBlob(SkGpuDevice*, BitmapTextBlob* bmp, const SkPaint& sk
Paint, GrColor, |
341 const SkMatrix& viewMatrix, | 343 const SkMatrix& viewMatrix, |
342 const SkTextBlob* blob, SkScalar x, SkScalar y, | 344 const SkTextBlob* blob, SkScalar x, SkScalar y, |
343 SkDrawFilter* drawFilter, const SkIRect& clipRect, G
rRenderTarget*, | 345 SkDrawFilter* drawFilter, const SkIRect& clipRect, G
rRenderTarget*, |
344 const GrClip&, const GrPaint&); | 346 const GrClip&, const GrPaint&); |
345 inline static bool HasLCD(const SkTextBlob*); | 347 inline static bool HasLCD(const SkTextBlob*); |
346 inline void initDistanceFieldPaint(BitmapTextBlob*, SkPaint*, SkScalar* text
Ratio, | 348 inline void initDistanceFieldPaint(BitmapTextBlob*, SkPaint*, SkScalar* text
Ratio, |
347 const SkMatrix&); | 349 const SkMatrix&); |
348 | 350 |
349 // Test methods | 351 // Test methods |
350 // TODO this is really ugly. It'd be much nicer if positioning could be mov
ed to batch | 352 // TODO this is really ugly. It'd be much nicer if positioning could be mov
ed to batch |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 friend class BitmapTextBatch; | 391 friend class BitmapTextBatch; |
390 | 392 |
391 #ifdef GR_TEST_UTILS | 393 #ifdef GR_TEST_UTILS |
392 BATCH_TEST_FRIEND(TextBlobBatch); | 394 BATCH_TEST_FRIEND(TextBlobBatch); |
393 #endif | 395 #endif |
394 | 396 |
395 typedef GrTextContext INHERITED; | 397 typedef GrTextContext INHERITED; |
396 }; | 398 }; |
397 | 399 |
398 #endif | 400 #endif |
OLD | NEW |