2021-05-24 16:47:23 +00:00
|
|
|
#ifndef OPENMW_COMPONENTS_SCENEUTIL_SCREENCAPTURE_H
|
|
|
|
#define OPENMW_COMPONENTS_SCENEUTIL_SCREENCAPTURE_H
|
|
|
|
|
2021-07-11 12:43:52 +00:00
|
|
|
#include <components/misc/guarded.hpp>
|
|
|
|
|
2021-05-24 17:27:09 +00:00
|
|
|
#include <osg/ref_ptr>
|
2021-05-24 16:47:23 +00:00
|
|
|
#include <osgViewer/ViewerEventHandlers>
|
|
|
|
|
|
|
|
#include <string>
|
2021-07-11 12:43:52 +00:00
|
|
|
#include <vector>
|
2021-05-24 16:47:23 +00:00
|
|
|
|
|
|
|
namespace osg
|
|
|
|
{
|
|
|
|
class Image;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace SceneUtil
|
|
|
|
{
|
2021-05-24 17:27:09 +00:00
|
|
|
class WorkQueue;
|
2021-07-11 12:43:52 +00:00
|
|
|
class WorkItem;
|
2021-05-24 17:27:09 +00:00
|
|
|
|
2021-05-24 23:49:27 +00:00
|
|
|
std::string writeScreenshotToFile(const std::string& screenshotPath, const std::string& screenshotFormat,
|
|
|
|
const osg::Image& image);
|
2021-05-24 16:47:23 +00:00
|
|
|
|
|
|
|
class WriteScreenshotToFileOperation : public osgViewer::ScreenCaptureHandler::CaptureOperation
|
|
|
|
{
|
|
|
|
public:
|
2021-05-24 23:49:27 +00:00
|
|
|
WriteScreenshotToFileOperation(const std::string& screenshotPath, const std::string& screenshotFormat,
|
|
|
|
std::function<void (std::string)> callback);
|
2021-05-24 16:47:23 +00:00
|
|
|
|
2021-05-24 17:27:09 +00:00
|
|
|
void operator()(const osg::Image& image, const unsigned int context_id) override;
|
2021-05-24 16:47:23 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
const std::string mScreenshotPath;
|
|
|
|
const std::string mScreenshotFormat;
|
2021-05-24 23:49:27 +00:00
|
|
|
const std::function<void (std::string)> mCallback;
|
2021-05-24 16:47:23 +00:00
|
|
|
};
|
2021-05-24 17:27:09 +00:00
|
|
|
|
|
|
|
class AsyncScreenCaptureOperation : public osgViewer::ScreenCaptureHandler::CaptureOperation
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
AsyncScreenCaptureOperation(osg::ref_ptr<SceneUtil::WorkQueue> queue,
|
|
|
|
osg::ref_ptr<osgViewer::ScreenCaptureHandler::CaptureOperation> impl);
|
|
|
|
|
2021-07-11 12:43:52 +00:00
|
|
|
~AsyncScreenCaptureOperation();
|
|
|
|
|
|
|
|
void stop();
|
|
|
|
|
2021-05-24 17:27:09 +00:00
|
|
|
void operator()(const osg::Image& image, const unsigned int context_id) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
const osg::ref_ptr<SceneUtil::WorkQueue> mQueue;
|
|
|
|
const osg::ref_ptr<osgViewer::ScreenCaptureHandler::CaptureOperation> mImpl;
|
2021-07-11 12:43:52 +00:00
|
|
|
Misc::ScopeGuarded<std::vector<osg::ref_ptr<SceneUtil::WorkItem>>> mWorkItems;
|
2021-05-24 17:27:09 +00:00
|
|
|
};
|
2021-05-24 16:47:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|