Пример #1
0
static void _graphic_driver_vmode_init(void)
{
	if (_vfb_driver.width != _driver.width || _vfb_driver.height != _driver.height)
	{
		if (_vfb_driver.framebuffer != RT_NULL) rtgui_free((void*)_vfb_driver.framebuffer);

		_vfb_driver.device = RT_NULL;
		_vfb_driver.pixel_format = RTGUI_VFB_PIXEL_FMT;
		_vfb_driver.bits_per_pixel = rtgui_color_get_bits(RTGUI_VFB_PIXEL_FMT);
		_vfb_driver.width  = _driver.width;
		_vfb_driver.height = _driver.height;
		_vfb_driver.pitch  = _driver.width * _UI_BITBYTES(_vfb_driver.bits_per_pixel);
		_vfb_driver.framebuffer = rtgui_malloc(_vfb_driver.height * _vfb_driver.pitch);
		_vfb_driver.ext_ops = RT_NULL;
		_vfb_driver.ops = rtgui_framebuffer_get_ops(_vfb_driver.pixel_format);
	}
}
Пример #2
0
rt_err_t rtgui_graphic_set_device(rt_device_t device)
{
    rt_err_t result;
    struct rt_device_graphic_info info;
    struct rtgui_graphic_ext_ops *ext_ops;

    /* get framebuffer address */
    result = rt_device_control(device, RTGRAPHIC_CTRL_GET_INFO, &info);
    if (result != RT_EOK)
    {
        /* get device information failed */
        return -RT_ERROR;
    }

    /* if the first set graphic device */
    if (_driver.width == 0 || _driver.height == 0)
    {
        rtgui_rect_t rect;

        rtgui_get_mainwin_rect(&rect);
        if (rect.x2 == 0 || rect.y2 == 0)
        {
            rtgui_rect_init(&rect, 0, 0, info.width, info.height);
            /* re-set main-window */
            rtgui_set_mainwin_rect(&rect);
        }
    }

    /* initialize framebuffer driver */
    _driver.device = device;
    _driver.pixel_format = info.pixel_format;
    _driver.bits_per_pixel = info.bits_per_pixel;
    _driver.width = info.width;
    _driver.height = info.height;
    _driver.pitch = _driver.width * _UI_BITBYTES(_driver.bits_per_pixel);
    _driver.framebuffer = info.framebuffer;

    /* get graphic extension operations */
    result = rt_device_control(device, RTGRAPHIC_CTRL_GET_EXT, &ext_ops);
    if (result == RT_EOK)
    {
        _driver.ext_ops = ext_ops;
    }

    if (info.framebuffer != RT_NULL)
    {
        /* is a frame buffer device */
        _driver.ops = rtgui_framebuffer_get_ops(_driver.pixel_format);
    }
    else
    {
        /* is a pixel device */
        _driver.ops = rtgui_pixel_device_get_ops(_driver.pixel_format);
    }

#ifdef RTGUI_USING_HW_CURSOR
    /* set default cursor image */
    rtgui_cursor_set_image(RTGUI_CURSOR_ARROW);
#endif

#ifdef RTGUI_USING_VFRAMEBUFFER
    _graphic_driver_vmode_init();
#endif

    return RT_EOK;
}