gfx/skia/skia/src/gpu/GrPathRenderingDrawContext.cpp
author Wes Kocher <wkocher@mozilla.com>
Wed, 10 May 2017 10:01:18 -0700
changeset 407965 ce2218406119c36a551e3faea4e192186ee46cc5
permissions -rw-r--r--
Backed out 9 changesets (bug 1340627) for graphical glitches a=backout Backed out changeset 0b1371055c7f (bug 1340627) Backed out changeset f152be1fadb7 (bug 1340627) Backed out changeset c691e2ab6a0c (bug 1340627) Backed out changeset 3cb4bceb8d79 (bug 1340627) Backed out changeset 026aadd76d06 (bug 1340627) Backed out changeset fdbd5d281287 (bug 1340627) Backed out changeset 75fb0d9858a9 (bug 1340627) Backed out changeset 0d4ec7d38a00 (bug 1340627) Backed out changeset af6f19870b2a (bug 1340627) MozReview-Commit-ID: 9dHr7xMZezY

/*
 * 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 "GrPathRenderingDrawContext.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 GrPathRenderingDrawContext::drawText(const GrClip& clip,  const GrPaint& grPaint,
                                          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(), "GrPathRenderingDrawContext::drawText");

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

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

void GrPathRenderingDrawContext::drawPosText(const GrClip& clip, const GrPaint& grPaint,
                                             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(), "GrPathRenderingDrawContext::drawPosText");

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

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

void GrPathRenderingDrawContext::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(), "GrPathRenderingDrawContext::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);
}