mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-16 01:20:59 +00:00
Fixed a lot of important bugs in clipping code.
This commit is contained in:
parent
3f7621ec5c
commit
8ff997d2d2
@ -1260,11 +1260,12 @@ static void manager_pump_queue(JWidget widget_manager)
|
||||
acquire_bitmap(ji_screen);
|
||||
|
||||
/* set clip */
|
||||
set_clip(ji_screen,
|
||||
msg->draw.rect.x1, msg->draw.rect.y1,
|
||||
msg->draw.rect.x2-1, msg->draw.rect.y2-1);
|
||||
assert(get_clip_state(ji_screen));
|
||||
set_clip_rect(ji_screen,
|
||||
msg->draw.rect.x1, msg->draw.rect.y1,
|
||||
msg->draw.rect.x2-1, msg->draw.rect.y2-1);
|
||||
#ifdef REPORT_EVENTS
|
||||
printf(" - set_clip(%d, %d, %d, %d)\n",
|
||||
printf(" - clip(%d, %d, %d, %d)\n",
|
||||
msg->draw.rect.x1, msg->draw.rect.y1,
|
||||
msg->draw.rect.x2-1, msg->draw.rect.y2-1);
|
||||
fflush(stdout);
|
||||
@ -1278,7 +1279,7 @@ static void manager_pump_queue(JWidget widget_manager)
|
||||
|
||||
/* restore clip */
|
||||
if (msg->type == JM_DRAW) {
|
||||
set_clip(ji_screen, 0, 0, JI_SCREEN_W-1, JI_SCREEN_H-1);
|
||||
set_clip_rect(ji_screen, 0, 0, JI_SCREEN_W-1, JI_SCREEN_H-1);
|
||||
|
||||
/* dirty rectangles */
|
||||
if (ji_dirty_region)
|
||||
|
@ -644,13 +644,13 @@ void Frame::move_window(JRect rect, bool use_blit)
|
||||
|
||||
/* move the window's graphics */
|
||||
jmouse_hide();
|
||||
set_clip(ji_screen,
|
||||
man_pos->x1, man_pos->y1, man_pos->x2-1, man_pos->y2-1);
|
||||
set_clip_rect(ji_screen,
|
||||
man_pos->x1, man_pos->y1, man_pos->x2-1, man_pos->y2-1);
|
||||
|
||||
ji_move_region(moveable_region,
|
||||
this->rc->x1 - old_pos->x1,
|
||||
this->rc->y1 - old_pos->y1);
|
||||
set_clip(ji_screen, 0, 0, JI_SCREEN_W-1, JI_SCREEN_H-1);
|
||||
set_clip_rect(ji_screen, 0, 0, JI_SCREEN_W-1, JI_SCREEN_H-1);
|
||||
jmouse_show();
|
||||
|
||||
jregion_free(reg1);
|
||||
|
@ -1026,10 +1026,7 @@ void jstandard_theme::draw_separator(JWidget widget, JRect clip)
|
||||
}
|
||||
}
|
||||
|
||||
#if 1
|
||||
/* TODO when Allegro 4.1 will be officially released, replace this
|
||||
with the get_clip_rect, add_clip_rect, set_clip_rect functions */
|
||||
static int my_add_clip_rect(BITMAP *bitmap, int x1, int y1, int x2, int y2)
|
||||
static bool my_add_clip_rect(BITMAP *bitmap, int x1, int y1, int x2, int y2)
|
||||
{
|
||||
int u1 = MAX(x1, bitmap->cl);
|
||||
int v1 = MAX(y1, bitmap->ct);
|
||||
@ -1039,11 +1036,10 @@ static int my_add_clip_rect(BITMAP *bitmap, int x1, int y1, int x2, int y2)
|
||||
if (u1 > u2 || v1 > v2)
|
||||
return false;
|
||||
else
|
||||
set_clip(bitmap, u1, v1, u2, v2);
|
||||
set_clip_rect(bitmap, u1, v1, u2, v2);
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
void jstandard_theme::draw_slider(JWidget widget, JRect clip)
|
||||
{
|
||||
@ -1113,8 +1109,9 @@ void jstandard_theme::draw_slider(JWidget widget, JRect clip)
|
||||
/* text */
|
||||
{
|
||||
std::string old_text = widget->getText();
|
||||
int cx1, cy1, cx2, cy2;
|
||||
JRect r;
|
||||
int cx1, cy1, cx2, cy2;
|
||||
get_clip_rect(ji_screen, &cx1, &cy1, &cx2, &cy2);
|
||||
|
||||
usprintf(buf, "%d", value);
|
||||
|
||||
@ -1122,26 +1119,17 @@ void jstandard_theme::draw_slider(JWidget widget, JRect clip)
|
||||
|
||||
r = jrect_new(x1, y1, x2+1, y2+1);
|
||||
|
||||
/* TODO when Allegro 4.1 will be officially released, replace this
|
||||
with the get_clip_rect, add_clip_rect, set_clip_rect
|
||||
functions */
|
||||
|
||||
cx1 = ji_screen->cl;
|
||||
cy1 = ji_screen->ct;
|
||||
cx2 = ji_screen->cr-1;
|
||||
cy2 = ji_screen->cb-1;
|
||||
|
||||
if (my_add_clip_rect(ji_screen, x1, y1, x, y2))
|
||||
draw_textstring(NULL, COLOR_BACKGROUND,
|
||||
jwidget_is_disabled(widget) ?
|
||||
bg: COLOR_SELECTED, false, widget, r, 0);
|
||||
|
||||
set_clip(ji_screen, cx1, cy1, cx2, cy2);
|
||||
set_clip_rect(ji_screen, cx1, cy1, cx2, cy2);
|
||||
|
||||
if (my_add_clip_rect(ji_screen, x+1, y1, x2, y2))
|
||||
draw_textstring(NULL, COLOR_FOREGROUND, bg, false, widget, r, 0);
|
||||
|
||||
set_clip(ji_screen, cx1, cy1, cx2, cy2);
|
||||
set_clip_rect(ji_screen, cx1, cy1, cx2, cy2);
|
||||
|
||||
widget->setTextQuiet(old_text.c_str());
|
||||
jrect_free(r);
|
||||
|
@ -1019,10 +1019,7 @@ void SkinneableTheme::draw_separator(JWidget widget, JRect clip)
|
||||
}
|
||||
}
|
||||
|
||||
#if 1
|
||||
/* TODO when Allegro 4.1 will be officially released, replace this
|
||||
with the get_clip_rect, add_clip_rect, set_clip_rect functions */
|
||||
static int my_add_clip_rect(BITMAP *bitmap, int x1, int y1, int x2, int y2)
|
||||
static bool my_add_clip_rect(BITMAP *bitmap, int x1, int y1, int x2, int y2)
|
||||
{
|
||||
int u1 = MAX(x1, bitmap->cl);
|
||||
int v1 = MAX(y1, bitmap->ct);
|
||||
@ -1032,11 +1029,10 @@ static int my_add_clip_rect(BITMAP *bitmap, int x1, int y1, int x2, int y2)
|
||||
if (u1 > u2 || v1 > v2)
|
||||
return false;
|
||||
else
|
||||
set_clip(bitmap, u1, v1, u2, v2);
|
||||
set_clip_rect(bitmap, u1, v1, u2, v2);
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
void SkinneableTheme::draw_slider(JWidget widget, JRect clip)
|
||||
{
|
||||
@ -1096,8 +1092,9 @@ void SkinneableTheme::draw_slider(JWidget widget, JRect clip)
|
||||
/* text */
|
||||
{
|
||||
std::string old_text = widget->getText();
|
||||
int cx1, cy1, cx2, cy2;
|
||||
JRect r;
|
||||
int cx1, cy1, cx2, cy2;
|
||||
get_clip_rect(ji_screen, &cx1, &cy1, &cx2, &cy2);
|
||||
|
||||
usprintf(buf, "%d", value);
|
||||
|
||||
@ -1105,28 +1102,19 @@ void SkinneableTheme::draw_slider(JWidget widget, JRect clip)
|
||||
|
||||
r = jrect_new(x1, y1, x2, y2);
|
||||
|
||||
/* TODO when Allegro 4.1 will be officially released, replace this
|
||||
with the get_clip_rect, add_clip_rect, set_clip_rect
|
||||
functions */
|
||||
|
||||
cx1 = ji_screen->cl;
|
||||
cy1 = ji_screen->ct;
|
||||
cx2 = ji_screen->cr-1;
|
||||
cy2 = ji_screen->cb-1;
|
||||
|
||||
if (my_add_clip_rect(ji_screen, x1, y1, x, y2))
|
||||
draw_textstring(NULL,
|
||||
get_slider_full_text_color(),
|
||||
get_slider_full_face_color(), false, widget, r, 0);
|
||||
|
||||
set_clip(ji_screen, cx1, cy1, cx2, cy2);
|
||||
set_clip_rect(ji_screen, cx1, cy1, cx2, cy2);
|
||||
|
||||
if (my_add_clip_rect(ji_screen, x+1, y1, x2, y2))
|
||||
draw_textstring(NULL,
|
||||
get_slider_empty_text_color(),
|
||||
get_slider_empty_face_color(), false, widget, r, 0);
|
||||
|
||||
set_clip(ji_screen, cx1, cy1, cx2, cy2);
|
||||
set_clip_rect(ji_screen, cx1, cy1, cx2, cy2);
|
||||
|
||||
widget->setTextQuiet(old_text.c_str());
|
||||
jrect_free(r);
|
||||
@ -1482,10 +1470,7 @@ BITMAP* SkinneableTheme::get_toolicon(const char* tool_id) const
|
||||
void SkinneableTheme::draw_bounds(int x1, int y1, int x2, int y2, int nw, int bg)
|
||||
{
|
||||
int cx1, cy1, cx2, cy2;
|
||||
cx1 = ji_screen->cl;
|
||||
cy1 = ji_screen->ct;
|
||||
cx2 = ji_screen->cr-1;
|
||||
cy2 = ji_screen->cb-1;
|
||||
get_clip_rect(ji_screen, &cx1, &cy1, &cx2, &cy2);
|
||||
|
||||
int x, y;
|
||||
|
||||
@ -1503,7 +1488,7 @@ void SkinneableTheme::draw_bounds(int x1, int y1, int x2, int y2, int nw, int bg
|
||||
}
|
||||
draw_sprite(ji_screen, m_part[nw+1], x2-m_part[nw+2]->w-m_part[nw+1]->w+1, y1);
|
||||
}
|
||||
set_clip(ji_screen, cx1, cy1, cx2, cy2);
|
||||
set_clip_rect(ji_screen, cx1, cy1, cx2, cy2);
|
||||
|
||||
draw_sprite(ji_screen, m_part[nw+2], x2-m_part[nw+2]->w+1, y1);
|
||||
|
||||
@ -1521,7 +1506,7 @@ void SkinneableTheme::draw_bounds(int x1, int y1, int x2, int y2, int nw, int bg
|
||||
}
|
||||
draw_sprite(ji_screen, m_part[nw+5], x2-m_part[nw+4]->w-m_part[nw+5]->w+1, y2-m_part[nw+5]->h+1);
|
||||
}
|
||||
set_clip(ji_screen, cx1, cy1, cx2, cy2);
|
||||
set_clip_rect(ji_screen, cx1, cy1, cx2, cy2);
|
||||
|
||||
draw_sprite(ji_screen, m_part[nw+4], x2-m_part[nw+4]->w+1, y2-m_part[nw+4]->h+1);
|
||||
|
||||
@ -1544,7 +1529,7 @@ void SkinneableTheme::draw_bounds(int x1, int y1, int x2, int y2, int nw, int bg
|
||||
}
|
||||
draw_sprite(ji_screen, m_part[nw+3], x2-m_part[nw+3]->w+1, y2-m_part[nw+4]->h-m_part[nw+3]->h+1);
|
||||
}
|
||||
set_clip(ji_screen, cx1, cy1, cx2, cy2);
|
||||
set_clip_rect(ji_screen, cx1, cy1, cx2, cy2);
|
||||
|
||||
// background
|
||||
if (bg >= 0) {
|
||||
@ -1560,25 +1545,17 @@ void SkinneableTheme::draw_bounds(int x1, int y1, int x2, int y2, int nw, int bg
|
||||
void SkinneableTheme::draw_bounds2(int x1, int y1, int x2, int y2, int x_mid, int nw1, int nw2, int bg1, int bg2)
|
||||
{
|
||||
int cx1, cy1, cx2, cy2;
|
||||
|
||||
/* TODO when Allegro 4.1 will be officially released, replace this
|
||||
with the get_clip_rect, add_clip_rect, set_clip_rect
|
||||
functions */
|
||||
|
||||
cx1 = ji_screen->cl;
|
||||
cy1 = ji_screen->ct;
|
||||
cx2 = ji_screen->cr-1;
|
||||
cy2 = ji_screen->cb-1;
|
||||
get_clip_rect(ji_screen, &cx1, &cy1, &cx2, &cy2);
|
||||
|
||||
if (my_add_clip_rect(ji_screen, x1, y1, x_mid, y2))
|
||||
draw_bounds(x1, y1, x2, y2, nw1, bg1);
|
||||
|
||||
set_clip(ji_screen, cx1, cy1, cx2, cy2);
|
||||
set_clip_rect(ji_screen, cx1, cy1, cx2, cy2);
|
||||
|
||||
if (my_add_clip_rect(ji_screen, x_mid+1, y1, x2, y2))
|
||||
draw_bounds(x1, y1, x2, y2, nw2, bg2);
|
||||
|
||||
set_clip(ji_screen, cx1, cy1, cx2, cy2);
|
||||
set_clip_rect(ji_screen, cx1, cy1, cx2, cy2);
|
||||
}
|
||||
|
||||
void SkinneableTheme::draw_hline(int x1, int y1, int x2, int y2, int part)
|
||||
|
@ -1216,10 +1216,10 @@ next_pts:;
|
||||
for (c=0, rc=JI_REGION_RECTS(region);
|
||||
c<nrects;
|
||||
c++, rc++) {
|
||||
set_clip(ji_screen, rc->x1, rc->y1, rc->x2-1, rc->y2-1);
|
||||
set_clip_rect(ji_screen, rc->x1, rc->y1, rc->x2-1, rc->y2-1);
|
||||
rect(ji_screen, outx1, outy1, outx2, outy2, 0);
|
||||
}
|
||||
set_clip(ji_screen, 0, 0, JI_SCREEN_W-1, JI_SCREEN_H-1);
|
||||
set_clip_rect(ji_screen, 0, 0, JI_SCREEN_W-1, JI_SCREEN_H-1);
|
||||
jregion_free(region);
|
||||
|
||||
dotted_mode(-1);
|
||||
|
@ -732,7 +732,7 @@ static void draw_box(BITMAP *bmp,
|
||||
int x[4], y[4];
|
||||
int c;
|
||||
|
||||
set_clip(bmp, cx1, cy1, cx2, cy2);
|
||||
set_clip_rect(bmp, cx1, cy1, cx2, cy2);
|
||||
|
||||
/* calculate corner positions */
|
||||
apply_rotation(x1, y1, x2, y2, angle, cx, cy, x, y);
|
||||
@ -767,7 +767,7 @@ static void draw_box(BITMAP *bmp,
|
||||
DRAWICON(3, 2, fixadd(angle, itofix(192)));
|
||||
DRAWICON(2, 2, fixadd(angle, itofix(224)));
|
||||
|
||||
set_clip(bmp, 0, 0, bmp->w-1, bmp->h-1);
|
||||
set_clip_rect(bmp, 0, 0, bmp->w-1, bmp->h-1);
|
||||
}
|
||||
|
||||
static void draw_icon(BITMAP *bmp, int x, int y, int mode, fixed angle)
|
||||
|
@ -456,10 +456,10 @@ void Editor::editor_draw_mask_safe()
|
||||
for (c=0, rc=JI_REGION_RECTS(region);
|
||||
c<nrects;
|
||||
c++, rc++) {
|
||||
set_clip(ji_screen, rc->x1, rc->y1, rc->x2-1, rc->y2-1);
|
||||
set_clip_rect(ji_screen, rc->x1, rc->y1, rc->x2-1, rc->y2-1);
|
||||
editor_draw_mask();
|
||||
}
|
||||
set_clip(ji_screen, 0, 0, JI_SCREEN_W-1, JI_SCREEN_H-1);
|
||||
set_clip_rect(ji_screen, 0, 0, JI_SCREEN_W-1, JI_SCREEN_H-1);
|
||||
jregion_free(region);
|
||||
|
||||
/* draw the cursor */
|
||||
|
Loading…
x
Reference in New Issue
Block a user