cdalton | 855d83f | 2014-09-18 13:51:53 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 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 "include/core/SkMatrix.h" |
| 9 | #include "include/core/SkTypeface.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 10 | #include "src/core/SkDescriptor.h" |
| 11 | #include "src/core/SkGlyph.h" |
| 12 | #include "src/core/SkScalerContext.h" |
| 13 | #include "src/gpu/GrGpu.h" |
| 14 | #include "src/gpu/GrPathRendering.h" |
Robert Phillips | 901aff0 | 2019-10-08 12:32:56 -0400 | [diff] [blame] | 15 | #include "src/gpu/GrProgramInfo.h" |
Brian Salomon | 201cdbb | 2019-08-14 17:00:30 -0400 | [diff] [blame] | 16 | #include "src/gpu/GrRenderTarget.h" |
cdalton | 855d83f | 2014-09-18 13:51:53 -0700 | [diff] [blame] | 17 | |
cdalton | 193d9cf | 2016-05-12 11:52:02 -0700 | [diff] [blame] | 18 | const GrUserStencilSettings& GrPathRendering::GetStencilPassSettings(FillType fill) { |
| 19 | switch (fill) { |
| 20 | default: |
Ben Wagner | b4aab9a | 2017-08-16 10:53:04 -0400 | [diff] [blame] | 21 | SK_ABORT("Unexpected path fill."); |
cdalton | 193d9cf | 2016-05-12 11:52:02 -0700 | [diff] [blame] | 22 | case GrPathRendering::kWinding_FillType: { |
| 23 | constexpr static GrUserStencilSettings kWindingStencilPass( |
| 24 | GrUserStencilSettings::StaticInit< |
| 25 | 0xffff, |
| 26 | GrUserStencilTest::kAlwaysIfInClip, |
| 27 | 0xffff, |
| 28 | GrUserStencilOp::kIncWrap, |
| 29 | GrUserStencilOp::kIncWrap, |
| 30 | 0xffff>() |
| 31 | ); |
| 32 | return kWindingStencilPass; |
| 33 | } |
| 34 | case GrPathRendering::kEvenOdd_FillType: { |
| 35 | constexpr static GrUserStencilSettings kEvenOddStencilPass( |
| 36 | GrUserStencilSettings::StaticInit< |
| 37 | 0xffff, |
| 38 | GrUserStencilTest::kAlwaysIfInClip, |
| 39 | 0xffff, |
| 40 | GrUserStencilOp::kInvert, |
| 41 | GrUserStencilOp::kInvert, |
| 42 | 0xffff>() |
| 43 | ); |
| 44 | return kEvenOddStencilPass; |
| 45 | } |
| 46 | } |
| 47 | } |
| 48 | |
Robert Phillips | 646e429 | 2017-06-13 12:44:56 -0400 | [diff] [blame] | 49 | void GrPathRendering::stencilPath(const StencilPathArgs& args, const GrPath* path) { |
| 50 | fGpu->handleDirtyContext(); |
| 51 | this->onStencilPath(args, path); |
| 52 | } |
| 53 | |
Robert Phillips | 901aff0 | 2019-10-08 12:32:56 -0400 | [diff] [blame] | 54 | void GrPathRendering::drawPath(GrRenderTarget* renderTarget, |
| 55 | const GrProgramInfo& programInfo, |
Robert Phillips | 646e429 | 2017-06-13 12:44:56 -0400 | [diff] [blame] | 56 | // Cover pass settings in pipeline. |
| 57 | const GrStencilSettings& stencilPassSettings, |
| 58 | const GrPath* path) { |
| 59 | fGpu->handleDirtyContext(); |
Greg Daniel | d358cbe | 2020-09-11 09:33:54 -0400 | [diff] [blame] | 60 | if (auto barrierType = programInfo.pipeline().xferBarrierType(*fGpu->caps())) { |
Robert Phillips | d0fe875 | 2019-01-31 14:13:59 -0500 | [diff] [blame] | 61 | fGpu->xferBarrier(renderTarget, barrierType); |
Robert Phillips | 646e429 | 2017-06-13 12:44:56 -0400 | [diff] [blame] | 62 | } |
Chris Dalton | 304e14d | 2020-03-17 14:29:06 -0600 | [diff] [blame] | 63 | this->onDrawPath(stencilPassSettings, path); |
Robert Phillips | 646e429 | 2017-06-13 12:44:56 -0400 | [diff] [blame] | 64 | } |