Rename DataTypes related code/files/defines to avoid confusion and aid adding support

for other DataType classes.
Disable MNG/WebP by default as they aren't common and the required libs are quite
large; DataTypes can handle these formats for now.

svn path=/trunk/netsurf/; revision=12284
This commit is contained in:
Chris Young 2011-05-06 22:42:37 +00:00
parent e71691bae8
commit 208363fe2a
9 changed files with 129 additions and 78 deletions

View File

@ -220,9 +220,13 @@ ifeq ($(TARGET),amiga)
# Valid options: YES, NO, AUTO
NETSURF_USE_ROSPRITE := YES
# Enable NetSurf's use of libmng for displaying MNGs, JNGs and PNGs
# Valid options: YES, NO (at least one of PNG/MNG/DT highly recommended)
NETSURF_USE_MNG := NO
# Enable NetSurf's use of libwebp for displaying WebPs
# Valid options: YES, NO
NETSURF_USE_WEBP := YES
NETSURF_USE_WEBP := NO
# Enable NetSurf to display Amiga icons
# Valid options: YES, NO (recommended)
@ -230,7 +234,7 @@ ifeq ($(TARGET),amiga)
# Enable NetSurf's use of DataTypes for unknown filetypes
# Valid options: YES, NO
NETSURF_USE_PLUGINS := YES
NETSURF_USE_AMIGA_DATATYPES := YES
# Enable NetSurf's use of libsvgtiny for displaying SVGs
# (NB: Requires NETSURF_AMIGA_USE_CAIRO)

View File

@ -24,7 +24,7 @@ ifeq ($(HOST),amiga)
$(eval $(call feature_enabled,MNG,,-llcms -ljpeg,PNG/JNG/MNG (libmng)))
$(eval $(call feature_enabled,WEBP,-DWITH_WEBP,-lwebp,WebP (libwebp)))
$(eval $(call feature_enabled,AMIGA_ICON,-DWITH_AMIGA_ICON,,Amiga icon))
$(eval $(call feature_enabled,PLUGINS,-DWITH_PLUGIN,,DataTypes images))
$(eval $(call feature_enabled,AMIGA_DATATYPES,-DWITH_AMIGA_DATATYPES,,DataTypes))
CFLAGS += -I /SDK/local/common/include/libpng12
LDFLAGS += -lxml2 -lcurl -lrtmp -lpthread -lregex -lauto -lpbl
@ -43,7 +43,7 @@ else
$(eval $(call pkg_config_find_and_add,PNG,libpng,PNG))
$(eval $(call pkg_config_find_and_add,NSSVG,libsvgtiny,NSSVG))
$(eval $(call feature_enabled,AMIGA_ICON,-DWITH_AMIGA_ICON,,Amiga icon))
$(eval $(call feature_enabled,PLUGINS,-DWITH_PLUGIN,,DataTypes images))
$(eval $(call feature_enabled,AMIGA_DATATYPES,-DWITH_AMIGA_DATATYPES,,DataTypes))
CFLAGS += -I$(GCCSDK_INSTALL_ENV)/include
CFLAGS += $(shell $(PKG_CONFIG) --cflags libxml-2.0 libcurl libcares openssl)
@ -67,12 +67,13 @@ endif
# ----------------------------------------------------------------------------
# S_AMIGA are sources purely for the Amiga build
S_AMIGA := gui.c tree.c history.c hotlist.c schedule.c plugin.c \
S_AMIGA := gui.c tree.c history.c hotlist.c schedule.c \
thumbnail.c misc.c bitmap.c font.c filetype.c utf8.c login.c \
plotters.c object.c menu.c save_pdf.c arexx.c version.c \
cookies.c context_menu.c clipboard.c save_complete.c \
launch.c search.c history_local.c download.c iff_dr2d.c \
sslcert.c gui_options.c print.c theme.c drag.c icon.c system_colour.c \
datatypes.c dt_picture.c \
stringview/stringview.c stringview/urlhistory.c
S_AMIGA := $(addprefix amiga/,$(S_AMIGA))

View File

@ -16,22 +16,21 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NETSURF_AMIGA_PLUGIN_H_
#define NETSURF_AMIGA_PLUGIN_H_
#ifdef WITH_AMIGA_DATATYPES
#include "amiga/datatypes.h"
#include "utils/config.h"
#include "utils/errors.h"
nserror amiga_datatypes_init(void)
{
nserror err = NSERROR_OK;
#ifdef WITH_PLUGIN
err = amiga_dt_picture_init();
if(err != NSERROR_OK) return err;
nserror plugin_init(void);
void plugin_fini(void);
#else
#define plugin_init() NSERROR_OK
#define plugin_fini() ((void) 0)
#endif /* WITH_PLUGIN */
return NSERROR_OK;
}
void amiga_datatypes_fini(void)
{
amiga_dt_picture_fini();
}
#endif

