summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJorge Arellano Cid <jcid@dillo.org>2014-05-14 19:48:33 -0400
committerJorge Arellano Cid <jcid@dillo.org>2014-05-14 19:48:33 -0400
commit4681bc69ac265fae7f6f84cb834ec87ea5bec271 (patch)
treec599fd3b01f640507f58217463c6289011e05efa /src
parentb3e3c51d554c3b5146ea23e7074e29c6c4817823 (diff)
Avoid creation of unnecessary image bufs (at alt-text to img switch)
This is the first of a patch series for image code bugs that have severe impact on performance. With these testing files: 1imgA.html = <img src="maj00s.png" alt="img1"> 2imgSA.html = <img src="maj00s.png" alt="img1"> <img src="maj00s.png" alt="img12"> 3imgSA.html = <img src="maj00s.png" alt="img1"> <img src="maj00s.png" alt="img12"> <img src="maj00s.png" alt="img123"> 2imgA.html = <img src="maj00s.png" alt="img1"> <img src="maj21s.png" alt="img12"> 3imgA.html = <img src="maj00s.png" alt="img1"> <img src="maj21s.png" alt="img12"> <img src="c10s.png" alt="img123"> This are the results: .------------------------------------------------------------------. |imgbufs | No patch | Patched #1 | | | first time | upon reload | first time | upon reload | |------------------------------------------------------------------- |1imgA.html | 2 | 1 | 1 | 1 | |2imgSA.html | 3 | 2 | 1 | 2 | |3imgSA.html | 4 | 3 | 1 | 3 | |------------------------------------------------------------------- |2imgA.html | 4 | 2 | 2 | 2 | |3imgA.html | 6 | 3 | 3 | 3 | '------------------------------------------------------------------'
Diffstat (limited to 'src')
-rw-r--r--src/dicache.c6
-rw-r--r--src/html.cc4
-rw-r--r--src/image.cc6
3 files changed, 10 insertions, 6 deletions
diff --git a/src/dicache.c b/src/dicache.c
index db3b86b2..b63e9d3b 100644
--- a/src/dicache.c
+++ b/src/dicache.c
@@ -256,7 +256,9 @@ void a_Dicache_invalidate_entry(const DilloUrl *Url)
/*
* Set image's width, height & type
- * (By now, we'll use the image information despite the html tags --Jcid)
+ * - 'width' and 'height' come from the image data.
+ * - HTML width and height attrs are handled with setNonCssHint.
+ * - CSS sizing is handled by the CSS engine.
*/
void a_Dicache_set_parms(DilloUrl *url, int version, DilloImage *Image,
uint_t width, uint_t height, DilloImgType type,
@@ -269,7 +271,7 @@ void a_Dicache_set_parms(DilloUrl *url, int version, DilloImage *Image,
/* Find the DicEntry for this Image */
DicEntry = a_Dicache_get_entry(url, version);
dReturn_if_fail ( DicEntry != NULL );
- /* Parameters already set? */
+ /* Parameters already set? Don't do it twice. */
dReturn_if_fail ( DicEntry->State < DIC_SetParms );
_MSG(" RefCount=%d version=%d\n", DicEntry->RefCount, DicEntry->version);
diff --git a/src/html.cc b/src/html.cc
index c4033ca6..f465f888 100644
--- a/src/html.cc
+++ b/src/html.cc
@@ -1800,8 +1800,8 @@ static void Html_tag_open_style(DilloHtml *html, const char *tag, int tagsize)
static void Html_tag_close_style(DilloHtml *html)
{
if (prefs.parse_embedded_css && html->loadCssFromStash)
- html->styleEngine->parse(html, html->base_url, html->Stash->str, html->Stash->len,
- CSS_ORIGIN_AUTHOR);
+ html->styleEngine->parse(html, html->base_url, html->Stash->str,
+ html->Stash->len, CSS_ORIGIN_AUTHOR);
}
/*
diff --git a/src/image.cc b/src/image.cc
index 9915023a..97270eef 100644
--- a/src/image.cc
+++ b/src/image.cc
@@ -106,9 +106,11 @@ void a_Image_set_parms(DilloImage *Image, void *v_imgbuf, DilloUrl *url,
int version, uint_t width, uint_t height,
DilloImgType type)
{
- _MSG("a_Image_set_parms: width=%d height=%d\n", width, height);
+ _MSG("a_Image_set_parms: width=%d height=%d iw=%d ih=%d\n",
+ width, height, Image->width, Image->height);
- bool resize = (Image->width != width || Image->height != height);
+ /* Resize from 0,0 to width,height */
+ bool resize = true;
I2IR(Image)->setBuffer((Imgbuf*)v_imgbuf, resize);
if (!Image->BitVec)