aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrPathRenderingRenderTargetContext.cpp
blob: 90966a8e84f2796bcda08cd53f620ee4cae18104 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
 * Copyright 2016 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "GrPathRenderingRenderTargetContext.h"

#include "GrDrawingManager.h"

#include "text/GrStencilAndCoverTextContext.h"

#define ASSERT_SINGLE_OWNER \
    SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(this->singleOwner());)
#define RETURN_IF_ABANDONED        if (this->drawingManager()->wasAbandoned()) { return; }

void GrPathRenderingRenderTargetContext::drawText(const GrClip& clip, const SkPaint& skPaint,
                                                  const SkMatrix& viewMatrix, const char text[],
                                                  size_t byteLength, SkScalar x, SkScalar y,
                                                  const SkIRect& clipBounds) {
    ASSERT_SINGLE_OWNER
    RETURN_IF_ABANDONED
    SkDEBUGCODE(this->validate();)
    GR_AUDIT_TRAIL_AUTO_FRAME(this->auditTrail(), "GrPathRenderingRenderTargetContext::drawText");

    if (!fStencilAndCoverTextContext) {
        GrAtlasTextContext* fallbackContext = this->drawingManager()->getAtlasTextContext();
        fStencilAndCoverTextContext.reset(GrStencilAndCoverTextContext::Create(fallbackContext));
    }

    fStencilAndCoverTextContext->drawText(this->drawingManager()->getContext(), this, clip, skPaint,
                                          viewMatrix, this->surfaceProps(), text, byteLength, x, y,
                                          clipBounds);
}

void GrPathRenderingRenderTargetContext::drawPosText(const GrClip& clip, const SkPaint& skPaint,
                                                     const SkMatrix& viewMatrix, const char text[],
                                                     size_t byteLength, const SkScalar pos[],
                                                     int scalarsPerPosition, const SkPoint& offset,
                                                     const SkIRect& clipBounds) {
    ASSERT_SINGLE_OWNER
    RETURN_IF_ABANDONED
    SkDEBUGCODE(this->validate();)
    GR_AUDIT_TRAIL_AUTO_FRAME(this->auditTrail(),
                              "GrPathRenderingRenderTargetContext::drawPosText");

    if (!fStencilAndCoverTextContext) {
        GrAtlasTextContext* fallbackContext = this->drawingManager()->getAtlasTextContext();
        fStencilAndCoverTextContext.reset(GrStencilAndCoverTextContext::Create(fallbackContext));
    }

    fStencilAndCoverTextContext->drawPosText(
            this->drawingManager()->getContext(), this, clip, skPaint, viewMatrix,
            this->surfaceProps(), text, byteLength, pos, scalarsPerPosition, offset, clipBounds);
}

void GrPathRenderingRenderTargetContext::drawTextBlob(const GrClip& clip, const SkPaint& skPaint,
                                                      const SkMatrix& viewMatrix,
                                                      const SkTextBlob* blob,
                                                      SkScalar x, SkScalar y,
                                                      SkDrawFilter* filter,
                                                      const SkIRect& clipBounds) {
    ASSERT_SINGLE_OWNER
    RETURN_IF_ABANDONED
    SkDEBUGCODE(this->validate();)
    GR_AUDIT_TRAIL_AUTO_FRAME(this->auditTrail(),
                              "GrPathRenderingRenderTargetContext::drawTextBlob");

    if (!fStencilAndCoverTextContext) {
        GrAtlasTextContext* fallbackContext = this->drawingManager()->getAtlasTextContext();
        fStencilAndCoverTextContext.reset(GrStencilAndCoverTextContext::Create(fallbackContext));
    }

    fStencilAndCoverTextContext->drawTextBlob(this->drawingManager()->getContext(), this, clip,
                                              skPaint, viewMatrix, this->surfaceProps(), blob, x,
                                              y, filter, clipBounds);
}