joshualitt | 96880d9 | 2016-02-16 10:36:53 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "GrPathRenderingDrawContext.h" |
| 9 | |
| 10 | #include "GrDrawingManager.h" |
| 11 | |
| 12 | #include "text/GrStencilAndCoverTextContext.h" |
| 13 | |
| 14 | #define ASSERT_SINGLE_OWNER \ |
| 15 | SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(this->singleOwner());) |
| 16 | #define RETURN_IF_ABANDONED if (this->drawingManager()->abandoned()) { return; } |
| 17 | |
| 18 | void GrPathRenderingDrawContext::drawText(const GrClip& clip, const GrPaint& grPaint, |
| 19 | const SkPaint& skPaint, |
| 20 | const SkMatrix& viewMatrix, const char text[], |
| 21 | size_t byteLength, SkScalar x, SkScalar y, |
| 22 | const SkIRect& clipBounds) { |
| 23 | ASSERT_SINGLE_OWNER |
| 24 | RETURN_IF_ABANDONED |
| 25 | SkDEBUGCODE(this->validate();) |
| 26 | GR_AUDIT_TRAIL_AUTO_FRAME(this->auditTrail(), "GrPathRenderingDrawContext::drawText"); |
| 27 | |
| 28 | if (!fStencilAndCoverTextContext) { |
joshualitt | 8db8678 | 2016-02-17 05:40:00 -0800 | [diff] [blame] | 29 | fStencilAndCoverTextContext.reset(GrStencilAndCoverTextContext::Create()); |
joshualitt | 96880d9 | 2016-02-16 10:36:53 -0800 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | fStencilAndCoverTextContext->drawText(this->drawingManager()->getContext(), this, clip, grPaint, |
| 33 | skPaint, viewMatrix, this->surfaceProps(), |
| 34 | text, byteLength, x, y, clipBounds); |
| 35 | } |
| 36 | |
| 37 | void GrPathRenderingDrawContext::drawPosText(const GrClip& clip, const GrPaint& grPaint, |
| 38 | const SkPaint& skPaint, |
| 39 | const SkMatrix& viewMatrix, const char text[], |
| 40 | size_t byteLength, const SkScalar pos[], |
| 41 | int scalarsPerPosition, const SkPoint& offset, |
| 42 | const SkIRect& clipBounds) { |
| 43 | ASSERT_SINGLE_OWNER |
| 44 | RETURN_IF_ABANDONED |
| 45 | SkDEBUGCODE(this->validate();) |
| 46 | GR_AUDIT_TRAIL_AUTO_FRAME(this->auditTrail(), "GrPathRenderingDrawContext::drawPosText"); |
| 47 | |
| 48 | if (!fStencilAndCoverTextContext) { |
joshualitt | 8db8678 | 2016-02-17 05:40:00 -0800 | [diff] [blame] | 49 | fStencilAndCoverTextContext.reset(GrStencilAndCoverTextContext::Create()); |
joshualitt | 96880d9 | 2016-02-16 10:36:53 -0800 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | fStencilAndCoverTextContext->drawPosText(this->drawingManager()->getContext(), this, clip, |
| 53 | grPaint, skPaint, viewMatrix, this->surfaceProps(), |
| 54 | text, byteLength, pos, scalarsPerPosition, offset, |
| 55 | clipBounds); |
| 56 | } |
| 57 | |
| 58 | void GrPathRenderingDrawContext::drawTextBlob(const GrClip& clip, const SkPaint& skPaint, |
| 59 | const SkMatrix& viewMatrix, const SkTextBlob* blob, |
| 60 | SkScalar x, SkScalar y, |
| 61 | SkDrawFilter* filter, const SkIRect& clipBounds) { |
| 62 | ASSERT_SINGLE_OWNER |
| 63 | RETURN_IF_ABANDONED |
| 64 | SkDEBUGCODE(this->validate();) |
| 65 | GR_AUDIT_TRAIL_AUTO_FRAME(this->auditTrail(), "GrPathRenderingDrawContext::drawTextBlob"); |
| 66 | |
| 67 | if (!fStencilAndCoverTextContext) { |
joshualitt | 8db8678 | 2016-02-17 05:40:00 -0800 | [diff] [blame] | 68 | fStencilAndCoverTextContext.reset(GrStencilAndCoverTextContext::Create()); |
joshualitt | 96880d9 | 2016-02-16 10:36:53 -0800 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | fStencilAndCoverTextContext->drawTextBlob(this->drawingManager()->getContext(), this, clip, |
| 72 | skPaint, viewMatrix, this->surfaceProps(), blob, x, |
| 73 | y, filter, clipBounds); |
| 74 | } |