Beispiel #1
0
static Ret ftk_canvas_default_draw_rect(FtkCanvas* thiz, int x, int y, int w, int h,
                                        int round, int fill)
{
    Ret ret = RET_FAIL;
    FtkRect rect = {0};
    DECL_PRIV(thiz, priv);
    rect.x = x;
    rect.y = y;
    rect.width = w;
    rect.height = h;

    if(ftk_rect_and(&rect, &priv->clip->rect, &rect) != RET_OK)
    {
//		ftk_logd("%s: skip.\n", __func__);
        return RET_OK;
    }

    x = rect.x;
    y = rect.y;
    w = rect.width;
    h = rect.height;

    if(round)
    {
        ret = ftk_canvas_default_draw_round_rect(thiz, x, y, w, h, fill);
    }
    else
    {
        ret = ftk_canvas_default_draw_rect_impl(thiz, x, y, w, h, fill);
    }

    return ret;
}
Beispiel #2
0
static Ret ftk_canvas_default_clear_rect(FtkCanvas* thiz, size_t x, size_t y, size_t w, size_t h)
{
	size_t width = 0;
	int iter_w = 0;
	int iter_h = 0;
	FtkColor* color = NULL;
	FtkColor* bits = NULL;
	FtkColor* pdst = NULL;
	DECL_PRIV(thiz, priv);	
	
	FtkRect rect = {0};
	rect.x = x;
	rect.y = y;
	rect.width = w;
	rect.height = h;
	rect = ftk_rect_and(&rect, &priv->clip->rect);

	if(rect.width <= 0 || rect.height <= 0)
	{
//		ftk_logd("%s: skip.\n", __func__);
		return RET_OK;
	}

	width = priv->w;
	bits = priv->bits;

	x = rect.x;
	y = rect.y;
	w = rect.width;
	h = rect.height;

	iter_w = w;
	iter_h = h;
	bits += y * width;

	color = &(thiz->gc.fg);
	while(iter_h--)
	{
		pdst = bits + x;
		while(iter_w--)
		{
			*(unsigned int*)pdst = *(unsigned int*)color;
			pdst++;
		}
		iter_w = w;
		bits += width;
	}

	return RET_OK;
}