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