Crazy Eddies GUI System  0.6.0
Classes | Public Member Functions | List of all members
CEGUI::RenderCache Class Reference

Class that acts as a cache for images that need to be rendered. More...

Public Member Functions

 RenderCache ()
 Constructor.
 
 ~RenderCache ()
 Destructor.
 
bool hasCachedImagery () const
 Return whether the cache contains anything to draw. More...
 
void render (const Point &basePos, float baseZ, const Rect &clipper)
 Send the contents of the cache to the Renderer. More...
 
void clearCachedImagery ()
 Erase any stored image information.
 
void cacheImage (const Image &image, const Rect &destArea, float zOffset, const ColourRect &cols, const Rect *clipper=0, bool clipToDisplay=false)
 Add an image to the cache. More...
 
void cacheText (const String &text, Font *font, TextFormatting format, const Rect &destArea, float zOffset, const ColourRect &cols, const Rect *clipper=0, bool clipToDisplay=false)
 Add a text to the cache. More...
 

Detailed Description

Class that acts as a cache for images that need to be rendered.

This is in many ways an optimisation cache, it allows a full image redraw
to occur while limiting the amount of information that needs to be re-calculated.
Basically, unless the actual images (or their size) change, or the colours (or alpha) change then imagery cached in here will suffice for a full redraw. The reasoning behind this is that when some window underneath window 'X' changes, a full image redraw is required by the renderer, however, since window 'X' is unchanged, performing a total recalculation of all imagery is very wasteful, and so we use this cache to limit such waste.
As another example, when a window is simply moved, there is no need to perform a total imagery recalculation; we can still use the imagery cached here since it is position independant.

Member Function Documentation

void CEGUI::RenderCache::cacheImage ( const Image image,
const Rect destArea,
float  zOffset,
const ColourRect cols,
const Rect clipper = 0,
bool  clipToDisplay = false 
)

Add an image to the cache.

Parameters
imageImage object to be cached.
destAreaDestination area over which the Image object will be rendered. This area should be position independant; so position (0,0) will be to top-left corner of whatever it is you're rendering (like a Window for example).
zOffsetZero based z offset for this image. Allows imagery to be layered.
colsColourRect object describing the colours to be applied when rendering this image.
Returns
Nothing

Referenced by CEGUI::FrameComponent::render_impl(), and CEGUI::ImageryComponent::render_impl().

void CEGUI::RenderCache::cacheText ( const String text,
Font font,
TextFormatting  format,
const Rect destArea,
float  zOffset,
const ColourRect cols,
const Rect clipper = 0,
bool  clipToDisplay = false 
)

Add a text to the cache.

Parameters
textString object to be cached.
fontFont to be used when rendering.
formatTextFormatting value specifying the formatting to use when rendering.
destAreaDestination area over which the Image object will be rendered. This area should be position independant; so position (0,0) will be to top-left corner of whatever it is you're rendering (like a Window for example).
zOffsetZero based z offset for this image. Allows imagery to be layered.
colsColourRect object describing the colours to be applied when rendering this image.
Returns
Nothing

Referenced by CEGUI::TextComponent::render_impl().

bool CEGUI::RenderCache::hasCachedImagery ( ) const

Return whether the cache contains anything to draw.

Returns
  • true if the cache contains information about images to be drawn.
  • false if the cache is empty.

Referenced by CEGUI::Window::drawSelf().

void CEGUI::RenderCache::render ( const Point basePos,
float  baseZ,
const Rect clipper 
)

Send the contents of the cache to the Renderer.

Parameters
basePosPoint that describes a screen offset that cached imagery will be rendered relative to.
baseZZ value that cached imagery will use as a base figure when calculating final z values.
clipperRect object describing a rect to which imagery will be clipped.
Returns
Nothing

References CEGUI::Rect::getIntersection(), CEGUI::System::getSingleton(), and CEGUI::Rect::offset().

Referenced by CEGUI::Window::drawSelf().