mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-23 04:26:50 +03:00
More style guide formatting and tidy up.
svn path=/trunk/netsurf/; revision=5195
This commit is contained in:
parent
01ff577a66
commit
04c04d98b8
33
image/bmp.c
33
image/bmp.c
@ -17,6 +17,10 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/** \file
|
||||||
|
* Content for image/bmp (implementation)
|
||||||
|
*/
|
||||||
|
|
||||||
#include "utils/config.h"
|
#include "utils/config.h"
|
||||||
#ifdef WITH_BMP
|
#ifdef WITH_BMP
|
||||||
|
|
||||||
@ -35,8 +39,8 @@
|
|||||||
#include "utils/utils.h"
|
#include "utils/utils.h"
|
||||||
|
|
||||||
/* The Bitmap callbacks function table;
|
/* The Bitmap callbacks function table;
|
||||||
necessary for interaction with nsbmplib.
|
* necessary for interaction with nsbmplib.
|
||||||
*/
|
*/
|
||||||
bmp_bitmap_callback_vt bmp_bitmap_callbacks = {
|
bmp_bitmap_callback_vt bmp_bitmap_callbacks = {
|
||||||
.bitmap_create = nsbmp_bitmap_create,
|
.bitmap_create = nsbmp_bitmap_create,
|
||||||
.bitmap_destroy = bitmap_destroy,
|
.bitmap_destroy = bitmap_destroy,
|
||||||
@ -45,7 +49,8 @@ bmp_bitmap_callback_vt bmp_bitmap_callbacks = {
|
|||||||
.bitmap_get_bpp = bitmap_get_bpp
|
.bitmap_get_bpp = bitmap_get_bpp
|
||||||
};
|
};
|
||||||
|
|
||||||
bool nsbmp_create(struct content *c, const char *params[]) {
|
bool nsbmp_create(struct content *c, const char *params[])
|
||||||
|
{
|
||||||
union content_msg_data msg_data;
|
union content_msg_data msg_data;
|
||||||
|
|
||||||
c->data.bmp.bmp = calloc(sizeof(struct bmp_image), 1);
|
c->data.bmp.bmp = calloc(sizeof(struct bmp_image), 1);
|
||||||
@ -59,7 +64,8 @@ bool nsbmp_create(struct content *c, const char *params[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool nsbmp_convert(struct content *c, int iwidth, int iheight) {
|
bool nsbmp_convert(struct content *c, int iwidth, int iheight)
|
||||||
|
{
|
||||||
bmp_result res;
|
bmp_result res;
|
||||||
bmp_image *bmp;
|
bmp_image *bmp;
|
||||||
union content_msg_data msg_data;
|
union content_msg_data msg_data;
|
||||||
@ -84,8 +90,7 @@ bool nsbmp_convert(struct content *c, int iwidth, int iheight) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Store our content width and description
|
/* Store our content width and description */
|
||||||
*/
|
|
||||||
c->width = bmp->width;
|
c->width = bmp->width;
|
||||||
c->height = bmp->height;
|
c->height = bmp->height;
|
||||||
LOG(("BMP width %u height %u\n\n", c->width, c->height));
|
LOG(("BMP width %u height %u\n\n", c->width, c->height));
|
||||||
@ -99,6 +104,7 @@ bool nsbmp_convert(struct content *c, int iwidth, int iheight) {
|
|||||||
/* exit as a success */
|
/* exit as a success */
|
||||||
c->bitmap = bmp->bitmap;
|
c->bitmap = bmp->bitmap;
|
||||||
c->status = CONTENT_STATUS_DONE;
|
c->status = CONTENT_STATUS_DONE;
|
||||||
|
|
||||||
/* Done: update status bar */
|
/* Done: update status bar */
|
||||||
content_set_status(c, "");
|
content_set_status(c, "");
|
||||||
return true;
|
return true;
|
||||||
@ -108,13 +114,15 @@ bool nsbmp_convert(struct content *c, int iwidth, int iheight) {
|
|||||||
bool nsbmp_redraw(struct content *c, int x, int y,
|
bool nsbmp_redraw(struct content *c, int x, int y,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
|
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
|
||||||
float scale, unsigned long background_colour) {
|
float scale, unsigned long background_colour)
|
||||||
|
{
|
||||||
|
|
||||||
if (!c->data.bmp.bmp->decoded)
|
if (!c->data.bmp.bmp->decoded)
|
||||||
if (bmp_decode(c->data.bmp.bmp) != BMP_OK)
|
if (bmp_decode(c->data.bmp.bmp) != BMP_OK)
|
||||||
return false;
|
return false;
|
||||||
c->bitmap = c->data.bmp.bmp->bitmap;
|
c->bitmap = c->data.bmp.bmp->bitmap;
|
||||||
return plot.bitmap(x, y, width, height, c->bitmap, background_colour, c);
|
return plot.bitmap(x, y, width, height, c->bitmap,
|
||||||
|
background_colour, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -122,7 +130,8 @@ bool nsbmp_redraw_tiled(struct content *c, int x, int y,
|
|||||||
int width, int height,
|
int width, int height,
|
||||||
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
|
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
|
||||||
float scale, unsigned long background_colour,
|
float scale, unsigned long background_colour,
|
||||||
bool repeat_x, bool repeat_y) {
|
bool repeat_x, bool repeat_y)
|
||||||
|
{
|
||||||
|
|
||||||
if (!c->data.bmp.bmp->decoded)
|
if (!c->data.bmp.bmp->decoded)
|
||||||
if (bmp_decode(c->data.bmp.bmp) != BMP_OK)
|
if (bmp_decode(c->data.bmp.bmp) != BMP_OK)
|
||||||
@ -149,12 +158,14 @@ void nsbmp_destroy(struct content *c)
|
|||||||
* \param state a flag word indicating the initial state
|
* \param state a flag word indicating the initial state
|
||||||
* \return an opaque struct bitmap, or NULL on memory exhaustion
|
* \return an opaque struct bitmap, or NULL on memory exhaustion
|
||||||
*/
|
*/
|
||||||
void *nsbmp_bitmap_create(int width, int height, unsigned int bmp_state) {
|
void *nsbmp_bitmap_create(int width, int height, unsigned int bmp_state)
|
||||||
|
{
|
||||||
unsigned int bitmap_state = BITMAP_NEW;
|
unsigned int bitmap_state = BITMAP_NEW;
|
||||||
|
|
||||||
/* set bitmap state based on bmp state */
|
/* set bitmap state based on bmp state */
|
||||||
bitmap_state |= (bmp_state & BMP_OPAQUE) ? BITMAP_OPAQUE : 0;
|
bitmap_state |= (bmp_state & BMP_OPAQUE) ? BITMAP_OPAQUE : 0;
|
||||||
bitmap_state |= (bmp_state & BMP_CLEAR_MEMORY) ? BITMAP_CLEAR_MEMORY : 0;
|
bitmap_state |= (bmp_state & BMP_CLEAR_MEMORY) ?
|
||||||
|
BITMAP_CLEAR_MEMORY : 0;
|
||||||
|
|
||||||
/* return the created bitmap */
|
/* return the created bitmap */
|
||||||
return bitmap_create(width, height, bitmap_state);
|
return bitmap_create(width, height, bitmap_state);
|
||||||
|
@ -17,6 +17,10 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/** \file
|
||||||
|
* Content for image/bmp (interface).
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef _NETSURF_IMAGE_BMP_H_
|
#ifndef _NETSURF_IMAGE_BMP_H_
|
||||||
#define _NETSURF_IMAGE_BMP_H_
|
#define _NETSURF_IMAGE_BMP_H_
|
||||||
|
|
||||||
|
54
image/gif.c
54
image/gif.c
@ -18,6 +18,16 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/** \file
|
||||||
|
* Content for image/gif (implementation)
|
||||||
|
*
|
||||||
|
* All GIFs are dynamically decompressed using the routines that gifread.c
|
||||||
|
* provides. Whilst this allows support for progressive decoding, it is
|
||||||
|
* not implemented here as NetSurf currently does not provide such support.
|
||||||
|
*
|
||||||
|
* [rjw] - Sun 4th April 2004
|
||||||
|
*/
|
||||||
|
|
||||||
#include "utils/config.h"
|
#include "utils/config.h"
|
||||||
#ifdef WITH_GIF
|
#ifdef WITH_GIF
|
||||||
|
|
||||||
@ -37,17 +47,6 @@
|
|||||||
#include "utils/messages.h"
|
#include "utils/messages.h"
|
||||||
#include "utils/utils.h"
|
#include "utils/utils.h"
|
||||||
|
|
||||||
|
|
||||||
/** \file
|
|
||||||
* GIF support (implementation)
|
|
||||||
*
|
|
||||||
* All GIFs are dynamically decompressed using the routines that gifread.c
|
|
||||||
* provides. Whilst this allows support for progressive decoding, it is
|
|
||||||
* not implemented here as NetSurf currently does not provide such support.
|
|
||||||
*
|
|
||||||
* [rjw] - Sun 4th April 2004
|
|
||||||
*/
|
|
||||||
|
|
||||||
static void nsgif_invalidate(void *bitmap, void *private_word);
|
static void nsgif_invalidate(void *bitmap, void *private_word);
|
||||||
static void nsgif_animate(void *p);
|
static void nsgif_animate(void *p);
|
||||||
static gif_result nsgif_get_frame(struct content *c);
|
static gif_result nsgif_get_frame(struct content *c);
|
||||||
@ -65,7 +64,8 @@ gif_bitmap_callback_vt gif_bitmap_callbacks = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
bool nsgif_create(struct content *c, const char *params[]) {
|
bool nsgif_create(struct content *c, const char *params[])
|
||||||
|
{
|
||||||
union content_msg_data msg_data;
|
union content_msg_data msg_data;
|
||||||
/* Initialise our data structure */
|
/* Initialise our data structure */
|
||||||
c->data.gif.gif = calloc(sizeof(gif_animation), 1);
|
c->data.gif.gif = calloc(sizeof(gif_animation), 1);
|
||||||
@ -79,7 +79,8 @@ bool nsgif_create(struct content *c, const char *params[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool nsgif_convert(struct content *c, int iwidth, int iheight) {
|
bool nsgif_convert(struct content *c, int iwidth, int iheight)
|
||||||
|
{
|
||||||
int res;
|
int res;
|
||||||
struct gif_animation *gif;
|
struct gif_animation *gif;
|
||||||
union content_msg_data msg_data;
|
union content_msg_data msg_data;
|
||||||
@ -101,7 +102,8 @@ bool nsgif_convert(struct content *c, int iwidth, int iheight) {
|
|||||||
msg_data.error = messages_get("BadGIF");
|
msg_data.error = messages_get("BadGIF");
|
||||||
break;
|
break;
|
||||||
case GIF_INSUFFICIENT_MEMORY:
|
case GIF_INSUFFICIENT_MEMORY:
|
||||||
msg_data.error = messages_get("NoMemory");
|
msg_data.error = messages_get(
|
||||||
|
"NoMemory");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
|
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
|
||||||
@ -142,7 +144,8 @@ bool nsgif_convert(struct content *c, int iwidth, int iheight) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsgif_invalidate(void *bitmap, void *private_word) {
|
void nsgif_invalidate(void *bitmap, void *private_word)
|
||||||
|
{
|
||||||
struct gif_animation *gif = (struct gif_animation *)private_word;
|
struct gif_animation *gif = (struct gif_animation *)private_word;
|
||||||
|
|
||||||
gif->decoded_frame = -1;
|
gif->decoded_frame = -1;
|
||||||
@ -151,13 +154,14 @@ void nsgif_invalidate(void *bitmap, void *private_word) {
|
|||||||
bool nsgif_redraw(struct content *c, int x, int y,
|
bool nsgif_redraw(struct content *c, int x, int y,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
|
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
|
||||||
float scale, unsigned long background_colour) {
|
float scale, unsigned long background_colour)
|
||||||
|
{
|
||||||
if (c->data.gif.current_frame != c->data.gif.gif->decoded_frame)
|
if (c->data.gif.current_frame != c->data.gif.gif->decoded_frame)
|
||||||
if (nsgif_get_frame(c) != GIF_OK)
|
if (nsgif_get_frame(c) != GIF_OK)
|
||||||
return false;
|
return false;
|
||||||
c->bitmap = c->data.gif.gif->frame_image;
|
c->bitmap = c->data.gif.gif->frame_image;
|
||||||
return plot.bitmap(x, y, width, height, c->bitmap, background_colour, c);
|
return plot.bitmap(x, y, width, height, c->bitmap,
|
||||||
|
background_colour, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -165,8 +169,8 @@ bool nsgif_redraw_tiled(struct content *c, int x, int y,
|
|||||||
int width, int height,
|
int width, int height,
|
||||||
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
|
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
|
||||||
float scale, unsigned long background_colour,
|
float scale, unsigned long background_colour,
|
||||||
bool repeat_x, bool repeat_y) {
|
bool repeat_x, bool repeat_y)
|
||||||
|
{
|
||||||
gif_result res;
|
gif_result res;
|
||||||
|
|
||||||
if (c->data.gif.current_frame != c->data.gif.gif->decoded_frame)
|
if (c->data.gif.current_frame != c->data.gif.gif->decoded_frame)
|
||||||
@ -180,7 +184,6 @@ bool nsgif_redraw_tiled(struct content *c, int x, int y,
|
|||||||
|
|
||||||
void nsgif_destroy(struct content *c)
|
void nsgif_destroy(struct content *c)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* Free all the associated memory buffers */
|
/* Free all the associated memory buffers */
|
||||||
schedule_remove(nsgif_animate, c);
|
schedule_remove(nsgif_animate, c);
|
||||||
gif_finalise(c->data.gif.gif);
|
gif_finalise(c->data.gif.gif);
|
||||||
@ -194,7 +197,8 @@ void nsgif_destroy(struct content *c)
|
|||||||
*
|
*
|
||||||
* \param c the content to update
|
* \param c the content to update
|
||||||
*/
|
*/
|
||||||
gif_result nsgif_get_frame(struct content *c) {
|
gif_result nsgif_get_frame(struct content *c)
|
||||||
|
{
|
||||||
int previous_frame, current_frame, frame;
|
int previous_frame, current_frame, frame;
|
||||||
gif_result res = GIF_OK;
|
gif_result res = GIF_OK;
|
||||||
|
|
||||||
@ -290,7 +294,8 @@ void nsgif_animate(void *p)
|
|||||||
data.redraw.height =
|
data.redraw.height =
|
||||||
gif->frames[f - 1].redraw_y -
|
gif->frames[f - 1].redraw_y -
|
||||||
data.redraw.y +
|
data.redraw.y +
|
||||||
gif->frames[f - 1].redraw_height;
|
gif->frames[f - 1].
|
||||||
|
redraw_height;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* do advanced check */
|
/* do advanced check */
|
||||||
@ -325,7 +330,8 @@ void nsgif_animate(void *p)
|
|||||||
* \param height width of image in pixels
|
* \param height width of image in pixels
|
||||||
* \return an opaque struct bitmap, or NULL on memory exhaustion
|
* \return an opaque struct bitmap, or NULL on memory exhaustion
|
||||||
*/
|
*/
|
||||||
void *nsgif_bitmap_create(int width, int height) {
|
void *nsgif_bitmap_create(int width, int height)
|
||||||
|
{
|
||||||
return bitmap_create(width, height, BITMAP_NEW);
|
return bitmap_create(width, height, BITMAP_NEW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/** \file
|
/** \file
|
||||||
* GIF support (interface).
|
* Content for image/gif (interface).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _NETSURF_IMAGE_GIF_H_
|
#ifndef _NETSURF_IMAGE_GIF_H_
|
||||||
|
31
image/ico.c
31
image/ico.c
@ -16,6 +16,10 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/** \file
|
||||||
|
* Content for image/ico (implementation)
|
||||||
|
*/
|
||||||
|
|
||||||
#include "utils/config.h"
|
#include "utils/config.h"
|
||||||
#ifdef WITH_BMP
|
#ifdef WITH_BMP
|
||||||
|
|
||||||
@ -33,11 +37,14 @@
|
|||||||
#include "utils/messages.h"
|
#include "utils/messages.h"
|
||||||
#include "utils/utils.h"
|
#include "utils/utils.h"
|
||||||
|
|
||||||
bool nsico_create(struct content *c, const char *params[]) {
|
bool nsico_create(struct content *c, const char *params[])
|
||||||
|
{
|
||||||
union content_msg_data msg_data;
|
union content_msg_data msg_data;
|
||||||
extern bmp_bitmap_callback_vt bmp_bitmap_callbacks; /**< external structure containing
|
extern bmp_bitmap_callback_vt bmp_bitmap_callbacks; /**< external
|
||||||
* bitmap callback functions */
|
* structure
|
||||||
|
* containing
|
||||||
|
* bitmap callback
|
||||||
|
* functions */
|
||||||
c->data.ico.ico = calloc(sizeof(ico_collection), 1);
|
c->data.ico.ico = calloc(sizeof(ico_collection), 1);
|
||||||
if (!c->data.ico.ico) {
|
if (!c->data.ico.ico) {
|
||||||
msg_data.error = messages_get("NoMemory");
|
msg_data.error = messages_get("NoMemory");
|
||||||
@ -49,7 +56,8 @@ bool nsico_create(struct content *c, const char *params[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool nsico_convert(struct content *c, int iwidth, int iheight) {
|
bool nsico_convert(struct content *c, int iwidth, int iheight)
|
||||||
|
{
|
||||||
struct bmp_image *bmp;
|
struct bmp_image *bmp;
|
||||||
bmp_result res;
|
bmp_result res;
|
||||||
ico_collection *ico;
|
ico_collection *ico;
|
||||||
@ -59,7 +67,9 @@ bool nsico_convert(struct content *c, int iwidth, int iheight) {
|
|||||||
ico = c->data.ico.ico;
|
ico = c->data.ico.ico;
|
||||||
|
|
||||||
/* analyse the ico */
|
/* analyse the ico */
|
||||||
res = ico_analyse(ico, c->source_size, (unsigned char *) c->source_data);
|
res = ico_analyse(ico, c->source_size, (unsigned char *)
|
||||||
|
c->source_data);
|
||||||
|
|
||||||
switch (res) {
|
switch (res) {
|
||||||
case BMP_OK:
|
case BMP_OK:
|
||||||
break;
|
break;
|
||||||
@ -74,8 +84,7 @@ bool nsico_convert(struct content *c, int iwidth, int iheight) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Store our content width and description
|
/* Store our content width and description */
|
||||||
*/
|
|
||||||
c->width = ico->width;
|
c->width = ico->width;
|
||||||
c->height = ico->height;
|
c->height = ico->height;
|
||||||
c->title = malloc(100);
|
c->title = malloc(100);
|
||||||
@ -97,7 +106,8 @@ bool nsico_convert(struct content *c, int iwidth, int iheight) {
|
|||||||
bool nsico_redraw(struct content *c, int x, int y,
|
bool nsico_redraw(struct content *c, int x, int y,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
|
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
|
||||||
float scale, unsigned long background_colour) {
|
float scale, unsigned long background_colour)
|
||||||
|
{
|
||||||
struct bmp_image *bmp = ico_find(c->data.ico.ico, width, height);
|
struct bmp_image *bmp = ico_find(c->data.ico.ico, width, height);
|
||||||
if (!bmp->decoded)
|
if (!bmp->decoded)
|
||||||
if (bmp_decode(bmp) != BMP_OK)
|
if (bmp_decode(bmp) != BMP_OK)
|
||||||
@ -112,7 +122,8 @@ bool nsico_redraw_tiled(struct content *c, int x, int y,
|
|||||||
int width, int height,
|
int width, int height,
|
||||||
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
|
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
|
||||||
float scale, unsigned long background_colour,
|
float scale, unsigned long background_colour,
|
||||||
bool repeat_x, bool repeat_y) {
|
bool repeat_x, bool repeat_y)
|
||||||
|
{
|
||||||
struct bmp_image *bmp = ico_find(c->data.ico.ico, width, height);
|
struct bmp_image *bmp = ico_find(c->data.ico.ico, width, height);
|
||||||
if (!bmp->decoded)
|
if (!bmp->decoded)
|
||||||
if (bmp_decode(bmp) != BMP_OK)
|
if (bmp_decode(bmp) != BMP_OK)
|
||||||
|
@ -16,6 +16,10 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/** \file
|
||||||
|
* Content for image/ico (interface).
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef _NETSURF_IMAGE_ICO_H_
|
#ifndef _NETSURF_IMAGE_ICO_H_
|
||||||
#define _NETSURF_IMAGE_ICO_H_
|
#define _NETSURF_IMAGE_ICO_H_
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user