rename overlapped_zone to layer
This commit is contained in:
parent
7a6e5d071f
commit
24db5c6c7e
76
GuiLite.h
76
GuiLite.h
|
@ -391,7 +391,7 @@ class c_display {
|
||||||
public:
|
public:
|
||||||
inline c_display(void* phy_fb, int display_width, int display_height, int surface_width, int surface_height, unsigned int color_bytes, int surface_cnt, EXTERNAL_GFX_OP* gfx_op = 0);//multiple surface or surface_no_fb
|
inline c_display(void* phy_fb, int display_width, int display_height, int surface_width, int surface_height, unsigned int color_bytes, int surface_cnt, EXTERNAL_GFX_OP* gfx_op = 0);//multiple surface or surface_no_fb
|
||||||
inline c_display(void* phy_fb, int display_width, int display_height, c_surface* surface);//single custom surface
|
inline c_display(void* phy_fb, int display_width, int display_height, c_surface* surface);//single custom surface
|
||||||
inline c_surface* alloc_surface(Z_ORDER_LEVEL max_zorder, c_rect overlap_rect = c_rect(0, 0, -1, -1));//for multiple surfaces
|
inline c_surface* alloc_surface(Z_ORDER_LEVEL max_zorder, c_rect layer_rect = c_rect(0, 0, -1, -1));//for multiple surfaces
|
||||||
inline int swipe_surface(c_surface* s0, c_surface* s1, int x0, int x1, int y0, int y1, int offset);
|
inline int swipe_surface(c_surface* s0, c_surface* s1, int x0, int x1, int y0, int y1, int offset);
|
||||||
int get_width() { return m_width; }
|
int get_width() { return m_width; }
|
||||||
int get_height() { return m_height; }
|
int get_height() { return m_height; }
|
||||||
|
@ -449,10 +449,10 @@ private:
|
||||||
int m_surface_cnt;
|
int m_surface_cnt;
|
||||||
int m_surface_index;
|
int m_surface_index;
|
||||||
};
|
};
|
||||||
class c_overlap_zone
|
class c_layer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
c_overlap_zone() { fb = 0; }
|
c_layer() { fb = 0; }
|
||||||
void* fb;
|
void* fb;
|
||||||
c_rect rect;
|
c_rect rect;
|
||||||
};
|
};
|
||||||
|
@ -472,9 +472,9 @@ public:
|
||||||
ASSERT(false);
|
ASSERT(false);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (m_overlap_zones[z_order].fb)
|
if (m_layers[z_order].fb)
|
||||||
{
|
{
|
||||||
return (m_color_bytes == 4) ? ((unsigned int*)(m_overlap_zones[z_order].fb))[y * m_width + x] : GL_RGB_16_to_32(((unsigned short*)(m_overlap_zones[z_order].fb))[y * m_width + x]);
|
return (m_color_bytes == 4) ? ((unsigned int*)(m_layers[z_order].fb))[y * m_width + x] : GL_RGB_16_to_32(((unsigned short*)(m_layers[z_order].fb))[y * m_width + x]);
|
||||||
}
|
}
|
||||||
else if (m_fb)
|
else if (m_fb)
|
||||||
{
|
{
|
||||||
|
@ -506,16 +506,16 @@ public:
|
||||||
{
|
{
|
||||||
m_top_zorder = (Z_ORDER_LEVEL)z_order;
|
m_top_zorder = (Z_ORDER_LEVEL)z_order;
|
||||||
}
|
}
|
||||||
if (m_overlap_zones[z_order].rect.PtInRect(x, y))
|
if (m_layers[z_order].rect.PtInRect(x, y))
|
||||||
{
|
{
|
||||||
c_rect overlap_rect = m_overlap_zones[z_order].rect;
|
c_rect layer_rect = m_layers[z_order].rect;
|
||||||
if (m_color_bytes == 4)
|
if (m_color_bytes == 4)
|
||||||
{
|
{
|
||||||
((unsigned int*)(m_overlap_zones[z_order].fb))[(x - overlap_rect.m_left) + (y - overlap_rect.m_top) * overlap_rect.Width()] = rgb;
|
((unsigned int*)(m_layers[z_order].fb))[(x - layer_rect.m_left) + (y - layer_rect.m_top) * layer_rect.Width()] = rgb;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
((unsigned short*)(m_overlap_zones[z_order].fb))[(x - overlap_rect.m_left) + (y - overlap_rect.m_top) * overlap_rect.Width()] = GL_RGB_32_to_16(rgb);
|
((unsigned short*)(m_layers[z_order].fb))[(x - layer_rect.m_left) + (y - layer_rect.m_top) * layer_rect.Width()] = GL_RGB_32_to_16(rgb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -526,7 +526,7 @@ public:
|
||||||
bool be_overlapped = false;
|
bool be_overlapped = false;
|
||||||
for (unsigned int tmp_z_order = Z_ORDER_LEVEL_MAX - 1; tmp_z_order > z_order; tmp_z_order--)
|
for (unsigned int tmp_z_order = Z_ORDER_LEVEL_MAX - 1; tmp_z_order > z_order; tmp_z_order--)
|
||||||
{
|
{
|
||||||
if (m_overlap_zones[tmp_z_order].rect.PtInRect(x, y))
|
if (m_layers[tmp_z_order].rect.PtInRect(x, y))
|
||||||
{
|
{
|
||||||
be_overlapped = true;
|
be_overlapped = true;
|
||||||
break;
|
break;
|
||||||
|
@ -550,21 +550,21 @@ public:
|
||||||
if (z_order == m_top_zorder)
|
if (z_order == m_top_zorder)
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
c_rect overlap_rect = m_overlap_zones[z_order].rect;
|
c_rect layer_rect = m_layers[z_order].rect;
|
||||||
unsigned int rgb_16 = GL_RGB_32_to_16(rgb);
|
unsigned int rgb_16 = GL_RGB_32_to_16(rgb);
|
||||||
for (y = y0; y <= y1; y++)
|
for (y = y0; y <= y1; y++)
|
||||||
{
|
{
|
||||||
for (x = x0; x <= x1; x++)
|
for (x = x0; x <= x1; x++)
|
||||||
{
|
{
|
||||||
if (overlap_rect.PtInRect(x, y))
|
if (layer_rect.PtInRect(x, y))
|
||||||
{
|
{
|
||||||
if (m_color_bytes == 4)
|
if (m_color_bytes == 4)
|
||||||
{
|
{
|
||||||
((unsigned int*)m_overlap_zones[z_order].fb)[(y - overlap_rect.m_top) * overlap_rect.Width() + (x - overlap_rect.m_left)] = rgb;
|
((unsigned int*)m_layers[z_order].fb)[(y - layer_rect.m_top) * layer_rect.Width() + (x - layer_rect.m_left)] = rgb;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
((unsigned short*)m_overlap_zones[z_order].fb)[(y - overlap_rect.m_top) * overlap_rect.Width() + (x - overlap_rect.m_left)] = rgb_16;
|
((unsigned short*)m_layers[z_order].fb)[(y - layer_rect.m_top) * layer_rect.Width() + (x - layer_rect.m_left)] = rgb_16;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -667,19 +667,19 @@ public:
|
||||||
}
|
}
|
||||||
bool is_active() { return m_is_active; }
|
bool is_active() { return m_is_active; }
|
||||||
c_display* get_display() { return m_display; }
|
c_display* get_display() { return m_display; }
|
||||||
int show_overlapped_rect(c_rect& rect, unsigned int z_order)
|
int show_layer(c_rect& rect, unsigned int z_order)
|
||||||
{
|
{
|
||||||
ASSERT(z_order >= Z_ORDER_LEVEL_0 && z_order < Z_ORDER_LEVEL_MAX);
|
ASSERT(z_order >= Z_ORDER_LEVEL_0 && z_order < Z_ORDER_LEVEL_MAX);
|
||||||
c_rect overlap_rect = m_overlap_zones[z_order].rect;
|
c_rect layer_rect = m_layers[z_order].rect;
|
||||||
ASSERT(rect.m_left >= overlap_rect.m_left && rect.m_right <= overlap_rect.m_right &&
|
ASSERT(rect.m_left >= layer_rect.m_left && rect.m_right <= layer_rect.m_right &&
|
||||||
rect.m_top >= overlap_rect.m_top && rect.m_bottom <= overlap_rect.m_bottom);
|
rect.m_top >= layer_rect.m_top && rect.m_bottom <= layer_rect.m_bottom);
|
||||||
void* fb = m_overlap_zones[z_order].fb;
|
void* fb = m_layers[z_order].fb;
|
||||||
int width = overlap_rect.Width();
|
int width = layer_rect.Width();
|
||||||
for (int y = rect.m_top; y <= rect.m_bottom; y++)
|
for (int y = rect.m_top; y <= rect.m_bottom; y++)
|
||||||
{
|
{
|
||||||
for (int x = rect.m_left; x <= rect.m_right; x++)
|
for (int x = rect.m_left; x <= rect.m_right; x++)
|
||||||
{
|
{
|
||||||
unsigned int rgb = (m_color_bytes == 4) ? ((unsigned int*)fb)[(x - overlap_rect.m_left) + (y - overlap_rect.m_top) * width] : GL_RGB_16_to_32(((unsigned short*)fb)[(x - overlap_rect.m_left) + (y - overlap_rect.m_top) * width]);
|
unsigned int rgb = (m_color_bytes == 4) ? ((unsigned int*)fb)[(x - layer_rect.m_left) + (y - layer_rect.m_top) * width] : GL_RGB_16_to_32(((unsigned short*)fb)[(x - layer_rect.m_left) + (y - layer_rect.m_top) * width]);
|
||||||
draw_pixel_on_fb(x, y, rgb);
|
draw_pixel_on_fb(x, y, rgb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -765,7 +765,7 @@ protected:
|
||||||
m_phy_fb = display->m_phy_fb;
|
m_phy_fb = display->m_phy_fb;
|
||||||
m_phy_write_index = &display->m_phy_write_index;
|
m_phy_write_index = &display->m_phy_write_index;
|
||||||
}
|
}
|
||||||
void set_surface(Z_ORDER_LEVEL max_z_order, c_rect overlap_rect)
|
void set_surface(Z_ORDER_LEVEL max_z_order, c_rect layer_rect)
|
||||||
{
|
{
|
||||||
m_max_zorder = max_z_order;
|
m_max_zorder = max_z_order;
|
||||||
if (m_display && (m_display->m_surface_cnt > 1))
|
if (m_display && (m_display->m_surface_cnt > 1))
|
||||||
|
@ -774,15 +774,15 @@ protected:
|
||||||
}
|
}
|
||||||
for (int i = Z_ORDER_LEVEL_0; i < m_max_zorder; i++)
|
for (int i = Z_ORDER_LEVEL_0; i < m_max_zorder; i++)
|
||||||
{//Top layber fb always be 0
|
{//Top layber fb always be 0
|
||||||
ASSERT(m_overlap_zones[i].fb = calloc(overlap_rect.Width() * overlap_rect.Height(), m_color_bytes));
|
ASSERT(m_layers[i].fb = calloc(layer_rect.Width() * layer_rect.Height(), m_color_bytes));
|
||||||
m_overlap_zones[i].rect = overlap_rect;
|
m_layers[i].rect = layer_rect;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int m_width; //in pixels
|
int m_width; //in pixels
|
||||||
int m_height; //in pixels
|
int m_height; //in pixels
|
||||||
int m_color_bytes; //16 bits, 32 bits only
|
int m_color_bytes; //16 bits, 32 bits only
|
||||||
void* m_fb; //frame buffer you could see
|
void* m_fb; //frame buffer you could see
|
||||||
c_overlap_zone m_overlap_zones[Z_ORDER_LEVEL_MAX];//Top layber fb always be 0
|
c_layer m_layers[Z_ORDER_LEVEL_MAX];//Top layber fb always be 0
|
||||||
bool m_is_active;
|
bool m_is_active;
|
||||||
Z_ORDER_LEVEL m_max_zorder;
|
Z_ORDER_LEVEL m_max_zorder;
|
||||||
Z_ORDER_LEVEL m_top_zorder;
|
Z_ORDER_LEVEL m_top_zorder;
|
||||||
|
@ -878,10 +878,10 @@ inline c_display::c_display(void* phy_fb, int display_width, int display_height,
|
||||||
surface->m_is_active = true;
|
surface->m_is_active = true;
|
||||||
(m_surface_group[0] = surface)->attach_display(this);
|
(m_surface_group[0] = surface)->attach_display(this);
|
||||||
}
|
}
|
||||||
inline c_surface* c_display::alloc_surface(Z_ORDER_LEVEL max_zorder, c_rect overlap_rect)
|
inline c_surface* c_display::alloc_surface(Z_ORDER_LEVEL max_zorder, c_rect layer_rect)
|
||||||
{
|
{
|
||||||
ASSERT(max_zorder < Z_ORDER_LEVEL_MAX && m_surface_index < m_surface_cnt);
|
ASSERT(max_zorder < Z_ORDER_LEVEL_MAX && m_surface_index < m_surface_cnt);
|
||||||
(overlap_rect == c_rect(0, 0, -1, -1)) ? m_surface_group[m_surface_index]->set_surface(max_zorder, c_rect(0, 0, m_width - 1, m_height - 1)) : m_surface_group[m_surface_index]->set_surface(max_zorder, overlap_rect);
|
(layer_rect == c_rect(0, 0, -1, -1)) ? m_surface_group[m_surface_index]->set_surface(max_zorder, c_rect(0, 0, m_width - 1, m_height - 1)) : m_surface_group[m_surface_index]->set_surface(max_zorder, layer_rect);
|
||||||
return m_surface_group[m_surface_index++];
|
return m_surface_group[m_surface_index++];
|
||||||
}
|
}
|
||||||
inline int c_display::swipe_surface(c_surface* s0, c_surface* s1, int x0, int x1, int y0, int y1, int offset)
|
inline int c_display::swipe_surface(c_surface* s0, c_surface* s1, int x0, int x1, int y0, int y1, int offset)
|
||||||
|
@ -1249,9 +1249,9 @@ public:
|
||||||
c_rect lower_fb_rect;
|
c_rect lower_fb_rect;
|
||||||
if (z_order >= Z_ORDER_LEVEL_1)
|
if (z_order >= Z_ORDER_LEVEL_1)
|
||||||
{
|
{
|
||||||
lower_fb_16 = (unsigned short*)surface->m_overlap_zones[z_order - 1].fb;
|
lower_fb_16 = (unsigned short*)surface->m_layers[z_order - 1].fb;
|
||||||
lower_fb_32 = (unsigned int*)surface->m_overlap_zones[z_order - 1].fb;
|
lower_fb_32 = (unsigned int*)surface->m_layers[z_order - 1].fb;
|
||||||
lower_fb_rect = surface->m_overlap_zones[z_order - 1].rect;
|
lower_fb_rect = surface->m_layers[z_order - 1].rect;
|
||||||
lower_fb_width = lower_fb_rect.Width();
|
lower_fb_width = lower_fb_rect.Width();
|
||||||
}
|
}
|
||||||
unsigned int mask_rgb_16 = GL_RGB_32_to_16(mask_rgb);
|
unsigned int mask_rgb_16 = GL_RGB_32_to_16(mask_rgb);
|
||||||
|
@ -1290,9 +1290,9 @@ public:
|
||||||
c_rect lower_fb_rect;
|
c_rect lower_fb_rect;
|
||||||
if (z_order >= Z_ORDER_LEVEL_1)
|
if (z_order >= Z_ORDER_LEVEL_1)
|
||||||
{
|
{
|
||||||
lower_fb_16 = (unsigned short*)surface->m_overlap_zones[z_order - 1].fb;
|
lower_fb_16 = (unsigned short*)surface->m_layers[z_order - 1].fb;
|
||||||
lower_fb_32 = (unsigned int*)surface->m_overlap_zones[z_order - 1].fb;
|
lower_fb_32 = (unsigned int*)surface->m_layers[z_order - 1].fb;
|
||||||
lower_fb_rect = surface->m_overlap_zones[z_order - 1].rect;
|
lower_fb_rect = surface->m_layers[z_order - 1].rect;
|
||||||
lower_fb_width = lower_fb_rect.Width();
|
lower_fb_width = lower_fb_rect.Width();
|
||||||
}
|
}
|
||||||
unsigned int mask_rgb_16 = GL_RGB_32_to_16(mask_rgb);
|
unsigned int mask_rgb_16 = GL_RGB_32_to_16(mask_rgb);
|
||||||
|
@ -1940,7 +1940,7 @@ public:
|
||||||
c_rect rc;
|
c_rect rc;
|
||||||
dlg->get_screen_rect(rc);
|
dlg->get_screen_rect(rc);
|
||||||
dlg->set_attr(WND_ATTRIBUTION(0));
|
dlg->set_attr(WND_ATTRIBUTION(0));
|
||||||
surface->show_overlapped_rect(rc, dlg->m_z_order - 1);
|
surface->show_layer(rc, dlg->m_z_order - 1);
|
||||||
//clear the dialog
|
//clear the dialog
|
||||||
for (int i = 0; i < SURFACE_CNT_MAX; i++)
|
for (int i = 0; i < SURFACE_CNT_MAX; i++)
|
||||||
{
|
{
|
||||||
|
@ -2267,7 +2267,7 @@ protected:
|
||||||
{
|
{
|
||||||
s_keyboard.disconnect();
|
s_keyboard.disconnect();
|
||||||
m_z_order = m_parent->get_z_order();
|
m_z_order = m_parent->get_z_order();
|
||||||
m_surface->show_overlapped_rect(kb_rect, m_z_order);
|
m_surface->show_layer(kb_rect, m_z_order);
|
||||||
m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS);
|
m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS);
|
||||||
}
|
}
|
||||||
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_NORMAL), m_z_order);
|
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_NORMAL), m_z_order);
|
||||||
|
@ -2278,7 +2278,7 @@ protected:
|
||||||
{
|
{
|
||||||
s_keyboard.disconnect();
|
s_keyboard.disconnect();
|
||||||
m_z_order = m_parent->get_z_order();
|
m_z_order = m_parent->get_z_order();
|
||||||
m_surface->show_overlapped_rect(kb_rect, m_z_order);
|
m_surface->show_layer(kb_rect, m_z_order);
|
||||||
m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS);
|
m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS);
|
||||||
}
|
}
|
||||||
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_FOCUS), m_z_order);
|
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_FOCUS), m_z_order);
|
||||||
|
@ -2495,7 +2495,7 @@ protected:
|
||||||
if (m_z_order > m_parent->get_z_order())
|
if (m_z_order > m_parent->get_z_order())
|
||||||
{
|
{
|
||||||
m_z_order = m_parent->get_z_order();
|
m_z_order = m_parent->get_z_order();
|
||||||
m_surface->show_overlapped_rect(m_list_screen_rect, m_z_order);
|
m_surface->show_layer(m_list_screen_rect, m_z_order);
|
||||||
m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS);
|
m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS);
|
||||||
}
|
}
|
||||||
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_NORMAL), m_z_order);
|
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_NORMAL), m_z_order);
|
||||||
|
@ -2505,7 +2505,7 @@ protected:
|
||||||
if (m_z_order > m_parent->get_z_order())
|
if (m_z_order > m_parent->get_z_order())
|
||||||
{
|
{
|
||||||
m_z_order = m_parent->get_z_order();
|
m_z_order = m_parent->get_z_order();
|
||||||
m_surface->show_overlapped_rect(m_list_screen_rect, m_z_order);
|
m_surface->show_layer(m_list_screen_rect, m_z_order);
|
||||||
m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS);
|
m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS);
|
||||||
}
|
}
|
||||||
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_FOCUS), m_z_order);
|
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_FOCUS), m_z_order);
|
||||||
|
|
|
@ -20,9 +20,9 @@ public:
|
||||||
c_rect lower_fb_rect;
|
c_rect lower_fb_rect;
|
||||||
if (z_order >= Z_ORDER_LEVEL_1)
|
if (z_order >= Z_ORDER_LEVEL_1)
|
||||||
{
|
{
|
||||||
lower_fb_16 = (unsigned short*)surface->m_overlap_zones[z_order - 1].fb;
|
lower_fb_16 = (unsigned short*)surface->m_layers[z_order - 1].fb;
|
||||||
lower_fb_32 = (unsigned int*)surface->m_overlap_zones[z_order - 1].fb;
|
lower_fb_32 = (unsigned int*)surface->m_layers[z_order - 1].fb;
|
||||||
lower_fb_rect = surface->m_overlap_zones[z_order - 1].rect;
|
lower_fb_rect = surface->m_layers[z_order - 1].rect;
|
||||||
lower_fb_width = lower_fb_rect.Width();
|
lower_fb_width = lower_fb_rect.Width();
|
||||||
}
|
}
|
||||||
unsigned int mask_rgb_16 = GL_RGB_32_to_16(mask_rgb);
|
unsigned int mask_rgb_16 = GL_RGB_32_to_16(mask_rgb);
|
||||||
|
@ -63,9 +63,9 @@ public:
|
||||||
c_rect lower_fb_rect;
|
c_rect lower_fb_rect;
|
||||||
if (z_order >= Z_ORDER_LEVEL_1)
|
if (z_order >= Z_ORDER_LEVEL_1)
|
||||||
{
|
{
|
||||||
lower_fb_16 = (unsigned short*)surface->m_overlap_zones[z_order - 1].fb;
|
lower_fb_16 = (unsigned short*)surface->m_layers[z_order - 1].fb;
|
||||||
lower_fb_32 = (unsigned int*)surface->m_overlap_zones[z_order - 1].fb;
|
lower_fb_32 = (unsigned int*)surface->m_layers[z_order - 1].fb;
|
||||||
lower_fb_rect = surface->m_overlap_zones[z_order - 1].rect;
|
lower_fb_rect = surface->m_layers[z_order - 1].rect;
|
||||||
lower_fb_width = lower_fb_rect.Width();
|
lower_fb_width = lower_fb_rect.Width();
|
||||||
}
|
}
|
||||||
unsigned int mask_rgb_16 = GL_RGB_32_to_16(mask_rgb);
|
unsigned int mask_rgb_16 = GL_RGB_32_to_16(mask_rgb);
|
||||||
|
|
|
@ -30,7 +30,7 @@ class c_display {
|
||||||
public:
|
public:
|
||||||
inline c_display(void* phy_fb, int display_width, int display_height, int surface_width, int surface_height, unsigned int color_bytes, int surface_cnt, EXTERNAL_GFX_OP* gfx_op = 0);//multiple surface or surface_no_fb
|
inline c_display(void* phy_fb, int display_width, int display_height, int surface_width, int surface_height, unsigned int color_bytes, int surface_cnt, EXTERNAL_GFX_OP* gfx_op = 0);//multiple surface or surface_no_fb
|
||||||
inline c_display(void* phy_fb, int display_width, int display_height, c_surface* surface);//single custom surface
|
inline c_display(void* phy_fb, int display_width, int display_height, c_surface* surface);//single custom surface
|
||||||
inline c_surface* alloc_surface(Z_ORDER_LEVEL max_zorder, c_rect overlap_rect = c_rect(0, 0, -1, -1));//for multiple surfaces
|
inline c_surface* alloc_surface(Z_ORDER_LEVEL max_zorder, c_rect layer_rect = c_rect(0, 0, -1, -1));//for multiple surfaces
|
||||||
inline int swipe_surface(c_surface* s0, c_surface* s1, int x0, int x1, int y0, int y1, int offset);
|
inline int swipe_surface(c_surface* s0, c_surface* s1, int x0, int x1, int y0, int y1, int offset);
|
||||||
int get_width() { return m_width; }
|
int get_width() { return m_width; }
|
||||||
int get_height() { return m_height; }
|
int get_height() { return m_height; }
|
||||||
|
@ -97,10 +97,10 @@ private:
|
||||||
int m_surface_index;
|
int m_surface_index;
|
||||||
};
|
};
|
||||||
|
|
||||||
class c_overlap_zone
|
class c_layer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
c_overlap_zone() { fb = 0; }
|
c_layer() { fb = 0; }
|
||||||
void* fb;
|
void* fb;
|
||||||
c_rect rect;
|
c_rect rect;
|
||||||
};
|
};
|
||||||
|
@ -123,9 +123,9 @@ public:
|
||||||
ASSERT(false);
|
ASSERT(false);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (m_overlap_zones[z_order].fb)
|
if (m_layers[z_order].fb)
|
||||||
{
|
{
|
||||||
return (m_color_bytes == 4) ? ((unsigned int*)(m_overlap_zones[z_order].fb))[y * m_width + x] : GL_RGB_16_to_32(((unsigned short*)(m_overlap_zones[z_order].fb))[y * m_width + x]);
|
return (m_color_bytes == 4) ? ((unsigned int*)(m_layers[z_order].fb))[y * m_width + x] : GL_RGB_16_to_32(((unsigned short*)(m_layers[z_order].fb))[y * m_width + x]);
|
||||||
}
|
}
|
||||||
else if (m_fb)
|
else if (m_fb)
|
||||||
{
|
{
|
||||||
|
@ -160,16 +160,16 @@ public:
|
||||||
m_top_zorder = (Z_ORDER_LEVEL)z_order;
|
m_top_zorder = (Z_ORDER_LEVEL)z_order;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_overlap_zones[z_order].rect.PtInRect(x, y))
|
if (m_layers[z_order].rect.PtInRect(x, y))
|
||||||
{
|
{
|
||||||
c_rect overlap_rect = m_overlap_zones[z_order].rect;
|
c_rect layer_rect = m_layers[z_order].rect;
|
||||||
if (m_color_bytes == 4)
|
if (m_color_bytes == 4)
|
||||||
{
|
{
|
||||||
((unsigned int*)(m_overlap_zones[z_order].fb))[(x - overlap_rect.m_left) + (y - overlap_rect.m_top) * overlap_rect.Width()] = rgb;
|
((unsigned int*)(m_layers[z_order].fb))[(x - layer_rect.m_left) + (y - layer_rect.m_top) * layer_rect.Width()] = rgb;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
((unsigned short*)(m_overlap_zones[z_order].fb))[(x - overlap_rect.m_left) + (y - overlap_rect.m_top) * overlap_rect.Width()] = GL_RGB_32_to_16(rgb);
|
((unsigned short*)(m_layers[z_order].fb))[(x - layer_rect.m_left) + (y - layer_rect.m_top) * layer_rect.Width()] = GL_RGB_32_to_16(rgb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@ public:
|
||||||
bool be_overlapped = false;
|
bool be_overlapped = false;
|
||||||
for (unsigned int tmp_z_order = Z_ORDER_LEVEL_MAX - 1; tmp_z_order > z_order; tmp_z_order--)
|
for (unsigned int tmp_z_order = Z_ORDER_LEVEL_MAX - 1; tmp_z_order > z_order; tmp_z_order--)
|
||||||
{
|
{
|
||||||
if (m_overlap_zones[tmp_z_order].rect.PtInRect(x, y))
|
if (m_layers[tmp_z_order].rect.PtInRect(x, y))
|
||||||
{
|
{
|
||||||
be_overlapped = true;
|
be_overlapped = true;
|
||||||
break;
|
break;
|
||||||
|
@ -209,21 +209,21 @@ public:
|
||||||
if (z_order == m_top_zorder)
|
if (z_order == m_top_zorder)
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
c_rect overlap_rect = m_overlap_zones[z_order].rect;
|
c_rect layer_rect = m_layers[z_order].rect;
|
||||||
unsigned int rgb_16 = GL_RGB_32_to_16(rgb);
|
unsigned int rgb_16 = GL_RGB_32_to_16(rgb);
|
||||||
for (y = y0; y <= y1; y++)
|
for (y = y0; y <= y1; y++)
|
||||||
{
|
{
|
||||||
for (x = x0; x <= x1; x++)
|
for (x = x0; x <= x1; x++)
|
||||||
{
|
{
|
||||||
if (overlap_rect.PtInRect(x, y))
|
if (layer_rect.PtInRect(x, y))
|
||||||
{
|
{
|
||||||
if (m_color_bytes == 4)
|
if (m_color_bytes == 4)
|
||||||
{
|
{
|
||||||
((unsigned int*)m_overlap_zones[z_order].fb)[(y - overlap_rect.m_top) * overlap_rect.Width() + (x - overlap_rect.m_left)] = rgb;
|
((unsigned int*)m_layers[z_order].fb)[(y - layer_rect.m_top) * layer_rect.Width() + (x - layer_rect.m_left)] = rgb;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
((unsigned short*)m_overlap_zones[z_order].fb)[(y - overlap_rect.m_top) * overlap_rect.Width() + (x - overlap_rect.m_left)] = rgb_16;
|
((unsigned short*)m_layers[z_order].fb)[(y - layer_rect.m_top) * layer_rect.Width() + (x - layer_rect.m_left)] = rgb_16;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -343,21 +343,21 @@ public:
|
||||||
bool is_active() { return m_is_active; }
|
bool is_active() { return m_is_active; }
|
||||||
c_display* get_display() { return m_display; }
|
c_display* get_display() { return m_display; }
|
||||||
|
|
||||||
int show_overlapped_rect(c_rect& rect, unsigned int z_order)
|
int show_layer(c_rect& rect, unsigned int z_order)
|
||||||
{
|
{
|
||||||
ASSERT(z_order >= Z_ORDER_LEVEL_0 && z_order < Z_ORDER_LEVEL_MAX);
|
ASSERT(z_order >= Z_ORDER_LEVEL_0 && z_order < Z_ORDER_LEVEL_MAX);
|
||||||
|
|
||||||
c_rect overlap_rect = m_overlap_zones[z_order].rect;
|
c_rect layer_rect = m_layers[z_order].rect;
|
||||||
ASSERT(rect.m_left >= overlap_rect.m_left && rect.m_right <= overlap_rect.m_right &&
|
ASSERT(rect.m_left >= layer_rect.m_left && rect.m_right <= layer_rect.m_right &&
|
||||||
rect.m_top >= overlap_rect.m_top && rect.m_bottom <= overlap_rect.m_bottom);
|
rect.m_top >= layer_rect.m_top && rect.m_bottom <= layer_rect.m_bottom);
|
||||||
|
|
||||||
void* fb = m_overlap_zones[z_order].fb;
|
void* fb = m_layers[z_order].fb;
|
||||||
int width = overlap_rect.Width();
|
int width = layer_rect.Width();
|
||||||
for (int y = rect.m_top; y <= rect.m_bottom; y++)
|
for (int y = rect.m_top; y <= rect.m_bottom; y++)
|
||||||
{
|
{
|
||||||
for (int x = rect.m_left; x <= rect.m_right; x++)
|
for (int x = rect.m_left; x <= rect.m_right; x++)
|
||||||
{
|
{
|
||||||
unsigned int rgb = (m_color_bytes == 4) ? ((unsigned int*)fb)[(x - overlap_rect.m_left) + (y - overlap_rect.m_top) * width] : GL_RGB_16_to_32(((unsigned short*)fb)[(x - overlap_rect.m_left) + (y - overlap_rect.m_top) * width]);
|
unsigned int rgb = (m_color_bytes == 4) ? ((unsigned int*)fb)[(x - layer_rect.m_left) + (y - layer_rect.m_top) * width] : GL_RGB_16_to_32(((unsigned short*)fb)[(x - layer_rect.m_left) + (y - layer_rect.m_top) * width]);
|
||||||
draw_pixel_on_fb(x, y, rgb);
|
draw_pixel_on_fb(x, y, rgb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -448,7 +448,7 @@ protected:
|
||||||
m_phy_write_index = &display->m_phy_write_index;
|
m_phy_write_index = &display->m_phy_write_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_surface(Z_ORDER_LEVEL max_z_order, c_rect overlap_rect)
|
void set_surface(Z_ORDER_LEVEL max_z_order, c_rect layer_rect)
|
||||||
{
|
{
|
||||||
m_max_zorder = max_z_order;
|
m_max_zorder = max_z_order;
|
||||||
if (m_display && (m_display->m_surface_cnt > 1))
|
if (m_display && (m_display->m_surface_cnt > 1))
|
||||||
|
@ -458,8 +458,8 @@ protected:
|
||||||
|
|
||||||
for (int i = Z_ORDER_LEVEL_0; i < m_max_zorder; i++)
|
for (int i = Z_ORDER_LEVEL_0; i < m_max_zorder; i++)
|
||||||
{//Top layber fb always be 0
|
{//Top layber fb always be 0
|
||||||
ASSERT(m_overlap_zones[i].fb = calloc(overlap_rect.Width() * overlap_rect.Height(), m_color_bytes));
|
ASSERT(m_layers[i].fb = calloc(layer_rect.Width() * layer_rect.Height(), m_color_bytes));
|
||||||
m_overlap_zones[i].rect = overlap_rect;
|
m_layers[i].rect = layer_rect;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -467,7 +467,7 @@ protected:
|
||||||
int m_height; //in pixels
|
int m_height; //in pixels
|
||||||
int m_color_bytes; //16 bits, 32 bits only
|
int m_color_bytes; //16 bits, 32 bits only
|
||||||
void* m_fb; //frame buffer you could see
|
void* m_fb; //frame buffer you could see
|
||||||
c_overlap_zone m_overlap_zones[Z_ORDER_LEVEL_MAX];//Top layber fb always be 0
|
c_layer m_layers[Z_ORDER_LEVEL_MAX];//Top layber fb always be 0
|
||||||
bool m_is_active;
|
bool m_is_active;
|
||||||
Z_ORDER_LEVEL m_max_zorder;
|
Z_ORDER_LEVEL m_max_zorder;
|
||||||
Z_ORDER_LEVEL m_top_zorder;
|
Z_ORDER_LEVEL m_top_zorder;
|
||||||
|
@ -571,10 +571,10 @@ inline c_display::c_display(void* phy_fb, int display_width, int display_height,
|
||||||
(m_surface_group[0] = surface)->attach_display(this);
|
(m_surface_group[0] = surface)->attach_display(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline c_surface* c_display::alloc_surface(Z_ORDER_LEVEL max_zorder, c_rect overlap_rect)
|
inline c_surface* c_display::alloc_surface(Z_ORDER_LEVEL max_zorder, c_rect layer_rect)
|
||||||
{
|
{
|
||||||
ASSERT(max_zorder < Z_ORDER_LEVEL_MAX && m_surface_index < m_surface_cnt);
|
ASSERT(max_zorder < Z_ORDER_LEVEL_MAX && m_surface_index < m_surface_cnt);
|
||||||
(overlap_rect == c_rect(0, 0, -1, -1)) ? m_surface_group[m_surface_index]->set_surface(max_zorder, c_rect(0, 0, m_width - 1, m_height - 1)) : m_surface_group[m_surface_index]->set_surface(max_zorder, overlap_rect);
|
(layer_rect == c_rect(0, 0, -1, -1)) ? m_surface_group[m_surface_index]->set_surface(max_zorder, c_rect(0, 0, m_width - 1, m_height - 1)) : m_surface_group[m_surface_index]->set_surface(max_zorder, layer_rect);
|
||||||
return m_surface_group[m_surface_index++];
|
return m_surface_group[m_surface_index++];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ public:
|
||||||
c_rect rc;
|
c_rect rc;
|
||||||
dlg->get_screen_rect(rc);
|
dlg->get_screen_rect(rc);
|
||||||
dlg->set_attr(WND_ATTRIBUTION(0));
|
dlg->set_attr(WND_ATTRIBUTION(0));
|
||||||
surface->show_overlapped_rect(rc, dlg->m_z_order - 1);
|
surface->show_layer(rc, dlg->m_z_order - 1);
|
||||||
|
|
||||||
//clear the dialog
|
//clear the dialog
|
||||||
for (int i = 0; i < SURFACE_CNT_MAX; i++)
|
for (int i = 0; i < SURFACE_CNT_MAX; i++)
|
||||||
|
|
|
@ -54,7 +54,7 @@ protected:
|
||||||
{
|
{
|
||||||
s_keyboard.disconnect();
|
s_keyboard.disconnect();
|
||||||
m_z_order = m_parent->get_z_order();
|
m_z_order = m_parent->get_z_order();
|
||||||
m_surface->show_overlapped_rect(kb_rect, m_z_order);
|
m_surface->show_layer(kb_rect, m_z_order);
|
||||||
m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS);
|
m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS);
|
||||||
}
|
}
|
||||||
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_NORMAL), m_z_order);
|
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_NORMAL), m_z_order);
|
||||||
|
@ -65,7 +65,7 @@ protected:
|
||||||
{
|
{
|
||||||
s_keyboard.disconnect();
|
s_keyboard.disconnect();
|
||||||
m_z_order = m_parent->get_z_order();
|
m_z_order = m_parent->get_z_order();
|
||||||
m_surface->show_overlapped_rect(kb_rect, m_z_order);
|
m_surface->show_layer(kb_rect, m_z_order);
|
||||||
m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS);
|
m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS);
|
||||||
}
|
}
|
||||||
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_FOCUS), m_z_order);
|
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_FOCUS), m_z_order);
|
||||||
|
|
|
@ -71,7 +71,7 @@ protected:
|
||||||
if (m_z_order > m_parent->get_z_order())
|
if (m_z_order > m_parent->get_z_order())
|
||||||
{
|
{
|
||||||
m_z_order = m_parent->get_z_order();
|
m_z_order = m_parent->get_z_order();
|
||||||
m_surface->show_overlapped_rect(m_list_screen_rect, m_z_order);
|
m_surface->show_layer(m_list_screen_rect, m_z_order);
|
||||||
m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS);
|
m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS);
|
||||||
}
|
}
|
||||||
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_NORMAL), m_z_order);
|
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_NORMAL), m_z_order);
|
||||||
|
@ -81,7 +81,7 @@ protected:
|
||||||
if (m_z_order > m_parent->get_z_order())
|
if (m_z_order > m_parent->get_z_order())
|
||||||
{
|
{
|
||||||
m_z_order = m_parent->get_z_order();
|
m_z_order = m_parent->get_z_order();
|
||||||
m_surface->show_overlapped_rect(m_list_screen_rect, m_z_order);
|
m_surface->show_layer(m_list_screen_rect, m_z_order);
|
||||||
m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS);
|
m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS);
|
||||||
}
|
}
|
||||||
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_FOCUS), m_z_order);
|
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_FOCUS), m_z_order);
|
||||||
|
|
Loading…
Reference in New Issue