• 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,GrPathRendering::FillType fillType,bool hasStencilClip,const GrScissorState & scissor,const GrPath * path)17 std::unique_ptr<GrOp> GrStencilPathOp::Make(GrRecordingContext* 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->priv().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