blob: 614d014146c903b27fd50ef3d799b9da955b43d5 [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
Robert Phillips646e4292017-06-13 12:44:56 -04008#include "GrGpu.h"
cdalton855d83f2014-09-18 13:51:53 -07009#include "GrPathRendering.h"
10#include "SkDescriptor.h"
Brian Salomon2bbdcc42017-09-07 12:36:34 -040011#include "SkScalerContext.h"
cdalton855d83f2014-09-18 13:51:53 -070012#include "SkGlyph.h"
13#include "SkMatrix.h"
14#include "SkTypeface.h"
cdalton855d83f2014-09-18 13:51:53 -070015
cdalton193d9cf2016-05-12 11:52:02 -070016const GrUserStencilSettings& GrPathRendering::GetStencilPassSettings(FillType fill) {
17 switch (fill) {
18 default:
Ben Wagnerb4aab9a2017-08-16 10:53:04 -040019 SK_ABORT("Unexpected path fill.");
cdalton193d9cf2016-05-12 11:52:02 -070020 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 Phillips646e4292017-06-13 12:44:56 -040047void GrPathRendering::stencilPath(const StencilPathArgs& args, const GrPath* path) {
48 fGpu->handleDirtyContext();
49 this->onStencilPath(args, path);
50}
51
Brian Salomonff168d92018-06-23 15:17:27 -040052void GrPathRendering::drawPath(const GrPrimitiveProcessor& primProc,
53 const GrPipeline& pipeline,
Brian Salomon49348902018-06-26 09:12:38 -040054 const GrPipeline::FixedDynamicState& fixedDynamicState,
Robert Phillips646e4292017-06-13 12:44:56 -040055 // 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 Phillips2890fbf2017-07-26 15:48:41 -040060 fGpu->xferBarrier(pipeline.renderTarget(), barrierType);
Robert Phillips646e4292017-06-13 12:44:56 -040061 }
Brian Salomon49348902018-06-26 09:12:38 -040062 this->onDrawPath(primProc, pipeline, fixedDynamicState, stencilPassSettings, path);
Robert Phillips646e4292017-06-13 12:44:56 -040063}