2013-02-08 00:22:37 -08:00
|
|
|
// Copyright (c) 2012- PPSSPP Project.
|
|
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
|
// the Free Software Foundation, version 2.0 or later versions.
|
|
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
|
|
// Official git repository and contact information can be found at
|
|
|
|
|
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
|
|
|
|
|
|
|
|
|
#include <string>
|
2014-08-30 09:45:51 -07:00
|
|
|
#include <vector>
|
2013-02-08 00:22:37 -08:00
|
|
|
|
2017-08-31 17:13:18 +02:00
|
|
|
#include "Common/CommonTypes.h"
|
2021-05-09 18:38:48 +02:00
|
|
|
#include "Common/File/Path.h"
|
2013-02-08 00:22:37 -08:00
|
|
|
|
2014-08-30 09:45:51 -07:00
|
|
|
struct GPUDebugBuffer;
|
|
|
|
|
|
2013-09-16 08:15:59 -07:00
|
|
|
extern bool teamCityMode;
|
2020-12-30 14:10:03 -08:00
|
|
|
extern std::string currentTestName;
|
2013-09-16 08:15:59 -07:00
|
|
|
void TeamCityPrint(const char *fmt, ...);
|
2020-12-30 14:10:03 -08:00
|
|
|
void GitHubActionsPrint(const char *type, const char *fmt, ...);
|
2013-09-16 08:15:59 -07:00
|
|
|
|
2021-05-09 18:38:48 +02:00
|
|
|
Path ExpectedFromFilename(const Path &bootFilename);
|
|
|
|
|
Path ExpectedScreenshotFromFilename(const Path &bootFilename);
|
|
|
|
|
std::string GetTestName(const Path &bootFilename);
|
2013-09-16 23:49:41 -07:00
|
|
|
|
2021-05-09 18:38:48 +02:00
|
|
|
bool CompareOutput(const Path &bootFilename, const std::string &output, bool verbose);
|
2014-08-30 09:45:51 -07:00
|
|
|
std::vector<u32> TranslateDebugBufferToCompare(const GPUDebugBuffer *buffer, u32 stride, u32 h);
|
2021-11-07 10:01:39 -08:00
|
|
|
|
|
|
|
|
class ScreenshotComparer {
|
|
|
|
|
public:
|
|
|
|
|
ScreenshotComparer(const std::vector<u32> &pixels, u32 stride, u32 w, u32 h)
|
|
|
|
|
: pixels_(pixels), stride_(stride), w_(w), h_(h) {
|
|
|
|
|
}
|
2021-11-07 11:05:17 -08:00
|
|
|
~ScreenshotComparer();
|
2021-11-07 10:01:39 -08:00
|
|
|
|
|
|
|
|
double Compare(const Path &screenshotFilename);
|
|
|
|
|
|
|
|
|
|
std::string GetError() {
|
|
|
|
|
return error_;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-07 11:05:17 -08:00
|
|
|
bool SaveActualBitmap(const Path &filename);
|
|
|
|
|
bool SaveVisualComparisonPNG(const Path &filename);
|
|
|
|
|
|
2021-11-07 10:01:39 -08:00
|
|
|
protected:
|
2021-11-07 11:05:17 -08:00
|
|
|
void PlotVisualComparison(u32 *dst, u32 offset, u32 actual, u32 reference);
|
|
|
|
|
|
2021-11-07 10:01:39 -08:00
|
|
|
const std::vector<u32> &pixels_;
|
2021-11-07 11:05:17 -08:00
|
|
|
u32 *reference_ = nullptr;
|
|
|
|
|
bool asBitmap_ = false;
|
2021-11-07 10:01:39 -08:00
|
|
|
std::string error_;
|
2022-10-18 21:33:47 -07:00
|
|
|
u32 referenceStride_ = 0;
|
2021-11-07 10:01:39 -08:00
|
|
|
u32 stride_;
|
|
|
|
|
u32 w_;
|
|
|
|
|
u32 h_;
|
|
|
|
|
};
|