Flutter Engine
The Flutter Engine
GrTestUtils.h
Go to the documentation of this file.
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
12
13#if defined(GR_TEST_UTILS)
14
19#include "src/base/SkRandom.h"
25
26class GrColorInfo;
28class GrProcessorTestData;
29class GrStyle;
30class SkMatrix;
31class SkPath;
32class SkRRect;
33struct SkRect;
34
35namespace GrTest {
36/**
37 * Helpers for use in Test functions.
38 */
39const SkMatrix& TestMatrix(SkRandom*);
40const SkMatrix& TestMatrixPreservesRightAngles(SkRandom*);
41const SkMatrix& TestMatrixRectStaysRect(SkRandom*);
42const SkMatrix& TestMatrixInvertible(SkRandom*);
43const SkMatrix& TestMatrixPerspective(SkRandom*);
44void TestWrapModes(SkRandom*, GrSamplerState::WrapMode[2]);
45const SkRect& TestRect(SkRandom*);
46const SkRect& TestSquare(SkRandom*);
47const SkRRect& TestRRectSimple(SkRandom*);
48const SkPath& TestPath(SkRandom*);
49const SkPath& TestPathConvex(SkRandom*);
50SkStrokeRec TestStrokeRec(SkRandom*);
51/** Creates styles with dash path effects and null path effects */
52void TestStyle(SkRandom*, GrStyle*);
53sk_sp<SkColorSpace> TestColorSpace(SkRandom*);
54sk_sp<GrColorSpaceXform> TestColorXform(SkRandom*);
55
56GrColor RandomColor(SkRandom* random);
57uint8_t RandomCoverage(SkRandom* random);
58
59class TestAsFPArgs {
60public:
61 TestAsFPArgs(GrProcessorTestData*);
62 ~TestAsFPArgs();
63 const GrFPArgs& args() const { return fArgs; }
64
65private:
66 std::unique_ptr<GrColorInfo> fColorInfoStorage;
67 SkSurfaceProps fSurfaceProps;
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.
73class TestDashPathEffect : public SkPathEffectBase {
74public:
75 static sk_sp<SkPathEffect> Make(const SkScalar* intervals, int count, SkScalar phase) {
76 return sk_sp<SkPathEffect>(new TestDashPathEffect(intervals, count, phase));
77 }
78
79 Factory getFactory() const override { return nullptr; }
80 const char* getTypeName() const override { return nullptr; }
81
82protected:
83 bool onFilterPath(SkPath* dst, const SkPath&, SkStrokeRec* , const SkRect*,
84 const SkMatrix&) const override;
85 DashType onAsADash(DashInfo* info) const override;
86
87private:
88 TestDashPathEffect(const SkScalar* intervals, int count, SkScalar phase);
89
90 bool computeFastBounds(SkRect* bounds) const override { return true; }
91
92 int fCount;
95 SkScalar fInitialDashLength;
96 int fInitialDashIndex;
97 SkScalar fIntervalLength;
98};
99
100} // namespace GrTest
101
102#endif
103#endif
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
SkScalar fIntervals[2]
Definition: DashOp.cpp:190
SkScalar fPhase
Definition: DashOp.cpp:189
int count
Definition: FontMgrTest.cpp:50
uint32_t GrColor
Definition: GrColor.h:25
Definition: SkPath.h:59
float SkScalar
Definition: extension.cpp:12
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
SK_API sk_sp< SkDocument > Make(SkWStream *dst, const SkSerialProcs *=nullptr, std::function< void(const SkPicture *)> onEndPage=nullptr)
Optional< SkRect > bounds
Definition: SkRecords.h:189
SKSHAPER_API sk_sp< Factory > Factory()
dst
Definition: cp.py:12