⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainlcd.c

📁 MTK手机平台的MMI部分的源代码
💻 C
📖 第 1 页 / 共 4 页
字号:
        }

        /* check if this layer need to merge or not */
        if ((update_layer & layer_flag_table[layer_id]) != 0)
        {

            buffer_ptr = (U16*) lcd_layer_data[layer_id].frame_buffer_address;
            index_ptr = (U8*) lcd_layer_data[layer_id].frame_buffer_address;
            layer_ptr = &lcd_layer_data[layer_id];
            source_enable = layer_ptr->source_key_enable;
            opacity_enable = layer_ptr->opacity_enable;
            LUT_enable = layer_ptr->color_palette_enable;

            /* for each pixel within region */
            for (y = roi_offset_y; y <= roi_offset_y + roi_height; y++)
            {
                for (x = roi_offset_x; x <= roi_offset_x + roi_width; x++)
                {
                    skip = FALSE;
               /***********************************************************/
                    /* test if within region */
                    if ((x >= layer_ptr->x_offset) &&
                        (y >= layer_ptr->y_offset) &&
                        (x <= layer_ptr->x_offset + layer_ptr->column_number - 1) &&
                        (y <= layer_ptr->y_offset + layer_ptr->row_number - 1))
                    {

                        /* transform to layer's local coordinate */
                        x_layer = x - layer_ptr->x_offset;
                        y_layer = y - layer_ptr->y_offset;

                        /* GDI_ASSERT(x - layer_ptr->x_offset>=0); */

                        /* get original's pixel color */
                        if (is_first_layer)
                        {
                        #ifdef GDI_USING_LAYER_BACKGROUND
                            if (lcd_para->roi_background_color == 0)
                            {
                                origin_pixel = 0;
                            }
                            else
                            {
                                origin_pixel = 0xffff;
                            }
                        #else /* GDI_USING_LAYER_BACKGROUND */ 
                            origin_pixel = 0xffff;
                        #endif /* GDI_USING_LAYER_BACKGROUND */ 
                        }
                        else
                        {
                            if (lcd_id == MAIN_LCD)
                            {
                                origin_pixel = BUF_PIXEL_DATA(
                                                shadow_ptr,
                                                x - roi_offset_x + start_x,
                                                y - roi_offset_y + start_y,
                                                LCD_WIDTH);
                            }
                        #ifdef __MMI_SUBLCD__
                            else
                            {
                                origin_pixel = BUF_PIXEL_DATA(
                                                shadow_ptr,
                                                x - roi_offset_x + start_x,
                                                y - roi_offset_y + start_y,
                                                SUBLCD_WIDTH);
                            }
                        #endif /* __MMI_SUBLCD__ */ 
                        }
                        /* get layer's pixel color, check if it use LUT */
                        if (layer_ptr->color_palette_enable == KAL_TRUE)
                        {
                            /* get index, (U8) */
                            layer_pixel_index = BUF_PIXEL_DATA(index_ptr, x_layer, y_layer, layer_ptr->column_number);

                            /* ingore this error currently. just set index = 0 */
                            if ((layer_pixel_index < 0) || (layer_pixel_index > 255))
                            {
                                layer_pixel_index = 0;
                            }

                            /* this might contain error. but ignore. palette must be 0 or 1 */
                            if (layer_ptr->color_palette_select == 0)
                            {
                                layer_pixel = layer_sim_LUT0[layer_pixel_index];
                            }
                            else
                            {
                                layer_pixel = layer_sim_LUT1[layer_pixel_index];
                            }
                        }
                        else
                        {
                            U8 *b1 = GDI_LAYER.act_buf_ptr;
                            S32 b2 = GDI_LAYER.act_pitch;

                            GDI_LAYER.act_buf_ptr = (U8*) layer_ptr->frame_buffer_address;
                            GDI_LAYER.act_pitch = layer_ptr->column_number;

                            if (lcd_id == MAIN_LCD)
                            {
                                DRV_MAINLCD_GET_BUFFER_PIXEL(x_layer, y_layer, layer_pixel);
                            }
                        #ifdef __MMI_SUBLCD__
                            else
                            {
                                DRV_SUBLCD_GET_BUFFER_PIXEL(x_layer, y_layer, layer_pixel);
                            }
                        #endif /* __MMI_SUBLCD__ */ 
                            GDI_LAYER.act_buf_ptr = b1;
                            GDI_LAYER.act_pitch = b2;
                        }

                        /* source key check - tansparency */
                        if (source_enable == KAL_TRUE)
                        {
                            if (layer_ptr->source_key == layer_pixel)
                            {
                                skip = KAL_TRUE;
                            }
                        }

                        /* opacity check */
                        if (skip == FALSE)
                        {
                            if (opacity_enable == KAL_TRUE)
                            {
                                /* calc opacity ratio */
                            #ifdef LCD_MAX_OPACITY
                                op_value = layer_ptr->opacity_value * 255 / LCD_MAX_OPACITY;
                            #else 
                                op_value = layer_ptr->opacity_value << 3;
                            #endif 
                                op_value_c = ~op_value;

                                if (op_value != 0)
                                {
                                    if (lcd_id == MAIN_LCD)
                                    {
                                        r = HW_TO_RGB_R(origin_pixel) * op_value_c +
                                            DRV_HW_TO_RGB_R(layer_pixel) * op_value;
                                        g = HW_TO_RGB_G(origin_pixel) * op_value_c +
                                            DRV_HW_TO_RGB_G(layer_pixel) * op_value;
                                        b = HW_TO_RGB_B(origin_pixel) * op_value_c +
                                            DRV_HW_TO_RGB_B(layer_pixel) * op_value;
                                    }
                                #ifdef __MMI_SUBLCD__
                                    else
                                    {
                                        r = HW_TO_RGB_R(origin_pixel) * op_value_c +
                                            HW_FORMAT_TO_SUBMMI_R(layer_pixel) * op_value;
                                        g = HW_TO_RGB_G(origin_pixel) * op_value_c +
                                            HW_FORMAT_TO_SUBMMI_G(layer_pixel) * op_value;
                                        b = HW_TO_RGB_B(origin_pixel) * op_value_c +
                                            HW_FORMAT_TO_SUBMMI_B(layer_pixel) * op_value;
                                    }
                                #endif /* __MMI_SUBLCD__ */ 
                                    r >>= 8;
                                    g >>= 8;
                                    b >>= 8;
                                    origin_pixel = (U16) RGB_TO_HW(r, g, b);
                                }
                            }
                            else
                            {
                                if (lcd_id == MAIN_LCD)
                                {
                                    r = DRV_HW_TO_RGB_R(layer_pixel);
                                    g = DRV_HW_TO_RGB_G(layer_pixel);
                                    b = DRV_HW_TO_RGB_B(layer_pixel);
                                }
                            #ifdef __MMI_SUBLCD__
                                else
                                {
                                    r = HW_FORMAT_TO_SUBMMI_R(layer_pixel);
                                    g = HW_FORMAT_TO_SUBMMI_G(layer_pixel);
                                    b = HW_FORMAT_TO_SUBMMI_B(layer_pixel);
                                }
                            #endif /* __MMI_SUBLCD__ */ 
                                origin_pixel = (U16) RGB_TO_HW(r, g, b);
                            }
                        }

                        /* write back to shadow buffer */
                        if (lcd_id == MAIN_LCD)
                        {
                            BUF_PIXEL_DATA(shadow_ptr, x - roi_offset_x + start_x, y - roi_offset_y + start_y, LCD_WIDTH) = origin_pixel;       /* 040105 JF modified */
                        }
                    #ifdef __MMI_SUBLCD__
                        else
                        {
                            BUF_PIXEL_DATA(shadow_ptr, x - roi_offset_x + start_x, y - roi_offset_y + start_y, SUBLCD_WIDTH) = origin_pixel;    /* 040105 JF modified */
                        }
                    #endif /* __MMI_SUBLCD__ */ 
                  /***********************************************************/

                    }   /* if within region */
                }       /* for loop  x */
            }           /* for loop - y */
            is_first_layer = 0;
        }               /* if flag */
    }                   /* for each layer */

    /* send the main-lcd information to MODIS_UI for displaying */
    if (lcd_id == MAIN_LCD)
    {
        set_MODIS_UI_layer_data(
            MODIS_UI_layer_ptr,
            LCD_WIDTH,
            LCD_HEIGHT,
            SIMULATOR_LAYER_COUNT,
            &new_application_flag);
    }

    /* draw to dc */
    if (lcd_id == MAIN_LCD)
    {
        /* draw to simulator's main LCD region */
        hdc = GetDC(hWnd);
        hdcMem = CreateCompatibleDC(hdc);
        hbmp = CreateCompatibleBitmap(hdc, LCD_WIDTH, LCD_HEIGHT);
        SelectObject(hdcMem, hbmp);

        y1 = 0;
        y2 = LCD_WIDTH - 1;
        x1 = 0;
        x2 = LCD_HEIGHT - 1;

        for (i = 0; i < LCD_HEIGHT; i++)
        {
            for (j = 0; j < LCD_WIDTH; j++)
            {
                c.r = HW_TO_RGB_R(simulator_shadow_buffer[i * LCD_WIDTH + j]);
                c.g = HW_TO_RGB_G(simulator_shadow_buffer[i * LCD_WIDTH + j]);
                c.b = HW_TO_RGB_B(simulator_shadow_buffer[i * LCD_WIDTH + j]);
                c.alpha = 100;

                /* SetPixel(hdcMem, j, i ,RGB(c.r, c.g, c.b)); */
                BUF_PIXEL_DATA(simulator_frame_buffer, j, LCD_HEIGHT - 1 - i, LCD_WIDTH) = RGB(c.b, c.g, c.r);
            }
        }

        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__
    else if (lcd_id == SUB_LCD)
    {
        /* 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);

        y1 = 0;
        y2 = SUBLCD_WIDTH - 1;
        x1 = 0;
        x2 = SUBLCD_HEIGHT - 1;

        for (i = 0; i < SUBLCD_HEIGHT; i++)
        {
            for (j = 0; j < SUBLCD_WIDTH; j++)
            {
                c.r = HW_TO_RGB_R(simulator_sub_shadow_buffer[i * SUBLCD_WIDTH + j]);
                c.g = HW_TO_RGB_G(simulator_sub_shadow_buffer[i * SUBLCD_WIDTH + j]);
                c.b = HW_TO_RGB_B(simulator_sub_shadow_buffer[i * SUBLCD_WIDTH + j]);
                c.alpha = 100;

                /* SetPixel(sub_hdcMem, j, i ,RGB(c.r, c.g, c.b)); */
                BUF_PIXEL_DATA(sub_simulator_frame_buffer, j, SUBLCD_HEIGHT - 1 - i, SUBLCD_WIDTH) = RGB(c.b, c.g, c.r);
            }
        }

        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 lcd_fb_update */


