CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/headless/HeadlessHost.h
Views: 1401
// Copyright (c) 2012- PPSSPP Project.12// This program is free software: you can redistribute it and/or modify3// it under the terms of the GNU General Public License as published by4// the Free Software Foundation, version 2.0 or later versions.56// This program is distributed in the hope that it will be useful,7// but WITHOUT ANY WARRANTY; without even the implied warranty of8// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9// GNU General Public License 2.0 for more details.1011// A copy of the GPL 2.0 should have been included with the program.12// If not, see http://www.gnu.org/licenses/1314// Official git repository and contact information can be found at15// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.1617#pragma once1819#include "Common/CommonTypes.h"20#include "Common/File/Path.h"2122#include "Core/CoreParameter.h"2324class HeadlessHost {25public:26virtual ~HeadlessHost() {}27virtual bool InitGraphics(std::string *error_message, GraphicsContext **ctx, GPUCore core) {return false;}28virtual void ShutdownGraphics() {}2930virtual void SendDebugOutput(const std::string &output) {31if (!writeDebugOutput_)32return;33if (output.find('\n') != output.npos) {34FlushDebugOutput();35fwrite(output.data(), sizeof(char), output.length(), stdout);36} else {37debugOutputBuffer_ += output;38}39}40void FlushDebugOutput() {41if (!debugOutputBuffer_.empty()) {42fwrite(debugOutputBuffer_.data(), sizeof(char), debugOutputBuffer_.length(), stdout);43debugOutputBuffer_.clear();44}45}4647void SetWriteDebugOutput(bool flag) {48writeDebugOutput_ = flag;49}5051void SetComparisonScreenshot(const Path &filename, double maxError) {52comparisonScreenshot_ = filename;53maxScreenshotError_ = maxError;54}55void SetWriteFailureScreenshot(bool flag) {56writeFailureScreenshot_ = flag;57}5859void SendDebugScreenshot(const u8 *pixbuf, u32 w, u32 h);6061virtual void SwapBuffers() {}6263protected:64void SendAndCollectOutput(const std::string &output);6566Path comparisonScreenshot_;67double maxScreenshotError_ = 0.0;68std::string debugOutputBuffer_;69GPUCore gpuCore_;70GraphicsContext *gfx_ = nullptr;71bool writeFailureScreenshot_ = true;72bool writeDebugOutput_ = true;73};747576