From 059d9b3783a9875a43aa4429b2d719f43d527e4f Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sun, 5 Sep 2004 03:30:14 +0000 Subject: [PATCH] short circuit FindSurfaceTraits for RGB --- stepmania/src/RageSurfaceUtils.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/stepmania/src/RageSurfaceUtils.cpp b/stepmania/src/RageSurfaceUtils.cpp index bfe0d7dec7..2f46964db3 100644 --- a/stepmania/src/RageSurfaceUtils.cpp +++ b/stepmania/src/RageSurfaceUtils.cpp @@ -314,9 +314,28 @@ int RageSurfaceUtils::FindSurfaceTraits( const RageSurface *img ) uint32_t max_alpha; if( img->format->BitsPerPixel == 8 ) + { + /* Short circuit if we already know we have no transparency. */ + bool bHaveNonOpaque = false; + for( int c = 0; !bHaveNonOpaque && c < img->format->palette->ncolors; ++c ) + { + if( img->format->palette->colors[c].a != 256 ) + bHaveNonOpaque = true; + } + + if( !bHaveNonOpaque ) + return TRAIT_NO_TRANSPARENCY; + max_alpha = 0xFF; + } else + { + /* Short circuit if we already know we have no transparency. */ + if( img->format->Amask == 0 ) + return TRAIT_NO_TRANSPARENCY; + max_alpha = img->format->Amask; + } for(int y = 0; y < img->h; ++y) {