Esempio n. 1
0
static void rtgui_dc_client_blit_line (struct rtgui_dc* self, int x1, int x2, int y, rt_uint8_t* line_data)
{
	register rt_base_t index;
	rtgui_widget_t *owner;

	if (self == RT_NULL) return;

	/* get owner */
	owner = RTGUI_CONTAINER_OF(self, struct rtgui_widget, dc_type);
	if (!RTGUI_WIDGET_IS_DC_VISIBLE(owner)) return;

	/* convert logic to device */
	x1 = x1 + owner->extent.x1;
	x2 = x2 + owner->extent.x1;
	if (x1 > x2) _int_swap(x1, x2);
	y  = y + owner->extent.y1;

	if (rtgui_region_is_flat(&(owner->clip)) == RT_EOK)
	{
		rtgui_rect_t* prect;
		int offset = 0;
		prect = &(owner->clip.extents);

		/* calculate vline intersect */
		if (prect->y1 > y  || prect->y2 <= y ) return;
		if (prect->x2 <= x1 || prect->x1 > x2) return;

		if (prect->x1 > x1) x1 = prect->x1;
		if (prect->x2 < x2) x2 = prect->x2;

		/* patch note: 
		 * We need to adjust the offset when update widget clip!
		 * Of course at ordinary times for 0. General */
		offset = owner->clip.extents.x1 - owner->extent.x1;
		offset = offset * hw_driver->bits_per_pixel/8;
		/* draw hline */
		hw_driver->ops->draw_raw_hline(line_data+offset, x1, x2, y);
	}
	else for (index = 0; index < rtgui_region_num_rects(&(owner->clip)); index ++)
	{
		rtgui_rect_t* prect;
		register rt_base_t draw_x1, draw_x2;

		prect = ((rtgui_rect_t *)(owner->clip.data + index + 1));
		draw_x1 = x1;
		draw_x2 = x2;

		/* calculate hline clip */
		if (prect->y1 > y  || prect->y2 <= y ) continue;
		if (prect->x2 <= x1 || prect->x1 > x2) continue;

		if (prect->x1 > x1) draw_x1 = prect->x1;
		if (prect->x2 < x2) draw_x2 = prect->x2;

		/* draw hline */
		hw_driver->ops->draw_raw_hline(line_data + (draw_x1 - x1) * hw_driver->bits_per_pixel/8, draw_x1, draw_x2, y);
	}
}
Esempio n. 2
0
struct rtgui_dc* rtgui_dc_begin_drawing(rtgui_widget_t* owner)
{
	RT_ASSERT(owner != RT_NULL);

	if ((rtgui_region_is_flat(&owner->clip) == RT_EOK) &&
		rtgui_rect_is_equal(&(owner->extent), &(owner->clip.extents)) == RT_EOK) {
		/* use hardware DC */
		return rtgui_dc_hw_create(owner);
	}

	return rtgui_dc_client_create(owner);
}
Esempio n. 3
0
struct rtgui_dc* rtgui_dc_begin_drawing(rtgui_widget_t* owner)
{
	struct rtgui_dc* dc;
	RT_ASSERT(owner != RT_NULL);

	rtgui_screen_lock(RT_WAITING_FOREVER);

	if ((rtgui_region_is_flat(&owner->clip) == RT_EOK) &&
		rtgui_rect_is_equal(&(owner->extent), &(owner->clip.extents)) == RT_EOK)
		dc = rtgui_dc_hw_create(owner);
	else
		dc = rtgui_dc_client_create(owner);

	if (dc == RT_NULL) rtgui_screen_unlock();

	return dc;
}