📄 mainlcd.c
字号:
SIMULATOR_SKIN_LCD_X = device->skin_main_lcd_x;
SIMULATOR_SKIN_LCD_Y = device->skin_main_lcd_y;
#ifdef __MMI_SUBLCD__
SIMULATOR_SKIN_SUB_LCD_X = device->skin_sub_lcd_x;
SIMULATOR_SKIN_SUB_LCD_Y = device->skin_sub_lcd_y;
#endif /* __MMI_SUBLCD__ */
/* adjust the diplaying position for LCD if the skin is bigger than real one */
if (LCD_WIDTH < device->main_lcd_width)
{
SIMULATOR_SKIN_LCD_X = SIMULATOR_SKIN_LCD_X + (device->main_lcd_width - LCD_WIDTH) / 2;
device->skin_main_lcd_x = SIMULATOR_SKIN_LCD_X;
}
if (LCD_HEIGHT < device->main_lcd_height)
{
SIMULATOR_SKIN_LCD_Y = SIMULATOR_SKIN_LCD_Y + (device->main_lcd_height - LCD_HEIGHT) / 2;
device->skin_main_lcd_y = SIMULATOR_SKIN_LCD_Y;
}
#ifdef __MMI_SUBLCD__
/* adjust the diplaying position for sub-LCD if the skin is bigger than real one */
if (SUBLCD_WIDTH < device->sub_lcd_width)
{
SIMULATOR_SKIN_SUB_LCD_X = SIMULATOR_SKIN_SUB_LCD_X + (device->sub_lcd_width - SUBLCD_WIDTH) / 2;
device->skin_sub_lcd_x = SIMULATOR_SKIN_SUB_LCD_X;
}
if (SUBLCD_HEIGHT < device->sub_lcd_height)
{
SIMULATOR_SKIN_SUB_LCD_Y = SIMULATOR_SKIN_SUB_LCD_Y + (device->sub_lcd_height - SUBLCD_HEIGHT) / 2;
device->skin_sub_lcd_y = SIMULATOR_SKIN_SUB_LCD_Y;
}
#endif /* __MMI_SUBLCD__ */
/* set up the bitmap infomation */
bitmap_info.bmiHeader.biSize = sizeof(bitmap_info.bmiHeader);
bitmap_info.bmiHeader.biWidth = LCD_WIDTH;
bitmap_info.bmiHeader.biHeight = LCD_HEIGHT;
bitmap_info.bmiHeader.biPlanes = 1;
bitmap_info.bmiHeader.biBitCount = 32;
bitmap_info.bmiHeader.biCompression = BI_RGB;
bitmap_info.bmiHeader.biSizeImage = LCD_WIDTH * LCD_HEIGHT * 4;
bitmap_info.bmiHeader.biClrUsed = 0;
bitmap_info.bmiHeader.biClrImportant = 0;
#ifdef __MMI_SUBLCD__
/* set up the sub-bitmap infomation */
sub_bitmap_info.bmiHeader.biSize = sizeof(sub_bitmap_info.bmiHeader);
sub_bitmap_info.bmiHeader.biWidth = SUBLCD_WIDTH;
sub_bitmap_info.bmiHeader.biHeight = SUBLCD_HEIGHT;
sub_bitmap_info.bmiHeader.biPlanes = 1;
sub_bitmap_info.bmiHeader.biBitCount = 32;
sub_bitmap_info.bmiHeader.biCompression = BI_RGB;
sub_bitmap_info.bmiHeader.biSizeImage = SUBLCD_WIDTH * SUBLCD_HEIGHT * 4;
sub_bitmap_info.bmiHeader.biClrUsed = 0;
sub_bitmap_info.bmiHeader.biClrImportant = 0;
#endif /* __MMI_SUBLCD__ */
/* draw to simulator's main LCD region */
hdc = GetDC(hWnd);
hdcMem = CreateCompatibleDC(hdc);
hbmp = CreateCompatibleBitmap(hdc, LCD_WIDTH, LCD_HEIGHT);
SelectObject(hdcMem, hbmp);
#ifdef __MMI_SUBLCD__
/* draw to simulator's sub LCD region */
hdc = GetDC(hWnd);
sub_hdcMem = CreateCompatibleDC(hdc);
sub_hbmp = CreateCompatibleBitmap(hdc, SUBLCD_WIDTH, SUBLCD_HEIGHT);
SelectObject(sub_hdcMem, sub_hbmp);
#endif /* __MMI_SUBLCD__ */
} /* end of lcd_dspl_init */
/*****************************************************************************
* FUNCTION
* set_global_window_handle
* DESCRIPTION
* set global the window handle
* PARAMETERS
* hwnd [IN] The input window handle
* RETURNS
* void
*****************************************************************************/
void set_global_window_handle(HWND hwnd)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
hWnd = hwnd;
} /* end of set_global_window_handle */
/*****************************************************************************
* FUNCTION
* lcd_screen_init
* DESCRIPTION
* screen initialization
* PARAMETERS
* hWnd [IN]
* hInstance [IN]
* RETURNS
* void
*****************************************************************************/
void lcd_screen_init(HWND hWnd, HINSTANCE hInstance)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
device = GetDeviceData();
device->hwnd = hWnd;
set_global_window_handle(hWnd);
lcd_dspl_init();
} /* end of lcd_screen_init */
/*****************************************************************************
* FUNCTION
* update_screen
* DESCRIPTION
* update the screen
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void update_screen()
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
hdc = GetDC(hWnd);
hdcMem = CreateCompatibleDC(hdc);
hbmp = CreateCompatibleBitmap(hdc, LCD_WIDTH, LCD_HEIGHT);
SelectObject(hdcMem, hbmp);
if (simulator_frame_buffer != NULL)
{
SetDIBits(NULL, hbmp, 0, LCD_HEIGHT, simulator_frame_buffer, &bitmap_info, DIB_RGB_COLORS);
}
BitBlt(
hdc,
SIMULATOR_SKIN_LCD_X,
SIMULATOR_SKIN_LCD_Y,
SIMULATOR_SKIN_LCD_X + LCD_WIDTH,
SIMULATOR_SKIN_LCD_Y + LCD_HEIGHT,
hdcMem,
0,
0,
SRCCOPY);
ReleaseDC(hWnd, hdc);
DeleteDC(hdcMem);
DeleteObject(hbmp);
#ifdef __MMI_SUBLCD__
hdc = GetDC(hWnd);
sub_hdcMem = CreateCompatibleDC(hdc);
sub_hbmp = CreateCompatibleBitmap(hdc, SUBLCD_WIDTH, SUBLCD_HEIGHT);
SelectObject(sub_hdcMem, sub_hbmp);
if (sub_simulator_frame_buffer != NULL)
{
SetDIBits(NULL, sub_hbmp, 0, SUBLCD_HEIGHT, sub_simulator_frame_buffer, &sub_bitmap_info, DIB_RGB_COLORS);
}
BitBlt(
hdc,
SIMULATOR_SKIN_SUB_LCD_X,
SIMULATOR_SKIN_SUB_LCD_Y,
SIMULATOR_SKIN_SUB_LCD_X + SUBLCD_WIDTH,
SIMULATOR_SKIN_SUB_LCD_Y + SUBLCD_HEIGHT,
sub_hdcMem,
0,
0,
SRCCOPY);
ReleaseDC(hWnd, hdc);
DeleteDC(sub_hdcMem);
DeleteObject(sub_hbmp);
#endif /* __MMI_SUBLCD__ */ /* end of __MMI_SUBLCD__ */
} /* end of update_screen */
/*****************************************************************************
* FUNCTION
* win32_ui_set_layer_data
* DESCRIPTION
* set the flag to indicate that a new application starts
* PARAMETERS
* layer_index [IN] Index for the layer
* lcd_id [IN] Lcd id
* text_clip_left [IN] Text clipping region info
* text_clip_top [IN] Text clipping region info
* text_clip_right [IN] Text clipping region info
* text_clip_bottom [IN] Text clipping region info
* gfx_clip_left [IN] Clipping region info
* gfx_clip_top [IN] Clipping region info
* gfx_clip_right [IN] Clipping region info
* gfx_clip_bottom [IN] Clipping region info
* current_handle [IN] Current lcd handle
* active_handle [IN] Active lcd handle
* RETURNS
* void
*****************************************************************************/
void win32_ui_set_layer_data(
U8 layer_index,
U8 lcd_id,
S32 text_clip_left,
S32 text_clip_top,
S32 text_clip_right,
S32 text_clip_bottom,
S32 gfx_clip_left,
S32 gfx_clip_top,
S32 gfx_clip_right,
S32 gfx_clip_bottom,
S32 current_handle,
S32 active_handle)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (lcd_id == MAIN_LCD)
{
/* UIL := UI Layer */
uil_ptr = MODIS_UI_layer_ptr[layer_index];
uil_ptr->text_clip_left = text_clip_left;
uil_ptr->text_clip_top = text_clip_top;
uil_ptr->text_clip_right = text_clip_right;
uil_ptr->text_clip_bottom = text_clip_bottom;
uil_ptr->gfx_clip_left = gfx_clip_left;
uil_ptr->gfx_clip_top = gfx_clip_top;
uil_ptr->gfx_clip_right = gfx_clip_right;
uil_ptr->gfx_clip_bottom = gfx_clip_bottom;
if (current_handle == active_handle)
{
active_layer = layer_index;
}
}
} /* end of win32_ui_set_layer_data */
/*****************************************************************************
* FUNCTION
* lcd_fb_update
* DESCRIPTION
* void
* PARAMETERS
* lcd_para [IN] Lcd_frame_update_struct
* RETURNS
* void
*****************************************************************************/
void lcd_fb_update(lcd_frame_update_struct *lcd_para)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U16 x, y;
U16 x_layer, y_layer;
U16 origin_pixel;
U16 layer_pixel;
U16 layer_pixel_index; /* used for LUT */
U8 *index_ptr; /* used for LUT, get index value */
U16 *buffer_ptr;
U16 *shadow_ptr;
BOOL source_enable;
BOOL opacity_enable;
BOOL LUT_enable;
U32 r, g, b;
U8 op_value; /* opacity value */
U8 op_value_c; /* opacity value complement */
U32 layer_flag_table[4];
U8 layer_id;
U8 skip;
U32 i, j;
color c;
U16 y1, y2, x1, x2;
S32 roi_width;
S32 roi_height;
U8 lcd_id;
U16 start_x;
U16 start_y;
U16 end_x;
U16 end_y;
U16 roi_offset_x;
U16 roi_offset_y;
DWORD update_layer;
U8 is_first_layer;
lcd_layer_struct *layer_ptr; /* use this ptr to make code shorter */
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (IsLcdFirstInit != FALSE)
{
/* lcd_screen_init(hWnd, 0); */
IsLcdFirstInit = FALSE;
}
lcd_id = lcd_para->lcd_id;
start_x = lcd_para->lcm_start_x;
start_y = lcd_para->lcm_start_y;
end_x = lcd_para->lcm_end_x;
end_y = lcd_para->lcm_end_y;
roi_offset_x = lcd_para->roi_offset_x;
roi_offset_y = lcd_para->roi_offset_y;
update_layer = lcd_para->update_layer;
if (lcd_id == MAIN_LCD)
{
shadow_ptr = (U16*) simulator_shadow_buffer;
}
#ifdef __MMI_SUBLCD__
else if (lcd_id == SUB_LCD)
{
shadow_ptr = (U16*) simulator_sub_shadow_buffer;
}
#endif /* __MMI_SUBLCD__ */
/* create this table, so we can use for loop to prcess each layer */
layer_flag_table[0] = LCD_LAYER0_ENABLE;
layer_flag_table[1] = LCD_LAYER1_ENABLE;
layer_flag_table[2] = LCD_LAYER2_ENABLE;
layer_flag_table[3] = LCD_LAYER3_ENABLE;
roi_width = end_x - start_x;
roi_height = end_y - start_y;
/* copy base layer to shadow buffer directly for faster speed */
/* lcd_layer_data[0].offset_x */
/*
* buffer_ptr = (U16 *)lcd_layer_data[0].frame_buffer_address;
* memcpy(shadow_ptr, buffer_ptr, LCD_WIDTH * LCD_HEIGHT * 2);
*/
is_first_layer = 1;
for (layer_id = 0; layer_id < SIMULATOR_LAYER_COUNT; layer_id++)
{
/* set necessary data for MODIS UI displaying */
/* UIL := UI Layer */
if (lcd_id == MAIN_LCD)
{
uil_ptr = MODIS_UI_layer_ptr[layer_id];
uil_ptr->layer_x_offset = lcd_layer_data[layer_id].x_offset;
uil_ptr->layer_y_offset = lcd_layer_data[layer_id].y_offset;
uil_ptr->layer_width = lcd_layer_data[layer_id].column_number;
uil_ptr->layer_height = lcd_layer_data[layer_id].row_number;
uil_ptr->roi_x_offset = roi_offset_x;
uil_ptr->roi_y_offset = roi_offset_y;
uil_ptr->roi_width = roi_width;
uil_ptr->roi_height = roi_height;
uil_ptr->source_key_enable = lcd_layer_data[layer_id].source_key_enable;
uil_ptr->opacity_enable = lcd_layer_data[layer_id].opacity_enable;
uil_ptr->source_key = lcd_layer_data[layer_id].source_key;
uil_ptr->opacity_value = lcd_layer_data[layer_id].opacity_value;
uil_ptr->layer_enable = (update_layer & layer_flag_table[layer_id]);
uil_ptr->frame_buffer_address = lcd_layer_data[layer_id].frame_buffer_address;
uil_ptr->active_layer = active_layer;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -