Skip to content

Commit e02c737

Browse files
authored
Return early if blit got zero width or height (#161)
1 parent bdb42bf commit e02c737

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ All notable changes to this project will be documented in this file, in reverse
88
- Wrong image guard in `image.h` ([#113](https://github.com/tuupola/hagl/pull/113)).
99
- Filled polygon rendered incorrectly with negative x coordinates ([#122](https://github.com/tuupola/hagl/pull/122)).
1010
- Polygon and rectangle output did not match ([#123](https://github.com/tuupola/hagl/pull/123), [#124](https://github.com/tuupola/hagl/pull/124)).
11-
- Horizontal and vertical line parameters are now sorted ([#125](https://github.com/tuupola/hagl/pull/125)).
11+
- Horizontal and vertical line parameters are now sorted ([#125](https://github.com/tuupola/hagl/pull/125), [#121](https://github.com/tuupola/hagl/issues/121)).
1212
- Filled circle with radius of one did not produce correct output ([#145](https://github.com/tuupola/hagl/pull/145), [#144](https://github.com/tuupola/hagl/issues/144)).
1313
- Circle with zero radius did not produce a single pixel ([#146](https://github.com/tuupola/hagl/pull/146), [#140](https://github.com/tuupola/hagl/issues/140)).
1414
- Surface callbacks received pointer-to-pointer instead of pointer-to-struct ([#147](https://github.com/tuupola/hagl/pull/147)).

include/hagl/blit.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ static void inline hagl_blit(
7171
void const *surface, int16_t x0, int16_t y0, hagl_bitmap_t *source
7272
) {
7373
hagl_blit_xy(surface, x0, y0, source);
74-
};
74+
}
7575

7676
/**
7777
* Blit and scale a bitmap to a surface
@@ -111,7 +111,7 @@ static void inline hagl_blit_xyxy(
111111
uint16_t max_x = (x0 > x1) ? x0 : x1;
112112
uint16_t max_y = (y0 > y1) ? y0 : y1;
113113
hagl_blit_xywh(surface, min_x, min_y, max_x - min_x + 1, max_y - min_y + 1, source);
114-
};
114+
}
115115

116116
#ifdef __cplusplus
117117
}

src/hagl_blit.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,18 @@ void hagl_blit_xy(void const *_surface, int16_t x0, int16_t y0, hagl_bitmap_t *s
7272
}
7373
}
7474
}
75-
};
75+
}
7676

7777
void hagl_blit_xywh(
7878
void const *_surface, uint16_t x0, uint16_t y0, uint16_t w, uint16_t h,
7979
hagl_bitmap_t *source
8080
) {
8181
const hagl_surface_t *surface = _surface;
8282

83+
if (0 == w || 0 == h) {
84+
return;
85+
}
86+
8387
if (surface->scale_blit) {
8488
surface->scale_blit((void *)_surface, x0, y0, w, h, source);
8589
} else {
@@ -97,4 +101,4 @@ void hagl_blit_xywh(
97101
}
98102
}
99103
}
100-
};
104+
}

0 commit comments

Comments
 (0)