Fixed a huge bug with texture scaling.
authorSunny Sachanandani <sunnysachanandani@gmail.com>
Mon, 02 Aug 2010 11:13:40 +0530
changeset 462944fd1f0b895a
parent 4624 b70b99ab75b8
child 4630 02895e9c796b
Fixed a huge bug with texture scaling.
src/video/x11/SDL_x11render.c
     1.1 --- a/src/video/x11/SDL_x11render.c	Wed Jul 28 15:35:18 2010 +0530
     1.2 +++ b/src/video/x11/SDL_x11render.c	Mon Aug 02 11:13:40 2010 +0530
     1.3 @@ -1021,8 +1021,9 @@
     1.4              return -1;
     1.5          }
     1.6          texture->blendMode = SDL_BLENDMODE_NONE;
     1.7 +        texture->scaleMode = SDL_TEXTURESCALEMODE_NONE;
     1.8          data->blend_op = PictOpSrc;
     1.9 -        data->filter = "fast";
    1.10 +        data->filter = NULL;
    1.11      }
    1.12  #endif
    1.13      return 0;
    1.14 @@ -1159,6 +1160,11 @@
    1.15  
    1.16      switch (texture->scaleMode) {
    1.17      case SDL_TEXTURESCALEMODE_NONE:
    1.18 +#ifdef SDL_VIDEO_DRIVER_X11_XRENDER
    1.19 +        if (renderdata->use_xrender) {
    1.20 +            data->filter = NULL;
    1.21 +        }
    1.22 +#endif
    1.23          return 0;
    1.24      case SDL_TEXTURESCALEMODE_FAST:
    1.25          /* We can sort of fake it for streaming textures */
    1.26 @@ -1186,8 +1192,8 @@
    1.27          SDL_Unsupported();
    1.28  #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
    1.29          if (renderdata->use_xrender) {
    1.30 -            texture->scaleMode = SDL_TEXTURESCALEMODE_FAST;
    1.31 -            data->filter = FilterFast;
    1.32 +            texture->scaleMode = SDL_TEXTURESCALEMODE_NONE;
    1.33 +            data->filter = NULL;
    1.34          }
    1.35          else
    1.36  #endif
    1.37 @@ -1900,7 +1906,7 @@
    1.38          }
    1.39          else
    1.40          {
    1.41 -            mask = texturedata->picture;
    1.42 +            mask = src;
    1.43              mrect = srcrect;
    1.44          }
    1.45  
    1.46 @@ -1919,8 +1925,8 @@
    1.47                              mrect->x, mrect->y, dstrect->x, dstrect->y,
    1.48                              dstrect->w, dstrect->h);
    1.49          } else {
    1.50 -            double xscale = ((double) dstrect->w) / srcrect->w;
    1.51 -            double yscale = ((double) dstrect->h) / srcrect->h;
    1.52 +            double xscale = ((double) srcrect->w) / dstrect->w;
    1.53 +            double yscale = ((double) srcrect->h) / dstrect->h;
    1.54              XTransform xform = {{
    1.55                      {XDoubleToFixed(xscale), XDoubleToFixed(0), XDoubleToFixed(0)},
    1.56                      {XDoubleToFixed(0), XDoubleToFixed(yscale), XDoubleToFixed(0)},
    1.57 @@ -1937,8 +1943,10 @@
    1.58                                       CPComponentAlpha, &attr);
    1.59              }
    1.60  
    1.61 -            XRenderSetPictureFilter(data->display, src,
    1.62 -                                    texturedata->filter, 0, 0);
    1.63 +            if (texture->scaleMode != SDL_TEXTURESCALEMODE_NONE) {
    1.64 +                XRenderSetPictureFilter(data->display, src,
    1.65 +                                        texturedata->filter, 0, 0);
    1.66 +            }
    1.67  
    1.68              XRenderComposite(data->display, texturedata->blend_op,
    1.69                               src, mask, data->drawable_pict,
    1.70 @@ -1951,6 +1959,7 @@
    1.71                      {XDoubleToFixed(0), XDoubleToFixed(0), XDoubleToFixed(1)}}};
    1.72              XRenderSetPictureTransform(data->display, src, &identity);
    1.73          }
    1.74 +
    1.75          if (renderer->blendMode == SDL_BLENDMODE_MOD) {
    1.76              attr.component_alpha = False;
    1.77              XRenderChangePicture(data->display, data->stencil_pict,