File: screencapture.hpp

package info (click to toggle)
openmw 0.49.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 33,992 kB
  • sloc: cpp: 372,479; xml: 2,149; sh: 1,403; python: 797; makefile: 26
file content (59 lines) | stat: -rw-r--r-- 1,789 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef OPENMW_COMPONENTS_SCENEUTIL_SCREENCAPTURE_H
#define OPENMW_COMPONENTS_SCENEUTIL_SCREENCAPTURE_H

#include <components/misc/guarded.hpp>

#include <osg/ref_ptr>
#include <osgViewer/ViewerEventHandlers>

#include <filesystem>
#include <string>
#include <vector>

namespace osg
{
    class Image;
}

namespace SceneUtil
{
    class WorkQueue;
    class WorkItem;

    std::filesystem::path writeScreenshotToFile(
        const std::filesystem::path& screenshotPath, const std::string& screenshotFormat, const osg::Image& image);

    class WriteScreenshotToFileOperation : public osgViewer::ScreenCaptureHandler::CaptureOperation
    {
    public:
        WriteScreenshotToFileOperation(const std::filesystem::path& screenshotPath, const std::string& screenshotFormat,
            std::function<void(std::string)> callback);

        void operator()(const osg::Image& image, const unsigned int context_id) override;

    private:
        const std::filesystem::path mScreenshotPath;
        const std::string mScreenshotFormat;
        const std::function<void(std::string)> mCallback;
    };

    class AsyncScreenCaptureOperation : public osgViewer::ScreenCaptureHandler::CaptureOperation
    {
    public:
        AsyncScreenCaptureOperation(osg::ref_ptr<SceneUtil::WorkQueue> queue,
            osg::ref_ptr<osgViewer::ScreenCaptureHandler::CaptureOperation> impl);

        ~AsyncScreenCaptureOperation();

        void stop();

        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;
        Misc::ScopeGuarded<std::vector<osg::ref_ptr<SceneUtil::WorkItem>>> mWorkItems;
    };
}

#endif