Merge pull request #17 from glyptodon/terminal-regression

GUAC-1008: Properly init clipping rectangle.
This commit is contained in:
James Muehlner 2015-01-17 10:05:15 -08:00
commit e96020e35c
2 changed files with 19 additions and 3 deletions

View File

@ -122,6 +122,10 @@ static void __guac_common_clip_rect(guac_common_surface* surface,
int orig_x = rect->x;
int orig_y = rect->y;
/* Skip clipping if no clipping rectangle applied */
if (!surface->clipped)
return;
guac_common_rect_constrain(rect, &surface->clip_rect);
/* Update source X/Y if given */
@ -727,9 +731,9 @@ void guac_common_surface_resize(guac_common_surface* surface, int w, int h) {
/* Free old data */
free(old_buffer);
/* Clip dirty rect */
/* Resize dirty rect to fit new surface dimensions */
if (surface->dirty) {
guac_common_rect_constrain(&surface->dirty_rect, &surface->clip_rect);
__guac_common_bound_rect(surface, &surface->dirty_rect, NULL, NULL);
if (surface->dirty_rect.width <= 0 || surface->dirty_rect.height <= 0)
surface->dirty = 0;
}
@ -923,13 +927,19 @@ void guac_common_surface_clip(guac_common_surface* surface, int x, int y, int w,
guac_common_rect clip;
/* Init clipping rectangle if clipping not already applied */
if (!surface->clipped) {
guac_common_rect_init(&surface->clip_rect, 0, 0, surface->width, surface->height);
surface->clipped = 1;
}
guac_common_rect_init(&clip, x, y, w, h);
guac_common_rect_constrain(&surface->clip_rect, &clip);
}
void guac_common_surface_reset_clip(guac_common_surface* surface) {
guac_common_rect_init(&surface->clip_rect, 0, 0, surface->width, surface->height);
surface->clipped = 0;
}
/**

View File

@ -105,6 +105,12 @@ typedef struct guac_common_surface {
*/
int realized;
/**
* Whether drawing operations are currently clipped by the clipping
* rectangle.
*/
int clipped;
/**
* The clipping rectangle.
*/