Skip to content

Commit

Permalink
Allocate enough memory for overhang pixels in quarter-rendering of un…
Browse files Browse the repository at this point in the history
…even columns.

Columns with an uneven width in quarter rendering need a backing buffer for
the overhang pixel for quarter rendering (which is rounded to next even
pixel).

Issues #115
  • Loading branch information
hzeller committed Aug 16, 2023
1 parent 564e9e2 commit 2e9414e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/unicode-block-canvas.cc
Original file line number Diff line number Diff line change
Expand Up @@ -419,13 +419,14 @@ char *UnicodeBlockCanvas::RequestBuffers(int width, int height) {
+ SCREEN_END_OF_LINE_LEN); // Finishing a line.

// Depending on even/odd situation, we might need one extra row.
const size_t new_backing = width * (height + 1) * sizeof(rgba_t);
// For quarter, we have one extra possible pixel wider.
const size_t new_backing = (width + 1) * (height + 1) * sizeof(rgba_t);
if (new_backing > backing_buffer_size_) {
backing_buffer_ = (rgba_t *)realloc(backing_buffer_, new_backing);
backing_buffer_size_ = new_backing;
}

const size_t new_empty = width * sizeof(rgba_t);
const size_t new_empty = (width + 1) * sizeof(rgba_t);
if (new_empty > empty_line_size_) {
empty_line_ = (rgba_t *)realloc(empty_line_, new_empty);
empty_line_size_ = new_empty;
Expand Down

0 comments on commit 2e9414e

Please sign in to comment.