blob: d726b4bc65fd965ea908e64c730c305e0ba44e30 [file] [log] [blame]
cdalton855d83f2014-09-18 13:51:53 -07001/*
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 Kleinc0bd9f92019-04-23 12:05:21 -05008#include "include/core/SkMatrix.h"
9#include "include/core/SkTypeface.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050010#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 Phillips901aff02019-10-08 12:32:56 -040015#include "src/gpu/GrProgramInfo.h"
Brian Salomon201cdbb2019-08-14 17:00:30 -040016#include "src/gpu/GrRenderTarget.h"
cdalton855d83f2014-09-18 13:51:53 -070017
cdalton193d9cf2016-05-12 11:52:02 -070018const GrUserStencilSettings& GrPathRendering::GetStencilPassSettings(FillType fill) {
19 switch (fill) {
20 default:
Ben Wagnerb4aab9a2017-08-16 10:53:04 -040021 SK_ABORT("Unexpected path fill.");
cdalton193d9cf2016-05-12 11:52:02 -070022 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 Phillips646e4292017-06-13 12:44:56 -040049void GrPathRendering::stencilPath(const StencilPathArgs& args, const GrPath* path) {
50 fGpu->handleDirtyContext();
51 this->onStencilPath(args, path);
52}
53
Robert Phillips901aff02019-10-08 12:32:56 -040054void GrPathRendering::drawPath(GrRenderTarget* renderTarget,
55 const GrProgramInfo& programInfo,
Robert Phillips646e4292017-06-13 12:44:56 -040056 // Cover pass settings in pipeline.
57 const GrStencilSettings& stencilPassSettings,
58 const GrPath* path) {
59 fGpu->handleDirtyContext();
Greg Danield358cbe2020-09-11 09:33:54 -040060 if (auto barrierType = programInfo.pipeline().xferBarrierType(*fGpu->caps())) {
Robert Phillipsd0fe8752019-01-31 14:13:59 -050061 fGpu->xferBarrier(renderTarget, barrierType);
Robert Phillips646e4292017-06-13 12:44:56 -040062 }
Chris Dalton304e14d2020-03-17 14:29:06 -060063 this->onDrawPath(stencilPassSettings, path);
Robert Phillips646e4292017-06-13 12:44:56 -040064}