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