aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/ops/GrTestMeshDrawOp.h
blob: a4bf066a34e1078e915845036764b89c9f97dbb2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
 * Copyright 2015 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef GrTestMeshDrawOp_DEFINED
#define GrTestMeshDrawOp_DEFINED

#include "GrGeometryProcessor.h"
#include "GrOpFlushState.h"

#include "ops/GrMeshDrawOp.h"

/*
 * A simple solid color GrMeshDrawOp for testing purposes which doesn't ever combine. Subclassing
 * this in tests saves having to fill out some boiler plate methods.
 */
class GrTestMeshDrawOp : public GrMeshDrawOp {
public:
    const char* name() const override = 0;

protected:
    GrTestMeshDrawOp(uint32_t classID, const SkRect& bounds, GrColor color)
            : INHERITED(classID), fColor(color) {
        // Choose some conservative values for aa bloat and zero area.
        this->setBounds(bounds, HasAABloat::kYes, IsZeroArea::kYes);
    }

    GrColor color() const { return fColor; }

    bool usesLocalCoords() const { return fUsesLocalCoords; }

private:
    void getFragmentProcessorAnalysisInputs(GrPipelineAnalysisColor* color,
                                            GrPipelineAnalysisCoverage* coverage) const override {
        color->setToConstant(fColor);
        *coverage = GrPipelineAnalysisCoverage::kSingleChannel;
    }

    void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override {
        optimizations.getOverrideColorIfSet(&fColor);
        fUsesLocalCoords = optimizations.readsLocalCoords();
    }

    bool onCombineIfPossible(GrOp*, const GrCaps&) override { return false; }

    GrColor fColor;
    bool fUsesLocalCoords = false;

    typedef GrMeshDrawOp INHERITED;
};

#endif