mirror of
https://gitee.com/idea4good/GuiLite.git
synced 2025-11-24 08:33:17 +08:00
refactor display/surface
This commit is contained in:
@@ -24,6 +24,7 @@ c_display::c_display(void* phy_fb, unsigned int display_width, unsigned int disp
|
||||
m_phy_fb = phy_fb;
|
||||
m_phy_read_index = m_phy_write_index = 0;
|
||||
memset(m_surface_group, 0, sizeof(m_surface_group));
|
||||
m_surface_index = 0;
|
||||
m_surface_cnt = surface_cnt;
|
||||
ASSERT(m_surface_cnt <= SURFACE_CNT_MAX);
|
||||
|
||||
@@ -33,35 +34,16 @@ c_display::c_display(void* phy_fb, unsigned int display_width, unsigned int disp
|
||||
}
|
||||
}
|
||||
|
||||
c_surface* c_display::alloc_surface(void* usr, Z_ORDER_LEVEL max_zorder)
|
||||
c_surface* c_display::alloc_surface(Z_ORDER_LEVEL max_zorder)
|
||||
{
|
||||
int i = 0;
|
||||
ASSERT(max_zorder < Z_ORDER_LEVEL_MAX);
|
||||
|
||||
while (i < m_surface_cnt)
|
||||
if(max_zorder >= Z_ORDER_LEVEL_MAX || m_surface_index >= m_surface_cnt);
|
||||
{
|
||||
if (m_surface_group[i]->m_usr == usr)
|
||||
{
|
||||
//repeat register
|
||||
ASSERT(false);
|
||||
return m_surface_group[i];
|
||||
}
|
||||
i++;
|
||||
ASSERT(false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
while (i < m_surface_cnt)
|
||||
{
|
||||
if (m_surface_group[i]->m_usr == 0)
|
||||
{
|
||||
m_surface_group[i]->set_surface(usr, max_zorder);
|
||||
return m_surface_group[i];
|
||||
}
|
||||
i++;
|
||||
}
|
||||
//no surface for use
|
||||
ASSERT(false);
|
||||
return 0;
|
||||
int i = m_surface_index++;
|
||||
m_surface_group[i]->set_surface(max_zorder);
|
||||
return m_surface_group[i];
|
||||
}
|
||||
|
||||
int c_display::merge_surface(c_surface* s0, c_surface* s1, int x0, int x1, int y0, int y1, int offset)
|
||||
|
||||
@@ -18,15 +18,14 @@ c_surface::c_surface(c_display* display, unsigned int width, unsigned int heigh
|
||||
m_display = display;
|
||||
m_phy_fb = display->m_phy_fb;
|
||||
m_phy_write_index = &display->m_phy_write_index;
|
||||
m_fb = m_usr = 0;
|
||||
m_fb = 0;
|
||||
m_top_zorder = m_max_zorder = Z_ORDER_LEVEL_0;
|
||||
m_is_active = false;
|
||||
m_frame_layers[Z_ORDER_LEVEL_0].visible_rect = c_rect(0, 0, m_width, m_height);
|
||||
}
|
||||
|
||||
void c_surface::set_surface(void* wnd_root, Z_ORDER_LEVEL max_z_order)
|
||||
void c_surface::set_surface(Z_ORDER_LEVEL max_z_order)
|
||||
{
|
||||
m_usr = wnd_root;
|
||||
m_max_zorder = max_z_order;
|
||||
|
||||
if (m_display->m_surface_cnt > 1)
|
||||
|
||||
@@ -12,7 +12,7 @@ public:
|
||||
c_display(void* phy_fb, unsigned int display_width, unsigned int display_height,
|
||||
unsigned int surface_width, unsigned int surface_height,
|
||||
unsigned int color_bytes, unsigned int surface_cnt, EXTERNAL_GFX_OP* gfx_op = 0);
|
||||
c_surface* alloc_surface(void* usr, Z_ORDER_LEVEL max_zorder);
|
||||
c_surface* alloc_surface(Z_ORDER_LEVEL max_zorder);
|
||||
int merge_surface(c_surface* s1, c_surface* s2, int x0, int x1, int y0, int y2, int offset);
|
||||
unsigned int get_width() { return m_width; }
|
||||
unsigned int get_height() { return m_height; }
|
||||
@@ -28,5 +28,6 @@ private:
|
||||
int m_phy_write_index;
|
||||
c_surface* m_surface_group[SURFACE_CNT_MAX];
|
||||
unsigned int m_surface_cnt;
|
||||
unsigned int m_surface_index;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -57,14 +57,13 @@ public:
|
||||
protected:
|
||||
virtual void fill_rect_on_fb(int x0, int y0, int x1, int y1, unsigned int rgb);
|
||||
virtual void draw_pixel_on_fb(int x, int y, unsigned int rgb);
|
||||
void set_surface(void* wnd_root, Z_ORDER_LEVEL max_z_order);
|
||||
void set_surface(Z_ORDER_LEVEL max_z_order);
|
||||
c_surface(c_display* display, unsigned int width, unsigned int height, unsigned int color_bytes);
|
||||
int m_width; //in pixels
|
||||
int m_height; //in pixels
|
||||
int m_color_bytes; //16 bits, 32 bits only
|
||||
void* m_fb; //Top frame buffer you could see
|
||||
c_frame_layer m_frame_layers[Z_ORDER_LEVEL_MAX];//Top layber fb always be 0
|
||||
void* m_usr;
|
||||
bool m_is_active;
|
||||
Z_ORDER_LEVEL m_max_zorder;
|
||||
Z_ORDER_LEVEL m_top_zorder;
|
||||
|
||||
@@ -63,7 +63,7 @@ int c_slide_group::add_slide(c_wnd* slide, unsigned short resource_id, short x,
|
||||
}
|
||||
|
||||
c_surface* old_surface = get_surface();
|
||||
c_surface* new_surface = old_surface->get_display()->alloc_surface(slide,max_zorder);
|
||||
c_surface* new_surface = old_surface->get_display()->alloc_surface(max_zorder);
|
||||
new_surface->set_active(false);
|
||||
set_surface(new_surface);
|
||||
slide->connect(this, resource_id ,0 , x, y, width, height, p_child_tree);
|
||||
@@ -107,7 +107,7 @@ int c_slide_group::add_clone_silde(c_wnd* slide, unsigned short resource_id, sho
|
||||
}
|
||||
|
||||
c_surface* old_surface = get_surface();
|
||||
c_surface* new_surface = old_surface->get_display()->alloc_surface(slide,max_zorder);
|
||||
c_surface* new_surface = old_surface->get_display()->alloc_surface(max_zorder);
|
||||
new_surface->set_active(false);
|
||||
set_surface(new_surface);
|
||||
c_wnd* page_tmp = slide->connect_clone(this,resource_id,0,x,y,width,height,p_child_tree);
|
||||
|
||||
Reference in New Issue
Block a user