| 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 | |
| 8 | #include "include/core/SkMatrix.h" |
| 9 | #include "include/core/SkTypeface.h" |
| 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" |
| 15 | #include "src/gpu/GrProgramInfo.h" |
| 16 | #include "src/gpu/GrRenderTarget.h" |
| 17 | |
| 18 | const GrUserStencilSettings& GrPathRendering::GetStencilPassSettings(FillType fill) { |
| 19 | switch (fill) { |
| 20 | default: |
| 21 | SK_ABORT("Unexpected path fill." ); |
| 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 | |
| 49 | void GrPathRendering::stencilPath(const StencilPathArgs& args, const GrPath* path) { |
| 50 | fGpu->handleDirtyContext(); |
| 51 | this->onStencilPath(args, path); |
| 52 | } |
| 53 | |
| 54 | void GrPathRendering::drawPath(GrRenderTarget* renderTarget, |
| 55 | const GrProgramInfo& programInfo, |
| 56 | // Cover pass settings in pipeline. |
| 57 | const GrStencilSettings& stencilPassSettings, |
| 58 | const GrPath* path) { |
| 59 | fGpu->handleDirtyContext(); |
| 60 | if (auto barrierType = programInfo.pipeline().xferBarrierType(renderTarget->asTexture(), |
| 61 | *fGpu->caps())) { |
| 62 | fGpu->xferBarrier(renderTarget, barrierType); |
| 63 | } |
| 64 | this->onDrawPath(stencilPassSettings, path); |
| 65 | } |
| 66 | |