aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJorge Arellano Cid <jcid@dillo.org>2014-05-14 20:21:27 -0400
committerJorge Arellano Cid <jcid@dillo.org>2014-05-14 20:21:27 -0400
commitc039ea12dd95e358b2aff826971d73fa0c170d63 (patch)
tree8959df77b99c4fce37f5d89ceed14a7f4f11b1f1
parent4681bc69ac265fae7f6f84cb834ec87ea5bec271 (diff)
Avoid removing imgbuf and decoding the whole image again for reloads.
Using the same testing files as the previous patch, the results are: .---------------------------------------------. |imgbufs | No patch | Patch #1 | Patch #2 | |---------------------------------------------- |1imgA.html | 2/1 | 1/1 | 1/0 | |2imgSA.html | 3/2 | 1/2 | 1/0 | |3imgSA.html | 4/3 | 1/3 | 1/0 | |---------------------------------------------- |2imgA.html | 4/2 | 2/2 | 2/0 | |3imgA.html | 6/3 | 3/3 | 3/0 | '---------------------------------------------' n1/n2 means: n1 imgbufs were created for first load (empty cache) n2 imgbufs were created for reload (cached image) Notes: * Rendering is much faster. Easy to notice with Back operation. * Between four to five times on www.welt.de. * Corner cases can be more than ten times. Usually, it *feels* faster.
-rw-r--r--dw/image.cc4
-rw-r--r--dw/widget.cc4
-rw-r--r--src/cache.c1
-rw-r--r--src/dicache.c45
4 files changed, 33 insertions, 21 deletions
diff --git a/dw/image.cc b/dw/image.cc
index 5df6b93e..e71c8f2f 100644
--- a/dw/image.cc
+++ b/dw/image.cc
@@ -425,9 +425,6 @@ void Image::setBuffer (core::Imgbuf *buffer, bool resize)
{
core::Imgbuf *oldBuf = this->buffer;
- if (resize)
- queueResize (0, true);
-
if (wasAllocated () && needsResize () &&
getContentWidth () > 0 && getContentHeight () > 0) {
// Don't create a new buffer for the transition from alt text to img,
@@ -438,6 +435,7 @@ void Image::setBuffer (core::Imgbuf *buffer, bool resize)
this->buffer = buffer;
buffer->ref ();
}
+ queueResize (0, true);
DBG_OBJ_ASSOC_CHILD (this->buffer);
diff --git a/dw/widget.cc b/dw/widget.cc
index 82677cc8..e6c2aa76 100644
--- a/dw/widget.cc
+++ b/dw/widget.cc
@@ -164,6 +164,10 @@ void Widget::queueDrawArea (int x, int y, int width, int height)
x, y, width, height);
DBG_OBJ_MSG_START ();
+ _MSG("Widget::queueDrawArea alloc(%d %d %d %d) wid(%d %d %d %d)\n",
+ allocation.x, allocation.y,
+ allocation.width, allocation.ascent + allocation.descent,
+ x, y, width, height);
if (layout)
layout->queueDraw (x + allocation.x, y + allocation.y, width, height);
diff --git a/src/cache.c b/src/cache.c
index 04c8d356..6a7d2748 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -1258,7 +1258,6 @@ static CacheEntry_t *Cache_process_queue(CacheEntry_t *entry)
/* Trigger cleanup when there are no cache clients */
if (dList_length(ClientQueue) == 0) {
- _MSG(" a_Dicache_cleanup()\n");
a_Dicache_cleanup();
}
diff --git a/src/dicache.c b/src/dicache.c
index b63e9d3b..2704da50 100644
--- a/src/dicache.c
+++ b/src/dicache.c
@@ -182,8 +182,8 @@ static void Dicache_remove(const DilloUrl *Url, int version)
}
if (entry) {
- _MSG("Dicache_remove Decoder=%p DecoderData=%p\n",
- entry->Decoder, entry->DecoderData);
+ _MSG("Dicache_remove Imgbuf=%p Decoder=%p DecoderData=%p\n",
+ entry->v_imgbuf, entry->Decoder, entry->DecoderData);
/* Eliminate this dicache entry */
dFree(entry->cmap);
a_Bitvec_free(entry->BitVec);
@@ -218,9 +218,13 @@ void a_Dicache_unref(const DilloUrl *Url, int version)
_MSG("a_Dicache_unref\n");
if ((entry = a_Dicache_get_entry(Url, version))) {
- if (--entry->RefCount == 0) {
+ _MSG(" a_Dicache_unref: RefCount=%d\n", entry->RefCount);
+ _MSG(" a_Dicache_unref: ImgbufLastRef=%d\n",
+ entry->v_imgbuf ? a_Imgbuf_last_reference(entry->v_imgbuf) : -1);
+ if (entry->RefCount > 0) --entry->RefCount;
+ if (entry->v_imgbuf == NULL ||
+ (entry->RefCount == 0 && a_Imgbuf_last_reference(entry->v_imgbuf)))
Dicache_remove(Url, version);
- }
}
}
@@ -370,6 +374,9 @@ void a_Dicache_close(DilloUrl *url, int version, CacheClient_t *Client)
/* a_Dicache_unref() may free DicEntry */
_MSG("a_Dicache_close RefCount=%d\n", DicEntry->RefCount - 1);
+ _MSG("a_Dicache_close DIC_Close=%d State=%d\n", DIC_Close, DicEntry->State);
+ _MSG(" a_Dicache_close imgbuf=%p Decoder=%p DecoderData=%p\n",
+ DicEntry->v_imgbuf, DicEntry->Decoder, DicEntry->DecoderData);
if (DicEntry->State < DIC_Close) {
DicEntry->State = DIC_Close;
@@ -412,24 +419,27 @@ static void *Dicache_image(int ImgType, const char *MimeType, void *Ptr,
DicEntry = a_Dicache_get_entry(web->url, DIC_Last);
if (!DicEntry) {
- /* Let's create an entry for this image... */
+ /* Create an entry for this image... */
DicEntry = Dicache_add_entry(web->url);
- DicEntry->DecoderData =
- (ImgType == DIC_Png) ?
- a_Png_new(web->Image, DicEntry->url, DicEntry->version) :
- (ImgType == DIC_Gif) ?
- a_Gif_new(web->Image, DicEntry->url, DicEntry->version) :
- (ImgType == DIC_Jpeg) ?
- a_Jpeg_new(web->Image, DicEntry->url, DicEntry->version) :
- NULL;
+ /* Attach a decoder */
+ if (ImgType == DIC_Jpeg) {
+ DicEntry->Decoder = (CA_Callback_t)a_Jpeg_callback;
+ DicEntry->DecoderData =
+ a_Jpeg_new(web->Image, DicEntry->url, DicEntry->version);
+ } else if (ImgType == DIC_Gif) {
+ DicEntry->Decoder = (CA_Callback_t)a_Gif_callback;
+ DicEntry->DecoderData =
+ a_Gif_new(web->Image, DicEntry->url, DicEntry->version);
+ } else if (ImgType == DIC_Png) {
+ DicEntry->Decoder = (CA_Callback_t)a_Png_callback;
+ DicEntry->DecoderData =
+ a_Png_new(web->Image, DicEntry->url, DicEntry->version);
+ }
} else {
/* Repeated image */
a_Dicache_ref(DicEntry->url, DicEntry->version);
}
- DicEntry->Decoder = (ImgType == DIC_Png) ? (CA_Callback_t)a_Png_callback :
- (ImgType == DIC_Gif) ? (CA_Callback_t)a_Gif_callback :
- (ImgType == DIC_Jpeg) ? (CA_Callback_t)a_Jpeg_callback:
- NULL;
+
*Data = DicEntry->DecoderData;
*Call = (CA_Callback_t) a_Dicache_callback;
@@ -548,6 +558,7 @@ void a_Dicache_cleanup(void)
if (entry->v_imgbuf &&
a_Imgbuf_last_reference(entry->v_imgbuf)) {
/* free this unused entry */
+ _MSG("a_Dicache_cleanup: removing entry...\n");
if (entry->next) {
Dicache_remove(node->url, entry->version);
} else {