2006-02-26 05:25:19 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2006 Richard Wilson <info@tinct.net>
|
2007-08-08 20:16:03 +04:00
|
|
|
*
|
|
|
|
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
|
|
|
*
|
|
|
|
* NetSurf is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* NetSurf is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2006-02-26 05:25:19 +03:00
|
|
|
*/
|
|
|
|
|
2008-08-24 19:44:29 +04:00
|
|
|
/** \file
|
|
|
|
* Content for image/ico (implementation)
|
|
|
|
*/
|
|
|
|
|
2006-02-26 05:25:19 +03:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdlib.h>
|
Merged revisions 4345-4346,4350-4351,4389,4391,4395,4401-4403,4423,4485-4486 via svnmerge from
svn://semichrome.net/branches/dynis/netsurf
........
r4345 | dynis | 2008-06-15 18:37:23 -0500 (Sun, 15 Jun 2008) | 1 line
Move NetSurf's gifread.h to libnsgif
........
r4346 | dynis | 2008-06-15 18:38:38 -0500 (Sun, 15 Jun 2008) | 1 line
Remove NetSurf's gifread.c (replaced by libnsgif)
........
r4350 | dynis | 2008-06-15 18:57:17 -0500 (Sun, 15 Jun 2008) | 1 line
Added references to libnsgif where necessary; corrected function calls where callbacks were implemented
........
r4351 | dynis | 2008-06-15 19:00:33 -0500 (Sun, 15 Jun 2008) | 1 line
Updated Makefile to compile with libnsgif
........
r4389 | dynis | 2008-06-18 13:58:51 -0500 (Wed, 18 Jun 2008) | 1 line
Altered bitmap callback table name for gif images to avoid ambiguity when bmp image library is created
........
r4391 | dynis | 2008-06-18 14:08:39 -0500 (Wed, 18 Jun 2008) | 1 line
Updated netsurf branch to use new bitmap callback table structure name that was altered in libnsgif
........
r4395 | dynis | 2008-06-18 14:54:51 -0500 (Wed, 18 Jun 2008) | 1 line
Corrected param comments for bitmap_set_suspendable()
........
r4401 | dynis | 2008-06-18 18:39:50 -0500 (Wed, 18 Jun 2008) | 1 line
Added references to libnsbmp where necessary; corrected function calls where callbacks were implemented
........
r4402 | dynis | 2008-06-18 18:40:47 -0500 (Wed, 18 Jun 2008) | 1 line
Updated Makefile to compile with libnsbmp
........
r4403 | dynis | 2008-06-18 18:41:53 -0500 (Wed, 18 Jun 2008) | 1 line
Remove NetSurf's bmpread.c and bmpread.h (replaced by libnsbmp)
........
r4423 | dynis | 2008-06-22 14:21:30 -0500 (Sun, 22 Jun 2008) | 1 line
Correct a silly mistake in nsbmp_bitmap_create
........
r4485 | dynis | 2008-07-01 04:13:48 -0500 (Tue, 01 Jul 2008) | 1 line
Integrated the latest versions of libnsgif and libnsbmp into NetSurf
........
r4486 | dynis | 2008-07-01 05:27:10 -0500 (Tue, 01 Jul 2008) | 1 line
Altered bitmap functions to receive void pointers for proper utilisation of libnsgif and libnsbmp
........
svn path=/trunk/netsurf/; revision=5071
2008-08-12 07:49:34 +04:00
|
|
|
#include <libnsbmp.h>
|
2015-04-14 01:19:04 +03:00
|
|
|
|
2016-04-20 01:20:29 +03:00
|
|
|
#include "utils/utils.h"
|
2015-04-14 01:19:04 +03:00
|
|
|
#include "utils/log.h"
|
|
|
|
#include "utils/messages.h"
|
2016-06-06 10:59:23 +03:00
|
|
|
#include "netsurf/bitmap.h"
|
|
|
|
#include "netsurf/content.h"
|
|
|
|
#include "content/llcache.h"
|
2010-03-28 16:56:39 +04:00
|
|
|
#include "content/content_protected.h"
|
2015-04-14 01:19:04 +03:00
|
|
|
#include "desktop/gui_internal.h"
|
|
|
|
|
2016-06-06 16:47:27 +03:00
|
|
|
#include "image/image.h"
|
|
|
|
#include "image/ico.h"
|
2006-02-26 05:25:19 +03:00
|
|
|
|
2011-05-07 00:40:09 +04:00
|
|
|
typedef struct nsico_content {
|
|
|
|
struct content base;
|
|
|
|
|
|
|
|
struct ico_collection *ico; /** ICO collection data */
|
2011-08-31 16:12:41 +04:00
|
|
|
|
2011-05-07 00:40:09 +04:00
|
|
|
} nsico_content;
|
|
|
|
|
2015-04-14 01:19:04 +03:00
|
|
|
/**
|
|
|
|
* Callback for libnsbmp; forwards the call to bitmap_create()
|
|
|
|
*
|
|
|
|
* \param width width of image in pixels
|
|
|
|
* \param height width of image in pixels
|
2015-06-19 11:07:31 +03:00
|
|
|
* \param bmp_state A flag word indicating the initial state
|
2015-04-14 01:19:04 +03:00
|
|
|
* \return an opaque struct bitmap, or NULL on memory exhaustion
|
|
|
|
*/
|
|
|
|
static void *nsico_bitmap_create(int width, int height, unsigned int bmp_state)
|
|
|
|
{
|
|
|
|
unsigned int bitmap_state = BITMAP_NEW;
|
|
|
|
|
|
|
|
/* set bitmap state based on bmp state */
|
|
|
|
bitmap_state |= (bmp_state & BMP_OPAQUE) ? BITMAP_OPAQUE : 0;
|
|
|
|
bitmap_state |= (bmp_state & BMP_CLEAR_MEMORY) ?
|
|
|
|
BITMAP_CLEAR_MEMORY : 0;
|
|
|
|
|
|
|
|
/* return the created bitmap */
|
|
|
|
return guit->bitmap->create(width, height, bitmap_state);
|
|
|
|
}
|
2011-05-07 00:40:09 +04:00
|
|
|
|
2011-05-08 23:54:35 +04:00
|
|
|
static nserror nsico_create_ico_data(nsico_content *c)
|
|
|
|
{
|
2015-04-14 01:19:04 +03:00
|
|
|
bmp_bitmap_callback_vt bmp_bitmap_callbacks = {
|
|
|
|
.bitmap_create = nsico_bitmap_create,
|
|
|
|
.bitmap_destroy = guit->bitmap->destroy,
|
|
|
|
.bitmap_get_buffer = guit->bitmap->get_buffer,
|
|
|
|
.bitmap_get_bpp = guit->bitmap->get_bpp
|
|
|
|
};
|
2011-05-07 00:40:09 +04:00
|
|
|
|
2011-05-08 23:54:35 +04:00
|
|
|
c->ico = calloc(sizeof(ico_collection), 1);
|
|
|
|
if (c->ico == NULL) {
|
2019-08-05 17:25:15 +03:00
|
|
|
content_broadcast_error(&c->base, NSERROR_NOMEM, NULL);
|
2011-05-08 23:54:35 +04:00
|
|
|
return NSERROR_NOMEM;
|
2011-05-07 00:40:09 +04:00
|
|
|
}
|
2011-05-08 23:54:35 +04:00
|
|
|
ico_collection_create(c->ico, &bmp_bitmap_callbacks);
|
2011-05-07 00:40:09 +04:00
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-05-08 23:54:35 +04:00
|
|
|
static nserror nsico_create(const content_handler *handler,
|
2011-05-07 00:40:09 +04:00
|
|
|
lwc_string *imime_type, const struct http_parameter *params,
|
|
|
|
llcache_handle *llcache, const char *fallback_charset,
|
|
|
|
bool quirks, struct content **c)
|
|
|
|
{
|
|
|
|
nsico_content *result;
|
|
|
|
nserror error;
|
|
|
|
|
2012-10-03 22:24:58 +04:00
|
|
|
result = calloc(1, sizeof(nsico_content));
|
2011-05-07 00:40:09 +04:00
|
|
|
if (result == NULL)
|
|
|
|
return NSERROR_NOMEM;
|
|
|
|
|
|
|
|
error = content__init(&result->base, handler, imime_type, params,
|
|
|
|
llcache, fallback_charset, quirks);
|
|
|
|
if (error != NSERROR_OK) {
|
2012-10-03 22:24:58 +04:00
|
|
|
free(result);
|
2011-05-07 00:40:09 +04:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = nsico_create_ico_data(result);
|
|
|
|
if (error != NSERROR_OK) {
|
2012-10-03 22:24:58 +04:00
|
|
|
free(result);
|
2011-05-07 00:40:09 +04:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
*c = (struct content *) result;
|
|
|
|
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
2006-02-26 05:25:19 +03:00
|
|
|
|
|
|
|
|
2011-05-08 23:54:35 +04:00
|
|
|
static bool nsico_convert(struct content *c)
|
2008-08-24 19:44:29 +04:00
|
|
|
{
|
2011-05-07 00:40:09 +04:00
|
|
|
nsico_content *ico = (nsico_content *) c;
|
2006-02-26 05:25:19 +03:00
|
|
|
struct bmp_image *bmp;
|
|
|
|
bmp_result res;
|
2019-05-06 00:46:40 +03:00
|
|
|
const uint8_t *data;
|
|
|
|
size_t size;
|
2012-10-25 14:12:41 +04:00
|
|
|
char *title;
|
2006-02-26 05:25:19 +03:00
|
|
|
|
Merged revisions 4345-4346,4350-4351,4389,4391,4395,4401-4403,4423,4485-4486 via svnmerge from
svn://semichrome.net/branches/dynis/netsurf
........
r4345 | dynis | 2008-06-15 18:37:23 -0500 (Sun, 15 Jun 2008) | 1 line
Move NetSurf's gifread.h to libnsgif
........
r4346 | dynis | 2008-06-15 18:38:38 -0500 (Sun, 15 Jun 2008) | 1 line
Remove NetSurf's gifread.c (replaced by libnsgif)
........
r4350 | dynis | 2008-06-15 18:57:17 -0500 (Sun, 15 Jun 2008) | 1 line
Added references to libnsgif where necessary; corrected function calls where callbacks were implemented
........
r4351 | dynis | 2008-06-15 19:00:33 -0500 (Sun, 15 Jun 2008) | 1 line
Updated Makefile to compile with libnsgif
........
r4389 | dynis | 2008-06-18 13:58:51 -0500 (Wed, 18 Jun 2008) | 1 line
Altered bitmap callback table name for gif images to avoid ambiguity when bmp image library is created
........
r4391 | dynis | 2008-06-18 14:08:39 -0500 (Wed, 18 Jun 2008) | 1 line
Updated netsurf branch to use new bitmap callback table structure name that was altered in libnsgif
........
r4395 | dynis | 2008-06-18 14:54:51 -0500 (Wed, 18 Jun 2008) | 1 line
Corrected param comments for bitmap_set_suspendable()
........
r4401 | dynis | 2008-06-18 18:39:50 -0500 (Wed, 18 Jun 2008) | 1 line
Added references to libnsbmp where necessary; corrected function calls where callbacks were implemented
........
r4402 | dynis | 2008-06-18 18:40:47 -0500 (Wed, 18 Jun 2008) | 1 line
Updated Makefile to compile with libnsbmp
........
r4403 | dynis | 2008-06-18 18:41:53 -0500 (Wed, 18 Jun 2008) | 1 line
Remove NetSurf's bmpread.c and bmpread.h (replaced by libnsbmp)
........
r4423 | dynis | 2008-06-22 14:21:30 -0500 (Sun, 22 Jun 2008) | 1 line
Correct a silly mistake in nsbmp_bitmap_create
........
r4485 | dynis | 2008-07-01 04:13:48 -0500 (Tue, 01 Jul 2008) | 1 line
Integrated the latest versions of libnsgif and libnsbmp into NetSurf
........
r4486 | dynis | 2008-07-01 05:27:10 -0500 (Tue, 01 Jul 2008) | 1 line
Altered bitmap functions to receive void pointers for proper utilisation of libnsgif and libnsbmp
........
svn path=/trunk/netsurf/; revision=5071
2008-08-12 07:49:34 +04:00
|
|
|
/* set the ico data */
|
2010-03-28 16:56:39 +04:00
|
|
|
data = content__get_source_data(c, &size);
|
|
|
|
|
Merged revisions 4345-4346,4350-4351,4389,4391,4395,4401-4403,4423,4485-4486 via svnmerge from
svn://semichrome.net/branches/dynis/netsurf
........
r4345 | dynis | 2008-06-15 18:37:23 -0500 (Sun, 15 Jun 2008) | 1 line
Move NetSurf's gifread.h to libnsgif
........
r4346 | dynis | 2008-06-15 18:38:38 -0500 (Sun, 15 Jun 2008) | 1 line
Remove NetSurf's gifread.c (replaced by libnsgif)
........
r4350 | dynis | 2008-06-15 18:57:17 -0500 (Sun, 15 Jun 2008) | 1 line
Added references to libnsgif where necessary; corrected function calls where callbacks were implemented
........
r4351 | dynis | 2008-06-15 19:00:33 -0500 (Sun, 15 Jun 2008) | 1 line
Updated Makefile to compile with libnsgif
........
r4389 | dynis | 2008-06-18 13:58:51 -0500 (Wed, 18 Jun 2008) | 1 line
Altered bitmap callback table name for gif images to avoid ambiguity when bmp image library is created
........
r4391 | dynis | 2008-06-18 14:08:39 -0500 (Wed, 18 Jun 2008) | 1 line
Updated netsurf branch to use new bitmap callback table structure name that was altered in libnsgif
........
r4395 | dynis | 2008-06-18 14:54:51 -0500 (Wed, 18 Jun 2008) | 1 line
Corrected param comments for bitmap_set_suspendable()
........
r4401 | dynis | 2008-06-18 18:39:50 -0500 (Wed, 18 Jun 2008) | 1 line
Added references to libnsbmp where necessary; corrected function calls where callbacks were implemented
........
r4402 | dynis | 2008-06-18 18:40:47 -0500 (Wed, 18 Jun 2008) | 1 line
Updated Makefile to compile with libnsbmp
........
r4403 | dynis | 2008-06-18 18:41:53 -0500 (Wed, 18 Jun 2008) | 1 line
Remove NetSurf's bmpread.c and bmpread.h (replaced by libnsbmp)
........
r4423 | dynis | 2008-06-22 14:21:30 -0500 (Sun, 22 Jun 2008) | 1 line
Correct a silly mistake in nsbmp_bitmap_create
........
r4485 | dynis | 2008-07-01 04:13:48 -0500 (Tue, 01 Jul 2008) | 1 line
Integrated the latest versions of libnsgif and libnsbmp into NetSurf
........
r4486 | dynis | 2008-07-01 05:27:10 -0500 (Tue, 01 Jul 2008) | 1 line
Altered bitmap functions to receive void pointers for proper utilisation of libnsgif and libnsbmp
........
svn path=/trunk/netsurf/; revision=5071
2008-08-12 07:49:34 +04:00
|
|
|
/* analyse the ico */
|
2011-05-07 00:40:09 +04:00
|
|
|
res = ico_analyse(ico->ico, size, (unsigned char *) data);
|
2008-08-24 19:44:29 +04:00
|
|
|
|
2006-02-26 05:25:19 +03:00
|
|
|
switch (res) {
|
2010-03-28 16:56:39 +04:00
|
|
|
case BMP_OK:
|
|
|
|
break;
|
|
|
|
case BMP_INSUFFICIENT_MEMORY:
|
2019-08-05 17:25:15 +03:00
|
|
|
content_broadcast_error(c, NSERROR_NOMEM, NULL);
|
2010-03-28 16:56:39 +04:00
|
|
|
return false;
|
|
|
|
case BMP_INSUFFICIENT_DATA:
|
|
|
|
case BMP_DATA_ERROR:
|
2019-08-05 17:25:15 +03:00
|
|
|
content_broadcast_error(c, NSERROR_ICO_ERROR, NULL);
|
2010-03-28 16:56:39 +04:00
|
|
|
return false;
|
2006-02-26 05:25:19 +03:00
|
|
|
}
|
|
|
|
|
2012-10-25 14:12:41 +04:00
|
|
|
/* Store our content width, height and calculate size */
|
2011-05-07 00:40:09 +04:00
|
|
|
c->width = ico->ico->width;
|
|
|
|
c->height = ico->ico->height;
|
2012-10-25 14:12:41 +04:00
|
|
|
c->size += (ico->ico->width * ico->ico->height * 4) + 16 + 44;
|
|
|
|
|
|
|
|
/* set title text */
|
|
|
|
title = messages_get_buff("ICOTitle",
|
2012-10-24 21:22:45 +04:00
|
|
|
nsurl_access_leaf(llcache_handle_get_url(c->llcache)),
|
|
|
|
c->width, c->height);
|
2012-10-25 14:12:41 +04:00
|
|
|
if (title != NULL) {
|
|
|
|
content__set_title(c, title);
|
|
|
|
free(title);
|
|
|
|
}
|
2006-02-26 05:25:19 +03:00
|
|
|
|
2011-12-30 23:37:15 +04:00
|
|
|
/* select largest icon to ensure one can be selected */
|
2011-05-07 00:40:09 +04:00
|
|
|
bmp = ico_find(ico->ico, 255, 255);
|
2011-12-30 23:37:15 +04:00
|
|
|
if (bmp == NULL) {
|
|
|
|
/* return error */
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "Failed to select icon");
|
2011-12-30 23:37:15 +04:00
|
|
|
return false;
|
|
|
|
}
|
2011-02-27 23:11:39 +03:00
|
|
|
|
|
|
|
content_set_ready(c);
|
|
|
|
content_set_done(c);
|
2008-10-11 00:54:49 +04:00
|
|
|
|
2008-03-10 15:41:41 +03:00
|
|
|
/* Done: update status bar */
|
|
|
|
content_set_status(c, "");
|
2006-02-26 05:25:19 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-29 00:17:39 +04:00
|
|
|
static bool nsico_redraw(struct content *c, struct content_redraw_data *data,
|
2011-06-30 19:48:07 +04:00
|
|
|
const struct rect *clip, const struct redraw_context *ctx)
|
2008-08-24 19:44:29 +04:00
|
|
|
{
|
2011-12-30 23:37:15 +04:00
|
|
|
nsico_content *ico = (nsico_content *)c;
|
|
|
|
struct bmp_image *bmp;
|
|
|
|
|
|
|
|
/* select most appropriate sized icon for size */
|
|
|
|
bmp = ico_find(ico->ico, data->width, data->height);
|
2011-12-31 16:57:47 +04:00
|
|
|
if (bmp == NULL) {
|
|
|
|
/* return error */
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "Failed to select icon");
|
2011-12-31 16:57:47 +04:00
|
|
|
return false;
|
|
|
|
}
|
2009-06-30 17:02:23 +04:00
|
|
|
|
2011-12-30 23:37:15 +04:00
|
|
|
/* ensure its decided */
|
2011-10-08 04:18:16 +04:00
|
|
|
if (bmp->decoded == false) {
|
2011-12-30 23:37:15 +04:00
|
|
|
if (bmp_decode(bmp) != BMP_OK) {
|
Merged revisions 4345-4346,4350-4351,4389,4391,4395,4401-4403,4423,4485-4486 via svnmerge from
svn://semichrome.net/branches/dynis/netsurf
........
r4345 | dynis | 2008-06-15 18:37:23 -0500 (Sun, 15 Jun 2008) | 1 line
Move NetSurf's gifread.h to libnsgif
........
r4346 | dynis | 2008-06-15 18:38:38 -0500 (Sun, 15 Jun 2008) | 1 line
Remove NetSurf's gifread.c (replaced by libnsgif)
........
r4350 | dynis | 2008-06-15 18:57:17 -0500 (Sun, 15 Jun 2008) | 1 line
Added references to libnsgif where necessary; corrected function calls where callbacks were implemented
........
r4351 | dynis | 2008-06-15 19:00:33 -0500 (Sun, 15 Jun 2008) | 1 line
Updated Makefile to compile with libnsgif
........
r4389 | dynis | 2008-06-18 13:58:51 -0500 (Wed, 18 Jun 2008) | 1 line
Altered bitmap callback table name for gif images to avoid ambiguity when bmp image library is created
........
r4391 | dynis | 2008-06-18 14:08:39 -0500 (Wed, 18 Jun 2008) | 1 line
Updated netsurf branch to use new bitmap callback table structure name that was altered in libnsgif
........
r4395 | dynis | 2008-06-18 14:54:51 -0500 (Wed, 18 Jun 2008) | 1 line
Corrected param comments for bitmap_set_suspendable()
........
r4401 | dynis | 2008-06-18 18:39:50 -0500 (Wed, 18 Jun 2008) | 1 line
Added references to libnsbmp where necessary; corrected function calls where callbacks were implemented
........
r4402 | dynis | 2008-06-18 18:40:47 -0500 (Wed, 18 Jun 2008) | 1 line
Updated Makefile to compile with libnsbmp
........
r4403 | dynis | 2008-06-18 18:41:53 -0500 (Wed, 18 Jun 2008) | 1 line
Remove NetSurf's bmpread.c and bmpread.h (replaced by libnsbmp)
........
r4423 | dynis | 2008-06-22 14:21:30 -0500 (Sun, 22 Jun 2008) | 1 line
Correct a silly mistake in nsbmp_bitmap_create
........
r4485 | dynis | 2008-07-01 04:13:48 -0500 (Tue, 01 Jul 2008) | 1 line
Integrated the latest versions of libnsgif and libnsbmp into NetSurf
........
r4486 | dynis | 2008-07-01 05:27:10 -0500 (Tue, 01 Jul 2008) | 1 line
Altered bitmap functions to receive void pointers for proper utilisation of libnsgif and libnsbmp
........
svn path=/trunk/netsurf/; revision=5071
2008-08-12 07:49:34 +04:00
|
|
|
return false;
|
2011-12-30 23:37:15 +04:00
|
|
|
} else {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "Decoding bitmap");
|
2015-04-14 01:19:04 +03:00
|
|
|
guit->bitmap->modified(bmp->bitmap);
|
2011-12-30 23:37:15 +04:00
|
|
|
}
|
2009-06-30 17:02:23 +04:00
|
|
|
|
2011-12-30 23:37:15 +04:00
|
|
|
}
|
2009-06-30 17:02:23 +04:00
|
|
|
|
2011-12-30 23:37:15 +04:00
|
|
|
return image_bitmap_plot(bmp->bitmap, data, clip, ctx);
|
2006-02-26 05:25:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-05-08 23:54:35 +04:00
|
|
|
static void nsico_destroy(struct content *c)
|
2006-02-26 05:25:19 +03:00
|
|
|
{
|
2011-05-07 00:40:09 +04:00
|
|
|
nsico_content *ico = (nsico_content *) c;
|
|
|
|
|
|
|
|
ico_finalise(ico->ico);
|
|
|
|
free(ico->ico);
|
2006-02-26 05:25:19 +03:00
|
|
|
}
|
|
|
|
|
2011-05-08 23:54:35 +04:00
|
|
|
static nserror nsico_clone(const struct content *old, struct content **newc)
|
2010-04-04 16:41:19 +04:00
|
|
|
{
|
2011-05-07 00:40:09 +04:00
|
|
|
nsico_content *ico;
|
|
|
|
nserror error;
|
|
|
|
|
2012-10-03 22:24:58 +04:00
|
|
|
ico = calloc(1, sizeof(nsico_content));
|
2011-05-07 00:40:09 +04:00
|
|
|
if (ico == NULL)
|
|
|
|
return NSERROR_NOMEM;
|
|
|
|
|
|
|
|
error = content__clone(old, &ico->base);
|
|
|
|
if (error != NSERROR_OK) {
|
|
|
|
content_destroy(&ico->base);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2010-04-04 16:41:19 +04:00
|
|
|
/* Simply replay creation and conversion */
|
2011-05-07 00:40:09 +04:00
|
|
|
error = nsico_create_ico_data(ico);
|
|
|
|
if (error != NSERROR_OK) {
|
|
|
|
content_destroy(&ico->base);
|
|
|
|
return error;
|
|
|
|
}
|
2010-04-04 16:41:19 +04:00
|
|
|
|
|
|
|
if (old->status == CONTENT_STATUS_READY ||
|
|
|
|
old->status == CONTENT_STATUS_DONE) {
|
2011-05-07 00:40:09 +04:00
|
|
|
if (nsico_convert(&ico->base) == false) {
|
|
|
|
content_destroy(&ico->base);
|
|
|
|
return NSERROR_CLONE_FAILED;
|
|
|
|
}
|
2010-04-04 16:41:19 +04:00
|
|
|
}
|
|
|
|
|
2011-05-07 00:40:09 +04:00
|
|
|
*newc = (struct content *) ico;
|
|
|
|
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
2011-08-31 16:12:41 +04:00
|
|
|
static void *nsico_get_internal(const struct content *c, void *context)
|
|
|
|
{
|
|
|
|
nsico_content *ico = (nsico_content *) c;
|
2011-10-08 01:56:17 +04:00
|
|
|
/* TODO: Pick best size for purpose.
|
|
|
|
* Currently assumes it's for a URL bar. */
|
2011-12-31 16:57:47 +04:00
|
|
|
struct bmp_image *bmp;
|
|
|
|
|
|
|
|
bmp = ico_find(ico->ico, 16, 16);
|
|
|
|
if (bmp == NULL) {
|
|
|
|
/* return error */
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "Failed to select icon");
|
2011-12-31 16:57:47 +04:00
|
|
|
return NULL;
|
|
|
|
}
|
2011-10-07 23:39:52 +04:00
|
|
|
|
2011-10-08 04:18:16 +04:00
|
|
|
if (bmp->decoded == false) {
|
2011-12-30 23:37:15 +04:00
|
|
|
if (bmp_decode(bmp) != BMP_OK) {
|
2011-10-07 23:39:52 +04:00
|
|
|
return NULL;
|
2011-12-30 23:37:15 +04:00
|
|
|
} else {
|
2015-04-14 01:19:04 +03:00
|
|
|
guit->bitmap->modified(bmp->bitmap);
|
2011-12-30 23:37:15 +04:00
|
|
|
}
|
2011-10-08 04:18:16 +04:00
|
|
|
}
|
2011-10-07 23:39:52 +04:00
|
|
|
|
2011-12-30 23:37:15 +04:00
|
|
|
return bmp->bitmap;
|
2011-08-31 16:12:41 +04:00
|
|
|
}
|
|
|
|
|
2011-09-03 13:27:42 +04:00
|
|
|
static content_type nsico_content_type(void)
|
2011-05-07 00:40:09 +04:00
|
|
|
{
|
|
|
|
return CONTENT_IMAGE;
|
2010-04-04 16:41:19 +04:00
|
|
|
}
|
|
|
|
|
2011-05-08 23:54:35 +04:00
|
|
|
static const content_handler nsico_content_handler = {
|
2011-05-09 19:32:34 +04:00
|
|
|
.create = nsico_create,
|
|
|
|
.data_complete = nsico_convert,
|
|
|
|
.destroy = nsico_destroy,
|
|
|
|
.redraw = nsico_redraw,
|
|
|
|
.clone = nsico_clone,
|
2011-08-31 16:12:41 +04:00
|
|
|
.get_internal = nsico_get_internal,
|
2011-05-09 19:32:34 +04:00
|
|
|
.type = nsico_content_type,
|
|
|
|
.no_share = false,
|
2011-05-08 23:54:35 +04:00
|
|
|
};
|
|
|
|
|
2011-08-27 12:43:51 +04:00
|
|
|
static const char *nsico_types[] = {
|
|
|
|
"application/ico",
|
|
|
|
"application/x-ico",
|
|
|
|
"image/ico",
|
|
|
|
"image/vnd.microsoft.icon",
|
|
|
|
"image/x-icon"
|
|
|
|
};
|
2011-05-08 23:54:35 +04:00
|
|
|
|
2011-08-27 12:43:51 +04:00
|
|
|
CONTENT_FACTORY_REGISTER_TYPES(nsico, nsico_types, nsico_content_handler);
|