src/video/win32/SDL_d3drender.c
changeset 2990 502adab079a4
parent 2973 ab0c00f1b070
child 3011 8f4ed5ec2b06
     1.1 --- a/src/video/win32/SDL_d3drender.c	Sun Jan 04 17:10:04 2009 +0000
     1.2 +++ b/src/video/win32/SDL_d3drender.c	Sun Jan 04 17:14:27 2009 +0000
     1.3 @@ -39,7 +39,9 @@
     1.4  static SDL_Renderer *D3D_CreateRenderer(SDL_Window * window, Uint32 flags);
     1.5  static int D3D_DisplayModeChanged(SDL_Renderer * renderer);
     1.6  static int D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
     1.7 -static int D3D_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture, void **pixels, int *pitch);
     1.8 +static int D3D_QueryTexturePixels(SDL_Renderer * renderer,
     1.9 +                                  SDL_Texture * texture, void **pixels,
    1.10 +                                  int *pitch);
    1.11  static int D3D_SetTexturePalette(SDL_Renderer * renderer,
    1.12                                   SDL_Texture * texture,
    1.13                                   const SDL_Color * colors, int firstcolor,
    1.14 @@ -232,17 +234,18 @@
    1.15  }
    1.16  
    1.17  static SDL_bool
    1.18 -D3D_IsTextureFormatAvailable(IDirect3D9 *d3d, Uint32 display_format, Uint32 texture_format)
    1.19 +D3D_IsTextureFormatAvailable(IDirect3D9 * d3d, Uint32 display_format,
    1.20 +                             Uint32 texture_format)
    1.21  {
    1.22      HRESULT result;
    1.23  
    1.24 -    result = IDirect3D9_CheckDeviceFormat(d3d,
    1.25 -                                          D3DADAPTER_DEFAULT,        /* FIXME */
    1.26 +    result = IDirect3D9_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT,      /* FIXME */
    1.27                                            D3DDEVTYPE_HAL,
    1.28                                            PixelFormatToD3DFMT(display_format),
    1.29                                            0,
    1.30                                            D3DRTYPE_TEXTURE,
    1.31 -                                          PixelFormatToD3DFMT(texture_format));
    1.32 +                                          PixelFormatToD3DFMT
    1.33 +                                          (texture_format));
    1.34      return FAILED(result) ? SDL_FALSE : SDL_TRUE;
    1.35  }
    1.36  
    1.37 @@ -260,7 +263,8 @@
    1.38      d3drect.top = 0;
    1.39      d3drect.bottom = texture->h;
    1.40  
    1.41 -    result = IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect, 0);
    1.42 +    result =
    1.43 +        IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect, 0);
    1.44      if (FAILED(result)) {
    1.45          return;
    1.46      }
    1.47 @@ -285,28 +289,35 @@
    1.48      if (data->d3d) {
    1.49          int i;
    1.50          int formats[] = {
    1.51 -          SDL_PIXELFORMAT_INDEX8,
    1.52 -          SDL_PIXELFORMAT_RGB332,
    1.53 -          SDL_PIXELFORMAT_RGB444,
    1.54 -          SDL_PIXELFORMAT_RGB555,
    1.55 -          SDL_PIXELFORMAT_ARGB4444,
    1.56 -          SDL_PIXELFORMAT_ARGB1555,
    1.57 -          SDL_PIXELFORMAT_RGB565,
    1.58 -          SDL_PIXELFORMAT_RGB888,
    1.59 -          SDL_PIXELFORMAT_ARGB8888,
    1.60 -          SDL_PIXELFORMAT_ARGB2101010,
    1.61 +            SDL_PIXELFORMAT_INDEX8,
    1.62 +            SDL_PIXELFORMAT_RGB332,
    1.63 +            SDL_PIXELFORMAT_RGB444,
    1.64 +            SDL_PIXELFORMAT_RGB555,
    1.65 +            SDL_PIXELFORMAT_ARGB4444,
    1.66 +            SDL_PIXELFORMAT_ARGB1555,
    1.67 +            SDL_PIXELFORMAT_RGB565,
    1.68 +            SDL_PIXELFORMAT_RGB888,
    1.69 +            SDL_PIXELFORMAT_ARGB8888,
    1.70 +            SDL_PIXELFORMAT_ARGB2101010,
    1.71          };
    1.72  
    1.73          for (i = 0; i < SDL_arraysize(formats); ++i) {
    1.74 -            if (D3D_IsTextureFormatAvailable(data->d3d, mode->format, formats[i])) {
    1.75 -                info->texture_formats[info->num_texture_formats++] = formats[i];
    1.76 +            if (D3D_IsTextureFormatAvailable
    1.77 +                (data->d3d, mode->format, formats[i])) {
    1.78 +                info->texture_formats[info->num_texture_formats++] =
    1.79 +                    formats[i];
    1.80              }
    1.81          }
    1.82 -        info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YV12;
    1.83 -        info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_IYUV;
    1.84 -        info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YUY2;
    1.85 -        info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_UYVY;
    1.86 -        info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YVYU;
    1.87 +        info->texture_formats[info->num_texture_formats++] =
    1.88 +            SDL_PIXELFORMAT_YV12;
    1.89 +        info->texture_formats[info->num_texture_formats++] =
    1.90 +            SDL_PIXELFORMAT_IYUV;
    1.91 +        info->texture_formats[info->num_texture_formats++] =
    1.92 +            SDL_PIXELFORMAT_YUY2;
    1.93 +        info->texture_formats[info->num_texture_formats++] =
    1.94 +            SDL_PIXELFORMAT_UYVY;
    1.95 +        info->texture_formats[info->num_texture_formats++] =
    1.96 +            SDL_PIXELFORMAT_YVYU;
    1.97  
    1.98          SDL_AddRenderDriver(0, &D3D_RenderDriver);
    1.99      }
   1.100 @@ -549,9 +560,11 @@
   1.101  
   1.102      if (SDL_ISPIXELFORMAT_FOURCC(texture->format) &&
   1.103          (texture->format != SDL_PIXELFORMAT_YUY2 ||
   1.104 -         !D3D_IsTextureFormatAvailable(renderdata->d3d, display_format, texture->format)) &&
   1.105 -        (texture->format != SDL_PIXELFORMAT_YVYU ||
   1.106 -         !D3D_IsTextureFormatAvailable(renderdata->d3d, display_format, texture->format))) {
   1.107 +         !D3D_IsTextureFormatAvailable(renderdata->d3d, display_format,
   1.108 +                                       texture->format))
   1.109 +        && (texture->format != SDL_PIXELFORMAT_YVYU
   1.110 +            || !D3D_IsTextureFormatAvailable(renderdata->d3d, display_format,
   1.111 +                                             texture->format))) {
   1.112          data->yuv =
   1.113              SDL_SW_CreateYUVTexture(texture->format, texture->w, texture->h);
   1.114          if (!data->yuv) {
   1.115 @@ -680,7 +693,8 @@
   1.116          result =
   1.117              IDirect3DDevice9_CreateTexture(renderdata->device, texture->w,
   1.118                                             texture->h, 1, 0,
   1.119 -                                           PixelFormatToD3DFMT(texture->format),
   1.120 +                                           PixelFormatToD3DFMT(texture->
   1.121 +                                                               format),
   1.122                                             D3DPOOL_SYSTEMMEM, &temp, NULL);
   1.123          if (FAILED(result)) {
   1.124              D3D_SetError("CreateTexture()", result);
   1.125 @@ -733,7 +747,8 @@
   1.126          d3drect.bottom = rect->y + rect->h;
   1.127  
   1.128          result =
   1.129 -            IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect, 0);
   1.130 +            IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect,
   1.131 +                                       0);
   1.132          if (FAILED(result)) {
   1.133              D3D_SetError("LockRect()", result);
   1.134              return -1;
   1.135 @@ -776,7 +791,8 @@
   1.136  
   1.137          result =
   1.138              IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect,
   1.139 -                                       markDirty ? 0 : D3DLOCK_NO_DIRTY_UPDATE);
   1.140 +                                       markDirty ? 0 :
   1.141 +                                       D3DLOCK_NO_DIRTY_UPDATE);
   1.142          if (FAILED(result)) {
   1.143              D3D_SetError("LockRect()", result);
   1.144              return -1;