Minor changes for Amiga Cairo build

svn path=/trunk/netsurf/; revision=5940
This commit is contained in:
Chris Young 2008-12-28 12:24:18 +00:00
parent fcf46a91b6
commit 495fa6c648
4 changed files with 54 additions and 61 deletions

View File

@ -447,7 +447,7 @@ ifeq ($(TARGET),amiga)
LDFLAGS += -lxml2 -lcurl -lm -lsocket -lpthread -lregex -lauto -lraauto -lssl -lcrypto -lamisslauto -lparserutils -mcrt=newlib LDFLAGS += -lxml2 -lcurl -lm -lsocket -lpthread -lregex -lauto -lraauto -lssl -lcrypto -lamisslauto -lparserutils -mcrt=newlib
ifeq ($(NETSURF_AMIGA_USE_CAIRO),YES) ifeq ($(NETSURF_AMIGA_USE_CAIRO),YES)
CFLAGS += -DNS_AMIGA_CAIRO CFLAGS += -DNS_AMIGA_CAIRO -I SDK:local/common/include/cairo
LDFLAGS += -use-dynld -lcairo -lpixman-1 -lfreetype -lfontconfig -lpng12 -lexpat LDFLAGS += -use-dynld -lcairo -lpixman-1 -lfreetype -lfontconfig -lpng12 -lexpat
endif endif
endif endif

View File

