First attempt at Amiga printing support. Doesn't quite work - a column on the left

will print, but the rest of the page is an unexpected pastel pink.

svn path=/trunk/netsurf/; revision=9410
This commit is contained in:
Chris Young 2009-08-23 15:59:41 +00:00
parent 69ee94bb47
commit 3295d71a2f
17 changed files with 266 additions and 52 deletions

View File

@ -248,6 +248,7 @@ PDFNS:PDF...
IFF:IFF...
OpenFile:Open local file...
About:About...
PrintNS:Print
# Edit menu
#

View File

@ -248,6 +248,7 @@ PDFNS:PDF...
IFF:IFF...
OpenFile:Open local file...
About:About...
PrintNS:Print
# Edit menu
#

View File

@ -248,6 +248,7 @@ PDFNS:PDF...
IFF:IFF...
OpenFile:Open local file...
About:About...
PrintNS:Print
# Edit menu
#

View File

@ -250,6 +250,7 @@ PDFNS:PDF...
IFF:IFF...
OpenFile:Apri file locale...
About:Informazioni...
PrintNS:Print
# Edit menu
#

View File

@ -248,6 +248,7 @@ PDFNS:PDF...
IFF:IFF...
OpenFile:Open local file...
About:About...
PrintNS:Print
# Edit menu
#

View File

@ -84,7 +84,7 @@ S_AMIGA := compat.c gui.c tree.c history.c hotlist.c schedule.c \
plotters.c object.c menu.c save_pdf.c arexx.c version.c \
cookies.c context_menu.c clipboard.c save_complete.c \
fetch_file.c fetch_mailto.c search.c history_local.c \
download.c iff_dr2d.c sslcert.c gui_options.c \
download.c iff_dr2d.c sslcert.c gui_options.c print.c \
stringview/stringview.c stringview/urlhistory.c
S_AMIGA := $(addprefix amiga/,$(S_AMIGA))

View File

