diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2006-03-16 00:31:12 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2006-03-16 00:31:12 (GMT) |
commit | 035d55b64a22b761ad0d0cfb21b90c84497044ec (patch) | |
tree | 70bd3edfd02fab7739f7c69b3d81f8636fa3924c | |
parent | f7505e1446686d15cfed313b1d20f9cd0408b5a2 (diff) | |
download | tk-035d55b64a22b761ad0d0cfb21b90c84497044ec.zip tk-035d55b64a22b761ad0d0cfb21b90c84497044ec.tar.gz tk-035d55b64a22b761ad0d0cfb21b90c84497044ec.tar.bz2 |
Hack to make photo-to-photo copies cheaper in the common case of no alpha
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | generic/tkImgPhoto.c | 29 |
2 files changed, 33 insertions, 4 deletions
@@ -1,3 +1,11 @@ +2006-03-16 Donal K. Fellows <dkf@users.sf.net> + + * generic/tkImgPhoto.c (ImgPhotoCmd, Tk_PhotoPutBlock) + (Tk_PhotoPutZoomedBlock): Added hack to detect copying of a photo with + a simple alpha channel and skip calling ToggleComplexAlphaIfNeeded. + This should speed up many photo-to-photo copies, keeping the cost of + the alpha channel down. + 2006-03-15 Donal K. Fellows <dkf@users.sf.net> * generic/tkImgPhoto.c (Tk_PhotoPutBlock, Tk_PhotoPutZoomedBlock): Try diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c index 62c2192..83f5237 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.61 2006/03/15 23:20:27 dkf Exp $ + * RCS: @(#) $Id: tkImgPhoto.c,v 1.62 2006/03/16 00:31:13 dkf Exp $ */ #include "tkInt.h" @@ -186,6 +186,13 @@ typedef struct PhotoMaster { #define COMPLEX_ALPHA 4 /* + * Flag to OR with the compositing rule to indicate that the source, despite + * having an alpha channel, has simple alpha. + */ + +#define SOURCE_IS_SIMPLE_ALPHA_PHOTO 0x10000000 + +/* * The following data structure represents all of the instances of a photo * image in windows on a given screen that are using the same colormap. */ @@ -822,6 +829,15 @@ ImgPhotoCmd( } /* + * Hack to pass through the message that the place we're coming from + * has a simple alpha channel. + */ + + if (!(((PhotoMaster *) srcHandle)->flags & COMPLEX_ALPHA)) { + options.compositingRule |= SOURCE_IS_SIMPLE_ALPHA_PHOTO; + } + + /* * Fill in default values for unspecified parameters. */ @@ -4341,9 +4357,11 @@ Tk_PhotoPutBlock( unsigned char *srcPtr, *srcLinePtr; unsigned char *destPtr, *destLinePtr; int pitch; + int sourceIsSimplePhoto = compRule & SOURCE_IS_SIMPLE_ALPHA_PHOTO; XRectangle rect; masterPtr = (PhotoMaster *) handle; + compRule &= ~SOURCE_IS_SIMPLE_ALPHA_PHOTO; if ((masterPtr->userWidth != 0) && ((x + width) > masterPtr->userWidth)) { width = masterPtr->userWidth - x; @@ -4395,6 +4413,7 @@ Tk_PhotoPutBlock( alphaOffset = blockPtr->offset[3]; if ((alphaOffset >= blockPtr->pixelSize) || (alphaOffset < 0)) { alphaOffset = 0; + sourceIsSimplePhoto = 1; } else { alphaOffset -= blockPtr->offset[0]; } @@ -4600,7 +4619,7 @@ Tk_PhotoPutBlock( * Check if display code needs alpha blending... */ - if (alphaOffset != 0 || masterPtr->flags & COMPLEX_ALPHA) { + if (!sourceIsSimplePhoto || masterPtr->flags & COMPLEX_ALPHA) { /* * 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, @@ -4684,7 +4703,7 @@ Tk_PhotoPutZoomedBlock( unsigned char *destPtr, *destLinePtr; int pitch; int xRepeat, yRepeat; - int blockXSkip, blockYSkip; + int blockXSkip, blockYSkip, sourceIsSimplePhoto; XRectangle rect; if (zoomX==1 && zoomY==1 && subsampleX==1 && subsampleY==1) { @@ -4692,6 +4711,7 @@ Tk_PhotoPutZoomedBlock( compRule); } + sourceIsSimplePhoto = compRule & SOURCE_IS_SIMPLE_ALPHA_PHOTO; masterPtr = (PhotoMaster *) handle; if (zoomX <= 0 || zoomY <= 0) { @@ -4746,6 +4766,7 @@ Tk_PhotoPutZoomedBlock( alphaOffset = blockPtr->offset[3]; if ((alphaOffset >= blockPtr->pixelSize) || (alphaOffset < 0)) { alphaOffset = 0; + sourceIsSimplePhoto = 1; } else { alphaOffset -= blockPtr->offset[0]; } @@ -4895,7 +4916,7 @@ Tk_PhotoPutZoomedBlock( * Check if display code needs alpha blending... */ - if (alphaOffset != 0 || masterPtr->flags & COMPLEX_ALPHA) { + if (!sourceIsSimplePhoto || masterPtr->flags & COMPLEX_ALPHA) { /* * 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, |