Dillo v3.1.1-119-g140d9ebd
Loading...
Searching...
No Matches
dicache.c
Go to the documentation of this file.
1/*
2 * File: dicache.c
3 *
4 * Copyright 2000-2007 Jorge Arellano Cid <jcid@dillo.org>
5 * Copyright 2024 Rodrigo Arias Mallo <rodarima@gmail.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 */
12
13#include <string.h> /* for memset */
14#include <stdlib.h>
15
16#include "msg.h"
17#include "image.hh"
18#include "imgbuf.hh"
19#include "web.hh"
20#include "dicache.h"
21#include "dpng.h"
22#include "dwebp.h"
23#include "dgif.h"
24#include "djpeg.h"
25#include "dsvg.h"
26
27enum {
34};
35
36static const char *format_name[DIC_MAX] = {
37 [DIC_Gif] = "gif",
38 [DIC_Png] = "png",
39 [DIC_Webp] = "webp",
40 [DIC_Jpeg] = "jpeg",
41 [DIC_Svg] = "svg"
42};
43
44static int disabled_formats[DIC_MAX] = { 0 };
45
50static Dlist *CachedIMGs = NULL;
51
52static uint_t dicache_size_total; /* invariant: dicache_size_total is
53 * the sum of the image sizes (3*w*h)
54 * of all the images in the dicache. */
55
59static int Dicache_entry_cmp(const void *v1, const void *v2)
60{
61 const DICacheEntry *e1 = v1, *e2 = v2;
62
63 int st = a_Url_cmp(e1->url, e2->url);
64 if (st == 0) {
65 if (e2->version == DIC_Last)
66 st = (e1->Flags & DIF_Last ? 0 : -1);
67 else
68 st = (e1->version - e2->version);
69 }
70 return st;
71}
72
77{
78 CachedIMGs = dList_new(256);
80
82 for (int i = 0; i < DIC_MAX; i++) {
84 disabled_formats[i] = 1;
85 _MSG("Image format %s disabled\n", format_name[i]);
86 }
87 }
88 }
89}
90
95{
96 DICacheEntry *entry = dNew(DICacheEntry, 1);
97
98 entry->width = 0;
99 entry->height = 0;
100 entry->Flags = DIF_Valid;
101 entry->SurvCleanup = 0;
103 entry->cmap = NULL;
104 entry->v_imgbuf = NULL;
105 entry->RefCount = 1;
106 entry->TotalSize = 0;
107 entry->ScanNumber = 0;
108 entry->BitVec = NULL;
109 entry->State = DIC_Empty;
110 entry->version = 1;
111
112 entry->Decoder = NULL;
113 entry->DecoderData = NULL;
114 entry->DecodedSize = 0;
115
116 return entry;
117}
118
124{
125 DICacheEntry e, *entry, *last;
126
127 entry = Dicache_entry_new();
128 e.url = (DilloUrl*)Url;
129 e.version = DIC_Last;
131 if (last) {
132 /* URL is already in CachedIMGs, make a new version */
133 last->Flags &= ~DIF_Last;
134 entry->version = last->version + 1;
135 }
136 entry->url = a_Url_dup(Url);
137 entry->Flags |= DIF_Last;
139
140 return entry;
141}
142
151{
152 DICacheEntry e;
153 DICacheEntry *entry = NULL;
154
155 dReturn_val_if_fail(version != 0, NULL);
156 e.url = (DilloUrl*)Url;
157 e.version = version;
159 if (entry && !(entry->Flags & DIF_Valid) && version == DIC_Last)
160 entry = NULL;
161 return entry;
162}
163
167static void Dicache_remove(const DilloUrl *Url, int version)
168{
169 DICacheEntry e, *entry;
170
171 _MSG("Dicache_remove url=%s\n", URL_STR(Url));
172 e.url = (DilloUrl*)Url;
173 e.version = version;
175 dReturn_if (entry == NULL);
176
177 _MSG("Dicache_remove Imgbuf=%p Decoder=%p DecoderData=%p\n",
178 entry->v_imgbuf, entry->Decoder, entry->DecoderData);
179 /* Eliminate this dicache entry */
180 dList_remove(CachedIMGs, entry);
182
183 /* entry cleanup */
184 a_Url_free(entry->url);
185 dFree(entry->cmap);
186 a_Bitvec_free(entry->BitVec);
187 a_Imgbuf_unref(entry->v_imgbuf);
188 if (entry->Decoder) {
189 entry->Decoder(CA_Abort, entry->DecoderData);
190 }
191 dFree(entry);
192}
193
200void a_Dicache_unref(const DilloUrl *Url, int version)
201{
202 DICacheEntry *entry;
203
204 if ((entry = a_Dicache_get_entry(Url, version))) {
205 _MSG("a_Dicache_unref: RefCount=%d State=%d ImgbufLastRef=%d\n",
206 entry->RefCount, entry->State,
207 entry->v_imgbuf ? a_Imgbuf_last_reference(entry->v_imgbuf) : -1);
208 if (entry->RefCount > 0) --entry->RefCount;
209 if (entry->RefCount == 0 && entry->v_imgbuf == NULL)
210 Dicache_remove(Url, version);
211 }
212}
213
217DICacheEntry* a_Dicache_ref(const DilloUrl *Url, int version)
218{
219 DICacheEntry *entry;
220
221 if ((entry = a_Dicache_get_entry(Url, version))) {
222 ++entry->RefCount;
223 }
224 return entry;
225}
226
233{
235 if (entry)
236 entry->Flags &= ~DIF_Valid;
237}
238
239
240/* ------------------------------------------------------------------------- */
241
248void a_Dicache_set_parms(DilloUrl *url, int version, DilloImage *Image,
249 uint_t width, uint_t height, DilloImgType type,
250 double gamma)
251{
252 DICacheEntry *DicEntry;
253
254 _MSG("a_Dicache_set_parms (%s)\n", URL_STR(url));
255 dReturn_if_fail ( Image != NULL && width && height );
256 /* Find the DicEntry for this Image */
257 DicEntry = a_Dicache_get_entry(url, version);
258 dReturn_if_fail ( DicEntry != NULL );
259 /* Parameters already set? Don't do it twice. */
260 dReturn_if_fail ( DicEntry->State < DIC_SetParms );
261
262 _MSG(" RefCount=%d version=%d\n", DicEntry->RefCount, DicEntry->version);
263
264 /* BUG: there's just one image-type now */
265 #define I_RGB 0
266 DicEntry->v_imgbuf =
267 a_Imgbuf_new(Image->layout, I_RGB, width, height, gamma);
268
269 DicEntry->TotalSize = width * height * 3;
270 DicEntry->width = width;
271 DicEntry->height = height;
272 DicEntry->type = type;
273 DicEntry->BitVec = a_Bitvec_new((int)height);
274 DicEntry->State = DIC_SetParms;
275
276 dicache_size_total += DicEntry->TotalSize;
277}
278
282void a_Dicache_set_cmap(DilloUrl *url, int version, int bg_color,
283 const uchar_t *cmap, uint_t num_colors,
284 int num_colors_max, int bg_index)
285{
286 DICacheEntry *DicEntry = a_Dicache_get_entry(url, version);
287
288 _MSG("a_Dicache_set_cmap\n");
289 dReturn_if_fail ( DicEntry != NULL );
290
291 dFree(DicEntry->cmap);
292 DicEntry->cmap = dNew0(uchar_t, 3 * num_colors_max);
293 memcpy(DicEntry->cmap, cmap, 3 * num_colors);
294 if (bg_index >= 0 && (uint_t)bg_index < num_colors) {
295 DicEntry->cmap[bg_index * 3] = (bg_color >> 16) & 0xff;
296 DicEntry->cmap[bg_index * 3 + 1] = (bg_color >> 8) & 0xff;
297 DicEntry->cmap[bg_index * 3 + 2] = (bg_color) & 0xff;
298 }
299
300 DicEntry->State = DIC_SetCmap;
301}
302
306void a_Dicache_new_scan(const DilloUrl *url, int version)
307{
308 DICacheEntry *DicEntry;
309
310 _MSG("a_Dicache_new_scan\n");
311 dReturn_if_fail ( url != NULL );
312 DicEntry = a_Dicache_get_entry(url, version);
313 dReturn_if_fail ( DicEntry != NULL );
314 if (DicEntry->State < DIC_SetParms) {
315 MSG("a_Dicache_new_scan before DIC_SetParms\n");
316 exit(1);
317 }
318 a_Bitvec_clear(DicEntry->BitVec);
319 DicEntry->ScanNumber++;
320 a_Imgbuf_new_scan(DicEntry->v_imgbuf);
321}
322
329void a_Dicache_write(DilloUrl *url, int version, const uchar_t *buf, uint_t Y)
330{
331 DICacheEntry *DicEntry;
332
333 _MSG("a_Dicache_write\n");
334 DicEntry = a_Dicache_get_entry(url, version);
335 dReturn_if_fail ( DicEntry != NULL );
336 dReturn_if_fail ( DicEntry->width > 0 && DicEntry->height > 0 );
337
338 /* update the common buffer in the imgbuf */
339 a_Imgbuf_update(DicEntry->v_imgbuf, buf, DicEntry->type,
340 DicEntry->cmap, DicEntry->width, DicEntry->height, Y);
341
342 a_Bitvec_set_bit(DicEntry->BitVec, (int)Y);
343 DicEntry->State = DIC_Write;
344}
345
349void a_Dicache_close(DilloUrl *url, int version, CacheClient_t *Client)
350{
351 DilloWeb *Web = Client->Web;
352 DICacheEntry *DicEntry = a_Dicache_get_entry(url, version);
353
354 dReturn_if_fail ( DicEntry != NULL );
355
356 /* a_Dicache_unref() may free DicEntry */
357 _MSG("a_Dicache_close RefCount=%d\n", DicEntry->RefCount - 1);
358 _MSG("a_Dicache_close DIC_Close=%d State=%d\n", DIC_Close, DicEntry->State);
359 _MSG(" a_Dicache_close imgbuf=%p Decoder=%p DecoderData=%p\n",
360 DicEntry->v_imgbuf, DicEntry->Decoder, DicEntry->DecoderData);
361
362 if (DicEntry->State < DIC_Close) {
363 DicEntry->State = DIC_Close;
364 dFree(DicEntry->cmap);
365 DicEntry->cmap = NULL;
366 DicEntry->Decoder = NULL;
367 DicEntry->DecoderData = NULL;
368 }
369 a_Dicache_unref(url, version);
370
371 a_Bw_close_client(Web->bw, Client->Key);
372}
373
374/* ------------------------------------------------------------------------- */
375
386static void *Dicache_image(int ImgType, const char *MimeType, void *Ptr,
387 CA_Callback_t *Call, void **Data)
388{
389 DilloWeb *web = Ptr;
390 DICacheEntry *DicEntry;
391
392 dReturn_val_if_fail(MimeType && Ptr, NULL);
393
394 if (ImgType >= 0 && ImgType < DIC_MAX && disabled_formats[ImgType]) {
395 _MSG("Ignoring image format %s\n", format_name[ImgType]);
396 return NULL;
397 }
398
399 if (!web->Image) {
400 web->Image =
401 a_Image_new_with_dw(web->bw->render_layout, NULL, web->bgColor, 0);
402 a_Image_ref(web->Image);
403 }
404
405 DicEntry = a_Dicache_get_entry(web->url, DIC_Last);
406 if (!DicEntry) {
407 /* Create an entry for this image... */
408 DicEntry = Dicache_add_entry(web->url);
409 /* Attach a decoder */
410 if (ImgType == DIC_Jpeg) {
412 DicEntry->DecoderData =
413 a_Jpeg_new(web->Image, DicEntry->url, DicEntry->version);
414 } else if (ImgType == DIC_Gif) {
416 DicEntry->DecoderData =
417 a_Gif_new(web->Image, DicEntry->url, DicEntry->version);
418 } else if (ImgType == DIC_Webp) {
420 DicEntry->DecoderData =
421 a_Webp_new(web->Image, DicEntry->url, DicEntry->version);
422 } else if (ImgType == DIC_Png) {
424 DicEntry->DecoderData =
425 a_Png_new(web->Image, DicEntry->url, DicEntry->version);
426 } else if (ImgType == DIC_Svg) {
428 DicEntry->DecoderData =
429 a_Svg_new(web->Image, DicEntry->url, DicEntry->version);
430 }
431 } else {
432 /* Repeated image */
433 a_Dicache_ref(DicEntry->url, DicEntry->version);
434 }
435 /* Survive three cleanup passes (set to zero = old behaviour). */
436 DicEntry->SurvCleanup = 3;
437
438 *Data = DicEntry->DecoderData;
440
441 return (a_Image_get_dw (web->Image));
442}
443
447void *a_Dicache_png_image(const char *Type, void *Ptr, CA_Callback_t *Call,
448 void **Data)
449{
450 return Dicache_image(DIC_Png, Type, Ptr, Call, Data);
451}
452
456void *a_Dicache_webp_image(const char *Type, void *Ptr, CA_Callback_t *Call,
457 void **Data)
458{
459 return Dicache_image(DIC_Webp, Type, Ptr, Call, Data);
460}
461
465void *a_Dicache_gif_image(const char *Type, void *Ptr, CA_Callback_t *Call,
466 void **Data)
467{
468 return Dicache_image(DIC_Gif, Type, Ptr, Call, Data);
469}
470
474void *a_Dicache_jpeg_image(const char *Type, void *Ptr, CA_Callback_t *Call,
475 void **Data)
476{
477 return Dicache_image(DIC_Jpeg, Type, Ptr, Call, Data);
478}
479
483void *a_Dicache_svg_image(const char *Type, void *Ptr, CA_Callback_t *Call,
484 void **Data)
485{
486 return Dicache_image(DIC_Svg, Type, Ptr, Call, Data);
487}
488
493{
494 uint_t i;
495 DilloWeb *Web = Client->Web;
496 DilloImage *Image = Web->Image;
497 DICacheEntry *DicEntry = a_Dicache_get_entry(Web->url, DIC_Last);
498
499 dReturn_if_fail ( DicEntry != NULL );
500
501 /* Copy the version number in the Client */
502 if (Client->Version == 0)
503 Client->Version = DicEntry->version;
504
505 /* Only call the decoder when necessary */
506 if (Op == CA_Send && DicEntry->State < DIC_Close &&
507 DicEntry->DecodedSize < Client->BufSize) {
508 DicEntry->Decoder(Op, Client);
509 DicEntry->DecodedSize = Client->BufSize;
510 } else if (Op == CA_Close || Op == CA_Abort) {
511 if (DicEntry->State < DIC_Close) {
512 DicEntry->Decoder(Op, Client);
513 } else {
514 a_Dicache_close(DicEntry->url, DicEntry->version, Client);
515 }
516 }
517
518 /* when the data stream is not an image 'v_imgbuf' remains NULL */
519 if (Op == CA_Send && DicEntry->v_imgbuf) {
520 if (Image->height == 0 && DicEntry->State >= DIC_SetParms) {
521 /* Set parms */
523 Image, DicEntry->v_imgbuf, DicEntry->url,
524 DicEntry->version, DicEntry->width, DicEntry->height,
525 DicEntry->type);
526 }
527 if (DicEntry->State == DIC_Write) {
528 if (DicEntry->ScanNumber == Image->ScanNumber) {
529 for (i = 0; i < DicEntry->height; ++i)
530 if (a_Bitvec_get_bit(DicEntry->BitVec, (int)i) &&
531 !a_Bitvec_get_bit(Image->BitVec, (int)i) )
532 a_Image_write(Image, i);
533 } else {
534 for (i = 0; i < DicEntry->height; ++i) {
535 if (a_Bitvec_get_bit(DicEntry->BitVec, (int)i) ||
536 !a_Bitvec_get_bit(Image->BitVec, (int)i) ||
537 DicEntry->ScanNumber > Image->ScanNumber + 1) {
538 a_Image_write(Image, i);
539 }
540 if (!a_Bitvec_get_bit(DicEntry->BitVec, (int)i))
541 a_Bitvec_clear_bit(Image->BitVec, (int)i);
542 }
543 Image->ScanNumber = DicEntry->ScanNumber;
544 }
545 }
546 } else if (Op == CA_Close) {
547 a_Image_close(Image);
548 a_Bw_close_client(Web->bw, Client->Key);
549 } else if (Op == CA_Abort) {
550 a_Image_abort(Image);
551 a_Bw_close_client(Web->bw, Client->Key);
552 }
553}
554
555/* ------------------------------------------------------------------------- */
556
561{
562 int i;
563 DICacheEntry *entry;
564
565 for (i = 0; (entry = dList_nth_data(CachedIMGs, i)); ++i) {
566 _MSG(" SurvCleanup = %d\n", entry->SurvCleanup);
567 if (entry->RefCount == 0 &&
568 (!entry->v_imgbuf || a_Imgbuf_last_reference(entry->v_imgbuf))) {
569 if (--entry->SurvCleanup >= 0)
570 continue; /* keep the entry one more pass */
571
572 /* free this unused entry */
573 Dicache_remove(entry->url, entry->version);
574 --i; /* adjust counter */
575 }
576 }
577 _MSG("a_Dicache_cleanup: length = %d\n", dList_length(CachedIMGs));
578}
579
580/* ------------------------------------------------------------------------- */
581
587{
588 DICacheEntry *entry;
589
590 /* Remove all the dicache entries */
591 while ((entry = dList_nth_data(CachedIMGs, dList_length(CachedIMGs)-1))) {
593 a_Url_free(entry->url);
594 dFree(entry->cmap);
595 a_Bitvec_free(entry->BitVec);
596 a_Imgbuf_unref(entry->v_imgbuf);
598 dFree(entry);
599 }
601}
void a_Bitvec_clear(bitvec_t *bvec)
Clear a bitvec.
Definition bitvec.c:35
bitvec_t * a_Bitvec_new(int num_bits)
Create a new bitvec with 'num_bits' size.
Definition bitvec.c:23
void a_Bitvec_set_bit(bitvec_t *bvec, int pos)
Set a bit.
Definition bitvec.c:63
void a_Bitvec_free(bitvec_t *bvec)
Free a bitvec.
Definition bitvec.c:43
int a_Bitvec_get_bit(bitvec_t *bvec, int pos)
Get a bit.
Definition bitvec.c:54
#define a_Bitvec_clear_bit(bvec, pos)
Definition bitvec.h:31
#define _MSG(...)
Definition bookmarks.c:45
#define MSG(...)
Definition bookmarks.c:46
void a_Bw_close_client(BrowserWindow *bw, int ClientKey)
Close a cache-client upon successful retrieval.
Definition bw.c:167
#define CA_Send
Definition cache.h:15
void(* CA_Callback_t)(int Op, CacheClient_t *Client)
Callback type for cache clients.
Definition cache.h:43
#define CA_Abort
Definition cache.h:17
#define CA_Close
Definition cache.h:16
unsigned char uchar_t
Definition d_size.h:17
unsigned int uint_t
Definition d_size.h:20
void a_Dicache_set_parms(DilloUrl *url, int version, DilloImage *Image, uint_t width, uint_t height, DilloImgType type, double gamma)
Set image's width, height & type.
Definition dicache.c:248
DICacheEntry * a_Dicache_get_entry(const DilloUrl *Url, int version)
Search a particular version of a URL in the Dicache.
Definition dicache.c:150
void a_Dicache_cleanup(void)
Free the imgbuf (RGB data) of unused entries.
Definition dicache.c:560
static Dlist * CachedIMGs
List of DICacheEntry.
Definition dicache.c:50
static DICacheEntry * Dicache_entry_new(void)
Create, and initialize a new, empty, dicache entry.
Definition dicache.c:94
@ DIC_Svg
Definition dicache.c:32
@ DIC_MAX
Definition dicache.c:33
@ DIC_Jpeg
Definition dicache.c:31
@ DIC_Png
Definition dicache.c:29
@ DIC_Webp
Definition dicache.c:30
@ DIC_Gif
Definition dicache.c:28
void a_Dicache_invalidate_entry(const DilloUrl *Url)
Invalidate this entry.
Definition dicache.c:232
#define I_RGB
static const char * format_name[DIC_MAX]
Definition dicache.c:36
DICacheEntry * a_Dicache_ref(const DilloUrl *Url, int version)
Refs the counter of a dicache entry.
Definition dicache.c:217
void a_Dicache_new_scan(const DilloUrl *url, int version)
Reset for a new scan from a multiple-scan image.
Definition dicache.c:306
void a_Dicache_close(DilloUrl *url, int version, CacheClient_t *Client)
Implement the close method of the decoding process.
Definition dicache.c:349
void * a_Dicache_svg_image(const char *Type, void *Ptr, CA_Callback_t *Call, void **Data)
SVG wrapper for Dicache_image()
Definition dicache.c:483
void a_Dicache_init(void)
Initialize dicache data.
Definition dicache.c:76
void a_Dicache_unref(const DilloUrl *Url, int version)
Unrefs the counter of a dicache entry (it counts cache clients).
Definition dicache.c:200
void a_Dicache_callback(int Op, CacheClient_t *Client)
This function is a cache client; (but feeds its clients from dicache)
Definition dicache.c:492
void a_Dicache_write(DilloUrl *url, int version, const uchar_t *buf, uint_t Y)
Implement the write method (Write a scan line into the Dicache entry) buf: row buffer Y : row number.
Definition dicache.c:329
static int Dicache_entry_cmp(const void *v1, const void *v2)
Compare function for image entries.
Definition dicache.c:59
static void * Dicache_image(int ImgType, const char *MimeType, void *Ptr, CA_Callback_t *Call, void **Data)
Generic MIME handler for GIF, JPEG, PNG and SVG.
Definition dicache.c:386
void a_Dicache_freeall(void)
Deallocate memory used by dicache module (Call this one at exit time, with no cache clients queued)
Definition dicache.c:586
static uint_t dicache_size_total
Definition dicache.c:52
void a_Dicache_set_cmap(DilloUrl *url, int version, int bg_color, const uchar_t *cmap, uint_t num_colors, int num_colors_max, int bg_index)
Implement the set_cmap method for the Image.
Definition dicache.c:282
static void Dicache_remove(const DilloUrl *Url, int version)
Actually free a dicache entry, given the URL and the version number.
Definition dicache.c:167
void * a_Dicache_jpeg_image(const char *Type, void *Ptr, CA_Callback_t *Call, void **Data)
JPEG wrapper for Dicache_image()
Definition dicache.c:474
static DICacheEntry * Dicache_add_entry(const DilloUrl *Url)
Add a new entry in the dicache (a single URL may have several entries)
Definition dicache.c:123
void * a_Dicache_webp_image(const char *Type, void *Ptr, CA_Callback_t *Call, void **Data)
WEBP wrapper for Dicache_image()
Definition dicache.c:456
void * a_Dicache_gif_image(const char *Type, void *Ptr, CA_Callback_t *Call, void **Data)
GIF wrapper for Dicache_image()
Definition dicache.c:465
static int disabled_formats[DIC_MAX]
Definition dicache.c:44
void * a_Dicache_png_image(const char *Type, void *Ptr, CA_Callback_t *Call, void **Data)
PNG wrapper for Dicache_image()
Definition dicache.c:447
#define DIF_Last
Flags: Last version, Valid entry.
Definition dicache.h:16
#define DIF_Valid
Definition dicache.h:17
@ DIC_Close
Whole image got!
Definition dicache.h:26
@ DIC_SetCmap
Color map set.
Definition dicache.h:24
@ DIC_SetParms
Parameters set.
Definition dicache.h:23
@ DIC_Write
Feeding the entry.
Definition dicache.h:25
@ DIC_Empty
Just created the entry.
Definition dicache.h:22
#define DIC_Last
Symbolic name to request the last version of an image.
Definition dicache.h:14
void dList_insert_sorted(Dlist *lp, void *data, dCompareFunc func)
Insert an element into a sorted list.
Definition dlib.c:769
void dFree(void *mem)
Definition dlib.c:68
Dlist * dList_new(int size)
Create a new empty list.
Definition dlib.c:548
int dList_length(Dlist *lp)
For completing the ADT.
Definition dlib.c:613
void * dList_nth_data(Dlist *lp, int n0)
Return the nth data item, NULL when not found or 'n0' is out of range.
Definition dlib.c:662
void dList_remove_fast(Dlist *lp, const void *data)
Remove a data item without preserving order.
Definition dlib.c:623
char * dStriAsciiStr(const char *haystack, const char *needle)
Case insensitive strstr.
Definition dlib.c:184
void * dList_find_sorted(Dlist *lp, const void *data, dCompareFunc func)
Search a sorted list.
Definition dlib.c:796
void dList_free(Dlist *lp)
Free a list (not its elements)
Definition dlib.c:564
void dList_remove(Dlist *lp, const void *data)
Definition dlib.c:641
#define dReturn_if_fail(expr)
Definition dlib.h:72
#define dNew0(type, count)
Definition dlib.h:51
#define dReturn_val_if_fail(expr, val)
Definition dlib.h:76
#define dReturn_if(expr)
Definition dlib.h:64
#define dNew(type, count)
Definition dlib.h:49
void * a_Png_new(DilloImage *Image, DilloUrl *url, int version)
Create the image state data that must be kept between calls.
Definition png.c:448
void a_Png_callback(int Op, CacheClient_t *Client)
void a_Gif_callback()
Definition gif.c:1024
void * a_Gif_new()
Definition gif.c:1023
void * a_Imgbuf_new(void *layout, int img_type, uint_t width, uint_t height, double gamma)
Create a new Imgbuf.
Definition imgbuf.cc:93
void a_Imgbuf_update(void *v_imgbuf, const uchar_t *buf, DilloImgType type, uchar_t *cmap, uint_t width, uint_t height, uint_t y)
Update the root buffer of an imgbuf.
Definition imgbuf.cc:121
int a_Imgbuf_last_reference(void *v_imgbuf)
Last reference for this Imgbuf?
Definition imgbuf.cc:113
void a_Imgbuf_unref(void *v_imgbuf)
Decrement reference count for an Imgbuf.
Definition imgbuf.cc:84
void a_Imgbuf_new_scan(void *v_imgbuf)
Reset for a new scan from a multiple-scan image.
Definition imgbuf.cc:135
void a_Jpeg_callback()
Definition jpeg.c:423
void * a_Jpeg_new()
Definition jpeg.c:422
DilloPrefs prefs
Global Data.
Definition prefs.c:33
void a_Image_ref(DilloImage *Image)
Add a reference to an Image struct Do nothing if the argument is NULL.
Definition image.cc:100
DilloImage * a_Image_new_with_dw(void *layout, const char *alt_text, int32_t bg_color, int32_t fg_color)
Create and initialize a new image structure with an image widget.
Definition image.cc:59
void * a_Image_get_dw(DilloImage *Image)
Return the image renderer as a widget.
Definition image.cc:72
void a_Image_abort(DilloImage *Image)
Implement the abort method.
Definition image.cc:153
void a_Image_write(DilloImage *Image, uint_t y)
Implement the write method.
Definition image.cc:130
void a_Image_close(DilloImage *Image)
Implement the close method.
Definition image.cc:144
void a_Image_set_parms(DilloImage *Image, void *v_imgbuf, DilloUrl *url, int version, uint_t width, uint_t height, DilloImgType type)
Set initial parameters of the image.
Definition image.cc:109
The DilloImage data-structure and methods.
DilloImgType
Definition image.hh:42
@ DILLO_IMG_TYPE_NOTSET
Definition image.hh:47
void * render_layout
All the rendering is done by this.
Definition bw.h:34
Data structure for cache clients.
Definition cache.h:48
int Key
Primary Key for this client.
Definition cache.h:49
int Version
Dicache version of this Url (0 if not used)
Definition cache.h:51
uint_t BufSize
Valid size of cache-data.
Definition cache.h:53
void * Web
Pointer to the Web structure of our client.
Definition cache.h:56
int RefCount
Reference Counter.
Definition dicache.h:42
uint_t ScanNumber
Current decoding scan.
Definition dicache.h:39
int version
Version number, used for different versions of the same URL image.
Definition dicache.h:43
uchar_t * cmap
Color map.
Definition dicache.h:36
uint_t DecodedSize
Size of already decoded data.
Definition dicache.h:46
short SurvCleanup
Cleanup-pass survival for unused images.
Definition dicache.h:35
DilloImgType type
Image type.
Definition dicache.h:32
short Flags
See Flags.
Definition dicache.h:34
DicEntryState State
Current status for this entry.
Definition dicache.h:41
DilloUrl * url
Image URL for this entry.
Definition dicache.h:31
CA_Callback_t Decoder
Client function.
Definition dicache.h:47
uint_t TotalSize
Amount of memory the image takes up.
Definition dicache.h:38
uint_t width
Definition dicache.h:33
bitvec_t * BitVec
Bit vector for decoded rows.
Definition dicache.h:40
uint_t height
As taken from image data.
Definition dicache.h:33
void * DecoderData
Client function data.
Definition dicache.h:48
void * v_imgbuf
Void pointer to an Imgbuf object.
Definition dicache.h:37
char * ignore_image_formats
Definition prefs.h:100
Definition url.h:88
Definition dlib.h:131
void * layout
Definition image.hh:61
uint_t ScanNumber
Current decoding scan.
Definition image.hh:71
uint_t height
Definition image.hh:65
bitvec_t * BitVec
Bit vector for decoded rows.
Definition image.hh:70
DilloUrl * url
Requested URL.
Definition web.hh:25
BrowserWindow * bw
The requesting browser window [reference].
Definition web.hh:28
DilloImage * Image
For image urls [reference].
Definition web.hh:31
int32_t bgColor
for image backgrounds
Definition web.hh:33
void a_Svg_callback()
Definition svg.c:168
void * a_Svg_new()
Definition svg.c:167
int a_Url_cmp(const DilloUrl *A, const DilloUrl *B)
Compare two Url's to check if they're the same, or which one is bigger.
Definition url.c:506
void a_Url_free(DilloUrl *url)
Free a DilloUrl.
Definition url.c:208
DilloUrl * a_Url_dup(const DilloUrl *ori)
Duplicate a Url structure.
Definition url.c:477
#define URL_STR(u)
Definition url.h:76
void a_Webp_callback()
Definition webp.c:217
void * a_Webp_new()
Definition webp.c:216