@ -596,7 +596,7 @@ void gui_init2(int argc, char** argv)
if(notalreadyrunning)
{
ami_openscreen();
ami_init_layers(&browserglob);
ami_init_layers(&browserglob, 0, 0);
}
if(argc) // argc==0 is started from wb
@ -2238,19 +2238,6 @@ void gui_window_set_title(struct gui_window *g, const char *title)
}
}
void ami_clearclipreg(struct RastPort *rp)
{
struct Region *reg = NULL;
reg = InstallClipRegion(rp->Layer,NULL);
if(reg) DisposeRegion(reg);
browserglob.rect.MinX = 0;
browserglob.rect.MinY = 0;
browserglob.rect.MaxX = scrn->Width-1;
browserglob.rect.MaxY = scrn->Height-1;
}
/**
* Redraw an area of the browser window - Amiga-specific function
*
@ -2318,7 +2305,7 @@ void ami_do_redraw_limits(struct gui_window *g, struct content *c,int x0, int y0
current_redraw_browser = NULL;
ami_clearclipreg(&browserglob.rp);
ami_clearclipreg(&browserglob);
BltBitMapRastPort(browserglob.bm,x0-sx,y0-sy,g->shared->win->RPort,
xoffset+x0-sx,yoffset+y0-sy,x1-x0,y1-y0,0x0C0);
@ -2462,7 +2449,7 @@ void ami_do_redraw(struct gui_window_2 *g)
g->bw->scale,0xFFFFFF);
}
ami_clearclipreg(&browserglob.rp);
ami_clearclipreg(&browserglob);
BltBitMapRastPort(browserglob.bm,0,0,g->win->RPort,bbox->Left,bbox->Top,
bbox->Width,bbox->Height,0x0C0);
}
@ -2918,7 +2905,7 @@ void gui_window_new_content(struct gui_window *g)
c = g->shared->bw->current_content;
else return;
ami_clearclipreg(&browserglob.rp);
ami_clearclipreg(&browserglob);
g->shared->new_content = true;
g->scrollx = 0;
g->scrolly = 0;

View File

@ -119,7 +119,6 @@ void ami_update_pointer(struct Window *win, gui_pointer_shape shape);
void ami_close_all_tabs(struct gui_window_2 *gwin);
void ami_quit_netsurf(void);
void ami_get_theme_filename(char *filename,char *themestring);
void ami_clearclipreg(struct RastPort *rp);
void ami_do_redraw(struct gui_window_2 *g);
STRPTR ami_locale_langs(void);

View File

@ -167,7 +167,7 @@ void ami_history_redraw(struct history_window *hw)
// currp = &glob.rp;
ami_clearclipreg(&browserglob.rp);
ami_clearclipreg(&browserglob);
ami_history_update_extent(hw);
BltBitMapRastPort(browserglob.bm, 0, 0, hw->win->RPort,

View File

@ -47,6 +47,7 @@
#include "amiga/clipboard.h"
#include "content/fetch.h"
#include "amiga/gui_options.h"
#include "amiga/print.h"
BOOL menualreadyinit;
const char * const netsurf_version;
@ -87,27 +88,29 @@ void ami_init_menulabs(void)
menulab[12] = ami_utf8_easy((char *)messages_get("CloseTab"));
menulab[13] = ami_utf8_easy((char *)messages_get("CloseWindow"));
menulab[14] = NM_BARLABEL;
menulab[15] = ami_utf8_easy((char *)messages_get("About"));
menulab[16] = ami_utf8_easy((char *)messages_get("Quit"));
menulab[17] = ami_utf8_easy((char *)messages_get("Edit"));
menulab[18] = ami_utf8_easy((char *)messages_get("CopyNS"));
menulab[19] = ami_utf8_easy((char *)messages_get("PasteNS"));
menulab[20] = ami_utf8_easy((char *)messages_get("SelectAllNS"));
menulab[21] = ami_utf8_easy((char *)messages_get("ClearNS"));
menulab[22] = ami_utf8_easy((char *)messages_get("Browser"));
menulab[23] = ami_utf8_easy((char *)messages_get("FindTextNS"));
menulab[24] = NM_BARLABEL;
menulab[25] = ami_utf8_easy((char *)messages_get("normal"));
menulab[26] = ami_utf8_easy((char *)messages_get("HistLocalNS"));
menulab[27] = ami_utf8_easy((char *)messages_get("HistGlobalNS"));
menulab[28] = NM_BARLABEL;
menulab[29] = ami_utf8_easy((char *)messages_get("ShowCookies"));
menulab[15] = ami_utf8_easy((char *)messages_get("PrintNS"));
menulab[16] = NM_BARLABEL;
menulab[17] = ami_utf8_easy((char *)messages_get("About"));
menulab[18] = ami_utf8_easy((char *)messages_get("Quit"));
menulab[19] = ami_utf8_easy((char *)messages_get("Edit"));
menulab[20] = ami_utf8_easy((char *)messages_get("CopyNS"));
menulab[21] = ami_utf8_easy((char *)messages_get("PasteNS"));
menulab[22] = ami_utf8_easy((char *)messages_get("SelectAllNS"));
menulab[23] = ami_utf8_easy((char *)messages_get("ClearNS"));
menulab[24] = ami_utf8_easy((char *)messages_get("Browser"));
menulab[25] = ami_utf8_easy((char *)messages_get("FindTextNS"));
menulab[26] = NM_BARLABEL;
menulab[27] = ami_utf8_easy((char *)messages_get("normal"));
menulab[28] = ami_utf8_easy((char *)messages_get("HistLocalNS"));
menulab[29] = ami_utf8_easy((char *)messages_get("HistGlobalNS"));
menulab[30] = NM_BARLABEL;
menulab[31] = ami_utf8_easy((char *)messages_get("Redraw"));
menulab[32] = ami_utf8_easy((char *)messages_get("Hotlist"));
menulab[33] = ami_utf8_easy((char *)messages_get("HotlistAdd"));
menulab[34] = ami_utf8_easy((char *)messages_get("HotlistShowNS"));
menulab[35] = NM_BARLABEL;
menulab[31] = ami_utf8_easy((char *)messages_get("ShowCookies"));
menulab[32] = NM_BARLABEL;
menulab[33] = ami_utf8_easy((char *)messages_get("Redraw"));
menulab[34] = ami_utf8_easy((char *)messages_get("Hotlist"));
menulab[35] = ami_utf8_easy((char *)messages_get("HotlistAdd"));
menulab[36] = ami_utf8_easy((char *)messages_get("HotlistShowNS"));
menulab[37] = NM_BARLABEL;
menulab[AMI_MENU_HOTLIST_MAX] = ami_utf8_easy((char *)messages_get("Settings"));
menulab[AMI_MENU_HOTLIST_MAX+1] = ami_utf8_easy((char *)messages_get("SettingsEdit"));
@ -139,6 +142,8 @@ struct NewMenu *ami_create_menu(ULONG type)
{ NM_ITEM,0,"K",0,0,0,}, // close tab
{ NM_ITEM,0,0,0,0,0,}, // close window
{ NM_ITEM,NM_BARLABEL,0,0,0,0,},
{ NM_ITEM,0,"P",0,0,0,}, // print
{ NM_ITEM,NM_BARLABEL,0,0,0,0,},
{ NM_ITEM,0,"?",0,0,0,}, // about
{ NM_ITEM,0,"Q",0,0,0,}, // quit
{NM_TITLE,0,0,0,0,0,}, // edit
@ -563,7 +568,11 @@ void ami_menupick(ULONG code,struct gui_window_2 *gwin,struct MenuItem *item)
ami_close_all_tabs(gwin);
break;
case 9: // about
case 9: // print
ami_print(gwin->bw->current_content);
break;
case 11: // about
ami_update_pointer(gwin->win,GUI_POINTER_WAIT);
TimedDosRequesterTags(
@ -585,7 +594,7 @@ void ami_menupick(ULONG code,struct gui_window_2 *gwin,struct MenuItem *item)
ami_update_pointer(gwin->win,GUI_POINTER_DEFAULT);
break;
case 10: // quit
case 12: // quit
ami_quit_netsurf();
break;
}

View File

@ -28,10 +28,10 @@
/* Maximum number of menu items - first value is number of static items
* (ie. everything not intially defined as NM_IGNORE) */
#define AMI_MENU_MAX 44 + AMI_HOTLIST_ITEMS
#define AMI_MENU_MAX 46 + AMI_HOTLIST_ITEMS
/* Where the hotlist entries start */
#define AMI_MENU_HOTLIST 36
#define AMI_MENU_HOTLIST 38
/* Where the hotlist entries end */
#define AMI_MENU_HOTLIST_MAX AMI_MENU_HOTLIST+AMI_HOTLIST_ITEMS