@ -71,6 +71,9 @@
#include "amiga/fetch_mailto.h" #include "amiga/fetch_mailto.h"
#include "amiga/search.h" #include "amiga/search.h"
#ifdef NS_AMIGA_CAIRO
#include <cairo/cairo-amigaos.h>
#endif
#ifdef WITH_HUBBUB #ifdef WITH_HUBBUB
#include <hubbub/hubbub.h> #include <hubbub/hubbub.h>
#endif #endif
@ -113,8 +116,6 @@ ULONG throbber_width,throbber_height,throbber_frames;
BOOL rmbtrapped; BOOL rmbtrapped;
BOOL locked_screen = FALSE; BOOL locked_screen = FALSE;
//static struct RastPort dummyrp;
#define AMI_LASTPOINTER GUI_POINTER_PROGRESS+1 #define AMI_LASTPOINTER GUI_POINTER_PROGRESS+1
Object *mouseptrobj[AMI_LASTPOINTER+1]; Object *mouseptrobj[AMI_LASTPOINTER+1];
struct BitMap *mouseptrbm[AMI_LASTPOINTER+1]; struct BitMap *mouseptrbm[AMI_LASTPOINTER+1];
@ -434,14 +435,6 @@ void gui_init2(int argc, char** argv)
ami_fetch_file_register(); ami_fetch_file_register();
ami_fetch_mailto_register(); ami_fetch_mailto_register();
/*
InitRastPort(&dummyrp);
dummyrp.BitMap = p96AllocBitMap(1,1,32,
BMF_CLEAR | BMF_DISPLAYABLE | BMF_INTERLEAVED,
NULL,RGBFB_A8R8G8B8);
if(!dummyrp.BitMap) die(messages_get("NoMemory"));
*/
if(notalreadyrunning) if(notalreadyrunning)
{ {
if((option_modeid) && (option_modeid[0] != '\0')) if((option_modeid) && (option_modeid[0] != '\0'))
@ -497,8 +490,7 @@ void gui_init2(int argc, char** argv)
/* init shared bitmaps */ /* init shared bitmaps */
glob.bm = p96AllocBitMap(scrn->Width,scrn->Height,32, glob.bm = p96AllocBitMap(scrn->Width,scrn->Height,32,
BMF_CLEAR | BMF_DISPLAYABLE | BMF_INTERLEAVED, BMF_CLEAR | BMF_DISPLAYABLE | BMF_INTERLEAVED,
NULL, //gwin->shared->win->RPort->BitMap, scrn->RastPort.BitMap,RGBFB_A8R8G8B8);
RGBFB_A8R8G8B8);
if(!glob.bm) if(!glob.bm)
{ {
@ -536,8 +528,12 @@ void gui_init2(int argc, char** argv)
} }
InitTmpRas(glob.rp.TmpRas,glob.tmprasbuf,scrn->Width*scrn->Height); InitTmpRas(glob.rp.TmpRas,glob.tmprasbuf,scrn->Width*scrn->Height);
currp = &glob.rp; currp = &glob.rp;
#ifdef NS_AMIGA_CAIRO
glob.surface = cairo_amigaos_surface_create(glob.bm);
glob.cr = cairo_create(glob.surface);
#endif
/* init shared bitmaps */ /* init shared bitmaps */
if(argc) // argc==0 is started from wb if(argc) // argc==0 is started from wb
@ -1275,6 +1271,10 @@ void gui_quit(void)
ami_arexx_cleanup(); ami_arexx_cleanup();
#ifdef NS_AMIGA_CAIRO
cairo_destroy(glob.cr);
cairo_surface_destroy(glob.surface);
#endif
DeleteLayer(0,glob.rp.Layer); DeleteLayer(0,glob.rp.Layer);
DisposeLayerInfo(glob.layerinfo); DisposeLayerInfo(glob.layerinfo);
p96FreeBitMap(glob.bm); p96FreeBitMap(glob.bm);
@ -1287,7 +1287,6 @@ void gui_quit(void)
{ {
while(!CloseScreen(scrn)); while(!CloseScreen(scrn));
} }
// p96FreeBitMap(dummyrp.BitMap);
FreeVec(nsscreentitle); FreeVec(nsscreentitle);
@ -1497,7 +1496,7 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
WA_CustomScreen,scrn, WA_CustomScreen,scrn,
WA_ReportMouse,TRUE, WA_ReportMouse,TRUE,
WA_IDCMP,IDCMP_MENUPICK | IDCMP_MOUSEMOVE | IDCMP_MOUSEBUTTONS | WA_IDCMP,IDCMP_MENUPICK | IDCMP_MOUSEMOVE | IDCMP_MOUSEBUTTONS |
IDCMP_NEWSIZE | IDCMP_VANILLAKEY | IDCMP_RAWKEY | IDCMP_GADGETUP | IDCMP_IDCMPUPDATE | IDCMP_INTUITICKS, IDCMP_NEWSIZE | IDCMP_VANILLAKEY | IDCMP_RAWKEY | IDCMP_GADGETUP | IDCMP_IDCMPUPDATE | IDCMP_INTUITICKS | IDCMP_EXTENDEDMOUSE,
// WINDOW_IconifyGadget, TRUE, // WINDOW_IconifyGadget, TRUE,
// WINDOW_NewMenu,menu, // WINDOW_NewMenu,menu,
WINDOW_HorizProp,1, WINDOW_HorizProp,1,
@ -1506,6 +1505,7 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
WINDOW_IDCMPHookBits,IDCMP_IDCMPUPDATE, WINDOW_IDCMPHookBits,IDCMP_IDCMPUPDATE,
WINDOW_AppPort, appport, WINDOW_AppPort, appport,
WINDOW_AppWindow,TRUE, WINDOW_AppWindow,TRUE,
WINDOW_BuiltInScroll,TRUE,
WINDOW_SharedPort,sport, WINDOW_SharedPort,sport,
WINDOW_UserData,gwin->shared, WINDOW_UserData,gwin->shared,
// WINDOW_Position, WPOS_CENTERSCREEN, // WINDOW_Position, WPOS_CENTERSCREEN,
@ -1575,7 +1575,8 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE | IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE |
IDCMP_VANILLAKEY | IDCMP_RAWKEY | IDCMP_VANILLAKEY | IDCMP_RAWKEY |
IDCMP_GADGETUP | IDCMP_IDCMPUPDATE | IDCMP_GADGETUP | IDCMP_IDCMPUPDATE |
IDCMP_INTUITICKS | IDCMP_ACTIVEWINDOW, IDCMP_INTUITICKS | IDCMP_ACTIVEWINDOW |
IDCMP_EXTENDEDMOUSE,
// WINDOW_IconifyGadget, TRUE, // WINDOW_IconifyGadget, TRUE,
WINDOW_NewMenu,menu, WINDOW_NewMenu,menu,
WINDOW_HorizProp,1, WINDOW_HorizProp,1,
@ -1585,6 +1586,7 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
WINDOW_AppPort, appport, WINDOW_AppPort, appport,
WINDOW_AppWindow,TRUE, WINDOW_AppWindow,TRUE,
WINDOW_SharedPort,sport, WINDOW_SharedPort,sport,
WINDOW_BuiltInScroll,TRUE,
WINDOW_UserData,gwin->shared, WINDOW_UserData,gwin->shared,
// WINDOW_Position, WPOS_CENTERSCREEN, // WINDOW_Position, WPOS_CENTERSCREEN,
// WINDOW_CharSet,106, // WINDOW_CharSet,106,
@ -1736,7 +1738,7 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE | IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE |
IDCMP_VANILLAKEY | IDCMP_RAWKEY | IDCMP_VANILLAKEY | IDCMP_RAWKEY |
IDCMP_GADGETUP | IDCMP_IDCMPUPDATE | IDCMP_GADGETUP | IDCMP_IDCMPUPDATE |
IDCMP_INTUITICKS, IDCMP_INTUITICKS | IDCMP_EXTENDEDMOUSE,
WINDOW_HorizProp,1, WINDOW_HorizProp,1,
WINDOW_VertProp,1, WINDOW_VertProp,1,
WINDOW_IDCMPHook,&gwin->shared->scrollerhook, WINDOW_IDCMPHook,&gwin->shared->scrollerhook,
@ -1745,6 +1747,7 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
WINDOW_AppWindow,TRUE, WINDOW_AppWindow,TRUE,
WINDOW_SharedPort,sport, WINDOW_SharedPort,sport,
WINDOW_UserData,gwin->shared, WINDOW_UserData,gwin->shared,
WINDOW_BuiltInScroll,TRUE,
WINDOW_ParentGroup, gwin->shared->gadgets[GID_MAIN] = VGroupObject, WINDOW_ParentGroup, gwin->shared->gadgets[GID_MAIN] = VGroupObject,
LAYOUT_SpaceOuter, TRUE, LAYOUT_SpaceOuter, TRUE,
LAYOUT_AddChild, gwin->shared->gadgets[GID_BROWSER] = SpaceObject, LAYOUT_AddChild, gwin->shared->gadgets[GID_BROWSER] = SpaceObject,
@ -1826,8 +1829,6 @@ void gui_window_destroy(struct gui_window *g)
if(!g) return; if(!g) return;
// currp = &dummyrp;
if(g->shared->tabs > 1) if(g->shared->tabs > 1)
{ {
SetGadgetAttrs(g->shared->gadgets[GID_TABS],g->shared->win,NULL, SetGadgetAttrs(g->shared->gadgets[GID_TABS],g->shared->win,NULL,
@ -1979,7 +1980,6 @@ void gui_window_update_box(struct gui_window *g,
0xFFFFFF); 0xFFFFFF);
current_redraw_browser = NULL; current_redraw_browser = NULL;
// currp = &dummyrp;
ami_update_buttons(g->shared); ami_update_buttons(g->shared);
@ -2052,8 +2052,6 @@ void ami_do_redraw(struct gui_window_2 *g)
// } // }
current_redraw_browser = NULL; current_redraw_browser = NULL;
// currp = &dummyrp;
ami_update_buttons(g); ami_update_buttons(g);

View File

@ -24,6 +24,9 @@
#include "desktop/browser.h" #include "desktop/browser.h"
#include <dos/dos.h> #include <dos/dos.h>
#include "desktop/gui.h" #include "desktop/gui.h"
#ifdef NS_AMIGA_CAIRO
#include <cairo/cairo.h>
#endif
enum enum
{ {
@ -121,6 +124,10 @@ struct gui_globals
struct Layer_Info *layerinfo; struct Layer_Info *layerinfo;
APTR areabuf; APTR areabuf;
APTR tmprasbuf; APTR tmprasbuf;
#ifdef NS_AMIGA_CAIRO
cairo_surface_t *surface;
cairo_t *cr;
#endif
}; };
void ami_get_msg(void); void ami_get_msg(void);

View File

@ -75,7 +75,7 @@ void ami_cairo_set_colour(cairo_t *cr,colour c)
g = (c & 0xff00) >> 8; g = (c & 0xff00) >> 8;
b = (c & 0xff0000) >> 16; b = (c & 0xff0000) >> 16;
cairo_set_source_rgba(cr, r / 255.0, cairo_set_source_rgba(glob.cr, r / 255.0,
g / 255.0, b / 255.0, 1.0); g / 255.0, b / 255.0, 1.0);
} }
@ -83,21 +83,21 @@ void ami_cairo_set_solid(cairo_t *cr)
{ {
double dashes = 0; double dashes = 0;
cairo_set_dash(cr, &dashes, 0, 0); cairo_set_dash(glob.cr, &dashes, 0, 0);
} }
void ami_cairo_set_dotted(cairo_t *cr) void ami_cairo_set_dotted(cairo_t *cr)
{ {
double cdashes = 1; double cdashes = 1;
cairo_set_dash(cr, &cdashes, 1, 0); cairo_set_dash(glob.cr, &cdashes, 1, 0);
} }
void ami_cairo_set_dashed(cairo_t *cr) void ami_cairo_set_dashed(cairo_t *cr)
{ {
double cdashes = 3; double cdashes = 3;
cairo_set_dash(cr, &cdashes, 1, 0); cairo_set_dash(glob.cr, &cdashes, 1, 0);
} }
#endif #endif
@ -281,20 +281,14 @@ bool ami_arc(int x, int y, int radius, int angle1, int angle2,
colour c) colour c)
{ {
#ifdef NS_AMIGA_CAIRO #ifdef NS_AMIGA_CAIRO
cairo_surface_t *surface = cairo_amigaos_surface_create(currp->BitMap); ami_cairo_set_colour(glob.cr,c);
cairo_t *cr = cairo_create(surface); ami_cairo_set_solid(glob.cr);
ami_cairo_set_colour(cr,c); cairo_set_line_width(glob.cr, 1);
ami_cairo_set_solid(cr); cairo_arc(glob.cr, x, y, radius,
cairo_set_line_width(cr, 1);
cairo_arc(cr, x, y, radius,
(angle1 + 90) * (M_PI / 180), (angle1 + 90) * (M_PI / 180),
(angle2 + 90) * (M_PI / 180)); (angle2 + 90) * (M_PI / 180));
cairo_stroke(cr); cairo_stroke(glob.cr);
cairo_destroy (cr);
cairo_surface_destroy(surface);
#else #else
/* http://www.crbond.com/primitives.htm /* http://www.crbond.com/primitives.htm
CommonFuncsPPC.lha */ CommonFuncsPPC.lha */
@ -503,9 +497,6 @@ bool ami_path(float *p, unsigned int n, colour fill, float width,
/* For SVG only, because it needs Bezier curves we are going to cheat /* For SVG only, because it needs Bezier curves we are going to cheat
and insist on Cairo */ and insist on Cairo */
#ifdef NS_AMIGA_CAIRO #ifdef NS_AMIGA_CAIRO
cairo_surface_t *surface = cairo_amigaos_surface_create(currp->BitMap);
cairo_t *cr = cairo_create(surface);
unsigned int i; unsigned int i;
cairo_matrix_t old_ctm, n_ctm; cairo_matrix_t old_ctm, n_ctm;
@ -518,11 +509,11 @@ bool ami_path(float *p, unsigned int n, colour fill, float width,
} }
/* Save CTM */ /* Save CTM */
cairo_get_matrix(cr, &old_ctm); cairo_get_matrix(glob.cr, &old_ctm);
/* Set up line style and width */ /* Set up line style and width */
cairo_set_line_width(cr, 1); cairo_set_line_width(glob.cr, 1);
ami_cairo_set_solid(cr); ami_cairo_set_solid(glob.cr);
/* Load new CTM */ /* Load new CTM */
n_ctm.xx = transform[0]; n_ctm.xx = transform[0];
@ -532,56 +523,53 @@ bool ami_path(float *p, unsigned int n, colour fill, float width,
n_ctm.x0 = transform[4]; n_ctm.x0 = transform[4];
n_ctm.y0 = transform[5]; n_ctm.y0 = transform[5];
cairo_set_matrix(cr, &n_ctm); cairo_set_matrix(glob.cr, &n_ctm);
/* Construct path */ /* Construct path */
for (i = 0; i < n; ) { for (i = 0; i < n; ) {
if (p[i] == PLOTTER_PATH_MOVE) { if (p[i] == PLOTTER_PATH_MOVE) {
cairo_move_to(cr, p[i+1], p[i+2]); cairo_move_to(glob.cr, p[i+1], p[i+2]);
i += 3; i += 3;
} else if (p[i] == PLOTTER_PATH_CLOSE) { } else if (p[i] == PLOTTER_PATH_CLOSE) {
cairo_close_path(cr); cairo_close_path(glob.cr);
i++; i++;
} else if (p[i] == PLOTTER_PATH_LINE) { } else if (p[i] == PLOTTER_PATH_LINE) {
cairo_line_to(cr, p[i+1], p[i+2]); cairo_line_to(glob.cr, p[i+1], p[i+2]);
i += 3; i += 3;
} else if (p[i] == PLOTTER_PATH_BEZIER) { } else if (p[i] == PLOTTER_PATH_BEZIER) {
cairo_curve_to(cr, p[i+1], p[i+2], cairo_curve_to(glob.cr, p[i+1], p[i+2],
p[i+3], p[i+4], p[i+3], p[i+4],
p[i+5], p[i+6]); p[i+5], p[i+6]);
i += 7; i += 7;
} else { } else {
LOG(("bad path command %f", p[i])); LOG(("bad path command %f", p[i]));
/* Reset matrix for safety */ /* Reset matrix for safety */
cairo_set_matrix(cr, &old_ctm); cairo_set_matrix(glob.cr, &old_ctm);
return false; return false;
} }
} }
/* Restore original CTM */ /* Restore original CTM */
cairo_set_matrix(cr, &old_ctm); cairo_set_matrix(glob.cr, &old_ctm);
/* Now draw path */ /* Now draw path */
if (fill != TRANSPARENT) { if (fill != TRANSPARENT) {
ami_cairo_set_colour(cr,fill); ami_cairo_set_colour(glob.cr,fill);
if (c != TRANSPARENT) { if (c != TRANSPARENT) {
/* Fill & Stroke */ /* Fill & Stroke */
cairo_fill_preserve(cr); cairo_fill_preserve(glob.cr);
ami_cairo_set_colour(cr,c); ami_cairo_set_colour(glob.cr,c);
cairo_stroke(cr); cairo_stroke(glob.cr);
} else { } else {
/* Fill only */ /* Fill only */
cairo_fill(cr); cairo_fill(glob.cr);
} }
} else if (c != TRANSPARENT) { } else if (c != TRANSPARENT) {
/* Stroke only */ /* Stroke only */
ami_cairo_set_colour(cr,c); ami_cairo_set_colour(glob.cr,c);
cairo_stroke(cr); cairo_stroke(glob.cr);
} }
cairo_destroy (cr);
cairo_surface_destroy(surface);
#endif #endif
return true; return true;
} }