CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
hrydgard

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: hrydgard/ppsspp
Path: blob/master/headless/Compare.h
Views: 1401
1
// Copyright (c) 2012- PPSSPP Project.
2
3
// This program is free software: you can redistribute it and/or modify
4
// it under the terms of the GNU General Public License as published by
5
// the Free Software Foundation, version 2.0 or later versions.
6
7
// This program is distributed in the hope that it will be useful,
8
// but WITHOUT ANY WARRANTY; without even the implied warranty of
9
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
// GNU General Public License 2.0 for more details.
11
12
// A copy of the GPL 2.0 should have been included with the program.
13
// If not, see http://www.gnu.org/licenses/
14
15
// Official git repository and contact information can be found at
16
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
17
18
#include <string>
19
#include <vector>
20
21
#include "Common/CommonTypes.h"
22
#include "Common/File/Path.h"
23
24
struct GPUDebugBuffer;
25
26
extern bool teamCityMode;
27
extern std::string currentTestName;
28
void TeamCityPrint(const char *fmt, ...);
29
void GitHubActionsPrint(const char *type, const char *fmt, ...);
30
31
Path ExpectedFromFilename(const Path &bootFilename);
32
Path ExpectedScreenshotFromFilename(const Path &bootFilename);
33
std::string GetTestName(const Path &bootFilename);
34
35
bool CompareOutput(const Path &bootFilename, const std::string &output, bool verbose);
36
std::vector<u32> TranslateDebugBufferToCompare(const GPUDebugBuffer *buffer, u32 stride, u32 h);
37
38
class ScreenshotComparer {
39
public:
40
ScreenshotComparer(const std::vector<u32> &pixels, u32 stride, u32 w, u32 h)
41
: pixels_(pixels), stride_(stride), w_(w), h_(h) {
42
}
43
~ScreenshotComparer();
44
45
double Compare(const Path &screenshotFilename);
46
47
std::string GetError() {
48
return error_;
49
}
50
51
bool SaveActualBitmap(const Path &filename);
52
bool SaveVisualComparisonPNG(const Path &filename);
53
54
protected:
55
void PlotVisualComparison(u32 *dst, u32 offset, u32 actual, u32 reference);
56
57
const std::vector<u32> &pixels_;
58
u32 *reference_ = nullptr;
59
bool asBitmap_ = false;
60
std::string error_;
61
u32 referenceStride_ = 0;
62
u32 stride_;
63
u32 w_;
64
u32 h_;
65
};
66
67