Hasty Badger
Small UI library (a branch of Turbo Badger)
|
TBRenderer is a minimal interface for painting strings and bitmaps. More...
#include <tb_renderer.h>
Public Types | |
enum | BATCH_HINT { BATCH_HINT_DRAW_BITMAP_FRAGMENT } |
Defines the hint given to BeginBatchHint. More... | |
Public Member Functions | |
virtual void | BeginPaint (int render_target_w, int render_target_h)=0 |
Should be called before invoking paint on any widget. More... | |
virtual void | EndPaint ()=0 |
virtual void | Translate (int dx, int dy)=0 |
Translate all drawing with the given offset. | |
virtual void | SetOpacity (float opacity)=0 |
Set the current opacity that should apply to all drawing (0.f-1.f). More... | |
virtual float | GetOpacity ()=0 |
virtual TBRect | SetClipRect (const TBRect &rect, bool add_to_current)=0 |
Set a clip rect to the renderer. More... | |
virtual TBRect | GetClipRect ()=0 |
Get the current clip rect. More... | |
virtual void | DrawBitmap (const TBRect &dst_rect, const TBRect &src_rect, TBBitmapFragment *bitmap_fragment)=0 |
Draw the src_rect part of the fragment stretched to dst_rect. More... | |
virtual void | DrawBitmap (const TBRect &dst_rect, const TBRect &src_rect, TBBitmap *bitmap)=0 |
Draw the src_rect part of the bitmap stretched to dst_rect. More... | |
virtual void | DrawBitmapColored (const TBRect &dst_rect, const TBRect &src_rect, const TBColor &color, TBBitmapFragment *bitmap_fragment)=0 |
Draw the src_rect part of the fragment stretched to dst_rect. More... | |
virtual void | DrawBitmapColored (const TBRect &dst_rect, const TBRect &src_rect, const TBColor &color, TBBitmap *bitmap)=0 |
Draw the src_rect part of the bitmap stretched to dst_rect. More... | |
virtual void | DrawBitmapTile (const TBRect &dst_rect, TBBitmap *bitmap)=0 |
Draw the bitmap tiled into dst_rect. More... | |
virtual void | DrawBitmapTileColored (const TBRect &dst_rect, const TBColor &color, TBBitmap *bitmap)=0 |
Draw the bitmap tiled into dst_rect. More... | |
virtual void | FlushBitmapFragment (TBBitmapFragment *bitmap_fragment)=0 |
Make sure the given bitmap fragment is flushed from any batching, because it may be changed or deleted after this call. More... | |
virtual TBBitmap * | CreateBitmap (int width, int height, uint32_t *data)=0 |
Create a new TBBitmap from the given data (in BGRA32 format). More... | |
void | AddListener (TBRendererListener *listener) |
Add a listener to this renderer. More... | |
void | RemoveListener (TBRendererListener *listener) |
Remove a listener from this renderer. More... | |
void | InvokeContextLost () |
Invoke OnContextLost on all listeners. More... | |
void | InvokeContextRestored () |
Invoke OnContextRestored on all listeners. More... | |
virtual void | BeginBatchHint (BATCH_HINT) |
A hint to batching renderers that the following set of draw calls are of the same type so batching might be optimized. More... | |
virtual void | EndBatchHint () |
End the hint scope started with BeginBatchHint. More... | |
TBRenderer is a minimal interface for painting strings and bitmaps.
|
inline |
Add a listener to this renderer.
Does not take ownership.
|
inlinevirtual |
A hint to batching renderers that the following set of draw calls are of the same type so batching might be optimized.
The hint defines what operations are allowed between BeginBatchHint until EndBatchHint is called. All other draw operations are invalid. It's not valid to nest calls to BeginBatchHint.
|
pure virtual |
Should be called before invoking paint on any widget.
render_target_w and render_target_h should be the size of the render target that the renderer renders to. I.e window size, screen size or frame buffer object.
|
pure virtual |
Create a new TBBitmap from the given data (in BGRA32 format).
Width and height must be a power of two. Return nullptr if fail.
|
pure virtual |
Draw the src_rect part of the fragment stretched to dst_rect.
dst_rect or src_rect can have negative width and height to achieve horizontal and vertical flip.
|
pure virtual |
Draw the src_rect part of the bitmap stretched to dst_rect.
dst_rect or src_rect can have negative width and height to achieve horizontal and vertical flip.
|
pure virtual |
Draw the src_rect part of the fragment stretched to dst_rect.
The bitmap will be used as a mask for the color. dst_rect or src_rect can have negative width and height to achieve horizontal and vertical flip.
|
pure virtual |
Draw the src_rect part of the bitmap stretched to dst_rect.
The bitmap will be used as a mask for the color. dst_rect or src_rect can have negative width and height to achieve horizontal and vertical flip.
|
pure virtual |
Draw the bitmap tiled into dst_rect.
|
pure virtual |
Draw the bitmap tiled into dst_rect.
The bitmap will be used as a mask for the color
|
inlinevirtual |
End the hint scope started with BeginBatchHint.
|
pure virtual |
Make sure the given bitmap fragment is flushed from any batching, because it may be changed or deleted after this call.
|
pure virtual |
Get the current clip rect.
Note: This may be different from the rect sent to SetClipRect, due to intersecting with the previous cliprect!
void tb::TBRenderer::InvokeContextLost | ( | ) |
Invoke OnContextLost on all listeners.
Call when bitmaps should be forgotten.
void tb::TBRenderer::InvokeContextRestored | ( | ) |
Invoke OnContextRestored on all listeners.
Call when bitmaps can safely be restored.
|
inline |
Remove a listener from this renderer.
|
pure virtual |
Set a clip rect to the renderer.
add_to_current should be true when pushing a new cliprect that should clip inside the last clip rect, and false when restoring. It will return the clip rect that was in use before this call.
|
pure virtual |
Set the current opacity that should apply to all drawing (0.f-1.f).