View File

@ -41,6 +41,7 @@ extern char *option_download_dir;
extern bool option_faster_scroll;
extern bool option_scale_quality;
extern bool option_ask_overwrite;
extern int option_printer_unit;
#define EXTRA_OPTION_DEFINE \
bool option_verbose_log = false; \
@ -64,6 +65,7 @@ char *option_download_dir = 0; \
bool option_faster_scroll = true; \
bool option_scale_quality = false; \
bool option_ask_overwrite = false; \
int option_printer_unit = 0; \
#define EXTRA_OPTION_TABLE \
{ "verbose_log", OPTION_BOOL, &option_verbose_log}, \
@ -86,5 +88,7 @@ bool option_ask_overwrite = false; \
{ "download_dir", OPTION_STRING, &option_download_dir }, \
{ "faster_scroll", OPTION_BOOL, &option_faster_scroll}, \
{ "scale_quality", OPTION_BOOL, &option_scale_quality}, \
{ "ask_overwrite", OPTION_BOOL, &option_ask_overwrite},
{ "ask_overwrite", OPTION_BOOL, &option_ask_overwrite}, \
{ "printer_unit", OPTION_INTEGER, &option_printer_unit},
#endif

View File

@ -107,17 +107,20 @@ void ami_cairo_set_dashed(cairo_t *cr)
}
#endif
void ami_init_layers(struct gui_globals *gg)
void ami_init_layers(struct gui_globals *gg, ULONG width, ULONG height)
{
/* init shared bitmaps *
* Height is set to screen width to give enough space for thumbnails *
* Also applies to the further gfx/layers functions and memory below */
if(!width) width = scrn->Width;
if(!height) height = scrn->Width;
gg->layerinfo = NewLayerInfo();
gg->areabuf = AllocVec(100,MEMF_PRIVATE | MEMF_CLEAR);
gg->tmprasbuf = AllocVec(scrn->Width*scrn->Width,MEMF_PRIVATE | MEMF_CLEAR);
gg->tmprasbuf = AllocVec(width*height,MEMF_PRIVATE | MEMF_CLEAR);
gg->bm = p96AllocBitMap(scrn->Width,scrn->Width,32,
gg->bm = p96AllocBitMap(width, height, 32,
BMF_INTERLEAVED, NULL, RGBFB_A8R8G8B8);
if(!gg->bm) warn_user("NoMemory","");
@ -128,7 +131,7 @@ void ami_init_layers(struct gui_globals *gg)
SetDrMd(&gg->rp,BGBACKFILL);
gg->rp.Layer = CreateUpfrontLayer(gg->layerinfo,gg->rp.BitMap,0,0,
scrn->Width-1,scrn->Width-1,LAYERSIMPLE,NULL);
width-1, height-1, LAYERSIMPLE, NULL);
InstallLayerHook(gg->rp.Layer,LAYERS_NOBACKFILL);
@ -141,7 +144,7 @@ void ami_init_layers(struct gui_globals *gg)
if((!gg->tmprasbuf) || (!gg->rp.TmpRas)) warn_user("NoMemory","");
InitTmpRas(gg->rp.TmpRas,gg->tmprasbuf,scrn->Width*scrn->Width);
InitTmpRas(gg->rp.TmpRas, gg->tmprasbuf, width*height);
#ifdef NS_AMIGA_CAIRO
gg->surface = cairo_amigaos_surface_create(gg->rp.BitMap);
@ -178,6 +181,19 @@ bool ami_clg(colour c)
return true;
}
void ami_clearclipreg(struct gui_globals *gg)
{
struct Region *reg = NULL;
reg = InstallClipRegion(gg->rp.Layer,NULL);
if(reg) DisposeRegion(reg);
gg->rect.MinX = 0;
gg->rect.MinY = 0;
gg->rect.MaxX = scrn->Width-1;
gg->rect.MaxY = scrn->Height-1;
}
bool ami_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style)
{
if (style->fill_type != PLOT_OP_TYPE_NONE) {

View File

@ -60,8 +60,9 @@ bool ami_flush(void);
bool ami_path(const float *p, unsigned int n, colour fill, float width,
colour c, const float transform[6]);
void ami_init_layers(struct gui_globals *gg);
void ami_init_layers(struct gui_globals *gg, ULONG width, ULONG height);
void ami_free_layers(struct gui_globals *gg);
void ami_clearclipreg(struct gui_globals *gg);
struct gui_globals *glob;
#endif

169
amiga/print.c Normal file
View File

@ -0,0 +1,169 @@
/*
* Copyright 2009 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/>.
*/
#include "desktop/printer.h"
#include "amiga/plotters.h"
#include "render/font.h"
#include "amiga/gui.h"
#include "amiga/options.h"
#include <proto/exec.h>
#include <proto/Picasso96API.h>
#include <devices/printer.h>
#include <devices/prtbase.h>
bool ami_print_begin(struct print_settings *ps);
bool ami_print_next_page(void);
void ami_print_end(void);
bool ami_print_dump(void);
static VOID ami_print_hook(struct Hook *hook, APTR dummy,
struct DRPSourceMsg * drpm);
const struct printer amiprinter = {
&amiplot,
ami_print_begin,
ami_print_next_page,
ami_print_end,
};
struct ami_printer_info
{
struct gui_globals *gg;
struct IODRPTagsReq *PReq;
struct PrinterData *PD;
struct PrinterExtendedData *PED;
struct MsgPort *msgport;
int page;
};
struct Hook phook =
{
{NULL, NULL},
(HOOKFUNC)ami_print_hook,
NULL, NULL
};
struct ami_printer_info ami_print_info;
void ami_print(struct content *c)
{
struct print_settings *ps;
if(!(ami_print_info.msgport = AllocSysObjectTags(ASOT_PORT,
ASO_NoTrack,FALSE,
TAG_DONE))) return;
if(!(ami_print_info.PReq =
(struct IODRPTagsReq *)AllocSysObjectTags(ASOT_IOREQUEST,
ASOIOR_Size, sizeof(struct IODRPTagsReq),
ASOIOR_ReplyPort, ami_print_info.msgport,
ASO_NoTrack, FALSE,
TAG_DONE))) return;
if(OpenDevice("printer.device", option_printer_unit,
(struct IORequest *)ami_print_info.PReq, 0)) return;
ami_print_info.PD = (struct PrinterData *)ami_print_info.PReq->io_Device;
ami_print_info.PED = &ami_print_info.PD->pd_SegmentData->ps_PED;
ps = print_make_settings(PRINT_DEFAULT, c->url, &nsfont);
ps->page_width = ami_print_info.PED->ped_MaxXDots;
ps->page_height = ami_print_info.PED->ped_MaxYDots;
print_basic_run(c, &amiprinter, ps);
CloseDevice(ami_print_info.PReq);
FreeSysObject(ASOT_IOREQUEST,ami_print_info.PReq);
FreeSysObject(ASOT_PORT,ami_print_info.msgport);
}
bool ami_print_begin(struct print_settings *ps)
{
ami_print_info.gg = AllocVec(sizeof(struct gui_globals),
MEMF_PRIVATE | MEMF_CLEAR);
if(!ami_print_info.gg) return false;
ami_init_layers(ami_print_info.gg,
ami_print_info.PED->ped_MaxXDots,
ami_print_info.PED->ped_MaxYDots);
glob = ami_print_info.gg;
ami_print_info.page = 0;
return true;
}
bool ami_print_next_page(void)
{
bool ret = true;
if(ami_print_info.page > 0) ret = ami_print_dump();
ami_print_info.page++;
return ret;
}
void ami_print_end(void)
{
ami_print_dump();
ami_free_layers(ami_print_info.gg);
FreeVec(ami_print_info.gg);
glob = &browserglob;
}
bool ami_print_dump(void)
{
static struct TagItem tags[] = {
{DRPA_SourceHook, (Tag)&phook},
{DRPA_AspectX, 1},
{DRPA_AspectY, 1},
{TAG_DONE, 0}
};
ami_print_info.PReq->io_Command = PRD_DUMPRPORTTAGS;
ami_print_info.PReq->io_Flags = 0;
ami_print_info.PReq->io_Error = 0;
ami_print_info.PReq->io_RastPort = NULL;
ami_print_info.PReq->io_ColorMap = NULL;
ami_print_info.PReq->io_Modes = 0;
ami_print_info.PReq->io_SrcX = 0;
ami_print_info.PReq->io_SrcY = 0;
ami_print_info.PReq->io_SrcWidth = ami_print_info.PED->ped_MaxXDots;
ami_print_info.PReq->io_SrcHeight = ami_print_info.PED->ped_MaxYDots;
ami_print_info.PReq->io_DestCols = ami_print_info.PED->ped_MaxXDots;
ami_print_info.PReq->io_DestRows = ami_print_info.PED->ped_MaxYDots;
ami_print_info.PReq->io_Special = 0;
ami_print_info.PReq->io_TagList = tags;
DoIO(ami_print_info.PReq);
return true;
}
static VOID ami_print_hook(struct Hook *hook, APTR dummy,
struct DRPSourceMsg * drpm)
{
struct RenderInfo ri;
ri.Memory = drpm->buf;
ri.BytesPerRow = drpm->width;
ri.RGBFormat = RGBFB_A8R8G8B8;
p96ReadPixelArray(&ri, 0, 0, &ami_print_info.gg->rp, drpm->x, drpm->y,
drpm->width, drpm->height);
}

24
amiga/print.h Executable file
View File

@ -0,0 +1,24 @@
/*
* Copyright 2009 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 AMIGA_PRINT_H
#define AMIGA_PRINT_H
struct content;
void ami_print(struct content *c);
#endif

View File

@ -39,7 +39,7 @@ bool thumbnail_create(struct content *content, struct bitmap *bitmap,
bitmap->nativebmwidth = bitmap->width;
bitmap->nativebmheight = bitmap->height;
ami_clearclipreg(&browserglob.rp);
ami_clearclipreg(&browserglob);
plot = amiplot;
content_redraw(content, 0, 0, content->width, content->width,
0, 0, content->width, content->width, 1.0, 0xFFFFFF);