Coverage Report

Created: 2021-08-22 09:07

/src/skia/src/gpu/GrTestUtils.h
Line
Count
Source (jump to first uncovered line)
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 GrTestUtils_DEFINED
9
#define GrTestUtils_DEFINED
10
11
#include "include/core/SkTypes.h"
12
13
#if GR_TEST_UTILS
14
15
#include "include/core/SkStrokeRec.h"
16
#include "include/private/SkMacros.h"
17
#include "include/private/SkTemplates.h"
18
#include "include/utils/SkRandom.h"
19
#include "src/core/SkMatrixProvider.h"
20
#include "src/core/SkPathEffectBase.h"
21
#include "src/gpu/GrColor.h"
22
#include "src/gpu/GrFPArgs.h"
23
#include "src/gpu/GrSamplerState.h"
24
#include "src/shaders/SkShaderBase.h"
25
26
class GrColorInfo;
27
class GrColorSpaceXform;
28
class GrProcessorTestData;
29
class GrStyle;
30
class SkMatrix;
31
class SkPath;
32
class SkRRect;
33
struct SkRect;
34
35
namespace GrTest {
36
/**
37
 * Helpers for use in Test functions.
38
 */
39
const SkMatrix& TestMatrix(SkRandom*);
40
const SkMatrix& TestMatrixPreservesRightAngles(SkRandom*);
41
const SkMatrix& TestMatrixRectStaysRect(SkRandom*);
42
const SkMatrix& TestMatrixInvertible(SkRandom*);
43
const SkMatrix& TestMatrixPerspective(SkRandom*);
44
void TestWrapModes(SkRandom*, GrSamplerState::WrapMode[2]);
45
const SkRect& TestRect(SkRandom*);
46
const SkRect& TestSquare(SkRandom*);
47
const SkRRect& TestRRectSimple(SkRandom*);
48
const SkPath& TestPath(SkRandom*);
49
const SkPath& TestPathConvex(SkRandom*);
50
SkStrokeRec TestStrokeRec(SkRandom*);
51
/** Creates styles with dash path effects and null path effects */
52
void TestStyle(SkRandom*, GrStyle*);
53
sk_sp<SkColorSpace> TestColorSpace(SkRandom*);
54
sk_sp<GrColorSpaceXform> TestColorXform(SkRandom*);
55
56
GrColor RandomColor(SkRandom* random);
57
uint8_t RandomCoverage(SkRandom* random);
58
59
class TestAsFPArgs {
60
public:
61
    TestAsFPArgs(GrProcessorTestData*);
62
    ~TestAsFPArgs();
63
0
    const GrFPArgs& args() const { return fArgs; }
64
65
private:
66
    SkSimpleMatrixProvider fMatrixProvider;
67
    std::unique_ptr<GrColorInfo> fColorInfoStorage;
68
    GrFPArgs fArgs;
69
};
70
71
// We have a simplified dash path effect here to avoid relying on SkDashPathEffect which
72
// is in the optional build target effects.
73
class TestDashPathEffect : public SkPathEffectBase {
74
public:
75
0
    static sk_sp<SkPathEffect> Make(const SkScalar* intervals, int count, SkScalar phase) {
76
0
        return sk_sp<SkPathEffect>(new TestDashPathEffect(intervals, count, phase));
77
0
    }
78
79
0
    Factory getFactory() const override { return nullptr; }
80
0
    const char* getTypeName() const override { return nullptr; }
81
82
protected:
83
    bool onFilterPath(SkPath* dst, const SkPath&, SkStrokeRec* , const SkRect*,
84
                      const SkMatrix&) const override;
85
    DashType onAsADash(DashInfo* info) const override;
86
87
private:
88
    TestDashPathEffect(const SkScalar* intervals, int count, SkScalar phase);
89
90
0
    bool computeFastBounds(SkRect* bounds) const override { return true; }
91
92
    int                     fCount;
93
    SkAutoTArray<SkScalar>  fIntervals;
94
    SkScalar                fPhase;
95
    SkScalar                fInitialDashLength;
96
    int                     fInitialDashIndex;
97
    SkScalar                fIntervalLength;
98
};
99
100
}  // namespace GrTest
101
102
#endif
103
#endif