23#ifdef WITH_AMIGA_DATATYPES
27#include <proto/datatypes.h>
29#include <proto/exec.h>
30#include <proto/intuition.h>
31#include <datatypes/animationclass.h>
32#include <datatypes/pictureclass.h>
34#include <graphics/blitattr.h>
36#include <intuition/classusr.h>
53typedef struct amiga_dt_anim_content {
63} amiga_dt_anim_content;
65static APTR ami_colormap_to_clut(
struct ColorMap *cmap);
70 bool quirks,
struct content **c);
71static bool amiga_dt_anim_convert(
struct content *c);
73static void amiga_dt_anim_destroy(
struct content *c);
74static bool amiga_dt_anim_redraw(
struct content *c,
83static void *amiga_dt_anim_get_internal(
const struct content *c,
void *context)
85 amiga_dt_anim_content *adta_c = (amiga_dt_anim_content *)c;
87 return adta_c->bitmap;
91 .
create = amiga_dt_anim_create,
92 .data_complete = amiga_dt_anim_convert,
93 .reformat = amiga_dt_anim_reformat,
94 .destroy = amiga_dt_anim_destroy,
95 .redraw = amiga_dt_anim_redraw,
96 .open = amiga_dt_anim_open,
97 .close = amiga_dt_anim_close,
98 .clone = amiga_dt_anim_clone,
99 .get_internal = amiga_dt_anim_get_internal,
100 .type = amiga_dt_anim_content_type,
104nserror amiga_dt_anim_init(
void)
106 struct DataType *dt, *prevdt = NULL;
109 struct Node *node = NULL;
111 while((dt = ObtainDataType(DTST_RAM, NULL,
112 DTA_DataType, prevdt,
113 DTA_GroupID, GID_ANIMATION,
116 ReleaseDataType(prevdt);
125 lwc_string_data(
type),
126 &amiga_dt_anim_content_handler);
132 }
while (node != NULL);
136 ReleaseDataType(prevdt);
144 bool quirks,
struct content **c)
146 amiga_dt_anim_content *plugin;
149 plugin = calloc(1,
sizeof(amiga_dt_anim_content));
153 error =
content__init(&plugin->base, handler, imime_type, params,
154 llcache, fallback_charset, quirks);
160 *c = (
struct content *) plugin;
165bool amiga_dt_anim_convert(
struct content *c)
167 NSLOG(netsurf, INFO,
"amiga_dt_anim_convert");
169 amiga_dt_anim_content *plugin = (amiga_dt_anim_content *) c;
175 struct BitMapHeader *bmh;
177 struct adtFrame adt_frame;
182 if((plugin->dto = NewDTObject(NULL,
183 DTA_SourceType, DTST_MEMORY,
184 DTA_SourceAddress, data,
185 DTA_SourceSize, size,
186 DTA_GroupID, GID_ANIMATION,
188 if(GetDTAttrs(plugin->dto, PDTA_BitMapHeader, &bmh, TAG_DONE)) {
189 width = (int)bmh->bmh_Width;
190 height = (
int)bmh->bmh_Height;
193 if (!plugin->bitmap) {
202 adt_frame.MethodID = ADTM_LOADFRAME;
203 adt_frame.alf_TimeStamp = 0;
206 clut = ami_colormap_to_clut(adt_frame.alf_CMap);
211 BLITA_Source, adt_frame.alf_BitMap,
212 BLITA_SrcType, BLITT_BITMAP,
213 BLITA_Dest, bm_buffer,
214 BLITA_DestType, BLITT_RGB24,
215 BLITA_DestBytesPerRow,
width,
219#warning FIXME: Need to use a different blitter function for OS3!
223 adt_frame.MethodID = ADTM_UNLOADFRAME;
248void amiga_dt_anim_destroy(
struct content *c)
250 amiga_dt_anim_content *plugin = (amiga_dt_anim_content *) c;
252 NSLOG(netsurf, INFO,
"amiga_dt_anim_destroy");
254 if (plugin->bitmap != NULL)
257 DisposeDTObject(plugin->dto);
262bool amiga_dt_anim_redraw(
struct content *c,
266 amiga_dt_anim_content *plugin = (amiga_dt_anim_content *) c;
269 NSLOG(netsurf, INFO,
"amiga_dt_anim_redraw");
276 return (ctx->
plot->
bitmap(ctx, plugin->bitmap,
296 NSLOG(netsurf, INFO,
"amiga_dt_anim_open");
303 NSLOG(netsurf, INFO,
"amiga_dt_anim_close");
309 NSLOG(netsurf, INFO,
"amiga_dt_anim_reformat");
315 amiga_dt_anim_content *plugin;
318 NSLOG(netsurf, INFO,
"amiga_dt_anim_clone");
320 plugin = calloc(1,
sizeof(amiga_dt_anim_content));
333 if (amiga_dt_anim_convert(&plugin->base) ==
false) {
339 *newc = (
struct content *) plugin;
349static APTR ami_colormap_to_clut(
struct ColorMap *cmap)
352 UBYTE *clut = calloc(1, 256 * 4);
355 if(!clut)
return NULL;
358 GetRGB32(cmap, 0, 256, (ULONG *)&colr);
361 for(i = 0; i < 1024; i += 4)
363 clut[i] = (0xff << 24) |
364 ((colr[i] & 0xff000000) >> 8) |
365 ((colr[i + 1] & 0xff000000) >> 16) |
366 ((colr[i + 2] & 0xff000000) >> 24);
struct Node * ami_mime_from_datatype(struct DataType *dt, lwc_string **mimetype, struct Node *start_node)
Return a MIME Type matching a DataType.
Content handling interface.
void content_destroy(struct content *c)
Destroy and free a content.
void content_broadcast(struct content *c, content_msg msg, const union content_msg_data *data)
Send a message to all users.
void content_set_done(struct content *c)
Put a content in status CONTENT_STATUS_DONE.
nserror content__init(struct content *c, const content_handler *handler, lwc_string *imime_type, const struct http_parameter *params, llcache_handle *llcache, const char *fallback_charset, bool quirks)
const uint8_t * content__get_source_data(struct content *c, size_t *size)
Retrieve source of content.
nserror content__clone(const struct content *c, struct content *nc)
Clone a content's data members.
void content_set_ready(struct content *c)
Put a content in status CONTENT_STATUS_READY and unlock the content.
void content_set_status(struct content *c, const char *status_message)
Updates content with new status.
nserror content_factory_register_handler(const char *mime_type, const content_handler *handler)
Register a handler with the content factory.
Protected interface to Content handling.
@ CONTENT_STATUS_READY
Some parts of content still being loaded, but can be displayed.
@ CONTENT_STATUS_DONE
Content has completed all processing.
content_type
The type of a content.
@ CONTENT_IMAGE
All images.
@ CONTENT_MSG_ERROR
error occurred
nserror
Enumeration of error codes.
@ NSERROR_NOMEM
Memory exhaustion.
@ NSERROR_CLONE_FAILED
Failed to clone handle.
void * amiga_bitmap_create(int width, int height, enum gui_bitmap_flags flags)
Create a bitmap.
void amiga_bitmap_modified(void *bitmap)
The bitmap image has changed, so flush any persistant cache.
unsigned char * amiga_bitmap_get_buffer(void *bitmap)
Return a pointer to the pixel data in a bitmap.
void amiga_bitmap_destroy(void *bitmap)
Free a bitmap.
Generic bitmap handling interface.
@ BITMAP_OPAQUE
image is opaque
Public content interface.
Target independent plotting interface.
unsigned long bitmap_flags_t
static struct llcache_s * llcache
low level cache state
Low-level resource cache (interface)
#define NSLOG(catname, level, logmsg, args...)
const char * messages_get(const char *key)
Fast lookup of a message by key from the standard Messages hash.
Localised message support (interface).
Minimal compatibility header for AmigaOS 3.
RISC OS wimp toolkit bitmap.
Content operation function table.
nserror(* create)(const struct content_handler *handler, lwc_string *imime_type, const struct http_parameter *params, struct llcache_handle *llcache, const char *fallback_charset, bool quirks, struct content **c)
parameters to content redraw
int height
vertical dimension
bool repeat_y
whether content is tiled in y direction
bool repeat_x
whether content is tiled in x direction
int y
coordinate for top-left of redraw
int x
coordinate for top-left of redraw
colour background_colour
The background colour.
int width
dimensions to render content at (for scaling contents with intrinsic dimensions)
Content which corresponds to a single URL.
int height
Height dimension, if applicable.
int width
Width dimension, if applicable.
content_status status
Current status.
Representation of an HTTP parameter.
Handle to low-level cache object.
Parameters for object element and similar elements.
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.
const struct plotter_table * plot
Current plot operation table.
Extra data for some content_msg messages.
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.
static nserror clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.