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 | |
Robert Phillips | 646e429 | 2017-06-13 12:44:56 -0400 | [diff] [blame] | 8 | #include "GrGpu.h" |
cdalton | 855d83f | 2014-09-18 13:51:53 -0700 | [diff] [blame] | 9 | #include "GrPathRendering.h" |
| 10 | #include "SkDescriptor.h" |
Brian Salomon | 2bbdcc4 | 2017-09-07 12:36:34 -0400 | [diff] [blame] | 11 | #include "SkScalerContext.h" |
cdalton | 855d83f | 2014-09-18 13:51:53 -0700 | [diff] [blame] | 12 | #include "SkGlyph.h" |
| 13 | #include "SkMatrix.h" |
| 14 | #include "SkTypeface.h" |
cdalton | 855d83f | 2014-09-18 13:51:53 -0700 | [diff] [blame] | 15 | |
cdalton | 193d9cf | 2016-05-12 11:52:02 -0700 | [diff] [blame] | 16 | const GrUserStencilSettings& GrPathRendering::GetStencilPassSettings(FillType fill) { |
| 17 | switch (fill) { |
| 18 | default: |
Ben Wagner | b4aab9a | 2017-08-16 10:53:04 -0400 | [diff] [blame] | 19 | SK_ABORT("Unexpected path fill."); |
cdalton | 193d9cf | 2016-05-12 11:52:02 -0700 | [diff] [blame] | 20 | case GrPathRendering::kWinding_FillType: { |
| 21 | constexpr static GrUserStencilSettings kWindingStencilPass( |
| 22 | GrUserStencilSettings::StaticInit< |
| 23 | 0xffff, |
| 24 | GrUserStencilTest::kAlwaysIfInClip, |
| 25 | 0xffff, |
| 26 | GrUserStencilOp::kIncWrap, |
| 27 | GrUserStencilOp::kIncWrap, |
| 28 | 0xffff>() |
| 29 | ); |
| 30 | return kWindingStencilPass; |
| 31 | } |
| 32 | case GrPathRendering::kEvenOdd_FillType: { |
| 33 | constexpr static GrUserStencilSettings kEvenOddStencilPass( |
| 34 | GrUserStencilSettings::StaticInit< |
| 35 | 0xffff, |
| 36 | GrUserStencilTest::kAlwaysIfInClip, |
| 37 | 0xffff, |
| 38 | GrUserStencilOp::kInvert, |
| 39 | GrUserStencilOp::kInvert, |
| 40 | 0xffff>() |
| 41 | ); |
| 42 | return kEvenOddStencilPass; |
| 43 | } |
| 44 | } |
| 45 | } |
| 46 | |
Robert Phillips | 646e429 | 2017-06-13 12:44:56 -0400 | [diff] [blame] | 47 | void GrPathRendering::stencilPath(const StencilPathArgs& args, const GrPath* path) { |
| 48 | fGpu->handleDirtyContext(); |
| 49 | this->onStencilPath(args, path); |
| 50 | } |
| 51 | |
Brian Salomon | ff168d9 | 2018-06-23 15:17:27 -0400 | [diff] [blame] | 52 | void GrPathRendering::drawPath(const GrPrimitiveProcessor& primProc, |
| 53 | const GrPipeline& pipeline, |
Brian Salomon | 4934890 | 2018-06-26 09:12:38 -0400 | [diff] [blame] | 54 | const GrPipeline::FixedDynamicState& fixedDynamicState, |
Robert Phillips | 646e429 | 2017-06-13 12:44:56 -0400 | [diff] [blame] | 55 | // Cover pass settings in pipeline. |
| 56 | const GrStencilSettings& stencilPassSettings, |
| 57 | const GrPath* path) { |
| 58 | fGpu->handleDirtyContext(); |
| 59 | if (GrXferBarrierType barrierType = pipeline.xferBarrierType(*fGpu->caps())) { |
Robert Phillips | 2890fbf | 2017-07-26 15:48:41 -0400 | [diff] [blame] | 60 | fGpu->xferBarrier(pipeline.renderTarget(), barrierType); |
Robert Phillips | 646e429 | 2017-06-13 12:44:56 -0400 | [diff] [blame] | 61 | } |
Brian Salomon | 4934890 | 2018-06-26 09:12:38 -0400 | [diff] [blame] | 62 | this->onDrawPath(primProc, pipeline, fixedDynamicState, stencilPassSettings, path); |
Robert Phillips | 646e429 | 2017-06-13 12:44:56 -0400 | [diff] [blame] | 63 | } |