Composition manager. More...
#include <kanzi/core.ui/graphics2d/composition_manager.hpp>
Classes | |
struct | LRUTracker |
Least Recently Used wrapper for different resource types. More... | |
class | Request |
Composition request class. More... | |
struct | ReuseParameters |
Reuse and pruning parameters for unused composition targets. More... | |
class | Target |
Composition target. More... | |
Public Types | |
using | AvailableRenderbufferContainer |
Storage type for available renderbuffers. | |
using | AvailableTextureContainer |
Storage type for available textures. | |
using | AvailableTextureSpan |
Span type for available textures. | |
using | UsedTextureSpan |
Span type for used textures. | |
Public Member Functions | |
TextureSharedPtr | acquireTemporaryCompositionTarget (const CompositionContentRequirements &requirements) |
Requests a composition target. | |
virtual Target | acquireTemporaryCompositionTarget (const Request &compositionReq) |
Requests a composition target. | |
TextureSharedPtr | acquireTemporaryCompositionTarget (unsigned int width, unsigned int height, bool alpha, bool depth, bool stencil) |
Requests a composition target. | |
TextureSharedPtr | acquireTemporaryCompositionTarget (unsigned int width, unsigned int height, bool alpha, bool depth, bool stencil, unsigned int numSamples) |
Requests a composition target. | |
TextureSharedPtr | acquireTemporaryCompositionTarget (unsigned int width, unsigned int height, GraphicsFormat colorFormat, GraphicsFormat depthStencilFormat) |
Requests a composition target. | |
TextureSharedPtr | acquireTemporaryCompositionTarget (unsigned int width, unsigned int height, GraphicsFormat colorFormat, GraphicsFormat depthStencilFormat, unsigned int numSamples) |
Requests a composition target. | |
void | clear () |
Removes all allocated temporary composition targets. | |
bool | colorRenderbufferMatches (const Renderbuffer &renderbuffer, const Request &compositionReq) const |
Returns whether a given color render buffer matches composition requirements. | |
bool | colorTextureMatches (const Texture &texture, const Request &compositionReq) const |
Returns whether a given color texture matches composition requirements. | |
CompositionManager (ResourceManager *resourceManager) | |
Constructor. | |
bool | compositionTargetMatches (const Target &target, const Request &compositionReq) const |
Checks if a given composition target texture is an acceptable match for given requirements. | |
bool | compositionTargetMatches (const Target &target, const Request &compositionReq, float downScaleLimit) const |
Checks if a given composition target is an acceptable match for given requirements. | |
bool | compositionTargetMatches (TextureSharedPtr texture, unsigned int width, unsigned int height, bool alpha, bool depth, bool stencil) const |
Checks if a given composition target texture is an acceptable match for given requirements. | |
bool | compositionTargetMatches (TextureSharedPtr texture, unsigned int width, unsigned int height, bool alpha, bool depth, bool stencil, float downScaleLimit) const |
Checks if a given composition target texture is an acceptable match for given requirements. | |
bool | compositionTargetMatches (TextureSharedPtr texture, unsigned int width, unsigned int height, GraphicsFormat colorFormat, GraphicsFormat depthStencilFormat) const |
Checks if a given composition target texture is an acceptable match for given requirements. | |
RenderbufferSharedPtr | createPersistentColorRenderbuffer (const CompositionManager::Request &compositionReq) |
Creates a persistent color renderbuffer. | |
virtual Target | createPersistentCompositionTarget (const Request &compositionReq) |
Creates a persistent composition target. | |
TextureSharedPtr | createPersistentCompositionTarget (unsigned int width, unsigned int height, bool alpha, bool depth, bool stencil) |
Creates a persistent composition target. | |
TextureSharedPtr | createPersistentCompositionTarget (unsigned int width, unsigned int height, GraphicsFormat colorFormat, GraphicsFormat depthStencilFormat, Sampler::AddressingMode addressingMode) |
Creates a persistent composition target. | |
virtual RenderbufferSharedPtr | createPersistentDepthStencilRenderbuffer (const CompositionManager::Request &compositionReq) |
Creates a persistent depth and/or stencil renderbuffer. | |
RenderbufferSharedPtr | createPersistentDepthStencilRenderbuffer (unsigned int width, unsigned int height, bool depth, bool stencil, unsigned int samples) |
Creates a persistent depth and/or stencil renderbuffer. | |
RenderbufferSharedPtr | createPersistentDepthStencilRenderbuffer (unsigned int width, unsigned int height, GraphicsFormat depthStencilFormat, unsigned int samples) |
Creates a persistent depth and/or stencil renderbuffer. | |
TextureSharedPtr | createPersistentDepthTexture (const CompositionManager::Request &compositionReq) |
Creates a persistent depth texture. | |
TextureSharedPtr | createPersistentTexture (const CompositionManager::Request &compositionReq) |
Creates a persistent color texture. | |
bool | depthTextureMatches (const Texture &texture, const Request &compositionReq) const |
Returns whether a given depth texture matches composition requirements. | |
AvailableTextureSpan | getAvailableTextures () const |
Gets a span over the available textures. | |
GraphicsFormat | getColorFormat (bool alpha) const |
Gets color texture format format depending on alpha requirement. | |
GraphicsFormat | getDepthRenderbufferFormat () const |
Gets depth renderbuffer format. | |
GraphicsFormat | getDepthStencilFormat (bool depth, bool stencil) const |
Gets the depth or stencil renderbuffer format depending on requirements. | |
GraphicsFormat | getDepthStencilRenderbufferFormat () const |
Gets depth + stencil format. | |
GraphicsFormat | getDepthTextureFormat () const |
Gets format for depth textures. | |
ReuseParameters | getReuseParameters () const |
Gets the reuse and pruning parameters for unused composition targets. | |
GraphicsFormat | getStencilRenderbufferFormat () const |
Gets stencil renderbuffer format. | |
void | getUnusedTargetCounts (size_t &textures, size_t &renderBuffers, size_t &depthTextures) |
Gets the numbers of unused composition targets for statistics and test purposes. | |
UsedTextureSpan | getUsedTextures () const |
Gets a span over the textures that are in use. | |
void | initialize (Renderer &renderer) |
Initializes the composition manager. | |
void | pruneUnusedTargets () |
Prunes unused composition targets from free lists. | |
virtual void | releaseTemporaryCompositionTarget (const Target &target) |
Releases an earlier composition target. | |
void | setReuseParameters (const ReuseParameters &reuseParameters) |
Sets the reuse and pruning parameters for unused composition targets. | |
virtual | ~CompositionManager ()=default |
Destructor. | |
Composition manager.
Used for storing and managing composition targets and keeping track of their use. The rationale is to minimize memory used by composition targets.
Storage type for available renderbuffers.
Storage type for available textures.
Span type for available textures.
Span type for used textures.
|
explicit |
Constructor.
resourceManager | Resource manager owning this composition manager. |
|
virtualdefault |
Destructor.
void kanzi::CompositionManager::clear | ( | ) |
Removes all allocated temporary composition targets.
void kanzi::CompositionManager::pruneUnusedTargets | ( | ) |
Prunes unused composition targets from free lists.
|
virtual |
Requests a composition target.
compositionReq | Request details. |
|
inline |
Requests a composition target.
requirements | Content requirements details. |
|
inline |
Requests a composition target.
This function returns only the color texture element of the composition target.
width | Requested width. |
height | Requested height. |
colorFormat | Color buffer format. |
depthStencilFormat | Depth and/or stencil buffer format. |
TextureSharedPtr kanzi::CompositionManager::acquireTemporaryCompositionTarget | ( | unsigned int | width, |
unsigned int | height, | ||
GraphicsFormat | colorFormat, | ||
GraphicsFormat | depthStencilFormat, | ||
unsigned int | numSamples ) |
Requests a composition target.
This function returns only the color texture element of the composition target.
width | Requested width. |
height | Requested height. |
colorFormat | Color buffer format. |
depthStencilFormat | Depth and/or stencil buffer format. |
numSamples | Requested number of samples. |
|
inline |
Requests a composition target.
This function returns only the color texture element of the composition target.
width | Requested width. |
height | Requested height. |
alpha | Whether to request the alpha channel. |
depth | Whether to request the depth buffer. |
stencil | Whether to request the stencil buffer. |
|
inline |
Requests a composition target.
This function returns only the color texture element of the composition target.
width | Requested width. |
height | Requested height. |
alpha | Whether to request the alpha channel. |
depth | Whether to request the depth buffer. |
stencil | Whether to request the stencil buffer. |
numSamples | Requested number of samples. |
|
virtual |
Releases an earlier composition target.
This, released composition target may be re-used by successive requests.
target | Target to release. |
|
virtual |
Creates a persistent composition target.
Caller has ownership of all the components of this composition target, it is not stored within the composition manager.
compositionReq | Request details. |
TextureSharedPtr kanzi::CompositionManager::createPersistentCompositionTarget | ( | unsigned int | width, |
unsigned int | height, | ||
GraphicsFormat | colorFormat, | ||
GraphicsFormat | depthStencilFormat, | ||
Sampler::AddressingMode | addressingMode ) |
Creates a persistent composition target.
This function returns only the color texture element of the composition target. The caller of this function has ownership of this composition target. Kanzi does not store the composition target within the composition manager.
width | Requested width. |
height | Requested height. |
colorFormat | Color buffer format. |
depthStencilFormat | Depth and/or stencil buffer format. |
addressingMode | Addressing mode (wrap/clamp/etc.). |
|
inline |
Creates a persistent composition target.
This function returns only the color texture element of the composition target. The caller of this function has ownership of this composition target. Kanzi does not store the composition target within the composition manager.
width | Requested width. |
height | Requested height. |
alpha | Whether to require the alpha channel. |
depth | Whether to require the depth buffer. |
stencil | Whether to require the stencil buffer. |
TextureSharedPtr kanzi::CompositionManager::createPersistentTexture | ( | const CompositionManager::Request & | compositionReq | ) |
Creates a persistent color texture.
Note that the color format of this texture may be GraphicsFormatNone.
compositionReq | Request details. |
RenderbufferSharedPtr kanzi::CompositionManager::createPersistentColorRenderbuffer | ( | const CompositionManager::Request & | compositionReq | ) |
Creates a persistent color renderbuffer.
compositionReq | Request details. |
|
virtual |
Creates a persistent depth and/or stencil renderbuffer.
compositionReq | Request details. |
RenderbufferSharedPtr kanzi::CompositionManager::createPersistentDepthStencilRenderbuffer | ( | unsigned int | width, |
unsigned int | height, | ||
GraphicsFormat | depthStencilFormat, | ||
unsigned int | samples ) |
Creates a persistent depth and/or stencil renderbuffer.
width | The width of the renderbuffer. |
height | The height of the renderbuffer. |
depthStencilFormat | Depth or stencil format. |
samples | Number of samples. |
RenderbufferSharedPtr kanzi::CompositionManager::createPersistentDepthStencilRenderbuffer | ( | unsigned int | width, |
unsigned int | height, | ||
bool | depth, | ||
bool | stencil, | ||
unsigned int | samples ) |
Creates a persistent depth and/or stencil renderbuffer.
width | The width of the renderbuffer. |
height | The height of the renderbuffer. |
depth | If depth is required true, otherwise false. |
stencil | If stencil is required true, otherwise false. |
samples | Number of samples. |
TextureSharedPtr kanzi::CompositionManager::createPersistentDepthTexture | ( | const CompositionManager::Request & | compositionReq | ) |
Creates a persistent depth texture.
compositionReq | Request details. |
bool kanzi::CompositionManager::compositionTargetMatches | ( | const Target & | target, |
const Request & | compositionReq, | ||
float | downScaleLimit ) const |
Checks if a given composition target is an acceptable match for given requirements.
target | Composition target to test. |
compositionReq | Request details. |
downScaleLimit | Limit for matching against smaller composition targets. |
|
inline |
Checks if a given composition target texture is an acceptable match for given requirements.
target | Composition target to test. |
compositionReq | Request details. |
|
inline |
Checks if a given composition target texture is an acceptable match for given requirements.
Tolerance for how much smaller composition targets are accepted is determined automatically.
texture | Composition target texture to test. |
width | Requested width. |
height | Requested height. |
colorFormat | Color buffer format. |
depthStencilFormat | Depth/stencil buffer format. |
|
inline |
Checks if a given composition target texture is an acceptable match for given requirements.
Determines color, depth and stencil formats from on/off boolean values.
texture | Composition target texture to test. |
width | Requested width. |
height | Requested height. |
alpha | Alpha channel requirement. |
depth | Depth buffer requirement. |
stencil | Stencil buffer requirement. |
downScaleLimit | Limit for matching against smaller composition targets. |
|
inline |
Checks if a given composition target texture is an acceptable match for given requirements.
Determines color, depth and stencil formats from on/off boolean values. Tolerance for how much smaller composition targets are accepted is determined automatically.
texture | Composition target texture to test. |
width | Requested width. |
height | Requested height. |
alpha | Alpha channel requirement. |
depth | Depth buffer requirement. |
stencil | Stencil buffer requirement. |
|
inline |
Returns whether a given color render buffer matches composition requirements.
renderbuffer | Renderbuffer to test. |
compositionReq | Request details. |
|
inline |
Gets color texture format format depending on alpha requirement.
alpha | Whether to require alpha. |
|
inline |
Gets format for depth textures.
|
inline |
Gets the depth or stencil renderbuffer format depending on requirements.
depth | Whether to require depth. |
stencil | Whether to require stencil. |
|
inline |
Gets depth renderbuffer format.
|
inline |
Gets depth + stencil format.
|
inline |
Gets stencil renderbuffer format.
|
inline |
Gets a span over the available textures.
Do not call this function directly. Kanzi uses this function for internal verification.
|
inline |
Gets a span over the textures that are in use.
Do not call this function directly. Kanzi uses this function for internal verification.
|
inline |
Gets the numbers of unused composition targets for statistics and test purposes.
textures | Number of available color textures. |
renderBuffers | Number of available color renderbuffers. |
depthTextures | Number of available depth textures. |
|
inline |
Gets the reuse and pruning parameters for unused composition targets.
|
inline |
Sets the reuse and pruning parameters for unused composition targets.
reuseParameters | The struct that contains the reuse and pruning parameters. |
|
protected |
Creates a temporary composition target.
Called internally from within acquireTemporaryCompositionTarget() if suitable existing elements are not found. Adds the components of the temporary composition target to the arrays of resources in use.
compositionReq | Request details. |
texture | Existing main texture most closely matching the requirements. |
colorRenderbuffer | Existing color renderbuffer most closely matching the requirements. |
depthTexture | Existing depth texture most closely matching the requirements. |
|
protected |
Gets color renderbuffer match level for given requirements.
renderbuffer | Renderbuffer to test. |
compositionReq | Request details. |
|
protected |
Finds the color texture, which most closely matches a given composition requirement, and marks it used.
compositionReq | Request details. |
|
protected |
Finds the renderbuffer, which most closely matches a given composition requirement, and marks it used.
compositionReq | Request details. |
|
protected |
Finds the depth texture, which most closely matches a given composition requirement, and marks it used.
compositionReq | Request details. |
|
protected |
Marks a given color texture as available.
The texture must exist in used color textures.
texture | Texture to mark as used. |
|
protected |
Marks a given color renderbuffer as available.
The renderbuffer must exist in used color renderbuffers.
colorRenderbuffer | Renderbuffer to mark as used. |
|
protected |
Marks a given depth texture as available.
The texture must exist in used depth textures.
depthTexture | Texture to mark as used. |