blob: c0b7974360a4777deb3abf8de8a7c2b5b2327d6b [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"
Brian Salomon201cdbb2019-08-14 17:00:30 -040015#include "src/gpu/GrRenderTarget.h"
cdalton855d83f2014-09-18 13:51:53 -070016
cdalton193d9cf2016-05-12 11:52:02 -070017const GrUserStencilSettings& GrPathRendering::GetStencilPassSettings(FillType fill) {
18 switch (fill) {
19 default:
Ben Wagnerb4aab9a2017-08-16 10:53:04 -040020 SK_ABORT("Unexpected path fill.");
cdalton193d9cf2016-05-12 11:52:02 -070021 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 Phillips646e4292017-06-13 12:44:56 -040048void GrPathRendering::stencilPath(const StencilPathArgs& args, const GrPath* path) {
49 fGpu->handleDirtyContext();
50 this->onStencilPath(args, path);
51}
52
Robert Phillipsd0fe8752019-01-31 14:13:59 -050053void GrPathRendering::drawPath(GrRenderTarget* renderTarget, GrSurfaceOrigin origin,
54 const GrPrimitiveProcessor& primProc,
Brian Salomonff168d92018-06-23 15:17:27 -040055 const GrPipeline& pipeline,
Brian Salomon49348902018-06-26 09:12:38 -040056 const GrPipeline::FixedDynamicState& fixedDynamicState,
Robert Phillips646e4292017-06-13 12:44:56 -040057 // Cover pass settings in pipeline.
58 const GrStencilSettings& stencilPassSettings,
59 const GrPath* path) {
60 fGpu->handleDirtyContext();
Robert Phillipsd0fe8752019-01-31 14:13:59 -050061 if (GrXferBarrierType barrierType = pipeline.xferBarrierType(renderTarget->asTexture(),
62 *fGpu->caps())) {
63 fGpu->xferBarrier(renderTarget, barrierType);
Robert Phillips646e4292017-06-13 12:44:56 -040064 }
Robert Phillipsd0fe8752019-01-31 14:13:59 -050065 this->onDrawPath(renderTarget, origin, primProc, pipeline, fixedDynamicState,
66 stencilPassSettings, path);
Robert Phillips646e4292017-06-13 12:44:56 -040067}