OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 #include "GrPathRenderingDrawContext.h" | 8 #include "GrPathRenderingDrawContext.h" |
9 | 9 |
10 #include "GrDrawingManager.h" | 10 #include "GrDrawingManager.h" |
11 | 11 |
12 #include "text/GrStencilAndCoverTextContext.h" | 12 #include "text/GrStencilAndCoverTextContext.h" |
13 | 13 |
14 #define ASSERT_SINGLE_OWNER \ | 14 #define ASSERT_SINGLE_OWNER \ |
15 SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(this->singleOwner()
);) | 15 SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(this->singleOwner()
);) |
16 #define RETURN_IF_ABANDONED if (this->drawingManager()->wasAbandoned()) {
return; } | 16 #define RETURN_IF_ABANDONED if (this->drawingManager()->wasAbandoned()) {
return; } |
17 | 17 |
18 void GrPathRenderingDrawContext::drawText(const GrClip& clip, const GrPaint& gr
Paint, | 18 void GrPathRenderingDrawContext::drawText(const GrClip& clip, const GrPaint& gr
Paint, |
19 const SkPaint& skPaint, | 19 const SkPaint& skPaint, |
20 const SkMatrix& viewMatrix, const char
text[], | 20 const SkMatrix& viewMatrix, const char
text[], |
21 size_t byteLength, SkScalar x, SkScala
r y, | 21 size_t byteLength, SkScalar x, SkScala
r y, |
22 const SkIRect& clipBounds) { | 22 const SkIRect& clipBounds) { |
23 ASSERT_SINGLE_OWNER | 23 ASSERT_SINGLE_OWNER |
24 RETURN_IF_ABANDONED | 24 RETURN_IF_ABANDONED |
25 SkDEBUGCODE(this->validate();) | 25 SkDEBUGCODE(this->validate();) |
26 GR_AUDIT_TRAIL_AUTO_FRAME(this->auditTrail(), "GrPathRenderingDrawContext::d
rawText"); | 26 GR_AUDIT_TRAIL_AUTO_FRAME(this->auditTrail(), "GrPathRenderingDrawContext::d
rawText"); |
27 | 27 |
28 if (!fStencilAndCoverTextContext) { | 28 if (!fStencilAndCoverTextContext) { |
29 fStencilAndCoverTextContext.reset(GrStencilAndCoverTextContext::Create()
); | 29 GrAtlasTextContext* fallbackContext = this->drawingManager()->getAtlasTe
xtContext(); |
| 30 fStencilAndCoverTextContext.reset(GrStencilAndCoverTextContext::Create(f
allbackContext)); |
30 } | 31 } |
31 | 32 |
32 fStencilAndCoverTextContext->drawText(this->drawingManager()->getContext(),
this, clip, grPaint, | 33 fStencilAndCoverTextContext->drawText(this->drawingManager()->getContext(),
this, clip, grPaint, |
33 skPaint, viewMatrix, this->surfaceProp
s(), | 34 skPaint, viewMatrix, this->surfaceProp
s(), |
34 text, byteLength, x, y, clipBounds); | 35 text, byteLength, x, y, clipBounds); |
35 } | 36 } |
36 | 37 |
37 void GrPathRenderingDrawContext::drawPosText(const GrClip& clip, const GrPaint&
grPaint, | 38 void GrPathRenderingDrawContext::drawPosText(const GrClip& clip, const GrPaint&
grPaint, |
38 const SkPaint& skPaint, | 39 const SkPaint& skPaint, |
39 const SkMatrix& viewMatrix, const c
har text[], | 40 const SkMatrix& viewMatrix, const c
har text[], |
40 size_t byteLength, const SkScalar
pos[], | 41 size_t byteLength, const SkScalar
pos[], |
41 int scalarsPerPosition, const SkPoi
nt& offset, | 42 int scalarsPerPosition, const SkPoi
nt& offset, |
42 const SkIRect& clipBounds) { | 43 const SkIRect& clipBounds) { |
43 ASSERT_SINGLE_OWNER | 44 ASSERT_SINGLE_OWNER |
44 RETURN_IF_ABANDONED | 45 RETURN_IF_ABANDONED |
45 SkDEBUGCODE(this->validate();) | 46 SkDEBUGCODE(this->validate();) |
46 GR_AUDIT_TRAIL_AUTO_FRAME(this->auditTrail(), "GrPathRenderingDrawContext::d
rawPosText"); | 47 GR_AUDIT_TRAIL_AUTO_FRAME(this->auditTrail(), "GrPathRenderingDrawContext::d
rawPosText"); |
47 | 48 |
48 if (!fStencilAndCoverTextContext) { | 49 if (!fStencilAndCoverTextContext) { |
49 fStencilAndCoverTextContext.reset(GrStencilAndCoverTextContext::Create()
); | 50 GrAtlasTextContext* fallbackContext = this->drawingManager()->getAtlasTe
xtContext(); |
| 51 fStencilAndCoverTextContext.reset(GrStencilAndCoverTextContext::Create(f
allbackContext)); |
50 } | 52 } |
51 | 53 |
52 fStencilAndCoverTextContext->drawPosText(this->drawingManager()->getContext(
), this, clip, | 54 fStencilAndCoverTextContext->drawPosText(this->drawingManager()->getContext(
), this, clip, |
53 grPaint, skPaint, viewMatrix, this-
>surfaceProps(), | 55 grPaint, skPaint, viewMatrix, this-
>surfaceProps(), |
54 text, byteLength, pos, scalarsPerPo
sition, offset, | 56 text, byteLength, pos, scalarsPerPo
sition, offset, |
55 clipBounds); | 57 clipBounds); |
56 } | 58 } |
57 | 59 |
58 void GrPathRenderingDrawContext::drawTextBlob(const GrClip& clip, const SkPaint&
skPaint, | 60 void GrPathRenderingDrawContext::drawTextBlob(const GrClip& clip, const SkPaint&
skPaint, |
59 const SkMatrix& viewMatrix, const
SkTextBlob* blob, | 61 const SkMatrix& viewMatrix, const
SkTextBlob* blob, |
60 SkScalar x, SkScalar y, | 62 SkScalar x, SkScalar y, |
61 SkDrawFilter* filter, const SkIRec
t& clipBounds) { | 63 SkDrawFilter* filter, const SkIRec
t& clipBounds) { |
62 ASSERT_SINGLE_OWNER | 64 ASSERT_SINGLE_OWNER |
63 RETURN_IF_ABANDONED | 65 RETURN_IF_ABANDONED |
64 SkDEBUGCODE(this->validate();) | 66 SkDEBUGCODE(this->validate();) |
65 GR_AUDIT_TRAIL_AUTO_FRAME(this->auditTrail(), "GrPathRenderingDrawContext::d
rawTextBlob"); | 67 GR_AUDIT_TRAIL_AUTO_FRAME(this->auditTrail(), "GrPathRenderingDrawContext::d
rawTextBlob"); |
66 | 68 |
67 if (!fStencilAndCoverTextContext) { | 69 if (!fStencilAndCoverTextContext) { |
68 fStencilAndCoverTextContext.reset(GrStencilAndCoverTextContext::Create()
); | 70 GrAtlasTextContext* fallbackContext = this->drawingManager()->getAtlasTe
xtContext(); |
| 71 fStencilAndCoverTextContext.reset(GrStencilAndCoverTextContext::Create(f
allbackContext)); |
69 } | 72 } |
70 | 73 |
71 fStencilAndCoverTextContext->drawTextBlob(this->drawingManager()->getContext
(), this, clip, | 74 fStencilAndCoverTextContext->drawTextBlob(this->drawingManager()->getContext
(), this, clip, |
72 skPaint, viewMatrix, this->surface
Props(), blob, x, | 75 skPaint, viewMatrix, this->surface
Props(), blob, x, |
73 y, filter, clipBounds); | 76 y, filter, clipBounds); |
74 } | 77 } |
OLD | NEW |