summaryrefslogtreecommitdiff
path: root/amiga
diff options
context:
space:
mode:
Diffstat (limited to 'amiga')
-rw-r--r--amiga/font.c36
-rwxr-xr-xamiga/font.h2
-rwxr-xr-xamiga/gui.c23
-rwxr-xr-xamiga/gui.h1
-rwxr-xr-xamiga/gui_options.c2
-rwxr-xr-xamiga/plotters.c243
-rwxr-xr-xamiga/plotters.h2
7 files changed, 189 insertions, 120 deletions
diff --git a/amiga/font.c b/amiga/font.c
index 8be407612..ffecf85fe 100644
--- a/amiga/font.c
+++ b/amiga/font.c
@@ -79,7 +79,7 @@ ULONG ami_devicedpi;
ULONG ami_xdpi;
int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPort *rp,
- uint16 char1, uint16 char2, uint32 x, uint32 y, uint32 emwidth);
+ uint16 char1, uint16 char2, uint32 x, uint32 y, uint32 emwidth, bool aa);
int32 ami_font_width_glyph(struct OutlineFont *ofont,
uint16 char1, uint16 char2, uint32 emwidth);
struct OutlineFont *ami_open_outline_font(const plot_font_style_t *fstyle,
@@ -108,7 +108,7 @@ bool nsfont_width(const plot_font_style_t *fstyle,
const char *string, size_t length,
int *width)
{
- *width = ami_unicode_text(NULL,string,length,fstyle,0,0);
+ *width = ami_unicode_text(NULL, string, length, fstyle, 0, 0, false);
if(*width <= 0) *width == length; // fudge
@@ -517,20 +517,27 @@ struct OutlineFont *ami_open_outline_font(const plot_font_style_t *fstyle,
}
int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPort *rp,
- uint16 char1, uint16 char2, uint32 x, uint32 y, uint32 emwidth)
+ uint16 char1, uint16 char2, uint32 x, uint32 y, uint32 emwidth, bool aa)
{
struct GlyphMap *glyph;
UBYTE *glyphbm;
int32 char_advance = 0;
FIXED kern = 0;
-
+ ULONG glyphmaptag = OT_GlyphMap8Bit;
+ ULONG template_type = BLITT_ALPHATEMPLATE;
+
+ if(aa == false) {
+ glyphmaptag = OT_GlyphMap;
+ template_type = BLITT_TEMPLATE;
+ }
+
if(ESetInfo(&ofont->olf_EEngine,
OT_GlyphCode, char1,
OT_GlyphCode2, char2,
TAG_END) == OTERR_Success)
{
if(EObtainInfo(&ofont->olf_EEngine,
- OT_GlyphMap8Bit,&glyph,
+ glyphmaptag, &glyph,
TAG_END) == 0)
{
glyphbm = glyph->glm_BitMap;
@@ -545,7 +552,7 @@ int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPort *rp,
BLITA_Width, glyph->glm_BlackWidth,
BLITA_Height, glyph->glm_BlackHeight,
BLITA_Source, glyphbm,
- BLITA_SrcType, BLITT_ALPHATEMPLATE,
+ BLITA_SrcType, template_type,
BLITA_Dest, rp,
BLITA_DestType, BLITT_RASTPORT,
BLITA_SrcBytesPerRow, glyph->glm_BMModulo,
@@ -561,7 +568,7 @@ int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPort *rp,
char_advance = (ULONG)(((glyph->glm_Width - kern) * emwidth) / 65536);
EReleaseInfo(&ofont->olf_EEngine,
- OT_GlyphMap8Bit,glyph,
+ glyphmaptag, glyph,
TAG_END);
}
}
@@ -691,7 +698,8 @@ uint16 ami_font_translate_smallcaps(uint16 utf16char)
return utf16char;
}
-ULONG ami_unicode_text(struct RastPort *rp,const char *string,ULONG length,const plot_font_style_t *fstyle,ULONG dx, ULONG dy)
+ULONG ami_unicode_text(struct RastPort *rp, const char *string, ULONG length,
+ const plot_font_style_t *fstyle, ULONG dx, ULONG dy, bool aa)
{
uint16 *utf16 = NULL, *outf16 = NULL;
uint16 utf16charsc = 0, utf16nextsc = 0;
@@ -712,8 +720,6 @@ ULONG ami_unicode_text(struct RastPort *rp,const char *string,ULONG length,const
outf16 = utf16;
if(!(ofont = ami_open_outline_font(fstyle, 0))) return 0;
- if(rp) SetRPAttrs(rp,RPTAG_APenColor,p96EncodeColor(RGBFB_A8B8G8R8,fstyle->foreground),TAG_DONE);
-
while(*utf16 != 0)
{
if (*utf16 < 0xD800 || 0xDFFF < *utf16)
@@ -729,7 +735,8 @@ ULONG ami_unicode_text(struct RastPort *rp,const char *string,ULONG length,const
utf16nextsc = ami_font_translate_smallcaps(utf16next);
if(rp) {
- tempx = ami_font_plot_glyph(ofont, rp, utf16charsc, utf16nextsc, dx + x, dy, emwidth);
+ tempx = ami_font_plot_glyph(ofont, rp, utf16charsc, utf16nextsc,
+ dx + x, dy, emwidth, aa);
} else {
tempx = ami_font_width_glyph(ofont, utf16charsc, utf16nextsc, emwidth);
}
@@ -738,7 +745,8 @@ ULONG ami_unicode_text(struct RastPort *rp,const char *string,ULONG length,const
if(tempx == 0) {
if(rp) {
- tempx = ami_font_plot_glyph(ofont, rp, *utf16, utf16next, dx + x, dy, emwidth);
+ tempx = ami_font_plot_glyph(ofont, rp, *utf16, utf16next,
+ dx + x, dy, emwidth, aa);
} else {
tempx = ami_font_width_glyph(ofont, *utf16, utf16next, emwidth);
}
@@ -755,7 +763,7 @@ ULONG ami_unicode_text(struct RastPort *rp,const char *string,ULONG length,const
{
if(rp) {
tempx = ami_font_plot_glyph(ufont, rp, *utf16, utf16next,
- dx + x, dy, emwidth);
+ dx + x, dy, emwidth, aa);
} else {
tempx = ami_font_width_glyph(ufont, *utf16, utf16next, emwidth);
}
@@ -765,7 +773,7 @@ ULONG ami_unicode_text(struct RastPort *rp,const char *string,ULONG length,const
{
if(rp) {
tempx = ami_font_plot_glyph(ofont, rp, 0xfffd, utf16next,
- dx + x, dy, emwidth);
+ dx + x, dy, emwidth, aa);
} else {
tempx = ami_font_width_glyph(ofont, 0xfffd, utf16next, emwidth);
}
diff --git a/amiga/font.h b/amiga/font.h
index 36bdbf9ef..10137f777 100755
--- a/amiga/font.h
+++ b/amiga/font.h
@@ -26,7 +26,7 @@
struct ami_font_node;
ULONG ami_unicode_text(struct RastPort *rp, const char *string,
- ULONG length, const plot_font_style_t *fstyle, ULONG x, ULONG y);
+ ULONG length, const plot_font_style_t *fstyle, ULONG x, ULONG y, bool aa);
void ami_font_setdevicedpi(int id);
void ami_init_fonts(void);
void ami_close_fonts(void);
diff --git a/amiga/gui.c b/amiga/gui.c
index 6fc8a2991..d77210541 100755
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -603,7 +603,7 @@ void ami_openscreen(void)
if(screenmodereq = AllocAslRequest(ASL_ScreenModeRequest,NULL))
{
if(AslRequestTags(screenmodereq,
- ASLSM_MinDepth,16,
+ ASLSM_MinDepth,0,
ASLSM_MaxDepth,32,
TAG_DONE))
{
@@ -2209,6 +2209,7 @@ void ami_switch_tab(struct gui_window_2 *gwin,bool redraw)
return;
}
+ ami_plot_release_pens(&gwin->shared_pens);
ami_update_buttons(gwin);
ami_menu_update_disabled(gwin->bw->window, gwin->bw->current_content);
@@ -2574,6 +2575,8 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
return NULL;
}
+ NewMinList(&g->shared->shared_pens);
+
g->shared->scrollerhook.h_Entry = (void *)ami_scroller_hook;
g->shared->scrollerhook.h_Data = g->shared;
@@ -3182,12 +3185,14 @@ void gui_window_destroy(struct gui_window *g)
return;
}
+ ami_plot_release_pens(&g->shared->shared_pens);
+
DisposeObject(g->shared->objects[OID_MAIN]);
ami_gui_appicon_remove(g->shared);
if(g->shared->appwin) RemoveAppWindow(g->shared->appwin);
/* These aren't freed by the above.
- * TODO: nav_west etc need freeing too */
+ * TODO: nav_west etc need freeing too? */
DisposeObject(g->shared->objects[GID_ADDTAB_BM]);
DisposeObject(g->shared->objects[GID_CLOSETAB_BM]);
DisposeObject(g->shared->objects[GID_TABS_FLAG]);
@@ -3280,6 +3285,8 @@ void ami_do_redraw_tiled(struct gui_window_2 *gwin,
int tile_x_scale = (int)(nsoption_int(redraw_tile_size_x) / gwin->bw->scale);
int tile_y_scale = (int)(nsoption_int(redraw_tile_size_y) / gwin->bw->scale);
+ browserglob.shared_pens = &gwin->shared_pens;
+
if(top < 0) {
height += top;
top = 0;
@@ -3308,7 +3315,7 @@ void ami_do_redraw_tiled(struct gui_window_2 *gwin,
if(width <= 0) return;
if(height <= 0) return;
-//printf("%ld %ld %ld %ld\n",left, top, width, height);
+// printf("%ld %ld %ld %ld\n",left, top, width, height);
for(y = top; y < (top + height); y += tile_y_scale) {
clip.y0 = 0;
@@ -3470,14 +3477,14 @@ void ami_do_redraw(struct gui_window_2 *g)
g->bw->window->c_h = g->bw->window->c_h_temp;
- if(vcurrent>oldv)
+ if(vcurrent>oldv) /* Going down */
{
ami_do_redraw_limits(g->bw->window, g->bw,
hcurrent, (height / g->bw->scale) + oldv - 1,
hcurrent + (width / g->bw->scale),
vcurrent + (height / g->bw->scale) + 1);
}
- else if(vcurrent<oldv)
+ else if(vcurrent<oldv) /* Going up */
{
ami_do_redraw_limits(g->bw->window, g->bw,
hcurrent, vcurrent,
@@ -3485,14 +3492,14 @@ void ami_do_redraw(struct gui_window_2 *g)
oldv);
}
- if(hcurrent>oldh)
+ if(hcurrent>oldh) /* Going right */
{
ami_do_redraw_limits(g->bw->window, g->bw,
(width / g->bw->scale) + oldh , vcurrent,
hcurrent + (width / g->bw->scale),
vcurrent + (height / g->bw->scale));
}
- else if(hcurrent<oldh)
+ else if(hcurrent<oldh) /* Going left */
{
ami_do_redraw_limits(g->bw->window, g->bw,
hcurrent, vcurrent,
@@ -3997,7 +4004,7 @@ void gui_window_new_content(struct gui_window *g)
g->shared->oldh = 0;
g->shared->oldv = 0;
g->favicon = NULL;
-
+ ami_plot_release_pens(&g->shared->shared_pens);
ami_menu_update_disabled(g, c);
}
diff --git a/amiga/gui.h b/amiga/gui.h
index 01588c790..013be50c0 100755
--- a/amiga/gui.h
+++ b/amiga/gui.h
@@ -112,6 +112,7 @@ struct gui_window_2 {
gui_drag_type drag_op;
struct IBox *ptr_lock;
struct AppWindow *appwin;
+ struct MinList shared_pens;
};
struct gui_window
diff --git a/amiga/gui_options.c b/amiga/gui_options.c
index 2d65099b0..59e9c9038 100755
--- a/amiga/gui_options.c
+++ b/amiga/gui_options.c
@@ -669,7 +669,7 @@ void ami_gui_opts_open(void)
GA_RelVerify, TRUE,
GA_Disabled,screenmodedisabled,
GETSCREENMODE_DisplayID,screenmodeid,
- GETSCREENMODE_MinDepth, 16,
+ GETSCREENMODE_MinDepth, 0,
GETSCREENMODE_MaxDepth, 32,
GetScreenModeEnd,
LAYOUT_AddChild, gow->objects[GID_OPTS_SCREENNAME] = StringObject,
diff --git a/amiga/plotters.c b/amiga/plotters.c
index c2a5c0b2e..85376381d 100755
--- a/amiga/plotters.c
+++ b/amiga/plotters.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2008,2009 Chris Young <chris@unsatisfactorysoftware.co.uk>
+ * Copyright 2008, 2009, 2012 Chris Young <chris@unsatisfactorysoftware.co.uk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -19,23 +19,29 @@
#include "amiga/plotters.h"
#include "amiga/bitmap.h"
#include "amiga/font.h"
+#include "amiga/gui.h"
+#include "amiga/utf8.h"
+
+#include "desktop/options.h"
+#include "utils/utils.h"
+#include "utils/log.h"
+
#include <proto/Picasso96API.h>
+#include <proto/exec.h>
+#include <proto/intuition.h>
+
#include <intuition/intuition.h>
#include <graphics/rpattr.h>
#include <graphics/gfxmacros.h>
#include <graphics/gfxbase.h>
-#include "amiga/utf8.h"
-#include "desktop/options.h"
+
#ifdef __amigaos4__
#include <graphics/blitattr.h>
#include <graphics/composite.h>
#endif
-#include "utils/log.h"
+
#include <math.h>
#include <assert.h>
-#include <proto/exec.h>
-#include "amiga/gui.h"
-#include "utils/utils.h"
static void ami_bitmap_tile_hook(struct Hook *hook,struct RastPort *rp,struct BackFillMessage *bfmsg);
@@ -47,6 +53,7 @@ struct bfbitmap {
int offsety;
};
+bool palette_mapped = false;
#ifndef M_PI /* For some reason we don't always get this from math.h */
#define M_PI 3.14159265358979323846
@@ -118,20 +125,38 @@ 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 */
-
+
+ ULONG depth = 32;
+ struct DrawInfo *dri;
struct BitMap *friend = NULL; /* Required to be NULL for Cairo and ARGB bitmaps */
+ if(dri = GetScreenDrawInfo(scrn)) {
+ if((dri->dri_Depth < 16) || (nsoption_int(cairo_renderer) == -1)) {
+ palette_mapped = true;
+ depth = dri->dri_Depth; /* this is always wrong */
+ // friend = scrn->RastPort.BitMap;
+ } else {
+ palette_mapped = false;
+ }
+ FreeScreenDrawInfo(scrn, dri);
+ }
+
if(nsoption_int(redraw_tile_size_x) <= 0) nsoption_set_int(redraw_tile_size_x, scrn->Width);
if(nsoption_int(redraw_tile_size_y) <= 0) nsoption_set_int(redraw_tile_size_y, scrn->Height);
if(!width) width = nsoption_int(redraw_tile_size_x);
if(!height) height = nsoption_int(redraw_tile_size_y);
gg->layerinfo = NewLayerInfo();
- gg->areabuf = AllocVec(100,MEMF_PRIVATE | MEMF_CLEAR);
- gg->tmprasbuf = AllocVec(width*height,MEMF_PRIVATE | MEMF_CLEAR);
+ gg->areabuf = AllocVec(100, MEMF_PRIVATE | MEMF_CLEAR);
+ gg->tmprasbuf = AllocVec(width * height, MEMF_PRIVATE | MEMF_CLEAR);
- gg->bm = p96AllocBitMap(width, height, 32,
+ if(palette_mapped ==false) {
+ gg->bm = p96AllocBitMap(width, height, 32,
BMF_INTERLEAVED, friend, RGBFB_A8R8G8B8);
+ } else {
+ gg->bm = AllocBitMap(width, height, depth, BMF_INTERLEAVED, friend);
+ }
+
if(!gg->bm) warn_user("NoMemory","");
gg->rp = AllocVec(sizeof(struct RastPort), MEMF_PRIVATE | MEMF_CLEAR);
@@ -182,7 +207,11 @@ void ami_free_layers(struct gui_globals *gg)
FreeVec(gg->tmprasbuf);
FreeVec(gg->areabuf);
DisposeLayerInfo(gg->layerinfo);
- p96FreeBitMap(gg->bm);
+ if(palette_mapped == false) {
+ p96FreeBitMap(gg->bm);
+ } else {
+ FreeBitMap(gg->bm);
+ }
}
void ami_clearclipreg(struct gui_globals *gg)
@@ -198,6 +227,50 @@ void ami_clearclipreg(struct gui_globals *gg)
gg->rect.MaxY = scrn->Height-1;
}
+ULONG ami_plot_obtain_pen(struct MinList *shared_pens, ULONG colour)
+{
+ ULONG pen = ObtainBestPenA(scrn->ViewPort.ColorMap,
+ (colour & 0x000000ff) << 24,
+ (colour & 0x0000ff00) << 16,
+ (colour & 0x00ff0000) << 8,
+ NULL);
+
+ if(pen == -1) LOG(("WARNING: Cannot allocate pen for ABGR:%lx", colour));
+
+ /* TODO: add allocated pen to list */
+
+ return pen;
+}
+
+void ami_plot_release_pens(struct MinList *shared_pens)
+{
+ /* TODO: trawl through list releasing pens */
+}
+
+void ami_plot_setapen(ULONG colour)
+{
+ if(palette_mapped == false) {
+ SetRPAttrs(glob->rp, RPTAG_APenColor,
+ p96EncodeColor(RGBFF_A8B8G8R8, colour),
+ TAG_DONE);
+ } else {
+ ULONG pen = ami_plot_obtain_pen(glob->shared_pens, colour);
+ if(pen != -1) SetAPen(glob->rp, pen);
+ }
+}
+
+void ami_plot_setopen(ULONG colour)
+{
+ if(palette_mapped == false) {
+ SetRPAttrs(glob->rp, RPTAG_OPenColor,
+ p96EncodeColor(RGBFF_A8B8G8R8, colour),
+ TAG_DONE);
+ } else {
+ ULONG pen = ami_plot_obtain_pen(glob->shared_pens, colour);
+ if(pen != -1) SetOPen(glob->rp, pen);
+ }
+}
+
bool ami_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style)
{
#ifdef AMI_PLOTTER_DEBUG
@@ -206,11 +279,10 @@ bool ami_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style)
if (style->fill_type != PLOT_OP_TYPE_NONE) {
- if(nsoption_int(cairo_renderer) < 2)
+ if((nsoption_int(cairo_renderer) < 2) ||
+ (palette_mapped == true))
{
- SetRPAttrs(glob->rp, RPTAG_APenColor,
- p96EncodeColor(RGBFB_A8B8G8R8, style->fill_colour),
- TAG_DONE);
+ ami_plot_setapen(style->fill_colour);
RectFill(glob->rp, x0, y0, x1-1, y1-1);
}
else
@@ -228,7 +300,8 @@ bool ami_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style)
}
if (style->stroke_type != PLOT_OP_TYPE_NONE) {
- if(nsoption_int(cairo_renderer) < 2)
+ if((nsoption_int(cairo_renderer) < 2) ||
+ (palette_mapped == true))
{
glob->rp->PenWidth = style->stroke_width;
glob->rp->PenHeight = style->stroke_width;
@@ -248,10 +321,7 @@ bool ami_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style)
break;
}
- SetRPAttrs(glob->rp,
- RPTAG_APenColor,
- p96EncodeColor(RGBFB_A8B8G8R8, style->stroke_colour),
- TAG_DONE);
+ ami_plot_setapen(style->stroke_colour);
Move(glob->rp, x0,y0);
Draw(glob->rp, x1, y0);
Draw(glob->rp, x1, y1);
@@ -267,25 +337,25 @@ bool ami_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style)
#ifdef NS_AMIGA_CAIRO
ami_cairo_set_colour(glob->cr, style->stroke_colour);
- switch (style->stroke_type) {
- case PLOT_OP_TYPE_SOLID: /**< Solid colour */
- default:
- ami_cairo_set_solid(glob->cr);
- break;
+ switch (style->stroke_type) {
+ case PLOT_OP_TYPE_SOLID: /**< Solid colour */
+ default:
+ ami_cairo_set_solid(glob->cr);
+ break;
- case PLOT_OP_TYPE_DOT: /**< Doted plot */
- ami_cairo_set_dotted(glob->cr);
- break;
+ case PLOT_OP_TYPE_DOT: /**< Doted plot */
+ ami_cairo_set_dotted(glob->cr);
+ break;
- case PLOT_OP_TYPE_DASH: /**< dashed plot */
- ami_cairo_set_dashed(glob->cr);
- break;
- }
+ case PLOT_OP_TYPE_DASH: /**< dashed plot */
+ ami_cairo_set_dashed(glob->cr);
+ break;
+ }
- if (style->stroke_width == 0)
- cairo_set_line_width(glob->cr, 1);
- else
- cairo_set_line_width(glob->cr, style->stroke_width);
+ if (style->stroke_width == 0)
+ cairo_set_line_width(glob->cr, 1);
+ else
+ cairo_set_line_width(glob->cr, style->stroke_width);
cairo_rectangle(glob->cr, x0, y0, x1 - x0, y1 - y0);
cairo_stroke(glob->cr);
@@ -301,7 +371,7 @@ bool ami_line(int x0, int y0, int x1, int y1, const plot_style_t *style)
LOG(("[ami_plotter] Entered ami_line()"));
#endif
- if(nsoption_int(cairo_renderer) < 2)
+ if((nsoption_int(cairo_renderer) < 2) || (palette_mapped == true))
{
glob->rp->PenWidth = style->stroke_width;
glob->rp->PenHeight = style->stroke_width;
@@ -321,10 +391,7 @@ bool ami_line(int x0, int y0, int x1, int y1, const plot_style_t *style)
break;
}
- SetRPAttrs(glob->rp,
- RPTAG_APenColor,
- p96EncodeColor(RGBFB_A8B8G8R8, style->stroke_colour),
- TAG_DONE);
+ ami_plot_setapen(style->stroke_colour);
Move(glob->rp,x0,y0);
Draw(glob->rp,x1,y1);
@@ -337,25 +404,25 @@ bool ami_line(int x0, int y0, int x1, int y1, const plot_style_t *style)
#ifdef NS_AMIGA_CAIRO
ami_cairo_set_colour(glob->cr, style->stroke_colour);
- switch (style->stroke_type) {
- case PLOT_OP_TYPE_SOLID: /**< Solid colour */
- default:
- ami_cairo_set_solid(glob->cr);
- break;
-
- case PLOT_OP_TYPE_DOT: /**< Doted plot */
- ami_cairo_set_dotted(glob->cr);
- break;
-
- case PLOT_OP_TYPE_DASH: /**< dashed plot */
- ami_cairo_set_dashed(glob->cr);
- break;
- }
+ switch (style->stroke_type) {
+ case PLOT_OP_TYPE_SOLID: /**< Solid colour */
+ default:
+ ami_cairo_set_solid(glob->cr);
+ break;
+
+ case PLOT_OP_TYPE_DOT: /**< Doted plot */
+ ami_cairo_set_dotted(glob->cr);
+ break;
+
+ case PLOT_OP_TYPE_DASH: /**< dashed plot */
+ ami_cairo_set_dashed(glob->cr);
+ break;
+ }
- if (style->stroke_width == 0)
- cairo_set_line_width(glob->cr, 1);
- else
- cairo_set_line_width(glob->cr, style->stroke_width);
+ if (style->stroke_width == 0)
+ cairo_set_line_width(glob->cr, 1);
+ else
+ cairo_set_line_width(glob->cr, style->stroke_width);
/* core expects horizontal and vertical lines to be on pixels, not
* between pixels */
@@ -377,17 +444,12 @@ bool ami_polygon(const int *p, unsigned int n, const plot_style_t *style)
int k;
- if(nsoption_int(cairo_renderer) < 1)
+ if((nsoption_int(cairo_renderer) < 1) || (palette_mapped == true))
{
ULONG cx,cy;
- SetRPAttrs(glob->rp,
- RPTAG_APenColor,
- p96EncodeColor(RGBFB_A8B8G8R8, style->fill_colour),
- RPTAG_OPenColor,
- p96EncodeColor(RGBFB_A8B8G8R8, style->fill_colour),
-// RPTAG_OPenColor,0xffffffff,
- TAG_DONE);
+ ami_plot_setapen(style->fill_colour);
+ ami_plot_setopen(style->fill_colour);
AreaMove(glob->rp,p[0],p[1]);
@@ -443,7 +505,7 @@ bool ami_clip(const struct rect *clip)
}
#ifdef NS_AMIGA_CAIRO
- if(nsoption_int(cairo_renderer) == 2)
+ if((nsoption_int(cairo_renderer) == 2) && (palette_mapped == false))
{
cairo_reset_clip(glob->cr);
cairo_rectangle(glob->cr, clip->x0, clip->y0,
@@ -462,7 +524,9 @@ bool ami_text(int x, int y, const char *text, size_t length,
LOG(("[ami_plotter] Entered ami_text()"));
#endif
- ami_unicode_text(glob->rp,text,length,fstyle,x,y);
+ ami_plot_setapen(fstyle->foreground);
+ ami_unicode_text(glob->rp, text, length, fstyle, x, y, !palette_mapped);
+
return true;
}
@@ -472,23 +536,16 @@ bool ami_disc(int x, int y, int radius, const plot_style_t *style)
LOG(("[ami_plotter] Entered ami_disc()"));
#endif
- if(nsoption_int(cairo_renderer) < 2)
+ if((nsoption_int(cairo_renderer) < 2) || (palette_mapped == true))
{
if (style->fill_type != PLOT_OP_TYPE_NONE) {
- SetRPAttrs(glob->rp,
- RPTAG_APenColor,
- p96EncodeColor(RGBFB_A8B8G8R8, style->fill_colour),
- TAG_DONE);
+ ami_plot_setapen(style->fill_colour);
AreaCircle(glob->rp,x,y,radius);
AreaEnd(glob->rp);
}
if (style->stroke_type != PLOT_OP_TYPE_NONE) {
- SetRPAttrs(glob->rp,
- RPTAG_APenColor,
- p96EncodeColor(RGBFB_A8B8G8R8, style->stroke_colour),
- TAG_DONE);
-
+ ami_plot_setapen(style->stroke_colour);
DrawEllipse(glob->rp,x,y,radius,radius);
}
}
@@ -525,8 +582,12 @@ bool ami_arc(int x, int y, int radius, int angle1, int angle2, const plot_style_
LOG(("[ami_plotter] Entered ami_arc()"));
#endif
- if(nsoption_int(cairo_renderer) >= 1)
- {
+ if((nsoption_int(cairo_renderer) <= 0) || (palette_mapped == true)) {
+ /* TODO: gfx.lib plotter needs arc support */
+ /* eg. http://www.crbond.com/primitives.htm CommonFuncsPPC.lha */
+ ami_plot_setapen(style->fill_colour);
+ /* DrawArc(glob->rp,x,y,(float)angle1,(float)angle2,radius); */
+ } else {
#ifdef NS_AMIGA_CAIRO
ami_cairo_set_colour(glob->cr, style->fill_colour);
ami_cairo_set_solid(glob->cr);
@@ -538,19 +599,7 @@ bool ami_arc(int x, int y, int radius, int angle1, int angle2, const plot_style_
cairo_stroke(glob->cr);
#endif
}
- else
- {
- /* TODO: gfx.lib plotter needs arc support */
-/* http://www.crbond.com/primitives.htm
-CommonFuncsPPC.lha */
-
- SetRPAttrs(glob->rp,
- RPTAG_APenColor,
- p96EncodeColor(RGBFB_A8B8G8R8, style->fill_colour),
- TAG_DONE);
-
-// DrawArc(glob->rp,x,y,(float)angle1,(float)angle2,radius);
- }
+
return true;
}
@@ -627,6 +676,8 @@ bool ami_bitmap_tile(int x, int y, int width, int height,
LOG(("[ami_plotter] Entered ami_bitmap_tile()"));
#endif
+ if(palette_mapped == true) return true;
+
int xf,yf,xm,ym,oy,ox;
struct BitMap *tbm = NULL;
struct Hook *bfh = NULL;
@@ -801,7 +852,7 @@ bool ami_path(const float *p, unsigned int n, colour fill, float width,
/* We should probably check if the off-screen bitmap is 32-bit and render
* using Cairo regardless if it is. For now, we respect user preferences.
*/
- if(nsoption_int(cairo_renderer) >= 1)
+ if((nsoption_int(cairo_renderer) >= 1) && (palette_mapped == false))
{
unsigned int i;
cairo_matrix_t old_ctm, n_ctm;
diff --git a/amiga/plotters.h b/amiga/plotters.h
index c3f816dca..94dfaee6e 100755
--- a/amiga/plotters.h
+++ b/amiga/plotters.h
@@ -33,6 +33,7 @@ struct gui_globals
APTR areabuf;
APTR tmprasbuf;
struct Rectangle rect;
+ struct MinList *shared_pens;
#ifdef NS_AMIGA_CAIRO
cairo_surface_t *surface;
cairo_t *cr;
@@ -63,6 +64,7 @@ bool ami_path(const float *p, unsigned int n, colour fill, float width,
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);
+void ami_plot_release_pens(struct MinList *shared_pens);
struct gui_globals *glob;
#endif