diff options
author | Vincent Sanders <vince@kyllikki.org> | 2015-04-13 23:19:04 +0100 |
---|---|---|
committer | Vincent Sanders <vince@kyllikki.org> | 2015-04-13 23:19:04 +0100 |
commit | f37e52c39475e6efd3740c5ae1ec4f290662928f (patch) | |
tree | 88d01618e903975743a3cb74bff9bf8df54c2a45 /image/png.c | |
parent | 7a28131e4953934150967eb7886bc06678e249e8 (diff) | |
download | netsurf-f37e52c39475e6efd3740c5ae1ec4f290662928f.tar.gz netsurf-f37e52c39475e6efd3740c5ae1ec4f290662928f.tar.bz2 |
Move bitmap operations into an operation table.
The generic bitmap handlers provided by each frontend are called back
from the core and therefore should be in an operation table. This was
one of the very few remaining interfaces stopping the core code from
being split into a library.
Diffstat (limited to 'image/png.c')
-rw-r--r-- | image/png.c | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/image/png.c b/image/png.c index acf375e14..de2059f5a 100644 --- a/image/png.c +++ b/image/png.c @@ -18,25 +18,19 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <assert.h> #include <stdbool.h> -#include <string.h> #include <stdlib.h> - #include <png.h> -#include "desktop/plotters.h" - +#include "utils/log.h" +#include "utils/messages.h" #include "content/content_protected.h" +#include "desktop/gui_internal.h" -#include "image/bitmap.h" #include "image/image_cache.h" +#include "image/bitmap.h" #include "image/png.h" -#include "utils/log.h" -#include "utils/messages.h" -#include "utils/utils.h" - /* accommodate for old versions of libpng (beware security holes!) */ #ifndef png_jmpbuf @@ -164,14 +158,14 @@ static void info_callback(png_structp png_s, png_infop info) } /* Claim the required memory for the converted PNG */ - png_c->bitmap = bitmap_create(width, height, BITMAP_NEW); + png_c->bitmap = guit->bitmap->create(width, height, BITMAP_NEW); if (png_c->bitmap == NULL) { /* Failed to create bitmap skip pre-conversion */ longjmp(png_jmpbuf(png_s), CBERR_NOPRE); } - png_c->rowstride = bitmap_get_rowstride(png_c->bitmap); - png_c->bpp = bitmap_get_bpp(png_c->bitmap); + png_c->rowstride = guit->bitmap->get_rowstride(png_c->bitmap); + png_c->bpp = guit->bitmap->get_bpp(png_c->bitmap); nspng_setup_transforms(png_s, info); @@ -198,7 +192,7 @@ static void row_callback(png_structp png_s, png_bytep new_row, return; /* Get bitmap buffer */ - buffer = bitmap_get_buffer(png_c->bitmap); + buffer = guit->bitmap->get_buffer(png_c->bitmap); if (buffer == NULL) { /* No buffer, bail out */ longjmp(png_jmpbuf(png_s), 1); @@ -404,9 +398,9 @@ png_cache_read_fn(png_structp png_ptr, png_bytep data, png_size_t length) */ static png_bytep *calc_row_pointers(struct bitmap *bitmap) { - int height = bitmap_get_height(bitmap); - unsigned char *buffer= bitmap_get_buffer(bitmap); - size_t rowstride = bitmap_get_rowstride(bitmap); + int height = guit->bitmap->get_height(bitmap); + unsigned char *buffer= guit->bitmap->get_buffer(bitmap); + size_t rowstride = guit->bitmap->get_rowstride(bitmap); png_bytep *row_ptrs; int hloop; @@ -481,7 +475,7 @@ png_cache_convert(struct content *c) height = png_get_image_height(png_ptr, info_ptr); /* Claim the required memory for the converted PNG */ - bitmap = bitmap_create(width, height, BITMAP_NEW); + bitmap = guit->bitmap->create(width, height, BITMAP_NEW); if (bitmap == NULL) { /* cleanup and bail */ goto png_cache_convert_error; @@ -500,8 +494,9 @@ png_cache_convert_error: free((png_bytep *) row_pointers); - if (bitmap != NULL) - bitmap_modified((struct bitmap *)bitmap); + if (bitmap != NULL) { + guit->bitmap->modified((struct bitmap *)bitmap); + } return (struct bitmap *)bitmap; } @@ -527,8 +522,8 @@ static bool nspng_convert(struct content *c) } if (png_c->bitmap != NULL) { - bitmap_set_opaque(png_c->bitmap, bitmap_test_opaque(png_c->bitmap)); - bitmap_modified(png_c->bitmap); + guit->bitmap->set_opaque(png_c->bitmap, guit->bitmap->test_opaque(png_c->bitmap)); + guit->bitmap->modified(png_c->bitmap); } image_cache_add(c, png_c->bitmap, png_cache_convert); |