diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/dicache.c | 143 | ||||
-rw-r--r-- | src/image.cc | 2 | ||||
-rw-r--r-- | src/image.hh | 6 | ||||
-rw-r--r-- | src/jpeg.c | 2 | ||||
-rw-r--r-- | src/png.c | 1 |
5 files changed, 79 insertions, 75 deletions
diff --git a/src/dicache.c b/src/dicache.c index 21173c9a..c8cf7471 100644 --- a/src/dicache.c +++ b/src/dicache.c @@ -245,67 +245,6 @@ void a_Dicache_invalidate_entry(const DilloUrl *Url) /* ------------------------------------------------------------------------- */ /* - * This function is a cache client; (but feeds its clients from dicache) - */ -void a_Dicache_callback(int Op, CacheClient_t *Client) -{ - uint_t i; - DilloWeb *Web = Client->Web; - DilloImage *Image = Web->Image; - DICacheEntry *DicEntry = a_Dicache_get_entry(Web->url, DIC_Last); - - dReturn_if_fail ( DicEntry != NULL ); - - /* Copy the version number in the Client */ - if (Client->Version == 0) - Client->Version = DicEntry->version; - - /* Only call the decoder when necessary */ - if (Op == CA_Send && DicEntry->State < DIC_Close && - DicEntry->DecodedSize < Client->BufSize) { - DicEntry->Decoder(Op, Client); - DicEntry->DecodedSize = Client->BufSize; /* necessary ?? */ - } else if (Op == CA_Close || Op == CA_Abort) { - a_Dicache_close(DicEntry->url, DicEntry->version, Client); - } - - /* when the data stream is not an image 'v_imgbuf' remains NULL */ - if (Op == CA_Send && DicEntry->v_imgbuf) { - if (Image->height == 0 && DicEntry->State >= DIC_SetParms) { - /* Set parms */ - a_Image_set_parms( - Image, DicEntry->v_imgbuf, DicEntry->url, - DicEntry->version, DicEntry->width, DicEntry->height, - DicEntry->type); - } - if (DicEntry->State == DIC_Write) { - if (DicEntry->ScanNumber == Image->ScanNumber) { - for (i = 0; i < DicEntry->height; ++i) - if (a_Bitvec_get_bit(DicEntry->BitVec, (int)i) && - !a_Bitvec_get_bit(Image->BitVec, (int)i) ) - a_Image_write(Image, i); - } else { - for (i = 0; i < DicEntry->height; ++i) { - if (a_Bitvec_get_bit(DicEntry->BitVec, (int)i) || - !a_Bitvec_get_bit(Image->BitVec, (int)i) || - DicEntry->ScanNumber > Image->ScanNumber + 1) { - a_Image_write(Image, i); - } - if (!a_Bitvec_get_bit(DicEntry->BitVec, (int)i)) - a_Bitvec_clear_bit(Image->BitVec, (int)i); - } - Image->ScanNumber = DicEntry->ScanNumber; - } - } - } else if (Op == CA_Close || Op == CA_Abort) { - a_Image_close(Image); - a_Bw_close_client(Web->bw, Client->Key); - } -} - -/* ------------------------------------------------------------------------- */ - -/* * Set image's width, height & type * (By now, we'll use the image information despite the html tags --Jcid) */ @@ -416,18 +355,87 @@ void a_Dicache_close(DilloUrl *url, int version, CacheClient_t *Client) DICacheEntry *DicEntry = a_Dicache_get_entry(url, version); dReturn_if_fail ( DicEntry != NULL ); - _MSG("a_Dicache_close RefCount=%d\n", DicEntry->RefCount); - DicEntry->State = DIC_Close; - dFree(DicEntry->cmap); - DicEntry->cmap = NULL; - DicEntry->Decoder = NULL; - DicEntry->DecoderData = NULL; + if (DicEntry->State < DIC_Close) { + DicEntry->State = DIC_Close; + dFree(DicEntry->cmap); + DicEntry->cmap = NULL; + DicEntry->Decoder = NULL; + DicEntry->DecoderData = NULL; + } a_Dicache_unref(url, version); + MSG("a_Dicache_close RefCount=%d\n", DicEntry->RefCount); a_Bw_close_client(Web->bw, Client->Key); } +/* ------------------------------------------------------------------------- */ + +/* + * This function is a cache client; (but feeds its clients from dicache) + */ +void a_Dicache_callback(int Op, CacheClient_t *Client) +{ + uint_t i; + DilloWeb *Web = Client->Web; + DilloImage *Image = Web->Image; + DICacheEntry *DicEntry = a_Dicache_get_entry(Web->url, DIC_Last); + + dReturn_if_fail ( DicEntry != NULL ); + + /* Copy the version number in the Client */ + if (Client->Version == 0) + Client->Version = DicEntry->version; + + /* Only call the decoder when necessary */ + if (Op == CA_Send && DicEntry->State < DIC_Close && + DicEntry->DecodedSize < Client->BufSize) { + DicEntry->Decoder(Op, Client); + DicEntry->DecodedSize = Client->BufSize; + } else if (Op == CA_Close || Op == CA_Abort) { + if (DicEntry->State < DIC_Close) { + DicEntry->Decoder(Op, Client); + } else { + a_Dicache_close(DicEntry->url, DicEntry->version, Client); + } + } + + /* when the data stream is not an image 'v_imgbuf' remains NULL */ + if (Op == CA_Send && DicEntry->v_imgbuf) { + if (Image->height == 0 && DicEntry->State >= DIC_SetParms) { + /* Set parms */ + a_Image_set_parms( + Image, DicEntry->v_imgbuf, DicEntry->url, + DicEntry->version, DicEntry->width, DicEntry->height, + DicEntry->type); + } + if (DicEntry->State == DIC_Write) { + if (DicEntry->ScanNumber == Image->ScanNumber) { + for (i = 0; i < DicEntry->height; ++i) + if (a_Bitvec_get_bit(DicEntry->BitVec, (int)i) && + !a_Bitvec_get_bit(Image->BitVec, (int)i) ) + a_Image_write(Image, i); + } else { + for (i = 0; i < DicEntry->height; ++i) { + if (a_Bitvec_get_bit(DicEntry->BitVec, (int)i) || + !a_Bitvec_get_bit(Image->BitVec, (int)i) || + DicEntry->ScanNumber > Image->ScanNumber + 1) { + a_Image_write(Image, i); + } + if (!a_Bitvec_get_bit(DicEntry->BitVec, (int)i)) + a_Bitvec_clear_bit(Image->BitVec, (int)i); + } + Image->ScanNumber = DicEntry->ScanNumber; + } + } + } else if (Op == CA_Close || Op == CA_Abort) { + a_Image_close(Image); + a_Bw_close_client(Web->bw, Client->Key); + } +} + +/* ------------------------------------------------------------------------- */ + /* * Free the imgbuf (RGB data) of unused entries. */ @@ -437,6 +445,7 @@ void a_Dicache_cleanup(void) DICacheNode *node; DICacheEntry *entry; + _MSG("a_Dicache_cleanup\n"); for (i = 0; i < dList_length(CachedIMGs); ++i) { node = dList_nth_data(CachedIMGs, i); /* iterate each entry of this node */ diff --git a/src/image.cc b/src/image.cc index 0edaf35c..fa4f5516 100644 --- a/src/image.cc +++ b/src/image.cc @@ -144,7 +144,7 @@ void a_Image_write(DilloImage *Image, uint_t y) */ void a_Image_close(DilloImage *Image) { - _MSG("a_Image_close\n"); + MSG("a_Image_close\n"); a_Image_unref(Image); } diff --git a/src/image.hh b/src/image.hh index ea649ebc..d4525ba2 100644 --- a/src/image.hh +++ b/src/image.hh @@ -66,12 +66,6 @@ void a_Image_new_scan(DilloImage *image, void *v_imgbuf); void a_Image_write(DilloImage *Image, uint_t y); void a_Image_close(DilloImage *Image); -void a_Image_imgbuf_ref(void *v_imgbuf); -void a_Image_imgbuf_unref(void *v_imgbuf); -void *a_Image_imgbuf_new(void *v_dw, int img_type, int width, int height); -int a_Image_imgbuf_last_reference(void *v_imgbuf); -void a_Image_imgbuf_update(DilloImage *Image, void *v_imgbuf, - const uchar_t *buf, uint_t y); #ifdef __cplusplus } @@ -84,7 +84,6 @@ typedef struct DilloJpeg { static DilloJpeg *Jpeg_new(DilloImage *Image, DilloUrl *url, int version); static void Jpeg_callback(int Op, CacheClient_t *Client); static void Jpeg_write(DilloJpeg *jpeg, void *Buf, uint_t BufSize); -static void Jpeg_close(DilloJpeg *jpeg, CacheClient_t *Client); METHODDEF(void) Jpeg_errorexit (j_common_ptr cinfo); /* exported function */ @@ -140,6 +139,7 @@ void *a_Jpeg_image(const char *Type, void *P, CA_Callback_t *Call, */ static void Jpeg_close(DilloJpeg *jpeg, CacheClient_t *Client) { + MSG("Jpeg_close\n"); a_Dicache_close(jpeg->url, jpeg->version, Client); jpeg_destroy_decompress(&(jpeg->cinfo)); dFree(jpeg); @@ -304,6 +304,7 @@ static void */ static void Png_close(DilloPng *png, CacheClient_t *Client) { + MSG("Png_close\n"); /* Let dicache know decoding is over */ a_Dicache_close(png->url, png->version, Client); |