summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-01-04 18:50:29 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-01-04 18:50:29 +0100
commitf5decdf48e13d89f133c27e9e8b77c5e04aa4bbd (patch)
tree8a465ed37366c4658ea377544f314a1b7e12e76c
parent816b74acd5396ef095e57909305881c6094e1dce (diff)
parentac3bab6219c73fef181f120e11d9d2c07ba848c3 (diff)
merge
-rw-r--r--dw/fltkimgbuf.cc18
-rw-r--r--src/dicache.c143
-rw-r--r--src/image.cc2
-rw-r--r--src/image.hh6
-rw-r--r--src/jpeg.c2
-rw-r--r--src/png.c1
6 files changed, 86 insertions, 86 deletions
diff --git a/dw/fltkimgbuf.cc b/dw/fltkimgbuf.cc
index b8beb1cb..571a8abd 100644
--- a/dw/fltkimgbuf.cc
+++ b/dw/fltkimgbuf.cc
@@ -85,12 +85,7 @@ void FltkImgbuf::init (Type type, int width, int height, FltkImgbuf *root)
FltkImgbuf::~FltkImgbuf ()
{
- //printf ("FltkImgbuf::~FltkImgbuf (%s)\n", isRoot() ? "root" : "scaled");
-
- //if (root)
- // printf("FltkImgbuf[scaled %p, root is %p]: deleted\n", this, root);
- //else
- // printf("FltkImgbuf[root %p]: deleted\n", this);
+ //printf("~FltkImgbuf[%s %p] deleted\n", isRoot() ? "root":"scaled", this);
if (!isRoot())
root->detachScaledBuf (this);
@@ -175,7 +170,7 @@ void FltkImgbuf::newScan ()
core::Imgbuf* FltkImgbuf::getScaledBuf (int width, int height)
{
- if (root)
+ if (!isRoot())
return root->getScaledBuf (width, height);
if (width == this->width && height == this->height) {
@@ -256,10 +251,11 @@ void FltkImgbuf::unref ()
if (isRoot ()) {
// Root buffer, it must be ensured that no scaled buffers are left.
// See also FltkImgbuf::detachScaledBuf().
- if (scaledBuffers->isEmpty () && deleteOnUnref)
+ if (scaledBuffers->isEmpty () && deleteOnUnref) {
delete this;
- else
- printf("FltkImgbuf[root %p]: not deleted\n", this);
+ } else
+ printf("FltkImgbuf[root %p]: not deleted. numScaled=%d\n",
+ this, scaledBuffers->size ());
} else
// Scaled buffer buffer, simply delete it.
delete this;
@@ -293,7 +289,7 @@ int FltkImgbuf::scaledY(int ySrc)
}
void FltkImgbuf::draw (::fltk::Widget *target, int xRoot, int yRoot,
- int x, int y, int width, int height)
+ int x, int y, int width, int height)
{
// TODO (i): Implementation.
// TODO (ii): Clarify the question, whether "target" is the current widget
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
}
diff --git a/src/jpeg.c b/src/jpeg.c
index c495dbbe..4da2d39e 100644
--- a/src/jpeg.c
+++ b/src/jpeg.c
@@ -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);
diff --git a/src/png.c b/src/png.c
index 989809e8..f7e2de8d 100644
--- a/src/png.c
+++ b/src/png.c
@@ -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);