diff options
author | dkf <dkf@noemail.net> | 2006-03-15 23:10:53 (GMT) |
---|---|---|
committer | dkf <dkf@noemail.net> | 2006-03-15 23:10:53 (GMT) |
commit | e587982f9041479c4b8868f3905c3593b3542ed8 (patch) | |
tree | 5e21480b07977f248a61bd2005bef42a2b21eaa9 | |
parent | 429a152620648befb700e1d0a0289d3c06c17f8b (diff) | |
download | tk-e587982f9041479c4b8868f3905c3593b3542ed8.zip tk-e587982f9041479c4b8868f3905c3593b3542ed8.tar.gz tk-e587982f9041479c4b8868f3905c3593b3542ed8.tar.bz2 |
Squelch [Bug 1409140] by special-case-ing the single-pixel put case.
FossilOrigin-Name: 373ccb1bd5f2853e041450626761919305bd1d60
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | generic/tkImgPhoto.c | 40 |
2 files changed, 44 insertions, 3 deletions
@@ -1,3 +1,10 @@ +2006-03-15 Donal K. Fellows <donal.k.fellows@man.ac.uk> + + * generic/tkImgPhoto.c (Tk_PhotoPutBlock, Tk_PhotoPutZoomedBlock): Try + to squelch performance issue with code that writes to large images by + single pixels. Masses of thanks to George Staplin for helping to trace + this down to the COMPLEX_ALPHA flag handling code. [Bug 1409140] + 2006-03-13 Don Porter <dgp@users.sourceforge.net> * tests/scrollbar.test: Corrected several broken calls to [testmetrics] diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c index 5758897..e1d83ef 100644 --- a/generic/tkImgPhoto.c +++ b/generic/tkImgPhoto.c @@ -17,7 +17,7 @@ * Department of Computer Science, * Australian National University. * - * RCS: @(#) $Id: tkImgPhoto.c,v 1.36.2.14 2005/08/11 12:17:09 dkf Exp $ + * RCS: @(#) $Id: tkImgPhoto.c,v 1.36.2.15 2006/03/15 23:11:01 dkf Exp $ */ #include "tkInt.h" @@ -4587,7 +4587,24 @@ Tk_PhotoPutBlock(handle, blockPtr, x, y, width, height, compRule) */ if (alphaOffset != 0 || masterPtr->flags & COMPLEX_ALPHA) { - ToggleComplexAlphaIfNeeded(masterPtr); + /* + * Note that we skip in the single pixel case if we can. This speeds + * up code that builds up large simple-alpha images by single pixels, + * which seems to be a common use-case. [Bug 1409140] + */ + + if (width == 1 && height == 1 && !(masterPtr->flags & COMPLEX_ALPHA)) { + unsigned char newAlpha; + + destLinePtr = masterPtr->pix32 + (y * masterPtr->width + x) * 4; + newAlpha = destLinePtr[3]; + + if (newAlpha > 0 && newAlpha < 255) { + masterPtr->flags |= COMPLEX_ALPHA; + } + } else { + ToggleComplexAlphaIfNeeded(masterPtr); + } } /* @@ -4881,7 +4898,24 @@ Tk_PhotoPutZoomedBlock(handle, blockPtr, x, y, width, height, zoomX, zoomY, */ if (alphaOffset != 0 || masterPtr->flags & COMPLEX_ALPHA) { - ToggleComplexAlphaIfNeeded(masterPtr); + /* + * Note that we skip in the single pixel case if we can. This speeds + * up code that builds up large simple-alpha images by single pixels, + * which seems to be a common use-case. [Bug 1409140] + */ + + if (width == 1 && height == 1 && !(masterPtr->flags & COMPLEX_ALPHA)) { + unsigned char newAlpha; + + destLinePtr = masterPtr->pix32 + (y * masterPtr->width + x) * 4; + newAlpha = destLinePtr[3]; + + if (newAlpha > 0 && newAlpha < 255) { + masterPtr->flags |= COMPLEX_ALPHA; + } + } else { + ToggleComplexAlphaIfNeeded(masterPtr); + } } /* |