/*****************************************************************************
 * FUNCTION
 *  config_lcd_roi_window
 * DESCRIPTION
 *  void
 * PARAMETERS
 *  roi_x_offset        [IN]        U16
 *  roi_y_offset        [IN]        Kal_uint16
 *  roi_column          [IN]        Kal_uint16
 *  roi_row             [IN]        Kal_uint16
 * RETURNS
 * TRUE
 *****************************************************************************/
kal_bool config_lcd_roi_window(U16 roi_x_offset, kal_uint16 roi_y_offset, kal_uint16 roi_column, kal_uint16 roi_row)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    return KAL_TRUE;

}   /* end of config_lcd_roi_window */


/*****************************************************************************
 * FUNCTION
 *  lcd_init
 * DESCRIPTION
 *  void
 * PARAMETERS
 *  lcd_id                  [IN]        Kal_uint8
 *  background_color        [IN]        Kal_uint16
 * RETURNS
 *  void
 *****************************************************************************/
void lcd_init(kal_uint8 lcd_id, kal_uint16 background_color)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
}   /* end of lcd_init */


/*****************************************************************************
 * FUNCTION
 *  lcd_sleep_in
 * DESCRIPTION
 *  void
 * PARAMETERS
 *  lcd_id      [IN]        Kal_uint8
 * RETURNS
 *  void
 *****************************************************************************/
void lcd_sleep_in(kal_uint8 lcd_id)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
}   /* end of lcd_sleep_in */


/*****************************************************************************
 * FUNCTION
 *  lcd_sleep_out
 * DESCRIPTION
 *  void
 * PARAMETERS
 *  lcd_id      [IN]        Kal_uint8

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -