• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "src/gpu/ops/GrStencilPathOp.h"
9 
10 #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"
16 
Make(GrRecordingContext * context,const SkMatrix & viewMatrix,bool useHWAA,bool hasStencilClip,const GrScissorState & scissor,sk_sp<const GrPath> path)17 std::unique_ptr<GrOp> GrStencilPathOp::Make(GrRecordingContext* context,
18                                             const SkMatrix& viewMatrix,
19                                             bool useHWAA,
20                                             bool hasStencilClip,
21                                             const GrScissorState& scissor,
22                                             sk_sp<const GrPath> path) {
23     GrOpMemoryPool* pool = context->priv().opMemoryPool();
24 
25     return pool->allocate<GrStencilPathOp>(viewMatrix, useHWAA,
26                                            hasStencilClip, scissor, std::move(path));
27 }
28 
onExecute(GrOpFlushState * state,const SkRect & chainBounds)29 void GrStencilPathOp::onExecute(GrOpFlushState* state, const SkRect& chainBounds) {
30     GrRenderTarget* rt = state->drawOpArgs().proxy()->peekRenderTarget();
31     SkASSERT(rt);
32 
33     int numStencilBits = rt->renderTargetPriv().numStencilBits();
34     GrStencilSettings stencil(GrPathRendering::GetStencilPassSettings(fPath->getFillType()),
35                               fHasStencilClip, numStencilBits);
36 
37     GrPathRendering::StencilPathArgs args(fUseHWAA, state->drawOpArgs().proxy(),
38                                           state->drawOpArgs().origin(),
39                                           &fViewMatrix, &fScissor, &stencil);
40     state->gpu()->pathRendering()->stencilPath(args, fPath.get());
41 }
42