NetSurf
bitmap.c
Go to the documentation of this file.
1/*
2 * Copyright 2008, 2009, 2012, 2016 Chris Young <chris@unsatisfactorysoftware.co.uk>
3 *
4 * This file is part of NetSurf, http://www.netsurf-browser.org/
5 *
6 * NetSurf is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * NetSurf is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include "amiga/os3support.h"
20
21#include <stdlib.h>
22#include <string.h>
23#include <proto/exec.h>
24#ifdef __amigaos4__
25#include <graphics/blitattr.h>
26#include <graphics/composite.h>
27#endif
28#include <graphics/gfxbase.h>
29#include <proto/datatypes.h>
30#include <datatypes/pictureclass.h>
31#include <proto/dos.h>
32#include <proto/intuition.h>
33#include <proto/utility.h>
34
35#include <proto/guigfx.h>
36#include <guigfx/guigfx.h>
37#include <render/render.h>
38#ifndef __amigaos4__
39#include <inline/guigfx.h>
40#endif
41
42#ifdef __amigaos4__
43#include <exec/extmem.h>
44#include <sys/param.h>
45#endif
46#include "assert.h"
47
48#include "utils/log.h"
49#include "utils/nsoption.h"
50#include "utils/nsurl.h"
51#include "utils/messages.h"
52#include "netsurf/bitmap.h"
53#include "netsurf/content.h"
54
55#include "amiga/gui.h"
56#include "amiga/bitmap.h"
57#include "amiga/plotters.h"
58#include "amiga/memory.h"
59#include "amiga/misc.h"
60#include "amiga/rtg.h"
61#include "amiga/schedule.h"
62
63// disable use of "triangle mode" for scaling
64#ifdef AMI_NS_TRIANGLE_SCALING
65#undef AMI_NS_TRIANGLE_SCALING
66#endif
67
68struct bitmap {
69 int width;
70 int height;
71 UBYTE *pixdata;
72 struct ExtMemIFace *iextmem;
74 bool opaque;
75 int native;
76 struct BitMap *nativebm;
79 PLANEPTR native_mask;
80 Object *dto;
82 struct nsurl *url; /* temporary storage space */
83 char *title; /* temporary storage space */
84 ULONG *icondata; /* for appicons */
85};
86
87enum {
91};
92
93struct vertex {
94 float x, y;
95 float s, t, w;
96};
97
98#define VTX(I,X,Y,S,T) vtx[I].x = X; vtx[I].y = Y; vtx[I].s = S; vtx[I].t = T; vtx[I].w = 1.0f;
99#define VTX_RECT(SX,SY,SW,SH,DX,DY,DW,DH) \
100 VTX(0, DX, DY, SX, SY); \
101 VTX(1, DX + DW, DY, SX + SW, SY); \
102 VTX(2, DX, DY + DH, SX, SY + SH); \
103 VTX(3, DX + DW, DY, SX + SW, SY); \
104 VTX(4, DX, DY + DH, SX, SY + SH); \
105 VTX(5, DX + DW, DY + DH, SX + SW, SY + SH);
106
107static APTR pool_bitmap = NULL;
108static bool guigfx_warned = false;
109
110/* exported function documented in amiga/bitmap.h */
112{
113 struct bitmap *bitmap;
114
115 if(pool_bitmap == NULL) pool_bitmap = ami_memory_itempool_create(sizeof(struct bitmap));
116
118 if(bitmap == NULL) return NULL;
119
120 bitmap->size = width * height * 4;
121
122#ifdef __amigaos4__
123 if(nsoption_bool(use_extmem) == true) {
124 uint64 size64 = bitmap->size;
125 bitmap->iextmem = AllocSysObjectTags(ASOT_EXTMEM,
126 ASOEXTMEM_Size, &size64,
127 ASOEXTMEM_AllocationPolicy, EXTMEMPOLICY_IMMEDIATE,
128 TAG_END);
129
130 bitmap->pixdata = NULL;
132 memset(pixdata, 0xff, bitmap->size);
133 } else
134#endif
135 {
137 }
138
139 bitmap->width = width;
141
143
144 bitmap->nativebm = NULL;
147 bitmap->native_mask = NULL;
148 bitmap->drawhandle = NULL;
149 bitmap->url = NULL;
150 bitmap->title = NULL;
151 bitmap->icondata = NULL;
153
154 return bitmap;
155}
156
157static void amiga_bitmap_unmap_buffer(void *p)
158{
159#ifdef __amigaos4__
160 struct bitmap *bm = p;
161
162 if((nsoption_bool(use_extmem) == true) && (bm->pixdata != NULL)) {
163 NSLOG(netsurf, INFO,
164 "Unmapping ExtMem object %p for bitmap %p",
165 bm->iextmem,
166 bm);
167 bm->iextmem->Unmap(bm->pixdata, bm->size);
168 bm->pixdata = NULL;
169 }
170#endif
171}
172
173/* exported function documented in amiga/bitmap.h */
174unsigned char *amiga_bitmap_get_buffer(void *bitmap)
175{
176 struct bitmap *bm = bitmap;
177
178#ifdef __amigaos4__
179 if(nsoption_bool(use_extmem) == true) {
180 if(bm->pixdata == NULL) {
181 NSLOG(netsurf, INFO,
182 "Mapping ExtMem object %p for bitmap %p",
183 bm->iextmem,
184 bm);
185 bm->pixdata = bm->iextmem->Map(NULL, bm->size, 0LL, 0);
186 }
187
188 /* unmap the buffer after one second */
190 }
191#endif
192
193 return bm->pixdata;
194}
195
196/* exported function documented in amiga/bitmap.h */
198{
199 struct bitmap *bm = bitmap;
200
201 if(bm)
202 {
203 return ((bm->width)*4);
204 }
205 else
206 {
207 return 0;
208 }
209}
210
211
212/* exported function documented in amiga/bitmap.h */
214{
215 struct bitmap *bm = bitmap;
216
217 if(bm)
218 {
219 if((bm->nativebm)) { // && (bm->native == AMI_NSBM_TRUECOLOUR)) {
221 }
222
223 if(bm->native_mask) FreeRaster(bm->native_mask, bm->width, bm->height);
224
225#ifdef __amigaos4__
226 if(nsoption_bool(use_extmem) == true) {
229 FreeSysObject(ASOT_EXTMEM, bm->iextmem);
230 bm->iextmem = NULL;
231 } else
232#endif
233 {
234 if(bm->drawhandle) ReleaseDrawHandle(bm->drawhandle);
236 }
237
238 if(bm->url) nsurl_unref(bm->url);
239 if(bm->title) free(bm->title);
240
241 bm->pixdata = NULL;
242 bm->nativebm = NULL;
243 bm->native_mask = NULL;
244 bm->drawhandle = NULL;
245 bm->url = NULL;
246 bm->title = NULL;
247
248 ami_memory_itempool_free(pool_bitmap, bm, sizeof(struct bitmap));
249 bm = NULL;
250 }
251}
252
253
254/* exported function documented in amiga/bitmap.h */
255bool amiga_bitmap_save(void *bitmap, const char *path, unsigned flags)
256{
257 int err = 0;
258 Object *dto = NULL;
259
261 {
262 if (flags & AMI_BITMAP_SCALE_ICON) {
263 IDoMethod(dto, PDTM_SCALE, 16, 16, 0);
264
265 if((DoDTMethod(dto, 0, 0, DTM_PROCLAYOUT, 0, 1)) == 0) {
266 return false;
267 }
268 }
269
270 err = SaveDTObjectA(dto, NULL, NULL, path, DTWM_IFF, FALSE, NULL);
271 DisposeDTObject(dto);
272 }
273
274 if(err == 0) return false;
275 else return true;
276}
277
278
279/* exported function documented in amiga/bitmap.h */
281{
282 struct bitmap *bm = bitmap;
283
284#ifdef __amigaos4__
285 /* unmap the buffer after 0.5s - we might need it imminently */
287#endif
288
290 if(bm->drawhandle) ReleaseDrawHandle(bm->drawhandle);
291 if(bm->native_mask) FreeRaster(bm->native_mask, bm->width, bm->height);
292 bm->nativebm = NULL;
293 bm->drawhandle = NULL;
294 bm->native_mask = NULL;
295 bm->native = AMI_NSBM_NONE;
296}
297
298
299/* exported function documented in amiga/bitmap.h */
301{
302 struct bitmap *bm = bitmap;
303 assert(bitmap);
304 bm->opaque = opaque;
305}
306
307
308/* exported function documented in amiga/bitmap.h */
310{
311 struct bitmap *bm = bitmap;
312 assert(bitmap);
313 return bm->opaque;
314}
315
316/**
317 * get width of a bitmap.
318 */
320{
321 struct bitmap *bm = bitmap;
322
323 if(bm)
324 {
325 return(bm->width);
326 }
327 else
328 {
329 return 0;
330 }
331}
332
333/**
334 * get height of a bitmap.
335 */
337{
338 struct bitmap *bm = bitmap;
339
340 if(bm)
341 {
342 return(bm->height);
343 }
344 else
345 {
346 return 0;
347 }
348}
349
350#ifdef BITMAP_DUMP
351void bitmap_dump(struct bitmap *bitmap)
352{
353 int x,y;
354 ULONG *bm = (ULONG *)amiga_bitmap_get_buffer(bitmap);
355
356 printf("Width=%ld, Height=%ld, Opaque=%s\nnativebm=%lx, width=%ld, height=%ld\n",
357 bitmap->width, bitmap->height, bitmap->opaque ? "true" : "false",
359
360 for(y = 0; y < bitmap->height; y++) {
361 for(x = 0; x < bitmap->width; x++) {
362 printf("%lx ", bm[(y*bitmap->width) + x]);
363 }
364 printf("\n");
365 }
366}
367#endif
368
370{
371 Object *dto;
372 struct BitMapHeader *bmhd;
373
374 if((dto = NewDTObject(NULL,
375 DTA_SourceType,DTST_RAM,
376 DTA_GroupID,GID_PICTURE,
377 //DTA_BaseName,"ilbm",
378 PDTA_DestMode,PMODE_V43,
379 TAG_DONE)))
380 {
381 if(GetDTAttrs(dto,PDTA_BitMapHeader,&bmhd,TAG_DONE))
382 {
383 bmhd->bmh_Width = (UWORD)bitmap_get_width(bitmap);
384 bmhd->bmh_Height = (UWORD)bitmap_get_height(bitmap);
385 bmhd->bmh_Depth = (UBYTE)32;
386 if(!amiga_bitmap_get_opaque(bitmap)) bmhd->bmh_Masking = mskHasAlpha;
387 }
388
389 SetDTAttrs(dto,NULL,NULL,
390 DTA_ObjName, bitmap->url ? nsurl_access(bitmap->url) : "",
391 DTA_ObjAnnotation,bitmap->title,
392 DTA_ObjAuthor,messages_get("NetSurf"),
393 DTA_NominalHoriz,bitmap_get_width(bitmap),
394 DTA_NominalVert,bitmap_get_height(bitmap),
395 PDTA_SourceMode,PMODE_V43,
396 TAG_DONE);
397
398 IDoMethod(dto, PDTM_WRITEPIXELARRAY, amiga_bitmap_get_buffer(bitmap),
399 PBPAFMT_ARGB, amiga_bitmap_get_rowstride(bitmap), 0, 0,
401 }
402
403 return dto;
404}
405
406/* Quick way to get an object on disk into a struct bitmap */
407struct bitmap *ami_bitmap_from_datatype(char *filename)
408{
409 Object *dto;
410 struct bitmap *bm = NULL;
411
412 if((dto = NewDTObject(filename,
413 DTA_GroupID, GID_PICTURE,
414 PDTA_DestMode, PMODE_V43,
415 PDTA_PromoteMask, TRUE,
416 TAG_DONE))) {
417 struct BitMapHeader *bmh;
418
419 if(GetDTAttrs(dto, PDTA_BitMapHeader, &bmh, TAG_DONE))
420 {
421 bm = amiga_bitmap_create(bmh->bmh_Width, bmh->bmh_Height, 0);
422
423 IDoMethod(dto, PDTM_READPIXELARRAY, amiga_bitmap_get_buffer(bm),
424 PBPAFMT_ARGB, amiga_bitmap_get_rowstride(bm), 0, 0,
425 bmh->bmh_Width, bmh->bmh_Height);
426
428 }
429 DisposeDTObject(dto);
430 }
431
432 return bm;
433}
434
435static inline struct BitMap *ami_bitmap_get_generic(struct bitmap *bitmap,
436 int width, int height, struct BitMap *restrict friendbm, int type)
437{
438 struct BitMap *restrict tbm = NULL;
439 struct Screen *scrn = ami_gui_get_screen();
440
441 if(bitmap->nativebm)
442 {
444 tbm = bitmap->nativebm;
445 return tbm;
446 } else if((bitmap->nativebmwidth == bitmap->width) &&
447 (bitmap->nativebmheight == bitmap->height)) { // >= width/height ?
448 tbm = bitmap->nativebm;
449 } else {
451 }
452 }
453
454 if(tbm == NULL) {
457 friendbm, AMI_BITMAP_FORMAT);
458 if(tbm == NULL) return NULL;
459
461 tbm, bitmap->width, bitmap->height,
463 } else {
465 8, 0, friendbm, AMI_BITMAP_FORMAT);
466 if(tbm == NULL) return NULL;
467
468 if(GuiGFXBase != NULL) {
469 struct RastPort rp;
470 InitRastPort(&rp);
471 rp.BitMap = tbm;
472 ULONG dithermode = DITHERMODE_NONE;
473
474 if(nsoption_int(dither_quality) == 1) {
475 dithermode = DITHERMODE_EDD;
476 } else if(nsoption_int(dither_quality) == 2) {
477 dithermode = DITHERMODE_FS;
478 }
479
480 bitmap->drawhandle = ObtainDrawHandle(
481 NULL,
482 &rp,
483 scrn->ViewPort.ColorMap,
484 GGFX_DitherMode, dithermode,
485 TAG_DONE);
486 if(bitmap->drawhandle) {
487 APTR ddh = CreateDirectDrawHandle(bitmap->drawhandle,
489 width, height, NULL);
490
491 DirectDrawTrueColor(ddh, (ULONG *)amiga_bitmap_get_buffer(bitmap), 0, 0, TAG_DONE);
492 DeleteDirectDrawHandle(ddh);
493 ReleaseDrawHandle(bitmap->drawhandle);
494 bitmap->drawhandle = NULL;
495 }
496 } else {
497 if(guigfx_warned == false) {
498 amiga_warn_user("BMConvErr", NULL);
499 guigfx_warned = true;
500 }
501 }
502 }
503
504 if(((type == AMI_NSBM_TRUECOLOUR) && (nsoption_int(cache_bitmaps) == 2)) ||
505 ((type == AMI_NSBM_PALETTEMAPPED) && (((bitmap->width == width) &&
506 (bitmap->height == height) && (nsoption_int(cache_bitmaps) == 2)) ||
507 (nsoption_int(cache_bitmaps) >= 1)))) {
508 bitmap->nativebm = tbm;
512 } else {
515 }
516 bitmap->native = type;
517 }
518
520 return tbm;
521 }
522
523 if((bitmap->width != width) || (bitmap->height != height)) {
524 struct BitMap *restrict scaledbm;
525 struct BitScaleArgs bsa;
526 int depth = 32;
527 if(type == AMI_NSBM_PALETTEMAPPED) depth = 8;
528
529 scaledbm = ami_rtg_allocbitmap(width, height, depth, 0,
530 friendbm, AMI_BITMAP_FORMAT);
531#ifdef __amigaos4__
532 if(__builtin_expect(((GfxBase->LibNode.lib_Version >= 53) &&
533 (type == AMI_NSBM_TRUECOLOUR)), 1)) {
534 /* AutoDoc says v52, but this function isn't in OS4.0, so checking for v53 (OS4.1)
535 * Additionally, when we use friend BitMaps in non 32-bit modes it freezes the OS */
536
537 uint32 flags = 0;
538 uint32 err = COMPERR_Success;
539#ifdef AMI_NS_TRIANGLE_SCALING
540 struct vertex vtx[6];
541 VTX_RECT(0, 0, bitmap->width, bitmap->height, 0, 0, width, height);
542
543 flags = COMPFLAG_HardwareOnly;
544 if(nsoption_bool(scale_quality) == true) flags |= COMPFLAG_SrcFilter;
545
546 err = CompositeTags(COMPOSITE_Src, tbm, scaledbm,
547 COMPTAG_VertexArray, vtx,
548 COMPTAG_VertexFormat, COMPVF_STW0_Present,
549 COMPTAG_NumTriangles, 2,
550 COMPTAG_Flags, flags,
551 COMPTAG_FriendBitMap, scrn->RastPort.BitMap,
552 TAG_DONE);
553
554 if (err != COMPERR_Success) {
555 NSLOG(netsurf, INFO,
556 "Composite error %ld - falling back",
557 err);
558 /* If it failed, do it again the way
559 * which works in software
560 */
561#else
562 {
563#endif
564 flags = 0;
565 if(nsoption_bool(scale_quality) == true) flags |= COMPFLAG_SrcFilter;
566
567 err = CompositeTags(COMPOSITE_Src, tbm, scaledbm,
568 COMPTAG_ScaleX, COMP_FLOAT_TO_FIX((float)width/bitmap->width),
569 COMPTAG_ScaleY, COMP_FLOAT_TO_FIX((float)height/bitmap->height),
570 COMPTAG_Flags, flags,
571 COMPTAG_FriendBitMap, scrn->RastPort.BitMap,
572 TAG_DONE);
573 /* If it still fails... it's non-fatal */
574 NSLOG(netsurf, INFO,
575 "Fallback returned error %ld", err);
576 }
577 } else /* Do it the old-fashioned way. This is pretty slow, even on OS4.1 */
578#endif
579 {
580 bsa.bsa_SrcX = 0;
581 bsa.bsa_SrcY = 0;
582 bsa.bsa_SrcWidth = bitmap->width;
583 bsa.bsa_SrcHeight = bitmap->height;
584 bsa.bsa_DestX = 0;
585 bsa.bsa_DestY = 0;
586 bsa.bsa_XSrcFactor = bitmap->width;
587 bsa.bsa_XDestFactor = width;
588 bsa.bsa_YSrcFactor = bitmap->height;
589 bsa.bsa_YDestFactor = height;
590 bsa.bsa_SrcBitMap = tbm;
591 bsa.bsa_DestBitMap = scaledbm;
592 bsa.bsa_Flags = 0;
593
594 BitMapScale(&bsa);
595 }
596
599 tbm = scaledbm;
600 bitmap->nativebm = NULL;
602
603 if(nsoption_int(cache_bitmaps) >= 1)
604 {
605 bitmap->nativebm = tbm;
608 bitmap->native = type;
609 }
610 }
611
612 return tbm;
613}
614
615
616static inline struct BitMap *ami_bitmap_get_truecolour(struct bitmap *bitmap,
617 int width, int height, struct BitMap *friendbm)
618{
621 }
622
624}
625
627 int height, struct BitMap *n_bm)
628{
630 UBYTE maskbit = 0;
631 ULONG bm_width;
632 int y, x, bpr;
633
634 if((height != bitmap->height) || (width != bitmap->width)) return NULL;
635 if(amiga_bitmap_get_opaque(bitmap) == true) return NULL;
637
638 bm_width = GetBitMapAttr(n_bm, BMA_WIDTH);
639 bpr = RASSIZE(bm_width, 1);
640 bitmap->native_mask = AllocRaster(bm_width, height);
641 SetMem(bitmap->native_mask, 0, bpr * height);
642
643 for(y=0; y<height; y++) {
644 for(x=0; x<width; x++) {
645 if ((*bmi & 0xff000000U) <= (ULONG)nsoption_int(mask_alpha)) maskbit = 0;
646 else maskbit = 1;
647 bmi++;
648 bitmap->native_mask[(y*bpr) + (x/8)] |=
649 maskbit << (7 - (x % 8));
650 }
651 }
652
653 return bitmap->native_mask;
654}
655
656static inline struct BitMap *ami_bitmap_get_palettemapped(struct bitmap *bitmap,
657 int width, int height, struct BitMap *friendbm)
658{
661 }
662
664}
665
666struct BitMap *ami_bitmap_get_native(struct bitmap *bitmap,
667 int width, int height, bool palette_mapped, struct BitMap *friendbm)
668{
669 if(bitmap == NULL) return NULL;
670
671 if(__builtin_expect(palette_mapped == true, 0)) {
673 } else {
674 return ami_bitmap_get_truecolour(bitmap, width, height, friendbm);
675 }
676}
677
679{
681 pool_bitmap = NULL;
682}
683
685{
686#ifdef __amigaos4__
687 NSLOG(netsurf, INFO, "Entering bitmap_render");
688
689 int plot_width;
690 int plot_height;
691 struct gui_globals *bm_globals;
692
693 plot_width = MIN(content_get_width(content), bitmap->width);
694 plot_height = ((plot_width * bitmap->height) + (bitmap->width / 2)) /
695 bitmap->width;
696
697 bm_globals = ami_plot_ra_alloc(bitmap->width, bitmap->height, true, false);
698 ami_clearclipreg(bm_globals);
699
700 struct redraw_context ctx = {
701 .interactive = false,
702 .background_images = true,
703 .plot = &amiplot,
704 .priv = bm_globals
705 };
706
707 content_scaled_redraw(content, plot_width, plot_height, &ctx);
708
709 BltBitMapTags( BLITA_SrcX, 0,
710 BLITA_SrcY, 0,
711 BLITA_Width, bitmap->width,
712 BLITA_Height, bitmap->height,
713 BLITA_Source, ami_plot_ra_get_bitmap(bm_globals),
714 BLITA_SrcType, BLITT_BITMAP,
715 BLITA_Dest, amiga_bitmap_get_buffer(bitmap),
716 BLITA_DestType, BLITT_ARGB32,
717 BLITA_DestBytesPerRow, 4 * bitmap->width,
718 BLITA_DestX, 0,
719 BLITA_DestY, 0,
720 TAG_DONE);
721
722 /**\todo In theory we should be able to move the bitmap to our native area
723 to try to avoid re-conversion (at the expense of memory) */
724
725 ami_plot_ra_free(bm_globals);
727#else
728#warning FIXME for OS3 (in current state none of bitmap_render can work!)
729#endif
730
731 return NSERROR_OK;
732}
733
734void ami_bitmap_set_url(struct bitmap *bm, struct nsurl *url)
735{
736 if(bm->url != NULL) return;
737 bm->url = nsurl_ref(url);
738}
739
740void ami_bitmap_set_title(struct bitmap *bm, const char *title)
741{
742 if(bm->title != NULL) return;
743 bm->title = strdup(title);
744}
745
746void ami_bitmap_set_icondata(struct bitmap *bm, ULONG *icondata)
747{
748 bm->icondata = icondata;
749}
750
752{
753 if(bm->icondata) free(bm->icondata);
754 bm->icondata = NULL;
755}
756
757bool ami_bitmap_is_nativebm(struct bitmap *bm, struct BitMap *nbm)
758{
759 if(bm->nativebm == nbm) return true;
760 else return false;
761}
762
763
766 .destroy = amiga_bitmap_destroy,
767 .set_opaque = amiga_bitmap_set_opaque,
768 .get_opaque = amiga_bitmap_get_opaque,
769 .get_buffer = amiga_bitmap_get_buffer,
770 .get_rowstride = amiga_bitmap_get_rowstride,
771 .get_width = bitmap_get_width,
772 .get_height = bitmap_get_height,
773 .modified = amiga_bitmap_modified,
774 .render = bitmap_render,
775};
776
struct Screen * ami_gui_get_screen(void)
Get a pointer to the screen NetSurf is running on.
Definition: gui.c:403
static struct Screen * scrn
Definition: gui.c:326
nserror amiga_warn_user(const char *warning, const char *detail)
Warn the user of an event.
Definition: misc.c:79
const struct plotter_table amiplot
Definition: plotters.c:1180
void ami_plot_ra_free(struct gui_globals *gg)
Free a plotter render area.
Definition: plotters.c:258
struct BitMap * ami_plot_ra_get_bitmap(struct gui_globals *gg)
Get a drawing BitMap associated with a render area.
Definition: plotters.c:295
static bool palette_mapped
Definition: plotters.c:98
void ami_clearclipreg(struct gui_globals *gg)
Definition: plotters.c:311
struct gui_globals * ami_plot_ra_alloc(ULONG width, ULONG height, bool force32bit, bool alloc_pen_list)
Alloc a plotter render area.
Definition: plotters.c:113
nserror ami_schedule(int t, void(*callback)(void *p), void *p)
Schedule a callback.
Definition: schedule.c:331
bool bitmap_test_opaque(void *bitmap)
Test whether a bitmap is completely opaque (no transparency).
Definition: bitmap.c:316
nserror
Enumeration of error codes.
Definition: errors.h:29
@ NSERROR_OK
No error.
Definition: errors.h:30
const char * type
Definition: filetype.cpp:44
#define VTX_RECT(SX, SY, SW, SH, DX, DY, DW, DH)
Definition: bitmap.c:99
size_t amiga_bitmap_get_rowstride(void *bitmap)
Find the width of a pixel row in bytes.
Definition: bitmap.c:197
static struct gui_bitmap_table bitmap_table
Definition: bitmap.c:764
void * amiga_bitmap_create(int width, int height, enum gui_bitmap_flags flags)
Create a bitmap.
Definition: bitmap.c:111
void ami_bitmap_set_url(struct bitmap *bm, struct nsurl *url)
Set bitmap URL.
Definition: bitmap.c:734
struct BitMap * ami_bitmap_get_native(struct bitmap *bitmap, int width, int height, bool palette_mapped, struct BitMap *friendbm)
Definition: bitmap.c:666
int bitmap_get_width(void *bitmap)
get width of a bitmap.
Definition: bitmap.c:319
void ami_bitmap_free_icondata(struct bitmap *bm)
Free an icondata pointer.
Definition: bitmap.c:751
static nserror bitmap_render(struct bitmap *bitmap, struct hlcache_handle *content)
Definition: bitmap.c:684
void ami_bitmap_fini(void)
Cleanup bitmap allocations.
Definition: bitmap.c:678
int bitmap_get_height(void *bitmap)
get height of a bitmap.
Definition: bitmap.c:336
static struct BitMap * ami_bitmap_get_truecolour(struct bitmap *bitmap, int width, int height, struct BitMap *friendbm)
Definition: bitmap.c:616
bool amiga_bitmap_save(void *bitmap, const char *path, unsigned flags)
Save a bitmap in the platform's native format.
Definition: bitmap.c:255
PLANEPTR ami_bitmap_get_mask(struct bitmap *bitmap, int width, int height, struct BitMap *n_bm)
Definition: bitmap.c:626
static struct BitMap * ami_bitmap_get_generic(struct bitmap *bitmap, int width, int height, struct BitMap *restrict friendbm, int type)
Definition: bitmap.c:435
static void amiga_bitmap_unmap_buffer(void *p)
Definition: bitmap.c:157
bool ami_bitmap_is_nativebm(struct bitmap *bm, struct BitMap *nbm)
Test if a BitMap is owned by a bitmap.
Definition: bitmap.c:757
struct bitmap * ami_bitmap_from_datatype(char *filename)
Definition: bitmap.c:407
struct gui_bitmap_table * amiga_bitmap_table
Definition: bitmap.c:777
void ami_bitmap_set_title(struct bitmap *bm, const char *title)
Set bitmap title.
Definition: bitmap.c:740
void amiga_bitmap_modified(void *bitmap)
The bitmap image has changed, so flush any persistant cache.
Definition: bitmap.c:280
static APTR pool_bitmap
Definition: bitmap.c:107
static struct BitMap * ami_bitmap_get_palettemapped(struct bitmap *bitmap, int width, int height, struct BitMap *friendbm)
Definition: bitmap.c:656
void amiga_bitmap_set_opaque(void *bitmap, bool opaque)
Sets whether a bitmap should be plotted opaque.
Definition: bitmap.c:300
static bool guigfx_warned
Definition: bitmap.c:108
Object * ami_datatype_object_from_bitmap(struct bitmap *bitmap)
Definition: bitmap.c:369
@ AMI_NSBM_TRUECOLOUR
Definition: bitmap.c:89
@ AMI_NSBM_PALETTEMAPPED
Definition: bitmap.c:90
@ AMI_NSBM_NONE
Definition: bitmap.c:88
void ami_bitmap_set_icondata(struct bitmap *bm, ULONG *icondata)
Set an icondata pointer.
Definition: bitmap.c:746
bool amiga_bitmap_get_opaque(void *bitmap)
Gets whether a bitmap should be plotted opaque.
Definition: bitmap.c:309
unsigned char * amiga_bitmap_get_buffer(void *bitmap)
Return a pointer to the pixel data in a bitmap.
Definition: bitmap.c:174
void amiga_bitmap_destroy(void *bitmap)
Free a bitmap.
Definition: bitmap.c:213
#define AMI_BITMAP_SCALE_ICON
Definition: bitmap.h:31
#define AMI_BITMAP_FORMAT
Definition: bitmap.h:30
Generic bitmap handling interface.
gui_bitmap_flags
Bitmap creation flags.
Definition: bitmap.h:36
@ BITMAP_OPAQUE
image is opaque
Definition: bitmap.h:38
Public content interface.
int content_get_width(struct hlcache_handle *h)
Retrieve width of content.
Definition: content.c:1158
bool content_scaled_redraw(struct hlcache_handle *h, int width, int height, const struct redraw_context *ctx)
Redraw a content with scale set for horizontal fit.
Definition: content.c:583
#define NSLOG(catname, level, logmsg, args...)
Definition: log.h:116
void * ami_memory_clear_alloc(size_t size, UBYTE value)
Definition: memory.c:42
#define ami_memory_itempool_create(s)
Definition: memory.h:54
#define ami_memory_itempool_alloc(p, s)
Definition: memory.h:56
#define ami_memory_itempool_free(p, i, s)
Definition: memory.h:57
#define ami_memory_itempool_delete(p)
Definition: memory.h:55
#define ami_memory_clear_free(p)
Definition: memory.h:39
const char * messages_get(const char *key)
Fast lookup of a message by key from the standard Messages hash.
Definition: messages.c:241
Localised message support (interface).
NetSurf URL handling (interface).
void nsurl_unref(nsurl *url)
Drop a reference to a NetSurf URL object.
const char * nsurl_access(const nsurl *url)
Access a NetSurf URL object as a string.
nsurl * nsurl_ref(nsurl *url)
Increment the reference count to a NetSurf URL object.
struct nsurl nsurl
NetSurf URL object.
Definition: nsurl.h:31
void FreeSysObject(ULONG type, APTR obj)
Definition: os3support.c:350
Minimal compatibility header for AmigaOS 3.
#define AllocSysObjectTags(A, B, C, D)
Definition: os3support.h:157
#define PDTA_PromoteMask
Definition: os3support.h:75
#define MIN(a, b)
Definition: os3support.h:51
#define IDoMethod
Definition: os3support.h:169
uint64_t uint64
Definition: os3support.h:186
uint32_t uint32
Definition: os3support.h:184
#define SaveDTObjectA(O, W, R, F, M, I, A)
Definition: os3support.h:146
#define SetMem
Definition: os3support.h:175
int width
Definition: gui.c:159
int height
Definition: gui.c:160
void ami_rtg_writepixelarray(UBYTE *pixdata, struct BitMap *bm, ULONG width, ULONG height, ULONG bpr, ULONG format)
Definition: rtg.c:44
void ami_rtg_freebitmap(struct BitMap *bm)
Definition: rtg.c:35
struct BitMap * ami_rtg_allocbitmap(ULONG width, ULONG height, ULONG depth, ULONG flags, struct BitMap *friend, RGBFTYPE format)
Definition: rtg.c:25
Abstract RTG functions for newer/older/non-P96 systems.
Interface to utility string handling.
RISC OS wimp toolkit bitmap.
Definition: bitmap.c:68
char * title
Definition: bitmap.c:83
int nativebmwidth
Definition: bitmap.c:77
int native
Definition: bitmap.c:75
int width
width of bitmap
Definition: bitmap.c:69
struct BitMap * nativebm
Definition: bitmap.c:76
ULONG * icondata
Definition: bitmap.c:84
int height
height of bitmap
Definition: bitmap.c:70
Object * dto
Definition: bitmap.c:80
bool opaque
Whether the bitmap is opaque.
Definition: bitmap.c:74
UBYTE * pixdata
Definition: bitmap.c:71
struct ExtMemIFace * iextmem
Definition: bitmap.c:72
struct nsurl * url
Definition: bitmap.c:82
APTR drawhandle
Definition: bitmap.c:81
int nativebmheight
Definition: bitmap.c:78
PLANEPTR native_mask
Definition: bitmap.c:79
uint32 size
Definition: bitmap.c:73
Content which corresponds to a single URL.
Bitmap operations.
Definition: bitmap.h:125
void *(* create)(int width, int height, enum gui_bitmap_flags flags)
Create a new bitmap.
Definition: bitmap.h:136
High-level cache handle.
Definition: hlcache.c:66
Redraw context.
Definition: plotters.h:51
bool interactive
Redraw to show interactive features.
Definition: plotters.h:59
Definition: bitmap.c:93
float t
Definition: bitmap.c:95
float x
Definition: bitmap.c:94
float s
Definition: bitmap.c:95
float w
Definition: bitmap.c:95
float y
Definition: bitmap.c:94
Option reading and saving interface.
#define nsoption_int(OPTION)
Get the value of an integer option.
Definition: nsoption.h:279
#define nsoption_bool(OPTION)
Get the value of a boolean option.
Definition: nsoption.h:270
static nserror path(const struct redraw_context *ctx, const plot_style_t *pstyle, const float *p, unsigned int n, const float transform[6])
Plots a path.
Definition: plot.c:821
static nserror bitmap(const struct redraw_context *ctx, struct bitmap *bitmap, int x, int y, int width, int height, colour bg, bitmap_flags_t flags)
Plot a bitmap.
Definition: plot.c:857