blob: 25dbf311e55bb197b1c75b0b6787a84da30edeb5 [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
8#include "GrStencilPathOp.h"
9
Robert Phillips7c525e62018-06-12 10:11:12 -040010#include "GrContext.h"
11#include "GrContextPriv.h"
Robert Phillips009e9af2017-06-15 14:01:04 -040012#include "GrGpu.h"
Robert Phillips7c525e62018-06-12 10:11:12 -040013#include "GrMemoryPool.h"
Robert Phillips009e9af2017-06-15 14:01:04 -040014#include "GrOpFlushState.h"
Robert Phillips65048132017-08-10 08:44:49 -040015#include "GrRenderTargetPriv.h"
Robert Phillips009e9af2017-06-15 14:01:04 -040016
Robert Phillips7c525e62018-06-12 10:11:12 -040017std::unique_ptr<GrOp> GrStencilPathOp::Make(GrContext* context,
18 const SkMatrix& viewMatrix,
19 bool useHWAA,
20 GrPathRendering::FillType fillType,
21 bool hasStencilClip,
22 const GrScissorState& scissor,
23 const GrPath* path) {
Robert Phillipsc994a932018-06-19 13:09:54 -040024 GrOpMemoryPool* pool = context->contextPriv().opMemoryPool();
25
26 return pool->allocate<GrStencilPathOp>(viewMatrix, useHWAA, fillType,
27 hasStencilClip, scissor, path);
Robert Phillips7c525e62018-06-12 10:11:12 -040028}
29
Robert Phillips009e9af2017-06-15 14:01:04 -040030void GrStencilPathOp::onExecute(GrOpFlushState* state) {
Robert Phillips65048132017-08-10 08:44:49 -040031 GrRenderTarget* rt = state->drawOpArgs().renderTarget();
32 SkASSERT(rt);
33
34 int numStencilBits = rt->renderTargetPriv().numStencilBits();
35 GrStencilSettings stencil(GrPathRendering::GetStencilPassSettings(fFillType),
36 fHasStencilClip, numStencilBits);
37
Robert Phillips7311b402017-07-27 12:01:46 -040038 GrPathRendering::StencilPathArgs args(fUseHWAA, state->drawOpArgs().fProxy,
Robert Phillips65048132017-08-10 08:44:49 -040039 &fViewMatrix, &fScissor, &stencil);
Robert Phillips009e9af2017-06-15 14:01:04 -040040 state->gpu()->pathRendering()->stencilPath(args, fPath.get());
41}
42