blob: 90966a8e84f2796bcda08cd53f620ee4cae18104 [file] [log] [blame]
Brian Osman11052242016-10-27 14:47:55 -04001/*
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 "GrPathRenderingRenderTargetContext.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()->wasAbandoned()) { return; }
17
Brian Salomon6f1d36c2017-01-13 12:02:17 -050018void GrPathRenderingRenderTargetContext::drawText(const GrClip& clip, const SkPaint& skPaint,
Brian Osman11052242016-10-27 14:47:55 -040019 const SkMatrix& viewMatrix, const char text[],
20 size_t byteLength, SkScalar x, SkScalar y,
21 const SkIRect& clipBounds) {
22 ASSERT_SINGLE_OWNER
23 RETURN_IF_ABANDONED
24 SkDEBUGCODE(this->validate();)
25 GR_AUDIT_TRAIL_AUTO_FRAME(this->auditTrail(), "GrPathRenderingRenderTargetContext::drawText");
26
27 if (!fStencilAndCoverTextContext) {
28 GrAtlasTextContext* fallbackContext = this->drawingManager()->getAtlasTextContext();
29 fStencilAndCoverTextContext.reset(GrStencilAndCoverTextContext::Create(fallbackContext));
30 }
31
Brian Salomon6f1d36c2017-01-13 12:02:17 -050032 fStencilAndCoverTextContext->drawText(this->drawingManager()->getContext(), this, clip, skPaint,
33 viewMatrix, this->surfaceProps(), text, byteLength, x, y,
34 clipBounds);
Brian Osman11052242016-10-27 14:47:55 -040035}
36
Brian Salomon6f1d36c2017-01-13 12:02:17 -050037void GrPathRenderingRenderTargetContext::drawPosText(const GrClip& clip, const SkPaint& skPaint,
Brian Osman11052242016-10-27 14:47:55 -040038 const SkMatrix& viewMatrix, const char text[],
Brian Salomon82f44312017-01-11 13:42:54 -050039 size_t byteLength, const SkScalar pos[],
Brian Osman11052242016-10-27 14:47:55 -040040 int scalarsPerPosition, const SkPoint& offset,
41 const SkIRect& clipBounds) {
42 ASSERT_SINGLE_OWNER
43 RETURN_IF_ABANDONED
44 SkDEBUGCODE(this->validate();)
45 GR_AUDIT_TRAIL_AUTO_FRAME(this->auditTrail(),
46 "GrPathRenderingRenderTargetContext::drawPosText");
47
48 if (!fStencilAndCoverTextContext) {
49 GrAtlasTextContext* fallbackContext = this->drawingManager()->getAtlasTextContext();
50 fStencilAndCoverTextContext.reset(GrStencilAndCoverTextContext::Create(fallbackContext));
51 }
52
Brian Salomon6f1d36c2017-01-13 12:02:17 -050053 fStencilAndCoverTextContext->drawPosText(
54 this->drawingManager()->getContext(), this, clip, skPaint, viewMatrix,
55 this->surfaceProps(), text, byteLength, pos, scalarsPerPosition, offset, clipBounds);
Brian Osman11052242016-10-27 14:47:55 -040056}
57
58void GrPathRenderingRenderTargetContext::drawTextBlob(const GrClip& clip, const SkPaint& skPaint,
59 const SkMatrix& viewMatrix,
60 const SkTextBlob* blob,
61 SkScalar x, SkScalar y,
62 SkDrawFilter* filter,
63 const SkIRect& clipBounds) {
64 ASSERT_SINGLE_OWNER
65 RETURN_IF_ABANDONED
66 SkDEBUGCODE(this->validate();)
67 GR_AUDIT_TRAIL_AUTO_FRAME(this->auditTrail(),
68 "GrPathRenderingRenderTargetContext::drawTextBlob");
69
70 if (!fStencilAndCoverTextContext) {
71 GrAtlasTextContext* fallbackContext = this->drawingManager()->getAtlasTextContext();
72 fStencilAndCoverTextContext.reset(GrStencilAndCoverTextContext::Create(fallbackContext));
73 }
74
75 fStencilAndCoverTextContext->drawTextBlob(this->drawingManager()->getContext(), this, clip,
76 skPaint, viewMatrix, this->surfaceProps(), blob, x,
77 y, filter, clipBounds);
78}