From 014e245baa2015aa98a48b36d65e1a9510e557df Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Mon, 5 May 2014 11:17:38 -0700 Subject: [PATCH] GUAC-669: Limit how high the fill pattern heuristic is allowed to increase update cost. --- src/common/guac_surface.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/common/guac_surface.c b/src/common/guac_surface.c index e19c0a17..e30fbbd0 100644 --- a/src/common/guac_surface.c +++ b/src/common/guac_surface.c @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -64,6 +65,13 @@ */ #define GUAC_SURFACE_NEGLIGIBLE_INCREASE 4 +/** + * If combining an update because it appears to be follow a fill pattern, + * the combined cost must not exceed + * GUAC_SURFACE_FILL_PATTERN_FACTOR * (total uncombined cost). + */ +#define GUAC_SURFACE_FILL_PATTERN_FACTOR 3 + /* Define cairo_format_stride_for_width() if missing */ #ifndef HAVE_CAIRO_FORMAT_STRIDE_FOR_WIDTH #define cairo_format_stride_for_width(format, width) (width*4) @@ -178,8 +186,10 @@ static int __guac_common_should_combine(guac_common_surface* surface, int x, int return 1; /* Combine if we anticipate further updates, as this update follows a common fill pattern */ - if (x == surface->dirty_x && y == surface->dirty_y + surface->dirty_height) - return 1; + if (x == surface->dirty_x && y == surface->dirty_y + surface->dirty_height) { + if (combined_cost <= (dirty_cost + update_cost) * GUAC_SURFACE_FILL_PATTERN_FACTOR) + return 1; + } }