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 "GrGpu.h"
9 #include "GrPathRendering.h"
10 #include "GrRenderTarget.h"
11 #include "SkDescriptor.h"
12 #include "SkScalerContext.h"
13 #include "SkGlyph.h"
14 #include "SkMatrix.h"
15 #include "SkTypeface.h"
16
GetStencilPassSettings(FillType fill)17 const GrUserStencilSettings& GrPathRendering::GetStencilPassSettings(FillType fill) {
18 switch (fill) {
19 default:
20 SK_ABORT("Unexpected path fill.");
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
stencilPath(const StencilPathArgs & args,const GrPath * path)48 void GrPathRendering::stencilPath(const StencilPathArgs& args, const GrPath* path) {
49 fGpu->handleDirtyContext();
50 this->onStencilPath(args, path);
51 }
52
drawPath(GrRenderTarget * renderTarget,GrSurfaceOrigin origin,const GrPrimitiveProcessor & primProc,const GrPipeline & pipeline,const GrPipeline::FixedDynamicState & fixedDynamicState,const GrStencilSettings & stencilPassSettings,const GrPath * path)53 void GrPathRendering::drawPath(GrRenderTarget* renderTarget, GrSurfaceOrigin origin,
54 const GrPrimitiveProcessor& primProc,
55 const GrPipeline& pipeline,
56 const GrPipeline::FixedDynamicState& fixedDynamicState,
57 // Cover pass settings in pipeline.
58 const GrStencilSettings& stencilPassSettings,
59 const GrPath* path) {
60 fGpu->handleDirtyContext();
61 if (GrXferBarrierType barrierType = pipeline.xferBarrierType(renderTarget->asTexture(),
62 *fGpu->caps())) {
63 fGpu->xferBarrier(renderTarget, barrierType);
64 }
65 this->onDrawPath(renderTarget, origin, primProc, pipeline, fixedDynamicState,
66 stencilPassSettings, path);
67 }
68