blob: 0707678f5678a946513ab2f2d664697bb2eb9b6b [file] [log] [blame]
Robert Phillips009e9af2017-06-15 14:01:04 -04001/*
2 * Copyright 2017 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
Mike Kleinc0bd9f92019-04-23 12:05:21 -05008#include "src/gpu/ops/GrStencilPathOp.h"
Robert Phillips009e9af2017-06-15 14:01:04 -04009
Mike Kleinc0bd9f92019-04-23 12:05:21 -050010#include "include/private/GrRecordingContext.h"
11#include "src/gpu/GrGpu.h"
12#include "src/gpu/GrMemoryPool.h"
13#include "src/gpu/GrOpFlushState.h"
14#include "src/gpu/GrRecordingContextPriv.h"
15#include "src/gpu/GrRenderTargetPriv.h"
Robert Phillips009e9af2017-06-15 14:01:04 -040016
Robert Phillipsb97da532019-02-12 15:24:12 -050017std::unique_ptr<GrOp> GrStencilPathOp::Make(GrRecordingContext* context,
Robert Phillips7c525e62018-06-12 10:11:12 -040018 const SkMatrix& viewMatrix,
19 bool useHWAA,
Robert Phillips7c525e62018-06-12 10:11:12 -040020 bool hasStencilClip,
21 const GrScissorState& scissor,
Robert Phillipse1efd382019-08-21 10:07:10 -040022 sk_sp<const GrPath> path) {
Robert Phillips9da87e02019-02-04 13:26:26 -050023 GrOpMemoryPool* pool = context->priv().opMemoryPool();
Robert Phillipsc994a932018-06-19 13:09:54 -040024
Robert Phillipse1efd382019-08-21 10:07:10 -040025 return pool->allocate<GrStencilPathOp>(viewMatrix, useHWAA,
26 hasStencilClip, scissor, std::move(path));
Robert Phillips7c525e62018-06-12 10:11:12 -040027}
28
Brian Salomon588cec72018-11-14 13:56:37 -050029void GrStencilPathOp::onExecute(GrOpFlushState* state, const SkRect& chainBounds) {
Robert Phillips65048132017-08-10 08:44:49 -040030 GrRenderTarget* rt = state->drawOpArgs().renderTarget();
31 SkASSERT(rt);
32
33 int numStencilBits = rt->renderTargetPriv().numStencilBits();
Robert Phillipse1efd382019-08-21 10:07:10 -040034 GrStencilSettings stencil(GrPathRendering::GetStencilPassSettings(fPath->getFillType()),
Robert Phillips65048132017-08-10 08:44:49 -040035 fHasStencilClip, numStencilBits);
36
Robert Phillips7311b402017-07-27 12:01:46 -040037 GrPathRendering::StencilPathArgs args(fUseHWAA, state->drawOpArgs().fProxy,
Robert Phillips65048132017-08-10 08:44:49 -040038 &fViewMatrix, &fScissor, &stencil);
Robert Phillips009e9af2017-06-15 14:01:04 -040039 state->gpu()->pathRendering()->stencilPath(args, fPath.get());
40}