Fixed MakeSubSurface compiling issue for DirectFB <= 1.2.0
authorCouriersud <couriersud@arcor.de>
Tue, 13 Jan 2009 22:59:02 +0000
changeset 3038c73a5f8a03d2
parent 3037 490f3e4fe753
child 3039 829043b363d1
Fixed MakeSubSurface compiling issue for DirectFB <= 1.2.0
src/video/directfb/SDL_DirectFB_render.c
src/video/directfb/SDL_DirectFB_video.h
src/video/directfb/SDL_DirectFB_window.c
     1.1 --- a/src/video/directfb/SDL_DirectFB_render.c	Tue Jan 13 21:17:38 2009 +0000
     1.2 +++ b/src/video/directfb/SDL_DirectFB_render.c	Tue Jan 13 22:59:02 2009 +0000
     1.3 @@ -86,6 +86,8 @@
     1.4                                      SDL_Texture * texture);
     1.5  static void DirectFB_DestroyRenderer(SDL_Renderer * renderer);
     1.6  
     1.7 +#define SDL_DFB_WINDOWSURFACE(win)  IDirectFBSurface *destsurf = ((DFB_WindowData *) ((win)->driverdata))->surface;
     1.8 +
     1.9  SDL_RenderDriver DirectFB_RenderDriver = {
    1.10      DirectFB_CreateRenderer,
    1.11      {
    1.12 @@ -122,7 +124,7 @@
    1.13  
    1.14  typedef struct
    1.15  {
    1.16 -    IDirectFBSurface *surface;
    1.17 +    SDL_Window *window;
    1.18      DFBSurfaceFlipFlags flipflags;
    1.19      int isyuvdirect;
    1.20      int size_changed;
    1.21 @@ -180,28 +182,30 @@
    1.22  SetBlendMode(DirectFB_RenderData * data, int blendMode,
    1.23               DirectFB_TextureData * source)
    1.24  {
    1.25 -    //FIXME: check for format change
    1.26 +	SDL_DFB_WINDOWSURFACE(data->window);
    1.27 +	
    1.28 +	//FIXME: check for format change
    1.29      if (1 || data->lastBlendMode != blendMode) {
    1.30          switch (blendMode) {
    1.31          case SDL_BLENDMODE_NONE:
    1.32                                             /**< No blending */
    1.33              data->blitFlags = DSBLIT_NOFX;
    1.34              data->drawFlags = DSDRAW_NOFX;
    1.35 -            data->surface->SetSrcBlendFunction(data->surface, DSBF_ONE);
    1.36 -            data->surface->SetDstBlendFunction(data->surface, DSBF_ZERO);
    1.37 +            destsurf->SetSrcBlendFunction(destsurf, DSBF_ONE);
    1.38 +            destsurf->SetDstBlendFunction(destsurf, DSBF_ZERO);
    1.39              break;
    1.40          case SDL_BLENDMODE_MASK:
    1.41              data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL;
    1.42              data->drawFlags = DSDRAW_BLEND;
    1.43 -            data->surface->SetSrcBlendFunction(data->surface, DSBF_SRCALPHA);
    1.44 -            data->surface->SetDstBlendFunction(data->surface,
    1.45 +            destsurf->SetSrcBlendFunction(destsurf, DSBF_SRCALPHA);
    1.46 +            destsurf->SetDstBlendFunction(destsurf,
    1.47                                                 DSBF_INVSRCALPHA);
    1.48              break;
    1.49          case SDL_BLENDMODE_BLEND:
    1.50              data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL;
    1.51              data->drawFlags = DSDRAW_BLEND;
    1.52 -            data->surface->SetSrcBlendFunction(data->surface, DSBF_SRCALPHA);
    1.53 -            data->surface->SetDstBlendFunction(data->surface,
    1.54 +            destsurf->SetSrcBlendFunction(destsurf, DSBF_SRCALPHA);
    1.55 +            destsurf->SetDstBlendFunction(destsurf,
    1.56                                                 DSBF_INVSRCALPHA);
    1.57              break;
    1.58          case SDL_BLENDMODE_ADD:
    1.59 @@ -211,17 +215,17 @@
    1.60              // It will be cheaper to copy the surface to
    1.61              // a temporay surface and premultiply 
    1.62              if (source && TextureHasAlpha(source))
    1.63 -                data->surface->SetSrcBlendFunction(data->surface,
    1.64 +                destsurf->SetSrcBlendFunction(destsurf,
    1.65                                                     DSBF_SRCALPHA);
    1.66              else
    1.67 -                data->surface->SetSrcBlendFunction(data->surface, DSBF_ONE);
    1.68 -            data->surface->SetDstBlendFunction(data->surface, DSBF_ONE);
    1.69 +                destsurf->SetSrcBlendFunction(destsurf, DSBF_ONE);
    1.70 +            destsurf->SetDstBlendFunction(destsurf, DSBF_ONE);
    1.71              break;
    1.72          case SDL_BLENDMODE_MOD:
    1.73              data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL;
    1.74              data->drawFlags = DSDRAW_BLEND;
    1.75 -            data->surface->SetSrcBlendFunction(data->surface, DSBF_DESTCOLOR);
    1.76 -            data->surface->SetDstBlendFunction(data->surface, DSBF_ZERO);
    1.77 +            destsurf->SetSrcBlendFunction(destsurf, DSBF_DESTCOLOR);
    1.78 +            destsurf->SetDstBlendFunction(destsurf, DSBF_ZERO);
    1.79              break;
    1.80          }
    1.81          data->lastBlendMode = blendMode;
    1.82 @@ -241,6 +245,7 @@
    1.83  {
    1.84  #if USE_DISPLAY_PALETTE
    1.85      DirectFB_RenderData *data = (DirectFB_RenderData *) userdata;
    1.86 +    SDL_DFB_WINDOWSURFACE(data->window);
    1.87      IDirectFBPalette *surfpal;
    1.88  
    1.89      int ret;
    1.90 @@ -248,7 +253,7 @@
    1.91      int ncolors;
    1.92      DFBColor entries[256];
    1.93  
    1.94 -    SDL_DFB_CHECKERR(data->surface->GetPalette(data->surface, &surfpal));
    1.95 +    SDL_DFB_CHECKERR(destsurf->GetPalette(destsurf, &surfpal));
    1.96  
    1.97      /* FIXME: number of colors */
    1.98      ncolors = (palette->ncolors < 256 ? palette->ncolors : 256);
    1.99 @@ -309,8 +314,7 @@
   1.100      renderer->info.flags =
   1.101          SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTDISCARD;
   1.102  
   1.103 -    data->surface = windata->surface;
   1.104 -    data->surface->AddRef(data->surface);
   1.105 +    data->window = window;
   1.106  
   1.107      data->flipflags = DSFLIP_PIPELINE | DSFLIP_BLIT;
   1.108  
   1.109 @@ -320,7 +324,7 @@
   1.110      } else
   1.111          data->flipflags |= DSFLIP_ONSYNC;
   1.112  
   1.113 -    SDL_DFB_CHECKERR(data->surface->GetCapabilities(data->surface, &scaps));
   1.114 +    SDL_DFB_CHECKERR(windata->surface->GetCapabilities(windata->surface, &scaps));
   1.115      if (scaps & DSCAPS_DOUBLE)
   1.116          renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2;
   1.117      else if (scaps & DSCAPS_TRIPLE)
   1.118 @@ -794,6 +798,8 @@
   1.119  PrepareDraw(SDL_Renderer * renderer)
   1.120  {
   1.121      DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
   1.122 +    SDL_DFB_WINDOWSURFACE(data->window);
   1.123 +    
   1.124      DFBResult ret;
   1.125      Uint8 r, g, b, a;
   1.126  
   1.127 @@ -803,7 +809,7 @@
   1.128      a = renderer->a;
   1.129  
   1.130      SetBlendMode(data, renderer->blendMode, NULL);
   1.131 -    SDL_DFB_CHECKERR(data->surface->SetDrawingFlags(data->surface,
   1.132 +    SDL_DFB_CHECKERR(destsurf->SetDrawingFlags(destsurf,
   1.133                                                      data->drawFlags));
   1.134  
   1.135      switch (renderer->blendMode) {
   1.136 @@ -820,7 +826,7 @@
   1.137          break;
   1.138      }
   1.139  
   1.140 -    SDL_DFB_CHECKERR(data->surface->SetColor(data->surface, r, g, b, a));
   1.141 +    SDL_DFB_CHECKERR(destsurf->SetColor(destsurf, r, g, b, a));
   1.142      return 0;
   1.143    error:
   1.144      return -1;
   1.145 @@ -830,10 +836,11 @@
   1.146  DirectFB_RenderPoint(SDL_Renderer * renderer, int x, int y)
   1.147  {
   1.148      DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
   1.149 +    SDL_DFB_WINDOWSURFACE(data->window);
   1.150      DFBResult ret;
   1.151  
   1.152      PrepareDraw(renderer);
   1.153 -    SDL_DFB_CHECKERR(data->surface->DrawLine(data->surface, x, y, x, y));
   1.154 +    SDL_DFB_CHECKERR(destsurf->DrawLine(destsurf, x, y, x, y));
   1.155      return 0;
   1.156    error:
   1.157      return -1;
   1.158 @@ -843,15 +850,16 @@
   1.159  DirectFB_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2)
   1.160  {
   1.161      DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
   1.162 +    SDL_DFB_WINDOWSURFACE(data->window);
   1.163      DFBResult ret;
   1.164  
   1.165      PrepareDraw(renderer);
   1.166      /* Use antialiasing when available */
   1.167  #if (DFB_VERSION_ATLEAST(1,2,0))
   1.168 -    SDL_DFB_CHECKERR(data->surface->SetRenderOptions(data->surface,
   1.169 +    SDL_DFB_CHECKERR(destsurf->SetRenderOptions(destsurf,
   1.170                                                       DSRO_ANTIALIAS));
   1.171  #endif
   1.172 -    SDL_DFB_CHECKERR(data->surface->DrawLine(data->surface, x1, y1, x2, y2));
   1.173 +    SDL_DFB_CHECKERR(destsurf->DrawLine(destsurf, x1, y1, x2, y2));
   1.174      return 0;
   1.175    error:
   1.176      return -1;
   1.177 @@ -861,11 +869,11 @@
   1.178  DirectFB_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect)
   1.179  {
   1.180      DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
   1.181 +    SDL_DFB_WINDOWSURFACE(data->window);
   1.182      DFBResult ret;
   1.183  
   1.184      PrepareDraw(renderer);
   1.185 -    SDL_DFB_CHECKERR(data->
   1.186 -                     surface->FillRectangle(data->surface, rect->x, rect->y,
   1.187 +    SDL_DFB_CHECKERR(destsurf->FillRectangle(destsurf, rect->x, rect->y,
   1.188                                              rect->w, rect->h));
   1.189  
   1.190      return 0;
   1.191 @@ -878,6 +886,7 @@
   1.192                      const SDL_Rect * srcrect, const SDL_Rect * dstrect)
   1.193  {
   1.194      DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
   1.195 +    SDL_DFB_WINDOWSURFACE(data->window);
   1.196      DirectFB_TextureData *texturedata =
   1.197          (DirectFB_TextureData *) texture->driverdata;
   1.198      Uint8 alpha = 0xFF;
   1.199 @@ -929,20 +938,17 @@
   1.200          SDLtoDFBRect(srcrect, &sr);
   1.201          SDLtoDFBRect(dstrect, &dr);
   1.202  
   1.203 -        SDL_DFB_CHECKERR(data->
   1.204 -                         surface->SetColor(data->surface, 0xFF, 0xFF, 0xFF,
   1.205 -                                           0xFF));
   1.206 +        SDL_DFB_CHECKERR(destsurf->SetColor(destsurf, 0xFF, 0xFF, 0xFF, 0xFF));
   1.207          if (texture->modMode &
   1.208              (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA)) {
   1.209              if (texture->modMode & SDL_TEXTUREMODULATE_ALPHA) {
   1.210                  alpha = texture->a;
   1.211 -                SDL_DFB_CHECKERR(data->
   1.212 -                                 surface->SetColor(data->surface, 0xFF, 0xFF,
   1.213 +                SDL_DFB_CHECKERR(destsurf->SetColor(destsurf, 0xFF, 0xFF,
   1.214                                                     0xFF, alpha));
   1.215              }
   1.216              if (texture->modMode & SDL_TEXTUREMODULATE_COLOR) {
   1.217  
   1.218 -                SDL_DFB_CHECKERR(data->surface->SetColor(data->surface,
   1.219 +                SDL_DFB_CHECKERR(destsurf->SetColor(destsurf,
   1.220                                                           texture->r,
   1.221                                                           texture->g,
   1.222                                                           texture->b, alpha));
   1.223 @@ -951,28 +957,27 @@
   1.224              if (alpha < 0xFF)
   1.225                  flags |= DSBLIT_SRC_PREMULTCOLOR;
   1.226          } else
   1.227 -            SDL_DFB_CHECKERR(data->
   1.228 -                             surface->SetColor(data->surface, 0xFF, 0xFF,
   1.229 +            SDL_DFB_CHECKERR(destsurf->SetColor(destsurf, 0xFF, 0xFF,
   1.230                                                 0xFF, 0xFF));
   1.231  
   1.232          SetBlendMode(data, texture->blendMode, texturedata);
   1.233  
   1.234 -        SDL_DFB_CHECKERR(data->surface->SetBlittingFlags(data->surface,
   1.235 +        SDL_DFB_CHECKERR(destsurf->SetBlittingFlags(destsurf,
   1.236                                                           data->blitFlags
   1.237                                                           | flags));
   1.238  
   1.239  #if (DFB_VERSION_ATLEAST(1,2,0))
   1.240 -        SDL_DFB_CHECKERR(data->surface->SetRenderOptions(data->surface,
   1.241 +        SDL_DFB_CHECKERR(destsurf->SetRenderOptions(destsurf,
   1.242                                                           texturedata->
   1.243                                                           render_options));
   1.244  #endif
   1.245  
   1.246          if (srcrect->w == dstrect->w && srcrect->h == dstrect->h) {
   1.247 -            SDL_DFB_CHECKERR(data->surface->Blit(data->surface,
   1.248 +            SDL_DFB_CHECKERR(destsurf->Blit(destsurf,
   1.249                                                   texturedata->surface,
   1.250                                                   &sr, dr.x, dr.y));
   1.251          } else {
   1.252 -            SDL_DFB_CHECKERR(data->surface->StretchBlit(data->surface,
   1.253 +            SDL_DFB_CHECKERR(destsurf->StretchBlit(destsurf,
   1.254                                                          texturedata->surface,
   1.255                                                          &sr, &dr));
   1.256          }
   1.257 @@ -1030,9 +1035,8 @@
   1.258  DirectFB_DestroyRenderer(SDL_Renderer * renderer)
   1.259  {
   1.260      DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
   1.261 -
   1.262 +    
   1.263      if (data) {
   1.264 -        SDL_DFB_RELEASE(data->surface);
   1.265          SDL_free(data);
   1.266      }
   1.267      SDL_free(renderer);
     2.1 --- a/src/video/directfb/SDL_DirectFB_video.h	Tue Jan 13 21:17:38 2009 +0000
     2.2 +++ b/src/video/directfb/SDL_DirectFB_video.h	Tue Jan 13 22:59:02 2009 +0000
     2.3 @@ -71,9 +71,9 @@
     2.4  #define DFBENV_USE_LINUX_INPUT		"SDL_DIRECTFB_LINUX_INPUT"      /* Default: on  */
     2.5  #define DFBENV_USE_WM				"SDL_DIRECTFB_WM"		      	/* Default: off  */
     2.6  
     2.7 -#define SDL_DFB_RELEASE(x) do { if ( x ) { x->Release(x); x = NULL; } } while (0)
     2.8 -#define SDL_DFB_FREE(x) do { if ( x ) { SDL_free(x); x = NULL; } } while (0)
     2.9 -#define SDL_DFB_UNLOCK(x) do { if ( x ) { x->Unlock(x); } } while (0)
    2.10 +#define SDL_DFB_RELEASE(x) do { if ( (x) != NULL ) { x->Release(x); x = NULL; } } while (0)
    2.11 +#define SDL_DFB_FREE(x) do { if ( (x) != NULL ) { SDL_free(x); x = NULL; } } while (0)
    2.12 +#define SDL_DFB_UNLOCK(x) do { if ( (x) != NULL ) { x->Unlock(x); } } while (0)
    2.13  
    2.14  #if DEBUG
    2.15  #define SDL_DFB_DEBUG(x...) do { fprintf(LOG_CHANNEL, "%s:", __FUNCTION__); fprintf(LOG_CHANNEL, x); } while (0)
     3.1 --- a/src/video/directfb/SDL_DirectFB_window.c	Tue Jan 13 21:17:38 2009 +0000
     3.2 +++ b/src/video/directfb/SDL_DirectFB_window.c	Tue Jan 13 22:59:02 2009 +0000
     3.3 @@ -420,7 +420,7 @@
     3.4      }
     3.5  
     3.6      if (adjust) {
     3.7 -#if DFB_VERSION_ATLEAST(1,2,0)
     3.8 +#if DFB_VERSION_ATLEAST(1,2,1)
     3.9         SDL_DFB_CHECKERR(windata->window->ResizeSurface(windata->window,
    3.10                                                          windata->size.w,
    3.11                                                          windata->size.h));
    3.12 @@ -430,16 +430,13 @@
    3.13                                                            &windata->client));
    3.14  #else
    3.15         /* recreate subsurface */
    3.16 -       windata->surface->ReleaseSource(windata->surface);
    3.17 -       windata->window_surface->ReleaseSource(windata->window_surface);
    3.18         SDL_DFB_RELEASE(windata->surface);
    3.19 -       windata->surface = NULL;
    3.20         SDL_DFB_CHECKERR(windata->window->ResizeSurface(windata->window,
    3.21                                                         windata->size.w,
    3.22                                                         windata->size.h));
    3.23         SDL_DFB_CHECKERR(windata->window_surface->
    3.24 -                        GetSubSurface(windata->window_surface, &windata->client,
    3.25 -                                      &windata->surface));
    3.26 +                      GetSubSurface(windata->window_surface, &windata->client,
    3.27 +                                  &windata->surface));
    3.28  #endif
    3.29         DirectFB_WM_RedrawLayout(window);
    3.30      }