43
amiga/datatypes.h Normal file
View File

@ -0,0 +1,43 @@
/*
* Copyright 2011 Chris Young <chris@unsatisfactorysoftware.co.uk>
*
* 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/>.
*/
#ifndef NETSURF_AMIGA_DATATYPES_H_
#define NETSURF_AMIGA_DATATYPES_H_
#include "utils/config.h"
#include "utils/errors.h"
#ifdef WITH_AMIGA_DATATYPES
nserror amiga_datatypes_init(void);
void amiga_datatypes_fini(void);
nserror amiga_dt_picture_init(void);
void amiga_dt_picture_fini(void);
#else
#define amiga_datatypes_init() NSERROR_OK
#define amiga_datatypes_fini() ((void) 0)
#define amiga_dt_picture_init() NSERROR_OK
#define amiga_dt_picture_fini() ((void) 0)
#endif /* WITH_AMIGA_DATATYPES */
#endif

View File

@ -17,13 +17,13 @@
*/
/** \file
* Temporary "plugin" to pass unknown MIME types to DataTypes (implementation)
* DataTypes picture handler (implementation)
*/
#ifdef WITH_PLUGIN
#ifdef WITH_AMIGA_DATATYPES
#include "amiga/filetype.h"
#include "amiga/gui.h"
#include "amiga/plugin.h"
#include "amiga/datatypes.h"
#include "content/content_protected.h"
#include "desktop/plotters.h"
#include "image/bitmap.h"
@ -37,7 +37,7 @@
#include <datatypes/pictureclass.h>
#include <intuition/classusr.h>
typedef struct plugin_content {
typedef struct amiga_dt_picture_content {
struct content base;
Object *dto;
@ -45,45 +45,45 @@ typedef struct plugin_content {
int y;
int w;
int h;
} plugin_content;
} amiga_dt_picture_content;
static nserror plugin_create(const content_handler *handler,
static nserror amiga_dt_picture_create(const content_handler *handler,
lwc_string *imime_type, const http_parameter *params,
llcache_handle *llcache, const char *fallback_charset,
bool quirks, struct content **c);
static bool plugin_convert(struct content *c);
static void plugin_reformat(struct content *c, int width, int height);
static void plugin_destroy(struct content *c);
static bool plugin_redraw(struct content *c, int x, int y,
static bool amiga_dt_picture_convert(struct content *c);
static void amiga_dt_picture_reformat(struct content *c, int width, int height);
static void amiga_dt_picture_destroy(struct content *c);
static bool amiga_dt_picture_redraw(struct content *c, int x, int y,
int width, int height, const struct rect *clip,
float scale, colour background_colour);
static void plugin_open(struct content *c, struct browser_window *bw,
static void amiga_dt_picture_open(struct content *c, struct browser_window *bw,
struct content *page, struct box *box,
struct object_params *params);
static void plugin_close(struct content *c);
static nserror plugin_clone(const struct content *old, struct content **newc);
static content_type plugin_content_type(lwc_string *mime_type);
static void amiga_dt_picture_close(struct content *c);
static nserror amiga_dt_picture_clone(const struct content *old, struct content **newc);
static content_type amiga_dt_picture_content_type(lwc_string *mime_type);
static const content_handler plugin_content_handler = {
plugin_create,
static const content_handler amiga_dt_picture_content_handler = {
amiga_dt_picture_create,
NULL,
plugin_convert,
plugin_reformat,
plugin_destroy,
amiga_dt_picture_convert,
amiga_dt_picture_reformat,
amiga_dt_picture_destroy,
NULL,
NULL,
NULL,
plugin_redraw,
amiga_dt_picture_redraw,
NULL,
plugin_open,
plugin_close,
plugin_clone,
amiga_dt_picture_open,
amiga_dt_picture_close,
amiga_dt_picture_clone,
NULL,
plugin_content_type,
amiga_dt_picture_content_type,
false
};
nserror plugin_init(void)
nserror amiga_dt_picture_init(void)
{
char dt_mime[50];
struct DataType *dt, *prevdt = NULL;
@ -107,7 +107,7 @@ nserror plugin_init(void)
return NSERROR_NOMEM;
error = content_factory_register_handler(type,
&plugin_content_handler);
&amiga_dt_picture_content_handler);
lwc_string_unref(type);
@ -121,20 +121,20 @@ nserror plugin_init(void)
return NSERROR_OK;
}
void plugin_fini(void)
void amiga_dt_picture_fini(void)
{
/* Nothing to do */
}
nserror plugin_create(const content_handler *handler,
nserror amiga_dt_picture_create(const content_handler *handler,
lwc_string *imime_type, const http_parameter *params,
llcache_handle *llcache, const char *fallback_charset,
bool quirks, struct content **c)
{
plugin_content *plugin;
amiga_dt_picture_content *plugin;
nserror error;
plugin = talloc_zero(0, plugin_content);
plugin = talloc_zero(0, amiga_dt_picture_content);
if (plugin == NULL)
return NSERROR_NOMEM;
@ -150,11 +150,11 @@ nserror plugin_create(const content_handler *handler,
return NSERROR_OK;
}
bool plugin_convert(struct content *c)
bool amiga_dt_picture_convert(struct content *c)
{
LOG(("plugin_convert"));
LOG(("amiga_dt_picture_convert"));
plugin_content *plugin = (plugin_content *) c;
amiga_dt_picture_content *plugin = (amiga_dt_picture_content *) c;
union content_msg_data msg_data;
int width, height;
char title[100];
@ -218,11 +218,11 @@ bool plugin_convert(struct content *c)
return true;
}
void plugin_destroy(struct content *c)
void amiga_dt_picture_destroy(struct content *c)
{
plugin_content *plugin = (plugin_content *) c;
amiga_dt_picture_content *plugin = (amiga_dt_picture_content *) c;
LOG(("plugin_destroy"));
LOG(("amiga_dt_picture_destroy"));
if (c->bitmap != NULL)
bitmap_destroy(c->bitmap);
@ -232,11 +232,11 @@ void plugin_destroy(struct content *c)
return;
}
bool plugin_redraw(struct content *c, int x, int y,
bool amiga_dt_picture_redraw(struct content *c, int x, int y,
int width, int height, const struct rect *clip,
float scale, colour background_colour)
{
LOG(("plugin_redraw"));
LOG(("amiga_dt_picture_redraw"));
return plot.bitmap(x, y, width, height,
c->bitmap, background_colour, BITMAPF_NONE);
@ -252,35 +252,35 @@ bool plugin_redraw(struct content *c, int x, int y,
* \param box box containing c, or 0 if not an object
* \param params object parameters, or 0 if not an object
*/
void plugin_open(struct content *c, struct browser_window *bw,
void amiga_dt_picture_open(struct content *c, struct browser_window *bw,
struct content *page, struct box *box,
struct object_params *params)
{
LOG(("plugin_open"));
LOG(("amiga_dt_picture_open"));
return;
}
void plugin_close(struct content *c)
void amiga_dt_picture_close(struct content *c)
{
LOG(("plugin_close"));
LOG(("amiga_dt_picture_close"));
return;
}
void plugin_reformat(struct content *c, int width, int height)
void amiga_dt_picture_reformat(struct content *c, int width, int height)
{
LOG(("plugin_reformat"));
LOG(("amiga_dt_picture_reformat"));
return;
}
nserror plugin_clone(const struct content *old, struct content **newc)
nserror amiga_dt_picture_clone(const struct content *old, struct content **newc)
{
plugin_content *plugin;
amiga_dt_picture_content *plugin;
nserror error;
LOG(("plugin_clone"));
LOG(("amiga_dt_picture_clone"));
plugin = talloc_zero(0, plugin_content);
plugin = talloc_zero(0, amiga_dt_picture_content);
if (plugin == NULL)
return NSERROR_NOMEM;
@ -293,7 +293,7 @@ nserror plugin_clone(const struct content *old, struct content **newc)
/* We "clone" the old content by replaying conversion */
if (old->status == CONTENT_STATUS_READY ||
old->status == CONTENT_STATUS_DONE) {
if (plugin_convert(&plugin->base) == false) {
if (amiga_dt_picture_convert(&plugin->base) == false) {
content_destroy(&plugin->base);
return NSERROR_CLONE_FAILED;
}
@ -304,7 +304,7 @@ nserror plugin_clone(const struct content *old, struct content **newc)
return NSERROR_OK;
}
content_type plugin_content_type(lwc_string *mime_type)
content_type amiga_dt_picture_content_type(lwc_string *mime_type)
{
return CONTENT_IMAGE;
}

View File

@ -178,6 +178,10 @@ void ami_datatype_to_mimetype(struct DataType *dtn, char *mimetype)
{
strcpy(mimetype,"image/x-riscos-sprite");
}
if(strcmp("mng",dth->dth_BaseName)==0)
{
strcpy(mimetype,"video/mng");
}
break;
case GID_ANIMATION:
case GID_MOVIE:

View File

@ -58,7 +58,7 @@
#define NSA_VALUE_SHEARSIN (1 << 14)
#define NSA_VALUE_SHEARCOS (1 << 16)
#define NSA_FONT_EMWIDTH(s) (ULONG)(s / FONT_SIZE_SCALE) * (ami_xdpi / 72.0)
#define NSA_FONT_EMWIDTH(s) (s / FONT_SIZE_SCALE) * (ami_xdpi / 72.0)
struct ami_font_node
{
@ -136,7 +136,7 @@ bool nsfont_position_in_string(const plot_font_style_t *fstyle,
uint8 *utf8;
uint32 co = 0;
int utf16charlen;
ULONG emwidth = NSA_FONT_EMWIDTH(fstyle->size);
ULONG emwidth = (ULONG)NSA_FONT_EMWIDTH(fstyle->size);
int32 tempx;
len = utf8_bounded_length(string, length);
@ -245,7 +245,7 @@ bool nsfont_split(const plot_font_style_t *fstyle,
size_t len;
int utf8len, utf8clen = 0;
int32 tempx = 0;
ULONG emwidth = NSA_FONT_EMWIDTH(fstyle->size);
ULONG emwidth = (ULONG)NSA_FONT_EMWIDTH(fstyle->size);
len = utf8_bounded_length(string, length);
if(utf8_to_enc((char *)string,"UTF-16",length,(char **)&utf16) != UTF8_CONVERT_OK) return false;
@ -550,7 +550,7 @@ ULONG ami_unicode_text(struct RastPort *rp,const char *string,ULONG length,const
uint32 x=0;
uint8 co = 0;
int32 tempx = 0;
ULONG emwidth = NSA_FONT_EMWIDTH(fstyle->size);
ULONG emwidth = (ULONG)NSA_FONT_EMWIDTH(fstyle->size);
if(!string || string[0]=='\0') return 0;
if(!length) return 0;

View File

@ -42,6 +42,7 @@
#include "amiga/clipboard.h"
#include "amiga/context_menu.h"
#include "amiga/cookies.h"
#include "amiga/datatypes.h"
#include "amiga/download.h"
#include "amiga/drag.h"
#include "amiga/font.h"
@ -57,7 +58,6 @@
#include "amiga/misc.h"
#include "amiga/options.h"
#include "amiga/plotters.h"
#include "amiga/plugin.h"
#include "amiga/print.h"
#include "amiga/schedule.h"
#include "amiga/search.h"
@ -750,7 +750,7 @@ int main(int argc, char** argv)
ami_schedule_open_timer();
ami_schedule_create();
plugin_init();
amiga_datatypes_init();
netsurf_init(&argc, &argv, "PROGDIR:Resources/Options", messages);
@ -771,7 +771,7 @@ int main(int argc, char** argv)
netsurf_exit();
plugin_fini();
amiga_datatypes_fini();
amiga_icon_fini();
return 0;

View File

@ -21,8 +21,8 @@ copy amiga/pkg/fitr ram:NetSurf/
makedir ram:NetSurf/Rexx
copy amiga/dist/Rexx/~(.svn) ram:NetSurf/Rexx/ COM
makedir ram:NetSurf/Libs
copy libs:parserutils.library libs:nsgif.library libs:nsbmp.library libs:iconv.library libs:hubbub.library libs:webp.library ram:NetSurf/Libs
copy libs:parserutils.library libs:nsgif.library libs:nsbmp.library libs:iconv.library libs:hubbub.library ram:NetSurf/Libs
; libs:css.library libs:wapcaplet.library
makedir ram:NetSurf/SObjs
copy sobjs:libjpeg.so.8 sobjs:libmng.so.1 sobjs:liblcms.so sobjs:libxml2.so.9 sobjs:libcurl.so.7 sobjs:librtmp.so.0 sobjs:libsvgtiny.so.0 sobjs:libz.so.1.2.5 sobjs:libssl.so.1.0.0 sobjs:libcrypto.so.1.0.0 sobjs:libcss.so.0 sobjs:libwapcaplet.so.0 sobjs:libpng12.so ram:NetSurf/SObjs clone
copy sobjs:libjpeg.so.8 sobjs:libxml2.so.9 sobjs:libcurl.so.7 sobjs:librtmp.so.0 sobjs:libsvgtiny.so.0 sobjs:libz.so.1.2.5 sobjs:libssl.so.1.0.0 sobjs:libcrypto.so.1.0.0 sobjs:libcss.so.0 sobjs:libwapcaplet.so.0 sobjs:libpng12.so ram:NetSurf/SObjs clone
;sobjs:libhpdf-2.2.0.so.0.0