fix canvas for fragment framebuffer

This commit is contained in:
xianjimli 2020-05-08 11:23:44 +08:00
parent 729519cf0f
commit 6c7da14b5f

View File

@ -1,4 +1,4 @@
/**
/**
* File: canvas.c
* Author: AWTK Develop Team
* Brief: canvas provides basic drawings functions.
@ -137,21 +137,36 @@ ret_t canvas_set_clip_rect(canvas_t* c, const rect_t* r_in) {
rect_t r_fix;
rect_t* r = canvas_fix_rect(r_in, &r_fix);
#ifdef FRAGMENT_FRAME_BUFFER_SIZE
rect_t dirty_r = rect_init(c->lcd->dirty_rect.x, c->lcd->dirty_rect.y, c->lcd->dirty_rect.w, c->lcd->dirty_rect.h);
#endif
return_value_if_fail(c != NULL, RET_BAD_PARAMS);
lcd_w = lcd_get_width(c->lcd);
lcd_h = lcd_get_height(c->lcd);
if (r) {
#ifdef FRAGMENT_FRAME_BUFFER_SIZE
r_fix = rect_intersect(&r_fix, &dirty_r);
#endif
c->clip_left = tk_max(0, r->x);
c->clip_top = tk_max(0, r->y);
c->clip_right = r->x + r->w - 1;
c->clip_bottom = r->y + r->h - 1;
} else {
#ifdef FRAGMENT_FRAME_BUFFER_SIZE
c->clip_left = tk_max(0, dirty_r.x);
c->clip_top = tk_max(0, dirty_r.y);
c->clip_right = dirty_r.x + dirty_r.w - 1;
c->clip_bottom = dirty_r.y + dirty_r.h - 1;
#else
c->clip_left = 0;
c->clip_top = 0;
c->clip_right = lcd_w - 1;
c->clip_bottom = lcd_h - 1;
#endif
}
if (c->clip_left < 0) {