diff -uNr flare_v017_1-orig/CMakeLists.txt flare_v017_1/CMakeLists.txt --- flare_v017_1-orig/CMakeLists.txt 2012-11-02 20:10:33.636702907 +0100 +++ flare_v017_1/CMakeLists.txt 2012-11-03 00:04:17.329578572 +0100 @@ -46,6 +46,8 @@ # Detect missing dependencies +SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/) + Find_Package (SDL REQUIRED) If (NOT SDL_FOUND) Message (FATAL_ERROR "Couldn't find SDL development files. On Debian-based systems (such as Ubuntu) you should install the 'libsdl1.2-dev' package.") @@ -74,6 +76,13 @@ Include_Directories (${SDLTTF_INCLUDE_DIR}) EndIf (NOT SDLTTF_FOUND) +Find_Package (SDL_gfx REQUIRED) +If (NOT SDLGFX_FOUND) + Message (FATAL_ERROR "Couldn't find SDL-gfx development files.") +Else (NOT SDLGFX_FOUND) + Include_Directories (${SDL_gfx_INCLUDE_DIR}) +EndIf (NOT SDLGFX_FOUND) + # Sources @@ -134,7 +143,6 @@ ./src/PowerManager.cpp ./src/QuestLog.cpp ./src/SaveLoad.cpp - ./src/SDL_gfxBlitFunc.c ./src/Settings.cpp ./src/SharedResources.cpp ./src/StatBlock.cpp @@ -171,7 +179,7 @@ Set (SDLMAIN_LIBRARY "") EndIf (NOT SDLMAIN_LIBRARY) -Target_Link_Libraries (flare ${CMAKE_LD_FLAGS} ${SDL_LIBRARY} ${SDLMIXER_LIBRARY} ${SDLIMAGE_LIBRARY} ${SDLTTF_LIBRARY} ${SDLMAIN_LIBRARY}) +Target_Link_Libraries (flare ${CMAKE_LD_FLAGS} ${SDL_LIBRARY} ${SDLMIXER_LIBRARY} ${SDLIMAGE_LIBRARY} ${SDLTTF_LIBRARY} ${SDLMAIN_LIBRARY} ${SDLGFX_LIBRARIES}) # desktop file diff -uNr flare_v017_1-orig/FindSDL_gfx.cmake flare_v017_1/FindSDL_gfx.cmake --- flare_v017_1-orig/FindSDL_gfx.cmake 1970-01-01 01:00:00.000000000 +0100 +++ flare_v017_1/FindSDL_gfx.cmake 2012-11-02 20:28:06.573308667 +0100 @@ -0,0 +1,40 @@ +# - Try to find SDL_gfx +# Once done this will define +# +# SDLGFX_FOUND - system has SDL_gfx +# SDLGFX_INCLUDE_DIR - the SDL_gfx include directory + +# Be quiet if SDL_gfx was already found +IF (SDL_gfx_INCLUDE_DIR AND SDL_gfx_LIBRARY) + SET(SDL_gfx_QUIET TRUE) +ENDIF (SDL_gfx_INCLUDE_DIR AND SDL_gfx_LIBRARY) + + +FIND_PATH(SDL_gfx_INCLUDE_DIR + NAMES SDL_rotozoom.h + PATH_SUFFIXES SDL + ) + +FIND_LIBRARY(SDL_gfx_LIBRARY + NAMES SDL_gfx + PATHS /usr/lib /usr/local/lib + ) + +MARK_AS_ADVANCED(SDL_gfx_INCLUDE_DIR SDL_gfx_LIBRARY) + + +IF (SDL_gfx_INCLUDE_DIR AND SDL_gfx_LIBRARY) + SET(SDLGFX_FOUND TRUE) + SET(SDLGFX_INCLUDE_DIR ${SDL_gfx_INCLUDE_DIR}) + SET(SDLGFX_LIBRARIES ${SDL_gfx_LIBRARY}) + + IF (NOT SDL_gfx_FIND_QUIETLY AND NOT SDL_gfx_QUIET) + MESSAGE(STATUS "Found SDL_gfx: ${SDL_gfx_LIBRARY}") + MESSAGE(STATUS "Include dir: ${SDL_gfx_INCLUDE_DIR}") + ENDIF (NOT SDL_gfx_FIND_QUIETLY AND NOT SDL_gfx_QUIET) +ENDIF (SDL_gfx_INCLUDE_DIR AND SDL_gfx_LIBRARY) + +# Bail out if SDL_gfx is not found but required +IF (NOT SDLGFX_FOUND AND SDL_gfx_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "Could NOT find SDL_gfx library ${SDLGFX_INCLUDE_DIR}") +ENDIF (NOT SDLGFX_FOUND AND SDL_gfx_FIND_REQUIRED) Binary files flare_v017_1-orig/flare and flare_v017_1/flare differ diff -uNr flare_v017_1-orig/src/Avatar.cpp flare_v017_1/src/Avatar.cpp --- flare_v017_1-orig/src/Avatar.cpp 2012-11-02 20:10:33.719701265 +0100 +++ flare_v017_1/src/Avatar.cpp 2012-11-02 20:37:09.365693439 +0100 @@ -23,7 +23,7 @@ */ -#include "SDL_gfxBlitFunc.h" +#include <SDL_gfxBlitFunc.h> #include "Animation.h" #include "AnimationManager.h" #include "AnimationSet.h" diff -uNr flare_v017_1-orig/src/FontEngine.cpp flare_v017_1/src/FontEngine.cpp --- flare_v017_1-orig/src/FontEngine.cpp 2012-11-02 20:10:33.676702111 +0100 +++ flare_v017_1/src/FontEngine.cpp 2012-11-02 20:37:09.301694737 +0100 @@ -19,7 +19,7 @@ * class FontEngine */ -#include "SDL_gfxBlitFunc.h" +#include <SDL_gfxBlitFunc.h> #include "FontEngine.h" #include "FileParser.h" #include "SharedResources.h" diff -uNr flare_v017_1-orig/src/GameStateLoad.cpp flare_v017_1/src/GameStateLoad.cpp --- flare_v017_1-orig/src/GameStateLoad.cpp 2012-11-02 20:10:33.689701855 +0100 +++ flare_v017_1/src/GameStateLoad.cpp 2012-11-02 20:37:09.320694352 +0100 @@ -19,7 +19,7 @@ * GameStateLoad */ -#include "SDL_gfxBlitFunc.h" +#include <SDL_gfxBlitFunc.h> #include "FileParser.h" #include "GameStateLoad.h" #include "GameStateTitle.h" diff -uNr flare_v017_1-orig/src/SDL_gfxBlitFunc.c flare_v017_1/src/SDL_gfxBlitFunc.c --- flare_v017_1-orig/src/SDL_gfxBlitFunc.c 2012-11-02 20:10:33.706701521 +0100 +++ flare_v017_1/src/SDL_gfxBlitFunc.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,639 +0,0 @@ -/* - -SDL_gfxBlitFunc.c: custom blitters - -Copyright (C) 2001-2011 Andreas Schiffler - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. - -Andreas Schiffler -- aschiffler at ferzkopp dot net - -*/ - -#include "SDL_gfxBlitFunc.h" - -/*! -\brief Alpha adjustment table for custom blitter. - -The table provides values for a modified, non-linear -transfer function which maintain brightness. - -*/ -static unsigned int GFX_ALPHA_ADJUST_ARRAY[256] = { - 0, /* 0 */ - 15, /* 1 */ - 22, /* 2 */ - 27, /* 3 */ - 31, /* 4 */ - 35, /* 5 */ - 39, /* 6 */ - 42, /* 7 */ - 45, /* 8 */ - 47, /* 9 */ - 50, /* 10 */ - 52, /* 11 */ - 55, /* 12 */ - 57, /* 13 */ - 59, /* 14 */ - 61, /* 15 */ - 63, /* 16 */ - 65, /* 17 */ - 67, /* 18 */ - 69, /* 19 */ - 71, /* 20 */ - 73, /* 21 */ - 74, /* 22 */ - 76, /* 23 */ - 78, /* 24 */ - 79, /* 25 */ - 81, /* 26 */ - 82, /* 27 */ - 84, /* 28 */ - 85, /* 29 */ - 87, /* 30 */ - 88, /* 31 */ - 90, /* 32 */ - 91, /* 33 */ - 93, /* 34 */ - 94, /* 35 */ - 95, /* 36 */ - 97, /* 37 */ - 98, /* 38 */ - 99, /* 39 */ - 100, /* 40 */ - 102, /* 41 */ - 103, /* 42 */ - 104, /* 43 */ - 105, /* 44 */ - 107, /* 45 */ - 108, /* 46 */ - 109, /* 47 */ - 110, /* 48 */ - 111, /* 49 */ - 112, /* 50 */ - 114, /* 51 */ - 115, /* 52 */ - 116, /* 53 */ - 117, /* 54 */ - 118, /* 55 */ - 119, /* 56 */ - 120, /* 57 */ - 121, /* 58 */ - 122, /* 59 */ - 123, /* 60 */ - 124, /* 61 */ - 125, /* 62 */ - 126, /* 63 */ - 127, /* 64 */ - 128, /* 65 */ - 129, /* 66 */ - 130, /* 67 */ - 131, /* 68 */ - 132, /* 69 */ - 133, /* 70 */ - 134, /* 71 */ - 135, /* 72 */ - 136, /* 73 */ - 137, /* 74 */ - 138, /* 75 */ - 139, /* 76 */ - 140, /* 77 */ - 141, /* 78 */ - 141, /* 79 */ - 142, /* 80 */ - 143, /* 81 */ - 144, /* 82 */ - 145, /* 83 */ - 146, /* 84 */ - 147, /* 85 */ - 148, /* 86 */ - 148, /* 87 */ - 149, /* 88 */ - 150, /* 89 */ - 151, /* 90 */ - 152, /* 91 */ - 153, /* 92 */ - 153, /* 93 */ - 154, /* 94 */ - 155, /* 95 */ - 156, /* 96 */ - 157, /* 97 */ - 158, /* 98 */ - 158, /* 99 */ - 159, /* 100 */ - 160, /* 101 */ - 161, /* 102 */ - 162, /* 103 */ - 162, /* 104 */ - 163, /* 105 */ - 164, /* 106 */ - 165, /* 107 */ - 165, /* 108 */ - 166, /* 109 */ - 167, /* 110 */ - 168, /* 111 */ - 168, /* 112 */ - 169, /* 113 */ - 170, /* 114 */ - 171, /* 115 */ - 171, /* 116 */ - 172, /* 117 */ - 173, /* 118 */ - 174, /* 119 */ - 174, /* 120 */ - 175, /* 121 */ - 176, /* 122 */ - 177, /* 123 */ - 177, /* 124 */ - 178, /* 125 */ - 179, /* 126 */ - 179, /* 127 */ - 180, /* 128 */ - 181, /* 129 */ - 182, /* 130 */ - 182, /* 131 */ - 183, /* 132 */ - 184, /* 133 */ - 184, /* 134 */ - 185, /* 135 */ - 186, /* 136 */ - 186, /* 137 */ - 187, /* 138 */ - 188, /* 139 */ - 188, /* 140 */ - 189, /* 141 */ - 190, /* 142 */ - 190, /* 143 */ - 191, /* 144 */ - 192, /* 145 */ - 192, /* 146 */ - 193, /* 147 */ - 194, /* 148 */ - 194, /* 149 */ - 195, /* 150 */ - 196, /* 151 */ - 196, /* 152 */ - 197, /* 153 */ - 198, /* 154 */ - 198, /* 155 */ - 199, /* 156 */ - 200, /* 157 */ - 200, /* 158 */ - 201, /* 159 */ - 201, /* 160 */ - 202, /* 161 */ - 203, /* 162 */ - 203, /* 163 */ - 204, /* 164 */ - 205, /* 165 */ - 205, /* 166 */ - 206, /* 167 */ - 206, /* 168 */ - 207, /* 169 */ - 208, /* 170 */ - 208, /* 171 */ - 209, /* 172 */ - 210, /* 173 */ - 210, /* 174 */ - 211, /* 175 */ - 211, /* 176 */ - 212, /* 177 */ - 213, /* 178 */ - 213, /* 179 */ - 214, /* 180 */ - 214, /* 181 */ - 215, /* 182 */ - 216, /* 183 */ - 216, /* 184 */ - 217, /* 185 */ - 217, /* 186 */ - 218, /* 187 */ - 218, /* 188 */ - 219, /* 189 */ - 220, /* 190 */ - 220, /* 191 */ - 221, /* 192 */ - 221, /* 193 */ - 222, /* 194 */ - 222, /* 195 */ - 223, /* 196 */ - 224, /* 197 */ - 224, /* 198 */ - 225, /* 199 */ - 225, /* 200 */ - 226, /* 201 */ - 226, /* 202 */ - 227, /* 203 */ - 228, /* 204 */ - 228, /* 205 */ - 229, /* 206 */ - 229, /* 207 */ - 230, /* 208 */ - 230, /* 209 */ - 231, /* 210 */ - 231, /* 211 */ - 232, /* 212 */ - 233, /* 213 */ - 233, /* 214 */ - 234, /* 215 */ - 234, /* 216 */ - 235, /* 217 */ - 235, /* 218 */ - 236, /* 219 */ - 236, /* 220 */ - 237, /* 221 */ - 237, /* 222 */ - 238, /* 223 */ - 238, /* 224 */ - 239, /* 225 */ - 240, /* 226 */ - 240, /* 227 */ - 241, /* 228 */ - 241, /* 229 */ - 242, /* 230 */ - 242, /* 231 */ - 243, /* 232 */ - 243, /* 233 */ - 244, /* 234 */ - 244, /* 235 */ - 245, /* 236 */ - 245, /* 237 */ - 246, /* 238 */ - 246, /* 239 */ - 247, /* 240 */ - 247, /* 241 */ - 248, /* 242 */ - 248, /* 243 */ - 249, /* 244 */ - 249, /* 245 */ - 250, /* 246 */ - 250, /* 247 */ - 251, /* 248 */ - 251, /* 249 */ - 252, /* 250 */ - 252, /* 251 */ - 253, /* 252 */ - 253, /* 253 */ - 254, /* 254 */ - 255 /* 255 */ -}; - -/*! -\brief Internal blitter using adjusted destination alpha during RGBA->RGBA blits. - -Performs the blit based on the 'info' structure and applies the transfer function -to the destination 'a' values. - -\param info The blit info to use. -*/ -void _SDL_gfxBlitBlitterRGBA(SDL_gfxBlitInfo * info) -{ - int width = info->d_width; - int height = info->d_height; - Uint8 *src = info->s_pixels; - int srcskip = info->s_skip; - Uint8 *dst = info->d_pixels; - int dstskip = info->d_skip; - SDL_PixelFormat *srcfmt = info->src; - SDL_PixelFormat *dstfmt = info->dst; - Uint8 srcbpp = srcfmt->BytesPerPixel; - Uint8 dstbpp = dstfmt->BytesPerPixel; - - while (height--) { - GFX_DUFFS_LOOP4( { - Uint32 pixel; - unsigned sR; - unsigned sG; - unsigned sB; - unsigned sA; - unsigned dR; - unsigned dG; - unsigned dB; - unsigned dA; - unsigned sAA; - GFX_DISASSEMBLE_RGBA(src, srcbpp, srcfmt, pixel, sR, sG, sB, sA); - GFX_DISASSEMBLE_RGBA(dst, dstbpp, dstfmt, pixel, dR, dG, dB, dA); - sAA=GFX_ALPHA_ADJUST_ARRAY[sA & 255]; - GFX_ALPHA_BLEND(sR, sG, sB, sAA, dR, dG, dB); - dA |= sAA; - GFX_ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA); - src += srcbpp; dst += dstbpp; - }, width); - src += srcskip; - dst += dstskip; - } -} - -/*! -\brief Internal blitter setup wrapper for RGBA->RGBA blits. - -Sets up the blitter info based on the 'src' and 'dst' surfaces and rectangles. - -\param src The source surface. -\param srcrect The source rectangle. -\param dst The destination surface. -\param dstrect The destination rectangle. - -\returns Returns 1 if blit was performed, 0 otherwise. -*/ -int _SDL_gfxBlitRGBACall(SDL_Surface * src, SDL_Rect * srcrect, SDL_Surface * dst, SDL_Rect * dstrect) -{ - /* - * Set up source and destination buffer pointers, then blit - */ - if (srcrect->w && srcrect->h) { - SDL_gfxBlitInfo info; - - /* - * Set up the blit information - */ -#if (SDL_MINOR_VERSION == 3) - info.s_pixels = (Uint8 *) src->pixels + (Uint16) srcrect->y * src->pitch + (Uint16) srcrect->x * src->format->BytesPerPixel; -#else - info.s_pixels = (Uint8 *) src->pixels + src->offset + (Uint16) srcrect->y * src->pitch + (Uint16) srcrect->x * src->format->BytesPerPixel; -#endif - info.s_width = srcrect->w; - info.s_height = srcrect->h; - info.s_skip = (int)(src->pitch - info.s_width * src->format->BytesPerPixel); -#if (SDL_MINOR_VERSION == 3) - info.d_pixels = (Uint8 *) dst->pixels + (Uint16) dstrect->y * dst->pitch + (Uint16) dstrect->x * dst->format->BytesPerPixel; -#else - info.d_pixels = (Uint8 *) dst->pixels + dst->offset + (Uint16) dstrect->y * dst->pitch + (Uint16) dstrect->x * dst->format->BytesPerPixel; -#endif - info.d_width = dstrect->w; - info.d_height = dstrect->h; - info.d_skip = (int)(dst->pitch - info.d_width * dst->format->BytesPerPixel); - info.aux_data = NULL; - info.src = src->format; - info.table = NULL; - info.dst = dst->format; - - /* - * Run the actual software blitter - */ - _SDL_gfxBlitBlitterRGBA(&info); - return 1; - } - - return (0); -} - -/*! -\brief Blitter for RGBA->RGBA blits with alpha adjustment. - -Verifies the input 'src' and 'dst' surfaces and rectangles and performs blit. -The destination clip rectangle is honored. - -\param src The source surface. -\param srcrect The source rectangle. -\param dst The destination surface. -\param dstrect The destination rectangle. - -\returns Returns 1 if blit was performed, 0 otherwise, or -1 if an error occured. -*/ -int SDL_gfxBlitRGBA(SDL_Surface * src, SDL_Rect * srcrect, SDL_Surface * dst, SDL_Rect * dstrect) -{ - SDL_Rect sr, dr; - int srcx, srcy, w, h; - - /* - * Make sure the surfaces aren't locked - */ - if (!src || !dst) { - SDL_SetError("SDL_UpperBlit: passed a NULL surface"); - return (-1); - } - if ((src->locked) || (dst->locked)) { - SDL_SetError("Surfaces must not be locked during blit"); - return (-1); - } - - /* - * If the destination rectangle is NULL, use the entire dest surface - */ - if (dstrect == NULL) { - dr.x = dr.y = 0; - dr.w = dst->w; - dr.h = dst->h; - } else { - dr = *dstrect; - } - - /* - * Clip the source rectangle to the source surface - */ - if (srcrect) { - int maxw, maxh; - - srcx = srcrect->x; - w = srcrect->w; - if (srcx < 0) { - w += srcx; - dr.x -= srcx; - srcx = 0; - } - maxw = src->w - srcx; - if (maxw < w) - w = maxw; - - srcy = srcrect->y; - h = srcrect->h; - if (srcy < 0) { - h += srcy; - dr.y -= srcy; - srcy = 0; - } - maxh = src->h - srcy; - if (maxh < h) - h = maxh; - - } else { - srcx = srcy = 0; - w = src->w; - h = src->h; - } - - /* - * Clip the destination rectangle against the clip rectangle - */ - { - SDL_Rect *clip = &dst->clip_rect; - int dx, dy; - - dx = clip->x - dr.x; - if (dx > 0) { - w -= dx; - dr.x += dx; - srcx += dx; - } - dx = dr.x + w - clip->x - clip->w; - if (dx > 0) - w -= dx; - - dy = clip->y - dr.y; - if (dy > 0) { - h -= dy; - dr.y += dy; - srcy += dy; - } - dy = dr.y + h - clip->y - clip->h; - if (dy > 0) - h -= dy; - } - - if (w > 0 && h > 0) { - sr.x = srcx; - sr.y = srcy; - sr.w = dr.w = w; - sr.h = dr.h = h; - return (_SDL_gfxBlitRGBACall(src, &sr, dst, &dr)); - } - - return 0; -} - -/*! -\brief Sets the alpha channel in a 32 bit surface. - -Helper function that sets the alpha channel in a 32 bit surface -to a constant value. -Only 32 bit surfaces can be used with this function. - -\param src Pointer to the target surface to change. -\param a The alpha value to set. - -\return Returns 1 if alpha was changed, -1 otherwise. -*/ -int SDL_gfxSetAlpha(SDL_Surface *src, Uint8 a) -{ -#if SDL_BYTEORDER == SDL_BIG_ENDIAN - const int alpha_offset = 0; -#else - const int alpha_offset = 3; -#endif - int i, j, row_skip; - Uint8 *pixels; - - /* Check if we have a 32bit surface */ - if ( (src==NULL) || - (src->format==NULL) || - (src->format->BytesPerPixel!=4) ) { - SDL_SetError("SDL_gfxSetAlpha: Invalid input surface."); - return -1; - } - - /* - * Lock the surface - */ - if (SDL_MUSTLOCK(src)) { - if (SDL_LockSurface(src) < 0) { - return (-1); - } - } - - /* Process */ - pixels = (Uint8 *)src->pixels; - row_skip = (src->pitch - (4*src->w)); - pixels += alpha_offset; - for ( i=0; i<src->h; i++ ) { - for ( j=0; j<src->w; j++ ) { - *pixels = a; - pixels += 4; - } - pixels += row_skip; - } - - /* - * Unlock surface - */ - if (SDL_MUSTLOCK(src)) { - SDL_UnlockSurface(src); - } - - return 1; -} - -/*! -\brief Multiply the alpha channel in a 32bit surface. - -Helper function that multiplies the alpha channel in a 32 bit surface -with a constant value. The final alpha is always scaled to the range -0-255 (i.e. the factor is a/256). - -Only 32 bit surfaces can be used with this function. - -\param src Pointer to the target surface to change. -\param a The alpha value to multiply with. When a is 255, this function is a NoOp. - -\return Returns 1 if alpha was changed, 0 otherwise. Returns -1 if input surface is invalid. -*/ -int SDL_gfxMultiplyAlpha(SDL_Surface *src, Uint8 a) -{ -#if SDL_BYTEORDER == SDL_BIG_ENDIAN - const int alpha_offset = 0; -#else - const int alpha_offset = 3; -#endif - int i, j, row_skip; - Uint8 *pixels; - - /* Check if we have a 32bit surface */ - if ( (src==NULL) || - (src->format==NULL) || - (src->format->BytesPerPixel!=4) ) { - SDL_SetError("SDL_gfxMultiplyAlpha: Invalid input surface."); - return -1; - } - - /* Check if multiplication is needed */ - if (a==255) { - return 0; - } - - /* - * Lock the surface - */ - if (SDL_MUSTLOCK(src)) { - if (SDL_LockSurface(src) < 0) { - return (-1); - } - } - - /* Process */ - pixels = (Uint8 *)src->pixels; - row_skip = (src->pitch - (4*src->w)); - pixels += alpha_offset; - for ( i=0; i<src->h; i++ ) { - for ( j=0; j<src->w; j++ ) { - *pixels = (Uint8)(((int)(*pixels)*a)>>8); - pixels += 4; - } - pixels += row_skip; - } - - /* - * Unlock surface - */ - if (SDL_MUSTLOCK(src)) { - SDL_UnlockSurface(src); - } - - return 1; -} diff -uNr flare_v017_1-orig/src/SDL_gfxBlitFunc.h flare_v017_1/src/SDL_gfxBlitFunc.h --- flare_v017_1-orig/src/SDL_gfxBlitFunc.h 2012-11-02 20:10:33.701701619 +0100 +++ flare_v017_1/src/SDL_gfxBlitFunc.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,165 +0,0 @@ -/* - -SDL_gfxBlitFunc.h: custom blitters - -Copyright (C) 2001-2011 Andreas Schiffler - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. - -Andreas Schiffler -- aschiffler at ferzkopp dot net - -*/ - -#ifndef _SDL_gfxBlitFunc_h -#define _SDL_gfxBlitFunc_h - -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -#include <stdio.h> -#include <stdlib.h> - -#include <SDL.h> -#include <SDL_video.h> - - /* ---- Function Prototypes */ - -#ifdef _MSC_VER -# if defined(DLL_EXPORT) && !defined(LIBSDL_GFX_DLL_IMPORT) -# define SDL_GFXBLITFUNC_SCOPE __declspec(dllexport) -# else -# ifdef LIBSDL_GFX_DLL_IMPORT -# define SDL_GFXBLITFUNC_SCOPE __declspec(dllimport) -# endif -# endif -#endif -#ifndef SDL_GFXBLITFUNC_SCOPE -# define SDL_GFXBLITFUNC_SCOPE extern -#endif - - - SDL_GFXBLITFUNC_SCOPE int SDL_gfxBlitRGBA(SDL_Surface * src, SDL_Rect * srcrect, SDL_Surface * dst, SDL_Rect * dstrect); - - SDL_GFXBLITFUNC_SCOPE int SDL_gfxSetAlpha(SDL_Surface * src, Uint8 a); - - SDL_GFXBLITFUNC_SCOPE int SDL_gfxMultiplyAlpha(SDL_Surface * src, Uint8 a); - - /* -------- Macros */ - - /* Define SDL macros locally as a substitute for an #include "SDL_blit.h", */ - /* which doesn't work since the include file doesn't get installed. */ - -/*! -\brief The structure passed to the low level blit functions. -*/ - typedef struct { - Uint8 *s_pixels; - int s_width; - int s_height; - int s_skip; - Uint8 *d_pixels; - int d_width; - int d_height; - int d_skip; - void *aux_data; - SDL_PixelFormat *src; - Uint8 *table; - SDL_PixelFormat *dst; - } SDL_gfxBlitInfo; - -/*! -\brief Unwrap RGBA values from a pixel using mask, shift and loss for surface. -*/ -#define GFX_RGBA_FROM_PIXEL(pixel, fmt, r, g, b, a) \ - { \ - r = ((pixel&fmt->Rmask)>>fmt->Rshift)<<fmt->Rloss; \ - g = ((pixel&fmt->Gmask)>>fmt->Gshift)<<fmt->Gloss; \ - b = ((pixel&fmt->Bmask)>>fmt->Bshift)<<fmt->Bloss; \ - a = ((pixel&fmt->Amask)>>fmt->Ashift)<<fmt->Aloss; \ - } - -/*! -\brief Disassemble buffer pointer into a pixel and separate RGBA values. -*/ -#define GFX_DISASSEMBLE_RGBA(buf, bpp, fmt, pixel, r, g, b, a) \ - do { \ - pixel = *((Uint32 *)(buf)); \ - GFX_RGBA_FROM_PIXEL(pixel, fmt, r, g, b, a); \ - pixel &= ~fmt->Amask; \ - } while(0) - -/*! -\brief Wrap a pixel from RGBA values using mask, shift and loss for surface. -*/ -#define GFX_PIXEL_FROM_RGBA(pixel, fmt, r, g, b, a) \ - { \ - pixel = ((r>>fmt->Rloss)<<fmt->Rshift)| \ - ((g>>fmt->Gloss)<<fmt->Gshift)| \ - ((b>>fmt->Bloss)<<fmt->Bshift)| \ - ((a<<fmt->Aloss)<<fmt->Ashift); \ - } - -/*! -\brief Assemble pixel into buffer pointer from separate RGBA values. -*/ -#define GFX_ASSEMBLE_RGBA(buf, bpp, fmt, r, g, b, a) \ - { \ - Uint32 pixel; \ - \ - GFX_PIXEL_FROM_RGBA(pixel, fmt, r, g, b, a); \ - *((Uint32 *)(buf)) = pixel; \ - } - -/*! -\brief Blend the RGB values of two pixels based on a source alpha value. -*/ -#define GFX_ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB) \ - do { \ - dR = (((sR-dR)*(A))/255)+dR; \ - dG = (((sG-dG)*(A))/255)+dG; \ - dB = (((sB-dB)*(A))/255)+dB; \ - } while(0) - -/*! -\brief 4-times unrolled DUFFs loop. - -This is a very useful loop for optimizing blitters. -*/ -#define GFX_DUFFS_LOOP4(pixel_copy_increment, width) \ - { int n = (width+3)/4; \ - switch (width & 3) { \ - case 0: do { pixel_copy_increment; \ - case 3: pixel_copy_increment; \ - case 2: pixel_copy_increment; \ - case 1: pixel_copy_increment; \ - } while ( --n > 0 ); \ - } \ - } - - - - /* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif - -#endif /* _SDL_gfxBlitFunc_h */ diff -uNr flare_v017_1-orig/src/WidgetButton.cpp flare_v017_1/src/WidgetButton.cpp --- flare_v017_1-orig/src/WidgetButton.cpp 2012-11-02 20:10:33.679702053 +0100 +++ flare_v017_1/src/WidgetButton.cpp 2012-11-02 20:37:09.307694615 +0100 @@ -21,7 +21,7 @@ #include "WidgetButton.h" #include "SharedResources.h" -#include "SDL_gfxBlitFunc.h" +#include <SDL_gfxBlitFunc.h> using namespace std; diff -uNr flare_v017_1-orig/src/WidgetCheckBox.cpp flare_v017_1/src/WidgetCheckBox.cpp --- flare_v017_1-orig/src/WidgetCheckBox.cpp 2012-11-02 20:10:33.699701659 +0100 +++ flare_v017_1/src/WidgetCheckBox.cpp 2012-11-02 20:37:09.322694312 +0100 @@ -28,7 +28,7 @@ #include "Widget.h" #include "WidgetCheckBox.h" #include "SharedResources.h" -#include "SDL_gfxBlitFunc.h" +#include <SDL_gfxBlitFunc.h> using namespace std; diff -uNr flare_v017_1-orig/src/WidgetInput.cpp flare_v017_1/src/WidgetInput.cpp --- flare_v017_1-orig/src/WidgetInput.cpp 2012-11-02 20:10:33.676702111 +0100 +++ flare_v017_1/src/WidgetInput.cpp 2012-11-02 20:37:09.300694758 +0100 @@ -18,7 +18,7 @@ #include "WidgetInput.h" #include "SharedResources.h" #include "Settings.h" -#include "SDL_gfxBlitFunc.h" +#include <SDL_gfxBlitFunc.h> using namespace std; diff -uNr flare_v017_1-orig/src/WidgetLabel.cpp flare_v017_1/src/WidgetLabel.cpp --- flare_v017_1-orig/src/WidgetLabel.cpp 2012-11-02 20:10:33.722701205 +0100 +++ flare_v017_1/src/WidgetLabel.cpp 2012-11-02 20:37:09.374693257 +0100 @@ -23,7 +23,7 @@ #include "WidgetLabel.h" #include "SharedResources.h" -#include "SDL_gfxBlitFunc.h" +#include <SDL_gfxBlitFunc.h> #include "UtilsParsing.h" using namespace std; diff -uNr flare_v017_1-orig/src/WidgetListBox.cpp flare_v017_1/src/WidgetListBox.cpp --- flare_v017_1-orig/src/WidgetListBox.cpp 2012-11-02 20:10:33.679702053 +0100 +++ flare_v017_1/src/WidgetListBox.cpp 2012-11-02 20:37:09.309694576 +0100 @@ -22,7 +22,7 @@ #include "WidgetListBox.h" #include "SharedResources.h" -#include "SDL_gfxBlitFunc.h" +#include <SDL_gfxBlitFunc.h> using namespace std; diff -uNr flare_v017_1-orig/src/WidgetScrollBar.cpp flare_v017_1/src/WidgetScrollBar.cpp --- flare_v017_1-orig/src/WidgetScrollBar.cpp 2012-11-02 20:10:33.703701579 +0100 +++ flare_v017_1/src/WidgetScrollBar.cpp 2012-11-02 20:37:09.327694210 +0100 @@ -22,7 +22,7 @@ #include "WidgetScrollBar.h" #include "SharedResources.h" -#include "SDL_gfxBlitFunc.h" +#include <SDL_gfxBlitFunc.h> using namespace std; diff -uNr flare_v017_1-orig/src/WidgetScrollBox.cpp flare_v017_1/src/WidgetScrollBox.cpp --- flare_v017_1-orig/src/WidgetScrollBox.cpp 2012-11-02 20:10:33.726701127 +0100 +++ flare_v017_1/src/WidgetScrollBox.cpp 2012-11-02 20:37:09.385693034 +0100 @@ -21,7 +21,7 @@ */ #include "WidgetScrollBox.h" -#include "SDL_gfxBlitFunc.h" +#include <SDL_gfxBlitFunc.h> using namespace std; diff -uNr flare_v017_1-orig/src/WidgetSlider.cpp flare_v017_1/src/WidgetSlider.cpp --- flare_v017_1-orig/src/WidgetSlider.cpp 2012-11-02 20:10:33.722701205 +0100 +++ flare_v017_1/src/WidgetSlider.cpp 2012-11-02 20:37:09.374693257 +0100 @@ -29,7 +29,7 @@ #include "WidgetSlider.h" #include "SharedResources.h" #include "UtilsDebug.h" -#include "SDL_gfxBlitFunc.h" +#include <SDL_gfxBlitFunc.h> using namespace std;