• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2015 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 #ifndef GrStencilPathOp_DEFINED
9 #define GrStencilPathOp_DEFINED
10 
11 #include "GrOp.h"
12 #include "GrPath.h"
13 #include "GrPathRendering.h"
14 #include "GrStencilSettings.h"
15 
16 class GrOpFlushState;
17 
18 class GrStencilPathOp final : public GrOp {
19 public:
20     DEFINE_OP_CLASS_ID
21 
Make(const SkMatrix & viewMatrix,bool useHWAA,GrPathRendering::FillType fillType,bool hasStencilClip,int numStencilBits,const GrScissorState & scissor,const GrPath * path)22     static std::unique_ptr<GrOp> Make(const SkMatrix& viewMatrix,
23                                       bool useHWAA,
24                                       GrPathRendering::FillType fillType,
25                                       bool hasStencilClip,
26                                       int numStencilBits,
27                                       const GrScissorState& scissor,
28                                       const GrPath* path) {
29 
30         return std::unique_ptr<GrOp>(new GrStencilPathOp(viewMatrix, useHWAA, fillType,
31                                                          hasStencilClip, numStencilBits, scissor,
32                                                          path));
33     }
34 
name()35     const char* name() const override { return "StencilPathOp"; }
36 
dumpInfo()37     SkString dumpInfo() const override {
38         SkString string;
39         string.printf("Path: 0x%p, AA: %d", fPath.get(), fUseHWAA);
40         string.append(INHERITED::dumpInfo());
41         return string;
42     }
43 
44 private:
GrStencilPathOp(const SkMatrix & viewMatrix,bool useHWAA,GrPathRendering::FillType fillType,bool hasStencilClip,int numStencilBits,const GrScissorState & scissor,const GrPath * path)45     GrStencilPathOp(const SkMatrix& viewMatrix,
46                     bool useHWAA,
47                     GrPathRendering::FillType fillType,
48                     bool hasStencilClip,
49                     int numStencilBits,
50                     const GrScissorState& scissor,
51                     const GrPath* path)
52             : INHERITED(ClassID())
53             , fViewMatrix(viewMatrix)
54             , fUseHWAA(useHWAA)
55             , fStencil(GrPathRendering::GetStencilPassSettings(fillType), hasStencilClip,
56                        numStencilBits)
57             , fScissor(scissor)
58             , fPath(path) {
59         this->setBounds(path->getBounds(), HasAABloat::kNo, IsZeroArea::kNo);
60     }
61 
onCombineIfPossible(GrOp * t,const GrCaps & caps)62     bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override { return false; }
63 
onPrepare(GrOpFlushState *)64     void onPrepare(GrOpFlushState*) override {}
65 
66     void onExecute(GrOpFlushState* state) override;
67 
68     SkMatrix                                          fViewMatrix;
69     bool                                              fUseHWAA;
70     GrStencilSettings                                 fStencil;
71     GrScissorState                                    fScissor;
72     GrPendingIOResource<const GrPath, kRead_GrIOType> fPath;
73 
74     typedef GrOp INHERITED;
75 };
76 
77 #endif
78