Beatmup
|
AbstractTask rendering a Scene. More...
#include <renderer.h>
Public Types | |
enum | OutputMapping { STRETCH = 0 , FIT_WIDTH_TO_TOP , FIT_WIDTH , FIT_HEIGHT } |
Scene coordinates to output (screen or bitmap) pixel coordinates mapping. More... | |
Public Types inherited from Beatmup::AbstractTask | |
enum class | TaskDeviceRequirement { CPU_ONLY , GPU_OR_CPU , GPU_ONLY } |
Specifies which device (CPU and/or GPU) is used to run the task. More... | |
Public Member Functions | |
SceneRenderer () | |
~SceneRenderer () | |
void | setOutput (AbstractBitmap *bitmap) |
Attaches a bitmap to the renderer output. More... | |
AbstractBitmap * | getOutput () const |
void | resetOutput () |
Removes a bitmap from the renderer output, if any, and switches to on-screen rendering. More... | |
const Scene * | getScene () const |
void | setScene (Scene *scene) |
void | setOutputMapping (const OutputMapping mapping) |
Specifies the output mapping specifying how the scene coordinates [0,1]² are mapped to the output (screen or bitmap) pixel coordinates. More... | |
OutputMapping | getOutputMapping () const |
Retrieves the output mapping specifying how the scene coordinates [0,1]² are mapped to the output (screen or bitmap) pixel coordinates. More... | |
void | setOutputReferenceWidth (int newWidth) |
Sets a value overriding output width for elements that have their size in pixels, in order to render a resolution-independent picture. More... | |
int | getOutputReferenceWidth () const |
void | setOutputPixelsFetching (bool fetch) |
Specifies whether the output image data is pulled from GPU to CPU memory every time the rendering is done. More... | |
bool | getOutputPixelsFetching () const |
Reports whether the output bitmap pixels are automatically offloaded from GPU to CPU memory every time the rendering is done. More... | |
void | setBackgroundImage (AbstractBitmap *) |
Sets an image to pave the background. More... | |
AbstractBitmap * | getBackgroundImage () const |
Scene::Layer * | pickLayer (float x, float y, bool inPixels) const |
Retrieves a scene layer visible at a given point, if any. More... | |
void | setRenderingEventListener (RenderingContext::EventListener *eventListener) |
Public Member Functions inherited from Beatmup::AbstractTask | |
virtual void | afterProcessing (ThreadIndex threadCount, GraphicPipeline *gpu, bool aborted) |
Instruction called after the task is executed. More... | |
Public Member Functions inherited from Beatmup::Object | |
virtual | ~Object () |
Protected Member Functions | |
bool | process (TaskThread &thread) |
Executes the task on CPU within a given thread. More... | |
bool | processOnGPU (GraphicPipeline &gpu, TaskThread &thread) |
Executes the task on GPU. More... | |
void | beforeProcessing (ThreadIndex threadCount, ProcessingTarget target, GraphicPipeline *gpu) |
Instruction called before the task is executed. More... | |
Private Member Functions | |
void | renderLayer (RenderingContext &context, TaskThread &thread, Scene::Layer &layer, const AffineMapping &base, unsigned int recursionLevel=0) |
bool | doRender (GraphicPipeline &gpu, TaskThread &thread) |
Private Attributes | |
Scene * | scene |
content to render More... | |
AbstractBitmap * | background |
used to pave the screen before rendering More... | |
AbstractBitmap * | output |
output bitmap More... | |
OutputMapping | outputMapping |
specifies how the scene coordinates [0,1] are mapped to the output (screen or bitmap) More... | |
AffineMapping | outputCoords |
the actual output mapping used during the last rendering More... | |
ImageResolution | resolution |
last rendered resolution More... | |
int | referenceWidth |
value overriding output width for elements that have their size in pixels, in order to render a resolution-independent picture More... | |
bool | outputPixelsFetching |
if true , the output bitmap data is fetched from GPU to CPU RAM every time the rendering is done More... | |
GL::TextureHandler * | cameraFrame |
last got camera frame; set to NULL before rendering, then asked from outside through eventListener More... | |
RenderingContext::EventListener * | eventListener |
Static Private Attributes | |
static const unsigned int | MAX_RECURSION_LEVEL = 256 |
Additional Inherited Members | |
Static Public Member Functions inherited from Beatmup::AbstractTask | |
static ThreadIndex | validThreadCount (int number) |
Valid thread count from a given integer value. More... | |
AbstractTask rendering a Scene.
The rendering may be done to a given bitmap or on screen, if the platform supports on-screen rendering.
Definition at line 29 of file renderer.h.
Scene coordinates to output (screen or bitmap) pixel coordinates mapping.
Definition at line 34 of file renderer.h.
SceneRenderer::SceneRenderer | ( | ) |
Definition at line 236 of file renderer.cpp.
SceneRenderer::~SceneRenderer | ( | ) |
Definition at line 245 of file renderer.cpp.
|
private |
Definition at line 37 of file renderer.cpp.
|
private |
Definition at line 147 of file renderer.cpp.
|
protectedvirtual |
Executes the task on CPU within a given thread.
Generally called by multiple threads.
thread | associated task execution context |
true
if the execution is finished correctly, false
otherwise Reimplemented from Beatmup::GpuTask.
Definition at line 230 of file renderer.cpp.
|
protectedvirtual |
Executes the task on GPU.
gpu | graphic pipeline instance |
thread | associated task execution context |
true
if the execution is finished correctly, false
otherwise Reimplemented from Beatmup::AbstractTask.
Definition at line 220 of file renderer.cpp.
|
protectedvirtual |
Instruction called before the task is executed.
threadCount | Number of threads used to perform the task |
target | Device used to perform the task |
gpu | A graphic pipeline instance; may be null. |
Reimplemented from Beatmup::AbstractTask.
Definition at line 138 of file renderer.cpp.
void SceneRenderer::setOutput | ( | AbstractBitmap * | bitmap | ) |
Attaches a bitmap to the renderer output.
Definition at line 76 of file renderer.cpp.
AbstractBitmap * SceneRenderer::getOutput | ( | ) | const |
Definition at line 66 of file renderer.cpp.
void SceneRenderer::resetOutput | ( | ) |
Removes a bitmap from the renderer output, if any, and switches to on-screen rendering.
The rendering is done on the display currently connected to the Context running the rendering task.
Definition at line 81 of file renderer.cpp.
const Scene * SceneRenderer::getScene | ( | ) | const |
Definition at line 61 of file renderer.cpp.
void SceneRenderer::setScene | ( | Scene * | scene | ) |
Definition at line 71 of file renderer.cpp.
void SceneRenderer::setOutputMapping | ( | const OutputMapping | mapping | ) |
Specifies the output mapping specifying how the scene coordinates [0,1]² are mapped to the output (screen or bitmap) pixel coordinates.
mapping | The coordinates mapping |
Definition at line 86 of file renderer.cpp.
SceneRenderer::OutputMapping SceneRenderer::getOutputMapping | ( | ) | const |
Retrieves the output mapping specifying how the scene coordinates [0,1]² are mapped to the output (screen or bitmap) pixel coordinates.
Definition at line 91 of file renderer.cpp.
void SceneRenderer::setOutputReferenceWidth | ( | int | newWidth | ) |
Sets a value overriding output width for elements that have their size in pixels, in order to render a resolution-independent picture.
newWidth | The new reference width in pixels. If set negative or zero, the actual output image width is used. |
Definition at line 96 of file renderer.cpp.
int SceneRenderer::getOutputReferenceWidth | ( | ) | const |
Definition at line 101 of file renderer.cpp.
void SceneRenderer::setOutputPixelsFetching | ( | bool | fetch | ) |
Specifies whether the output image data is pulled from GPU to CPU memory every time the rendering is done.
This is convenient if the rendered image is an application output result, and is further stored or sent through the network. Otherwise, if the image is to be further processed inside Beatmup, the pixel transfer likely introduces an unnecessary latency and may cause FPS drop in real-time rendering. Has no effect in on-screen rendering.
[in] | fetch | If true , pixels are pulled to CPU memory. |
Definition at line 111 of file renderer.cpp.
bool SceneRenderer::getOutputPixelsFetching | ( | ) | const |
Reports whether the output bitmap pixels are automatically offloaded from GPU to CPU memory every time the rendering is done.
Definition at line 116 of file renderer.cpp.
void SceneRenderer::setBackgroundImage | ( | AbstractBitmap * | bitmap | ) |
|
inline |
Definition at line 132 of file renderer.h.
Scene::Layer * SceneRenderer::pickLayer | ( | float | x, |
float | y, | ||
bool | inPixels | ||
) | const |
Retrieves a scene layer visible at a given point, if any.
In contrast to Scene::getLayer() it takes into account the output mapping. "Phantom" layers are ignored.
x | Horizontal coordinate. |
y | Vertical coordinate. |
inPixels | If true , the coordinates are taken in pixels. |
null
if no layer found. Definition at line 121 of file renderer.cpp.
void SceneRenderer::setRenderingEventListener | ( | RenderingContext::EventListener * | eventListener | ) |
Definition at line 133 of file renderer.cpp.
|
private |
content to render
Definition at line 42 of file renderer.h.
|
private |
used to pave the screen before rendering
Definition at line 43 of file renderer.h.
|
private |
output bitmap
Definition at line 44 of file renderer.h.
|
private |
specifies how the scene coordinates [0,1] are mapped to the output (screen or bitmap)
Definition at line 45 of file renderer.h.
|
private |
the actual output mapping used during the last rendering
Definition at line 46 of file renderer.h.
|
private |
last rendered resolution
Definition at line 47 of file renderer.h.
|
private |
value overriding output width for elements that have their size in pixels, in order to render a resolution-independent picture
Definition at line 48 of file renderer.h.
|
private |
if true
, the output bitmap data is fetched from GPU to CPU RAM every time the rendering is done
Definition at line 49 of file renderer.h.
|
private |
last got camera frame; set to NULL before rendering, then asked from outside through eventListener
Definition at line 50 of file renderer.h.
|
private |
Definition at line 51 of file renderer.h.
|
staticprivate |
Definition at line 54 of file renderer.h.