diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2022-03-29 15:25:33 +0100 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2022-03-29 15:25:33 +0100 |
commit | 8e56cc3b1a0d9d18e35811a015cf42b57ede1025 (patch) | |
tree | c3ec6fc87924e500e168986a6921f6bff93cd280 /desktop | |
parent | cfbd16cf7ea3335b7ac75989c4ffa63306224dfc (diff) | |
download | netsurf-8e56cc3b1a0d9d18e35811a015cf42b57ede1025.tar.gz netsurf-8e56cc3b1a0d9d18e35811a015cf42b57ede1025.tar.bz2 |
Bitmap: Implement test_opaque in core instead of in every frontend.
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/bitmap.c | 25 | ||||
-rw-r--r-- | desktop/gui_factory.c | 4 |
2 files changed, 25 insertions, 4 deletions
diff --git a/desktop/bitmap.c b/desktop/bitmap.c index acbd22e41..0602773ca 100644 --- a/desktop/bitmap.c +++ b/desktop/bitmap.c @@ -311,3 +311,28 @@ void bitmap_format_convert(void *bitmap, } } } + +/* Exported function, documented in desktop/bitmap.h */ +bool bitmap_test_opaque(void *bitmap) +{ + int width = guit->bitmap->get_width(bitmap); + int height = guit->bitmap->get_height(bitmap); + size_t rowstride = guit->bitmap->get_rowstride(bitmap); + const uint8_t *buffer = guit->bitmap->get_buffer(bitmap); + + width *= sizeof(uint32_t); + + for (int y = 0; y < height; y++) { + const uint8_t *row = buffer; + + for (int x = bitmap_layout.a; x < width; x += 4) { + if (row[x] != 0xff) { + return false; + } + } + + buffer += rowstride; + } + + return true; +} diff --git a/desktop/gui_factory.c b/desktop/gui_factory.c index cddafa09d..89f2e373f 100644 --- a/desktop/gui_factory.c +++ b/desktop/gui_factory.c @@ -560,10 +560,6 @@ static nserror verify_bitmap_register(struct gui_bitmap_table *gbt) return NSERROR_BAD_PARAMETER; } - if (gbt->test_opaque == NULL) { - return NSERROR_BAD_PARAMETER; - } - if (gbt->get_buffer == NULL) { return NSERROR_BAD_PARAMETER; } |