Skip to content

Commit

Permalink
Merge pull request #17 from glyptodon/terminal-regression
Browse files Browse the repository at this point in the history
GUAC-1008: Properly init clipping rectangle.
  • Loading branch information
jmuehlner committed Jan 17, 2015
2 parents 122de48 + 67ed8c5 commit e96020e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/common/guac_surface.c
Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}

/**
Expand Down
6 changes: 6 additions & 0 deletions src/common/guac_surface.h
Expand Up @@ -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.
*/
Expand Down

0 comments on commit e96020e

Please sign in to comment.