Robert Phillips | 009e9af | 2017-06-15 14:01:04 -0400 | [diff] [blame] | 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 | |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 10 | #include "GrContext.h" |
| 11 | #include "GrContextPriv.h" |
Robert Phillips | 009e9af | 2017-06-15 14:01:04 -0400 | [diff] [blame] | 12 | #include "GrGpu.h" |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 13 | #include "GrMemoryPool.h" |
Robert Phillips | 009e9af | 2017-06-15 14:01:04 -0400 | [diff] [blame] | 14 | #include "GrOpFlushState.h" |
Robert Phillips | 6504813 | 2017-08-10 08:44:49 -0400 | [diff] [blame] | 15 | #include "GrRenderTargetPriv.h" |
Robert Phillips | 009e9af | 2017-06-15 14:01:04 -0400 | [diff] [blame] | 16 | |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 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) { |
Robert Phillips | c994a93 | 2018-06-19 13:09:54 -0400 | [diff] [blame] | 24 | GrOpMemoryPool* pool = context->contextPriv().opMemoryPool(); |
| 25 | |
| 26 | return pool->allocate<GrStencilPathOp>(viewMatrix, useHWAA, fillType, |
| 27 | hasStencilClip, scissor, path); |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 28 | } |
| 29 | |
Robert Phillips | 009e9af | 2017-06-15 14:01:04 -0400 | [diff] [blame] | 30 | void GrStencilPathOp::onExecute(GrOpFlushState* state) { |
Robert Phillips | 6504813 | 2017-08-10 08:44:49 -0400 | [diff] [blame] | 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 | |
Robert Phillips | 7311b40 | 2017-07-27 12:01:46 -0400 | [diff] [blame] | 38 | GrPathRendering::StencilPathArgs args(fUseHWAA, state->drawOpArgs().fProxy, |
Robert Phillips | 6504813 | 2017-08-10 08:44:49 -0400 | [diff] [blame] | 39 | &fViewMatrix, &fScissor, &stencil); |
Robert Phillips | 009e9af | 2017-06-15 14:01:04 -0400 | [diff] [blame] | 40 | state->gpu()->pathRendering()->stencilPath(args, fPath.get()); |
| 41 | } |
| 42 | |