sync up with github

This commit is contained in:
idea4good
2018-11-01 10:35:37 +08:00
parent 65d735e984
commit 532a8a8069
23 changed files with 177 additions and 180 deletions

View File

@@ -15,13 +15,15 @@ void do_assert(const char* file, int line);
void log_out(const char* log);
#define COLOR_TRANPARENT 0xFF000000
#define GLT_RGB(r, g, b) ((0xFF << 24) | (((unsigned int)(r)) << 16) | (((unsigned int)(g)) << 8) | ((unsigned int)(b)))
#define GLT_RGB_R(rgb) ((((unsigned int)(rgb)) >> 16) & 0xFF)
#define GLT_RGB_G(rgb) ((((unsigned int)(rgb)) >> 8) & 0xFF)
#define GLT_RGB_B(rgb) (((unsigned int)(rgb)) & 0xFF)
#define GLT_RGB_32_to_16(rgb) (((((unsigned int)(rgb)) & 0xFF) >> 3) | ((((unsigned int)(rgb)) & 0xFC00) >> 5) | ((((unsigned int)(rgb)) & 0xF80000) >> 8))
#define GLT_RGB_16_to_32(rgb) (((((unsigned int)(rgb)) & 0x1F) << 3) | ((((unsigned int)(rgb)) & 0x7E0) << 5) | ((((unsigned int)(rgb)) & 0xF800) << 8))
#define GL_ARGB(a, r, g, b) ((((unsigned int)(a)) << 24) | (((unsigned int)(r)) << 16) | (((unsigned int)(g)) << 8) | ((unsigned int)(b)))
#define GL_ARGB_A(rgb) ((((unsigned int)(rgb)) >> 24) & 0xFF)
#define GL_RGB(r, g, b) ((0xFF << 24) | (((unsigned int)(r)) << 16) | (((unsigned int)(g)) << 8) | ((unsigned int)(b)))
#define GL_RGB_R(rgb) ((((unsigned int)(rgb)) >> 16) & 0xFF)
#define GL_RGB_G(rgb) ((((unsigned int)(rgb)) >> 8) & 0xFF)
#define GL_RGB_B(rgb) (((unsigned int)(rgb)) & 0xFF)
#define GL_RGB_32_to_16(rgb) (((((unsigned int)(rgb)) & 0xFF) >> 3) | ((((unsigned int)(rgb)) & 0xFC00) >> 5) | ((((unsigned int)(rgb)) & 0xF80000) >> 8))
#define GL_RGB_16_to_32(rgb) (((((unsigned int)(rgb)) & 0x1F) << 3) | ((((unsigned int)(rgb)) & 0x7E0) << 5) | ((((unsigned int)(rgb)) & 0xF800) << 8))
typedef struct _T_TIME
{

View File

@@ -28,7 +28,7 @@ typedef struct struct_font_info
//SHAPE
#define INVALID_RGN 0xFFFFFF
#define COLOR_USERDEF GLT_RGB(41,49,49)
#define COLOR_USERDEF GL_RGB(41,49,49)
typedef struct struct_color_rect
{
int l;

View File

@@ -21,10 +21,10 @@ class c_display;
class c_surface {
friend class c_display;
public:
virtual void set_pixel(int x, int y, unsigned int rgb, unsigned int z_order);
virtual unsigned int get_pixel(int x, int y, unsigned int z_order);
virtual void draw_pixel(int x, int y, unsigned int rgb, unsigned int z_order);
virtual void fill_rect(int x0, int y0, int x1, int y1, unsigned int rgb, unsigned int z_order);
void fill_rect_ex(int l, int t, int r, int b, unsigned int color, const COLOR_RECT* extend_rects, int z_order);
virtual unsigned int get_pixel(int x, int y, unsigned int z_order);
int get_width() { return m_width; }
int get_height() { return m_height; }
@@ -41,8 +41,8 @@ public:
int set_frame_layer(c_rect& rect, unsigned int z_order);
void set_active(bool flag){m_is_active = flag;}
protected:
virtual void set_pixel_on_fb(int x, int y, unsigned int rgb);
virtual void fill_rect_on_fb(int x0, int y0, int x1, int y1, unsigned int rgb);
virtual void set_pixel(int x, int y, unsigned int rgb);
void set_surface(void* wnd_root, Z_ORDER_LEVEL max_z_order);
int copy_layer_pixel_2_fb(int x, int y, unsigned int z_order);
@@ -64,10 +64,11 @@ class c_surface_16bits : public c_surface {
friend class c_display;
c_surface_16bits(c_display* display, void* phy_fb, unsigned int width, unsigned int height, unsigned int color_bytes) :
c_surface(display, phy_fb, width, height, color_bytes) {};
virtual void set_pixel(int x, int y, unsigned int rgb, unsigned int z_order);
virtual void set_pixel_on_fb(int x, int y, unsigned int rgb);
virtual void draw_pixel(int x, int y, unsigned int rgb, unsigned int z_order);
virtual void fill_rect(int x0, int y0, int x1, int y1, unsigned int rgb, unsigned int z_order);
virtual void fill_rect_on_fb(int x0, int y0, int x1, int y1, unsigned int rgb);
virtual unsigned int get_pixel(int x, int y, unsigned int z_order);
protected:
virtual void set_pixel(int x, int y, unsigned int rgb);
};
#endif

View File

@@ -47,8 +47,8 @@ public:
protected:
void draw_smooth_vline(int y_min, int y_max, int mid, unsigned int rgb);
void erase_oldest_vline();
void save_foreground();
void restore_background();
void save_background();
char* m_wave_name;
char* m_wave_unit;
@@ -74,7 +74,7 @@ protected:
private:
c_wave_buffer* m_wave;
void* m_bg_fb; //background frame buffer, could be used to draw scale line.
unsigned int* m_bg_fb; //background frame buffer, could be used to draw scale line.
int m_wave_cursor;
int m_wave_speed; //pixels per refresh
int m_wave_sample_rate;

View File

@@ -121,7 +121,7 @@ protected:
virtual void on_focus();
virtual void on_kill_focus();
void set_pixel(int x, int y, unsigned int rgb);
void draw_pixel(int x, int y, unsigned int rgb);
void draw_hline(int x0, int x1, int y, unsigned int rgb);
void draw_vline(int x, int y0, int y1, unsigned int rgb);
void draw_line(int x0, int y0, int x1, int y1, unsigned int rgb);

View File

@@ -96,7 +96,7 @@ void c_bitmap::draw_bitmap_565(c_surface* surface, int z_order, int x, int y, in
for (int i = 0; i < xsize; i++)
{
unsigned int rgb = *p++;
surface->set_pixel(x + i, y + j, GLT_RGB_16_to_32(rgb), z_order);
surface->draw_pixel(x + i, y + j, GL_RGB_16_to_32(rgb), z_order);
}
pData += BytesPerLine;
}
@@ -120,7 +120,7 @@ void c_bitmap::draw_bitmap_565_inrect(c_surface* surface, int z_order, int x, in
}
unsigned int rgb = *p++;
surface->set_pixel(x + i, y + j, GLT_RGB_16_to_32(rgb), z_order);
surface->draw_pixel(x + i, y + j, GL_RGB_16_to_32(rgb), z_order);
}
pData += BytesPerLine;
}

View File

@@ -169,7 +169,7 @@ int c_display::snap_shot(unsigned int display_id)
for (int i = 0; i < width * height; i++)
{
unsigned int rgb = *p_raw_data++;
p_bmp565_data[i] = GLT_RGB_32_to_16(rgb);
p_bmp565_data[i] = GL_RGB_32_to_16(rgb);
}
int ret = build_bmp(path, width, height, (unsigned char*)p_bmp565_data);

View File

@@ -34,7 +34,7 @@ void c_surface::set_surface(void* wnd_root, Z_ORDER_LEVEL max_z_order)
}
}
void c_surface::set_pixel(int x, int y, unsigned int rgb, unsigned int z_order)
void c_surface::draw_pixel(int x, int y, unsigned int rgb, unsigned int z_order)
{
if (x >= m_width || y >= m_height || x < 0 || y < 0)
{
@@ -59,14 +59,14 @@ void c_surface::set_pixel(int x, int y, unsigned int rgb, unsigned int z_order)
if (z_order == m_max_zorder)
{
return set_pixel_on_fb(x, y, rgb);
return set_pixel(x, y, rgb);
}
((unsigned int*)(m_frame_layers[z_order].fb))[x + y * m_width] = rgb;
if (z_order == m_top_zorder)
{
return set_pixel_on_fb(x, y, rgb);
return set_pixel(x, y, rgb);
}
bool is_covered = false;
@@ -81,11 +81,11 @@ void c_surface::set_pixel(int x, int y, unsigned int rgb, unsigned int z_order)
if (!is_covered)
{
set_pixel_on_fb(x, y, rgb);
set_pixel(x, y, rgb);
}
}
void c_surface::set_pixel_on_fb(int x, int y, unsigned int rgb)
void c_surface::set_pixel(int x, int y, unsigned int rgb)
{
((unsigned int*)m_fb)[y * m_width + x] = rgb;
@@ -180,7 +180,7 @@ void c_surface::draw_hline(int x0, int x1, int y, unsigned int rgb, unsigned int
for (;x0 <= x1; x0++)
{
set_pixel(x0, y, rgb, z_order);
draw_pixel(x0, y, rgb, z_order);
}
}
@@ -193,7 +193,7 @@ void c_surface::draw_vline(int x, int y0, int y1, unsigned int rgb, unsigned int
for (;y0 <= y1; y0++)
{
set_pixel(x, y0, rgb, z_order);
draw_pixel(x, y0, rgb, z_order);
}
}
@@ -210,7 +210,7 @@ void c_surface::draw_line(int x1, int y1, int x2, int y2, unsigned int rgb, unsi
e = dy - dx / 2;
for(; x1 <= x2; x1++, e += dy)
{
set_pixel(x1, y1, rgb, z_order);
draw_pixel(x1, y1, rgb, z_order);
if (e>0) { y1++; e -= dx; }
}
}
@@ -219,7 +219,7 @@ void c_surface::draw_line(int x1, int y1, int x2, int y2, unsigned int rgb, unsi
e = dx - dy / 2;
for(; y1 <= y2; y1++, e += dx)
{
set_pixel(x1, y1, rgb, z_order);
draw_pixel(x1, y1, rgb, z_order);
if (e>0) { x1++; e -= dy; }
}
}
@@ -233,7 +233,7 @@ void c_surface::draw_line(int x1, int y1, int x2, int y2, unsigned int rgb, unsi
e = dy - dx / 2;
for(; x1 <= x2; x1++, e += dy)
{
set_pixel(x1, y1, rgb, z_order);
draw_pixel(x1, y1, rgb, z_order);
if (e>0) { y1--; e -= dx; }
}
}
@@ -242,7 +242,7 @@ void c_surface::draw_line(int x1, int y1, int x2, int y2, unsigned int rgb, unsi
e = dx - dy / 2;
for(; y1 >= y2; y1--, e += dx)
{
set_pixel(x1, y1, rgb, z_order);
draw_pixel(x1, y1, rgb, z_order);
if (e>0) { x1++; e -= dy; }
}
}
@@ -256,7 +256,7 @@ void c_surface::draw_line(int x1, int y1, int x2, int y2, unsigned int rgb, unsi
e = dy - dx / 2;
for(; x1 >= x2; x1--, e += dy)
{
set_pixel(x1, y1, rgb, z_order);
draw_pixel(x1, y1, rgb, z_order);
if (e>0) { y1++; e -= dx; }
}
}
@@ -265,7 +265,7 @@ void c_surface::draw_line(int x1, int y1, int x2, int y2, unsigned int rgb, unsi
e = dx - dy / 2;
for(; y1 <= y2; y1++, e += dx)
{
set_pixel(x1, y1, rgb, z_order);
draw_pixel(x1, y1, rgb, z_order);
if (e>0) { x1--; e -= dy; }
}
}
@@ -280,7 +280,7 @@ void c_surface::draw_line(int x1, int y1, int x2, int y2, unsigned int rgb, unsi
e = dy - dx / 2;
for(; x1 >= x2; x1--, e += dy)
{
set_pixel(x1, y1, rgb, z_order);
draw_pixel(x1, y1, rgb, z_order);
if (e>0) { y1--; e -= dx; }
}
}
@@ -290,7 +290,7 @@ void c_surface::draw_line(int x1, int y1, int x2, int y2, unsigned int rgb, unsi
while (y1-- >= y2)
for(; y1 >= y2; y1--, e += dx)
{
set_pixel(x1, y1, rgb, z_order);
draw_pixel(x1, y1, rgb, z_order);
if (e>0) { x1--; e -= dy; }
}
}
@@ -402,7 +402,7 @@ void c_surface::fill_rect_ex(int l, int t, int r, int b, unsigned int color, con
{
for(int x = templ; x <= tempr; x++)
{
set_pixel(x , y, tempcolor, z_order);
draw_pixel(x , y, tempcolor, z_order);
}
}
}
@@ -453,7 +453,7 @@ bool c_surface::is_valid(c_rect rect)
}
//////////////////////////////////////////////////////////////////////////////////////
void c_surface_16bits::set_pixel(int x, int y, unsigned int rgb, unsigned int z_order)
void c_surface_16bits::draw_pixel(int x, int y, unsigned int rgb, unsigned int z_order)
{
if (x >= m_width || y >= m_height || x < 0 || y < 0)
{
@@ -476,17 +476,17 @@ void c_surface_16bits::set_pixel(int x, int y, unsigned int rgb, unsigned int z_
return;
}
rgb = GLT_RGB_32_to_16(rgb);
rgb = GL_RGB_32_to_16(rgb);
if (z_order == m_max_zorder)
{
return set_pixel_on_fb(x, y, rgb);
return set_pixel(x, y, rgb);
}
((unsigned short*)(m_frame_layers[z_order].fb))[x + y * m_width] = rgb;
if (z_order == m_top_zorder)
{
return set_pixel_on_fb(x, y, rgb);
return set_pixel(x, y, rgb);
}
bool is_covered = false;
@@ -501,11 +501,11 @@ void c_surface_16bits::set_pixel(int x, int y, unsigned int rgb, unsigned int z_
if (!is_covered)
{
set_pixel_on_fb(x, y, rgb);
set_pixel(x, y, rgb);
}
}
void c_surface_16bits::set_pixel_on_fb(int x, int y, unsigned int rgb)
void c_surface_16bits::set_pixel(int x, int y, unsigned int rgb)
{
((unsigned short*)m_fb)[y * m_width + x] = rgb;
@@ -519,10 +519,9 @@ void c_surface_16bits::set_pixel_on_fb(int x, int y, unsigned int rgb)
void c_surface_16bits::fill_rect(int x0, int y0, int x1, int y1, unsigned int rgb, unsigned int z_order)
{
rgb = GLT_RGB_32_to_16(rgb);
if (z_order == m_max_zorder)
{
return fill_rect_on_fb(x0, y0, x1, y1, rgb);
return fill_rect_on_fb(x0, y0, x1, y1, GL_RGB_32_to_16(rgb));
}
if (z_order == m_top_zorder)
{
@@ -537,7 +536,7 @@ void c_surface_16bits::fill_rect(int x0, int y0, int x1, int y1, unsigned int rg
*mem_fb++ = rgb;
}
}
return fill_rect_on_fb(x0, y0, x1, y1, rgb);
return fill_rect_on_fb(x0, y0, x1, y1, GL_RGB_32_to_16(rgb));
}
for (; y0 <= y1; y0++)
@@ -585,8 +584,8 @@ unsigned int c_surface_16bits::get_pixel(int x, int y, unsigned int z_order)
if (z_order == m_max_zorder)
{
return GLT_RGB_16_to_32(((unsigned short*)m_fb)[y * m_width + x]);
return GL_RGB_16_to_32(((unsigned short*)m_fb)[y * m_width + x]);
}
return GLT_RGB_16_to_32(((unsigned short*)(m_frame_layers[z_order].fb))[y * m_width + x]);
return GL_RGB_16_to_32(((unsigned short*)(m_frame_layers[z_order].fb))[y * m_width + x]);
}

View File

@@ -33,8 +33,8 @@ c_wave_ctrl::c_wave_ctrl()
m_gain = ZOOM_100;
m_frame_len_map_index = 0;
m_wave_name_color = m_wave_unit_color = m_wave_color = GLT_RGB(255,0,0);
m_back_color = GLT_RGB(0,0,0);
m_wave_name_color = m_wave_unit_color = m_wave_color = GL_RGB(255,0,0);
m_back_color = GL_RGB(0,0,0);
}
void c_wave_ctrl::on_init_children()
@@ -48,7 +48,7 @@ void c_wave_ctrl::on_init_children()
m_wave_bottom = rect.m_bottom - 4;
m_wave_cursor = m_wave_left;
m_bg_fb = calloc(rect.Width() * rect.Height(), 2);
m_bg_fb = (unsigned int*)calloc(rect.Width() * rect.Height(), 4);
}
void c_wave_ctrl::set_max_min_base(short max_data, short min_data, short data_base)
@@ -173,7 +173,7 @@ void c_wave_ctrl::refresh_wave(unsigned char frame)
CORRECT(mid, m_wave_bottom, m_wave_top);
draw_smooth_vline(y_min, y_max, mid, m_wave_color);
erase_oldest_vline();
restore_background();
//ring the wave
if ((m_wave_cursor + 1) > m_wave_right)
{
@@ -189,13 +189,13 @@ void c_wave_ctrl::refresh_wave(unsigned char frame)
void c_wave_ctrl::draw_smooth_vline(int y_min, int y_max, int mid, unsigned int rgb)
{
int dy = y_max - y_min;
short r = GLT_RGB_R(rgb);
short g = GLT_RGB_G(rgb);
short b = GLT_RGB_B(rgb);
short r = GL_RGB_R(rgb);
short g = GL_RGB_G(rgb);
short b = GL_RGB_B(rgb);
int index = dy / 2 + 2;
int y;
set_pixel(m_wave_cursor, mid, rgb);
draw_pixel(m_wave_cursor, mid, rgb);
if (dy < 1)
{
@@ -212,8 +212,8 @@ void c_wave_ctrl::draw_smooth_vline(int y_min, int y_max, int mid, unsigned int
cur_r = r*(index - i)/index;
cur_g = g*(index - i)/index;
cur_b = b*(index - i)/index;
cur_rgb = GLT_RGB(cur_r, cur_g, cur_b);
set_pixel(m_wave_cursor, y, cur_rgb);
cur_rgb = GL_RGB(cur_r, cur_g, cur_b);
draw_pixel(m_wave_cursor, y, cur_rgb);
}
if ( (mid - i) >= y_min )
{
@@ -221,8 +221,8 @@ void c_wave_ctrl::draw_smooth_vline(int y_min, int y_max, int mid, unsigned int
cur_r = r*(index - i)/index;
cur_g = g*(index - i)/index;
cur_b = b*(index - i)/index;
cur_rgb = GLT_RGB(cur_r, cur_g, cur_b);
set_pixel(m_wave_cursor, y, cur_rgb);
cur_rgb = GL_RGB(cur_r, cur_g, cur_b);
draw_pixel(m_wave_cursor, y, cur_rgb);
}
}
}
@@ -235,11 +235,11 @@ void c_wave_ctrl::on_paint()
fill_rect(rect.m_left, rect.m_top, rect.m_right, rect.m_bottom, m_back_color);
//show name
c_word::draw_string(m_surface, m_z_order, m_wave_name, m_wave_left + 10, rect.m_top, m_wave_name_font_type, m_wave_name_color, COLOR_TRANPARENT, ALIGN_LEFT);
c_word::draw_string(m_surface, m_z_order, m_wave_name, m_wave_left + 10, rect.m_top, m_wave_name_font_type, m_wave_name_color, GL_ARGB(0, 0, 0, 0), ALIGN_LEFT);
//show unit
c_word::draw_string(m_surface, m_z_order, m_wave_unit, m_wave_left + 60, rect.m_top, m_wave_unit_font_type, m_wave_unit_color, COLOR_TRANPARENT, ALIGN_LEFT);
c_word::draw_string(m_surface, m_z_order, m_wave_unit, m_wave_left + 60, rect.m_top, m_wave_unit_font_type, m_wave_unit_color, GL_ARGB(0, 0, 0, 0), ALIGN_LEFT);
save_foreground();
save_background();
}
void c_wave_ctrl::clear_wave(void)
@@ -252,9 +252,8 @@ void c_wave_ctrl::clear_wave(void)
m_wave_cursor = m_wave_left;
}
void c_wave_ctrl::erase_oldest_vline()
void c_wave_ctrl::restore_background()
{
//earse oldest vline = draw background on foreground.
int x = m_wave_cursor + WAVE_CURSOR_WIDTH;
if (x > m_wave_right)
{
@@ -266,20 +265,20 @@ void c_wave_ctrl::erase_oldest_vline()
register int width = rect.Width();
register int top = rect.m_top;
register int left = rect.m_left;
unsigned short* p_fb = (unsigned short*)m_bg_fb;
unsigned int* p_fb = m_bg_fb;
for (int y_pos = (m_wave_top - 1); y_pos <= (m_wave_bottom + 1); y_pos++)
{
set_pixel(x, y_pos, p_fb[(y_pos - top) * width + (x - left)]);
draw_pixel(x, y_pos, p_fb[(y_pos - top) * width + (x - left)]);
}
}
void c_wave_ctrl::save_foreground()
void c_wave_ctrl::save_background()
{
c_rect rect;
get_screen_rect(rect);
//copy foreground to background
register unsigned short* p_des = (unsigned short*)m_bg_fb;
register unsigned int* p_des = m_bg_fb;
for (int y = rect.m_top; y <= rect.m_bottom; y++)
{
for (int x = rect.m_left; x <= rect.m_right; x++)

View File

@@ -745,9 +745,9 @@ void c_wnd::notify_parent(unsigned short msg_id, unsigned int w_param, long l_pa
}
}
void c_wnd::set_pixel(int x, int y, unsigned int rgb)
void c_wnd::draw_pixel(int x, int y, unsigned int rgb)
{
m_surface->set_pixel(x, y, rgb, m_z_order);
m_surface->draw_pixel(x, y, rgb, m_z_order);
}
void c_wnd::draw_hline(int x0, int x1, int y, unsigned int rgb)

View File

@@ -9,21 +9,21 @@
#define BUFFER_LEN 16
unsigned char s_utf8_length_table[256] =
{
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 1, 1
};
@@ -92,18 +92,18 @@ void c_word::draw_string(c_surface* surface, int z_order, const char *s, int x,
ASSERT(FALSE);
}
int offset = 0;
unsigned int utf8_code;
while (*s)
{
int offset = 0;
unsigned int utf8_code;
while (*s)
{
if (*s == '\n')
{
y += font->height;
offset = 0;
continue;
}
s += get_utf8_code(s, utf8_code);
offset += draw_single_char(surface, z_order, utf8_code, (x + offset), y, font, font_color, bg_color);
}
s += get_utf8_code(s, utf8_code);
offset += draw_single_char(surface, z_order, utf8_code, (x + offset), y, font, font_color, bg_color);
}
}
@@ -137,24 +137,24 @@ void c_word::value_2_string(int value, int dot_position, char* buf, int len)
const LATTICE* c_word::get_lattice(const FONT_INFO* font, unsigned int utf8_code)
{
int first = 0;
int last = font->count - 1;
int middle = (first + last) / 2;
while (first <= last)
{
if (font->lattice_array[middle].utf8_code < utf8_code)
first = middle + 1;
else if (font->lattice_array[middle].utf8_code == utf8_code)
{
return &font->lattice_array[middle];
}
else
{
last = middle - 1;
}
middle = (first + last) / 2;
}
int first = 0;
int last = font->count - 1;
int middle = (first + last) / 2;
while (first <= last)
{
if (font->lattice_array[middle].utf8_code < utf8_code)
first = middle + 1;
else if (font->lattice_array[middle].utf8_code == utf8_code)
{
return &font->lattice_array[middle];
}
else
{
last = middle - 1;
}
middle = (first + last) / 2;
}
return NULL;
}
@@ -178,8 +178,8 @@ int c_word::draw_single_char(c_surface* surface, int z_order, unsigned int utf8_
{
for (int x_ = 0; x_ < len; x_++)
{
((y_ % 4) == 0) ? surface->set_pixel((x + x_), (y + y_), 0, z_order) :
surface->set_pixel((x + x_), (y + y_), 0xFFFFFFFF, z_order);
((y_ % 4) == 0) ? surface->draw_pixel((x + x_), (y + y_), 0, z_order) :
surface->draw_pixel((x + x_), (y + y_), 0xFFFFFFFF, z_order);
}
}
return len;
@@ -189,7 +189,6 @@ void c_word::draw_lattice(c_surface* surface, int z_order, int x, int y, int wid
const unsigned char* p_data, unsigned int font_color, unsigned int bg_color)
{
unsigned int r, g, b;
unsigned int bg_color_set = (COLOR_TRANPARENT == bg_color) ? surface->get_pixel(x, y, z_order) : bg_color;
for (int y_ = 0; y_ < height; y_++)
{
@@ -198,17 +197,17 @@ void c_word::draw_lattice(c_surface* surface, int z_order, int x, int y, int wid
unsigned char value = *p_data;
if (0x00 == value)
{
if (bg_color != COLOR_TRANPARENT)
if (GL_ARGB_A(bg_color))
{
surface->set_pixel(x + x_, y + y_, bg_color_set, z_order);
surface->draw_pixel(x + x_, y + y_, bg_color, z_order);
}
}
else
{
b = (GLT_RGB_B(font_color) * value + GLT_RGB_B(bg_color_set) * (255 - value)) >> 8;
g = (GLT_RGB_G(font_color) * value + GLT_RGB_G(bg_color_set) * (255 - value)) >> 8;
r = (GLT_RGB_R(font_color) * value + GLT_RGB_R(bg_color_set) * (255 - value)) >> 8;
surface->set_pixel((x + x_), (y + y_), GLT_RGB(r, g, b), z_order);
b = (GL_RGB_B(font_color) * value + GL_RGB_B(bg_color) * (255 - value)) >> 8;
g = (GL_RGB_G(font_color) * value + GL_RGB_G(bg_color) * (255 - value)) >> 8;
r = (GL_RGB_R(font_color) * value + GL_RGB_R(bg_color) * (255 - value)) >> 8;
surface->draw_pixel((x + x_), (y + y_), GL_RGB(r, g, b), z_order);
}
p_data++;
}
@@ -227,8 +226,8 @@ int c_word::get_str_pixel_length(const char *s, const FONT_INFO* font)
}
int lattice_width = 0;
unsigned int utf8_code;
int utf8_bytes;
unsigned int utf8_code;
int utf8_bytes;
while (*s)
{
utf8_bytes = get_utf8_code(s, utf8_code);