1 /*
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
10 #include "GrContext.h"
11 #include "GrContextPriv.h"
12 #include "GrGpu.h"
13 #include "GrMemoryPool.h"
14 #include "GrOpFlushState.h"
15 #include "GrRenderTargetPriv.h"
16
Make(GrContext * context,const SkMatrix & viewMatrix,bool useHWAA,GrPathRendering::FillType fillType,bool hasStencilClip,const GrScissorState & scissor,const GrPath * path)17 std::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) {
24 GrOpMemoryPool* pool = context->contextPriv().opMemoryPool();
25
26 return pool->allocate<GrStencilPathOp>(viewMatrix, useHWAA, fillType,
27 hasStencilClip, scissor, path);
28 }
29
onExecute(GrOpFlushState * state,const SkRect & chainBounds)30 void GrStencilPathOp::onExecute(GrOpFlushState* state, const SkRect& chainBounds) {
31 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
38 GrPathRendering::StencilPathArgs args(fUseHWAA, state->drawOpArgs().fProxy,
39 &fViewMatrix, &fScissor, &stencil);
40 state->gpu()->pathRendering()->stencilPath(args, fPath.get());
41 }
42