diff options
author | Sybren A. Stüvel <sybren@stuvel.eu> | 2015-11-24 11:15:15 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@stuvel.eu> | 2015-11-24 11:15:15 +0300 |
commit | 31cc60e76bfa81783e61a7b01586de9547de0174 (patch) | |
tree | cd5406cef65829caf1fae8e1aecf355034e53549 /source/gameengine/Rasterizer/RAS_ICanvas.h | |
parent | c026aa6d5473ca0d103a8f92e35e341402a571bf (diff) |
BGE: Save screenshots in a different thread
This patch allows the game engine to keep running while performing things like PNG compression and disk I/O.
As an example, my crowd simulation rasterizer saves a screenshot for every frame. This now takes up 13 msec per frame, which was 31 msec before this patch. Effectively, it allows the simulation to save every frame and still run at 60 FPS.
Reviewers: lordloki, moguri, panzergame
Reviewed By: moguri, panzergame
Projects: #game_engine
Differential Revision: https://developer.blender.org/D1507
Diffstat (limited to 'source/gameengine/Rasterizer/RAS_ICanvas.h')
-rw-r--r-- | source/gameengine/Rasterizer/RAS_ICanvas.h | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/source/gameengine/Rasterizer/RAS_ICanvas.h b/source/gameengine/Rasterizer/RAS_ICanvas.h index 471c2c97fa1..91cc13c8f85 100644 --- a/source/gameengine/Rasterizer/RAS_ICanvas.h +++ b/source/gameengine/Rasterizer/RAS_ICanvas.h @@ -37,6 +37,9 @@ #endif class RAS_Rect; +struct TaskScheduler; +struct TaskPool; +struct ImageFormatData; /** * 2D rendering device context. The connection from 3d rendercontext to 2d surface. @@ -56,10 +59,8 @@ public: MOUSE_NORMAL }; - virtual - ~RAS_ICanvas( - ) { - } + RAS_ICanvas(); + virtual ~RAS_ICanvas(); virtual void @@ -260,7 +261,23 @@ public: protected: RAS_MouseState m_mousestate; + int m_frame; /// frame number for screenshots. + TaskScheduler *m_taskscheduler; + TaskPool *m_taskpool; + /** + * Saves screenshot data to a file. The actual compression and disk I/O is performed in + * a separate thread. + * + * @param filename name of the file, can contain "###" for sequential numbering. A copy of the string + * is made, so the pointer can be freed by the caller. + * @param dumpsx width in pixels. + * @param dumpsy height in pixels. + * @param dumprect pixel data; ownership is passed to this function, which also frees the data. + * @param im_format image format for the file; ownership is passed to this function, which also frees the data. + */ + void save_screenshot(const char *filename, int dumpsx, int dumpsy, unsigned int *dumprect, + ImageFormatData * im_format); #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_ICanvas") |