Clip all rendered images to screen boundaries

This commit is contained in:
Kovid Goyal 2017-10-06 21:22:52 +05:30
parent 8d3ec7451b
commit d4e493727e
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -580,7 +580,7 @@ grman_update_layers(GraphicsManager *self, unsigned int scrolled_by, float scree
Image *img; ImageRef *ref;
ImageRect r;
float screen_width = dx * num_cols, screen_height = dy * num_rows;
float screen_bottom = screen_top - screen_height;
float screen_bottom = screen_top - screen_height, screen_right = screen_left + screen_width;
float screen_width_px = num_cols * global_state.cell_width;
float screen_height_px = num_rows * global_state.cell_height;
float y0 = screen_top - dy * scrolled_by;
@ -597,6 +597,12 @@ grman_update_layers(GraphicsManager *self, unsigned int scrolled_by, float scree
if (ref->num_cols) r.right = screen_left + (ref->start_column + ref->num_cols) * dx;
else r.right = r.left + screen_width * (float)ref->src_width / screen_width_px;
// Clip image to screen boundaries
if (r.top > screen_top) r.top = screen_top;
if (r.bottom < screen_bottom) r.bottom = screen_bottom;
if (r.left < screen_left) r.left = screen_left;
if (r.right > screen_right) r.right = screen_right;
if (ref->z_index < 0) self->num_of_negative_refs++; else self->num_of_positive_refs++;
ensure_space_for(self, render_data, ImageRenderData, self->count + 1, capacity, 100);
ImageRenderData *rd = self->render_data + self->count;