6 #ifndef TB_RENDERER_BATCHER_H
7 #define TB_RENDERER_BATCHER_H
9 #include "tb_renderer.h"
11 #ifdef TB_RENDERER_BATCHER
15 #define VERTEX_BATCH_SIZE 6 * 2048
20 class TBRendererBatcher :
public TBRenderer
29 struct {
unsigned char r, g, b, a; };
37 Batch() : vertex_count(0), bitmap(nullptr), fragment(nullptr), batch_id(0), is_flushing(false) {}
38 void Flush(TBRendererBatcher *batch_renderer);
39 Vertex *Reserve(TBRendererBatcher *batch_renderer,
int count);
41 Vertex vertex[VERTEX_BATCH_SIZE];
45 TBBitmapFragment *fragment;
52 virtual ~TBRendererBatcher();
54 virtual void BeginPaint(
int render_target_w,
int render_target_h);
55 virtual void EndPaint();
57 virtual void Translate(
int dx,
int dy);
59 virtual void SetOpacity(
float opacity);
60 virtual float GetOpacity();
62 virtual TBRect SetClipRect(
const TBRect &rect,
bool add_to_current);
63 virtual TBRect GetClipRect();
65 virtual void DrawBitmap(
const TBRect &dst_rect,
const TBRect &src_rect, TBBitmapFragment *bitmap_fragment);
66 virtual void DrawBitmap(
const TBRect &dst_rect,
const TBRect &src_rect, TBBitmap *bitmap);
67 virtual void DrawBitmapColored(
const TBRect &dst_rect,
const TBRect &src_rect,
const TBColor &color, TBBitmapFragment *bitmap_fragment);
68 virtual void DrawBitmapColored(
const TBRect &dst_rect,
const TBRect &src_rect,
const TBColor &color, TBBitmap *bitmap);
69 virtual void DrawBitmapTile(
const TBRect &dst_rect, TBBitmap *bitmap);
70 virtual void DrawBitmapTileColored(
const TBRect &dst_rect,
const TBColor &color, TBBitmap *bitmap);
71 virtual void FlushBitmap(TBBitmap *bitmap);
72 virtual void FlushBitmapFragment(TBBitmapFragment *bitmap_fragment);
75 virtual void EndBatchHint() {}
78 virtual TBBitmap *CreateBitmap(
int width,
int height, uint32_t *data) = 0;
79 virtual void RenderBatch(Batch *batch) = 0;
80 virtual void SetClipRect(
const TBRect &rect) = 0;
88 float m_u, m_v, m_uu, m_vv;
91 void AddQuadInternal(
const TBRect &dst_rect,
const TBRect &src_rect, uint32_t color, TBBitmap *bitmap, TBBitmapFragment *fragment);
92 void FlushAllInternal();
97 #endif // TB_RENDERER_BATCHER
99 #endif // TB_RENDERER_BATCHER_H
BATCH_HINT
Defines the hint given to BeginBatchHint.
Definition: tb_renderer.h:131