aboutsummaryrefslogtreecommitdiff
path: root/dw/image.cc
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 /dw/image.cc
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 'dw/image.cc')
-rw-r--r--dw/image.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/dw/image.cc b/dw/image.cc
index 74f96e57..5df6b93e 100644
--- a/dw/image.cc
+++ b/dw/image.cc
@@ -428,8 +428,10 @@ void Image::setBuffer (core::Imgbuf *buffer, bool resize)
if (resize)
queueResize (0, true);
- if (wasAllocated () && getContentWidth () > 0 && getContentHeight () > 0) {
- // Only scale when both dimensions are known.
+ if (wasAllocated () && needsResize () &&
+ getContentWidth () > 0 && getContentHeight () > 0) {
+ // Don't create a new buffer for the transition from alt text to img,
+ // and only scale when both dimensions are known.
this->buffer =
buffer->getScaledBuf (getContentWidth (), getContentHeight ());
} else {