Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
skqp.h
Go to the documentation of this file.
1/*
2 * Copyright 2018 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 skqp_DEFINED
9#define skqp_DEFINED
10
11#include <cstdint>
12#include <memory>
13#include <string>
14#include <vector>
15
16class SkData;
17template <typename T> class sk_sp;
18
19namespace skiagm {
20class GM;
21} // namespace skiagm
22
23namespace skiatest {
24struct Test;
25} // namespace skiatest
26
27class SkStreamAsset;
28
29////////////////////////////////////////////////////////////////////////////////
31public:
33 virtual ~SkQPAssetManager() {}
34 virtual sk_sp<SkData> open(const char* path) = 0;
35 virtual std::vector<std::string> iterateDir(const char* directory, const char* extension) = 0;
36
37private:
38 SkQPAssetManager(const SkQPAssetManager&) = delete;
39 SkQPAssetManager& operator=(const SkQPAssetManager&) = delete;
40};
41
42class SkQP {
43public:
44 using UnitTest = const skiatest::Test*;
45
47 std::string name;
48 std::string shaderText;
49 };
50
51 ////////////////////////////////////////////////////////////////////////////
52
53 /** These functions provide a descriptive name for the given value.*/
54 static const char* GetUnitTestName(UnitTest);
55
56 SkQP();
57 ~SkQP();
58
59 /**
60 Initialize Skia and the SkQP. Should be executed only once.
61
62 @param assetManager - provides assets for the models. Does not take ownership.
63 @param reportDirectory - where to write out report.
64 */
65 void init(SkQPAssetManager* assetManager, const char* reportDirectory);
66
67 /** @return a (hopefully empty) list of errors produced by this unit test. */
68 std::vector<std::string> executeTest(UnitTest);
69
70 /** Call this after running all checks to write a report into the given report directory. */
71 void makeReport();
72
73 /** @return a sorted list of all Skia GPU unit tests */
74 const std::vector<UnitTest>& getUnitTests() const { return fUnitTests; }
75
76 /** @return a sorted list of all SkSL error tests */
77 const std::vector<SkSLErrorTest>& getSkSLErrorTests() const { return fSkSLErrorTests; }
78
79 ////////////////////////////////////////////////////////////////////////////
80
81private:
82 struct TestResult {
83 std::string name;
84 std::vector<std::string> errors;
85 };
86 std::vector<TestResult> fTestResults;
87 std::string fReportDirectory;
88 std::vector<UnitTest> fUnitTests;
89 std::vector<SkSLErrorTest> fSkSLErrorTests;
90
91 // Defaults to zero since most checks care if it is greater than a specific value. So this will
92 // just default to it being less.
93 int fEnforcedAndroidAPILevel = 0;
94
95 SkQP(const SkQP&) = delete;
96 SkQP& operator=(const SkQP&) = delete;
97 void printBackendInfo(const char* dstPath);
98};
99#endif // skqp_DEFINED
100
virtual sk_sp< SkData > open(const char *path)=0
virtual std::vector< std::string > iterateDir(const char *directory, const char *extension)=0
virtual ~SkQPAssetManager()
Definition skqp.h:33
SkQPAssetManager()
Definition skqp.h:32
Definition skqp.h:42
void makeReport()
Definition skqp.cpp:192
SkQP()
Definition skqp.cpp:116
~SkQP()
Definition skqp.cpp:118
const std::vector< UnitTest > & getUnitTests() const
Definition skqp.h:74
const std::vector< SkSLErrorTest > & getSkSLErrorTests() const
Definition skqp.h:77
std::vector< std::string > executeTest(UnitTest)
Definition skqp.cpp:147
void init(SkQPAssetManager *assetManager, const char *reportDirectory)
Definition skqp.cpp:120
static const char * GetUnitTestName(UnitTest)
Definition skqp.cpp:114
std::string shaderText
Definition skqp.h:48
std::string name
Definition skqp.h:47