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 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 8 | #include "src/gpu/ops/GrStencilPathOp.h" |
Robert Phillips | 009e9af | 2017-06-15 14:01:04 -0400 | [diff] [blame] | 9 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 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" |
Robert Phillips | 009e9af | 2017-06-15 14:01:04 -0400 | [diff] [blame] | 16 | |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 17 | std::unique_ptr<GrOp> GrStencilPathOp::Make(GrRecordingContext* context, |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 18 | const SkMatrix& viewMatrix, |
| 19 | bool useHWAA, |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 20 | bool hasStencilClip, |
| 21 | const GrScissorState& scissor, |
Robert Phillips | e1efd38 | 2019-08-21 10:07:10 -0400 | [diff] [blame] | 22 | sk_sp<const GrPath> path) { |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 23 | GrOpMemoryPool* pool = context->priv().opMemoryPool(); |
Robert Phillips | c994a93 | 2018-06-19 13:09:54 -0400 | [diff] [blame] | 24 | |
Robert Phillips | e1efd38 | 2019-08-21 10:07:10 -0400 | [diff] [blame] | 25 | return pool->allocate<GrStencilPathOp>(viewMatrix, useHWAA, |
| 26 | hasStencilClip, scissor, std::move(path)); |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 27 | } |
| 28 | |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 29 | void GrStencilPathOp::onExecute(GrOpFlushState* state, const SkRect& chainBounds) { |
Robert Phillips | 6504813 | 2017-08-10 08:44:49 -0400 | [diff] [blame] | 30 | GrRenderTarget* rt = state->drawOpArgs().renderTarget(); |
| 31 | SkASSERT(rt); |
| 32 | |
| 33 | int numStencilBits = rt->renderTargetPriv().numStencilBits(); |
Robert Phillips | e1efd38 | 2019-08-21 10:07:10 -0400 | [diff] [blame] | 34 | GrStencilSettings stencil(GrPathRendering::GetStencilPassSettings(fPath->getFillType()), |
Robert Phillips | 6504813 | 2017-08-10 08:44:49 -0400 | [diff] [blame] | 35 | fHasStencilClip, numStencilBits); |
| 36 | |
Robert Phillips | 7311b40 | 2017-07-27 12:01:46 -0400 | [diff] [blame] | 37 | GrPathRendering::StencilPathArgs args(fUseHWAA, state->drawOpArgs().fProxy, |
Robert Phillips | 6504813 | 2017-08-10 08:44:49 -0400 | [diff] [blame] | 38 | &fViewMatrix, &fScissor, &stencil); |
Robert Phillips | 009e9af | 2017-06-15 14:01:04 -0400 | [diff] [blame] | 39 | state->gpu()->pathRendering()->stencilPath(args, fPath.get()); |
| 40 | } |