summaryrefslogtreecommitdiffstats
path: root/generic/tkImgPhoto.c
diff options
context:
space:
mode:
authorhobbs <hobbs>2006-05-13 00:47:20 (GMT)
committerhobbs <hobbs>2006-05-13 00:47:20 (GMT)
commit6381822f9e07b55c6e33a69617b3ce3d6ab526fa (patch)
treed5a85a99777ebb2a5cfa042073e009f853402e9a /generic/tkImgPhoto.c
parent163564c4e4bce2c7828adec931b3c692bddc930e (diff)
downloadtk-6381822f9e07b55c6e33a69617b3ce3d6ab526fa.zip
tk-6381822f9e07b55c6e33a69617b3ce3d6ab526fa.tar.gz
tk-6381822f9e07b55c6e33a69617b3ce3d6ab526fa.tar.bz2
* generic/tkImgPhoto.c (Tk_PhotoPutBlock, Tk_PhotoPutZoomedBlock):
Fix opt added 2006-03 that caused slowdown for some common cases. [Bug 1409140]
Diffstat (limited to 'generic/tkImgPhoto.c')
-rw-r--r--generic/tkImgPhoto.c48
1 files changed, 29 insertions, 19 deletions
diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c
index 86074b6..d3fc6d9 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.64 2006/03/16 10:04:49 das Exp $
+ * RCS: @(#) $Id: tkImgPhoto.c,v 1.65 2006/05/13 00:47:20 hobbs Exp $
*/
#include "tkInt.h"
@@ -4623,25 +4623,30 @@ Tk_PhotoPutBlock(
* Check if display code needs alpha blending...
*/
- if (!sourceIsSimplePhoto || masterPtr->flags & COMPLEX_ALPHA) {
+ if (!sourceIsSimplePhoto && (width == 1) && (height == 1)) {
/*
- * 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]
+ * Optimize the single pixel case if we can. This speeds up code that
+ * builds up large simple-alpha images by single pixels. We don't
+ * negate COMPLEX_ALPHA in this case. [Bug 1409140]
*/
-
- if (width == 1 && height == 1 && !(masterPtr->flags & COMPLEX_ALPHA)) {
+ if (!(masterPtr->flags & COMPLEX_ALPHA)) {
unsigned char newAlpha;
destLinePtr = masterPtr->pix32 + (y * masterPtr->width + x) * 4;
newAlpha = destLinePtr[3];
- if (newAlpha > 0 && newAlpha < 255) {
+ if (newAlpha && newAlpha != 255) {
masterPtr->flags |= COMPLEX_ALPHA;
}
- } else {
- ToggleComplexAlphaIfNeeded(masterPtr);
}
+ } else if ((alphaOffset != 0) || (masterPtr->flags & COMPLEX_ALPHA)) {
+ /*
+ * Check for partial transparency if alpha pixels are specified, or
+ * rescan if we already knew such pixels existed. To restrict this
+ * Toggle to only checking the changed pixels requires knowing where
+ * the alpha pixels are.
+ */
+ ToggleComplexAlphaIfNeeded(masterPtr);
}
/*
@@ -4921,25 +4926,30 @@ Tk_PhotoPutZoomedBlock(
* Check if display code needs alpha blending...
*/
- if (!sourceIsSimplePhoto || masterPtr->flags & COMPLEX_ALPHA) {
+ if (!sourceIsSimplePhoto && (width == 1) && (height == 1)) {
/*
- * 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]
+ * Optimize the single pixel case if we can. This speeds up code that
+ * builds up large simple-alpha images by single pixels. We don't
+ * negate COMPLEX_ALPHA in this case. [Bug 1409140]
*/
-
- if (width == 1 && height == 1 && !(masterPtr->flags & COMPLEX_ALPHA)) {
+ if (!(masterPtr->flags & COMPLEX_ALPHA)) {
unsigned char newAlpha;
destLinePtr = masterPtr->pix32 + (y * masterPtr->width + x) * 4;
newAlpha = destLinePtr[3];
- if (newAlpha > 0 && newAlpha < 255) {
+ if (newAlpha && newAlpha != 255) {
masterPtr->flags |= COMPLEX_ALPHA;
}
- } else {
- ToggleComplexAlphaIfNeeded(masterPtr);
}
+ } else if ((alphaOffset != 0) || (masterPtr->flags & COMPLEX_ALPHA)) {
+ /*
+ * Check for partial transparency if alpha pixels are specified, or
+ * rescan if we already knew such pixels existed. To restrict this
+ * Toggle to only checking the changed pixels requires knowing where
+ * the alpha pixels are.
+ */
+ ToggleComplexAlphaIfNeeded(masterPtr);
}
/*