src/video/SDL_surface.c
changeset 2222 926294b2bb4e
parent 1920 8a162bfdc838
child 2234 cf8c3b0117b3
     1.1 --- a/src/video/SDL_surface.c	Sat Aug 11 20:46:24 2007 +0000
     1.2 +++ b/src/video/SDL_surface.c	Sat Aug 11 20:54:31 2007 +0000
     1.3 @@ -170,62 +170,11 @@
     1.4      return surface;
     1.5  }
     1.6  
     1.7 -SDL_Surface *
     1.8 -SDL_CreateRGBSurfaceFromTexture(SDL_TextureID textureID)
     1.9 -{
    1.10 -    SDL_Surface *surface;
    1.11 -    Uint32 format;
    1.12 -    int w, h;
    1.13 -    int bpp;
    1.14 -    Uint32 Rmask, Gmask, Bmask, Amask;
    1.15 -    void *pixels;
    1.16 -    int pitch;
    1.17 -
    1.18 -    if (SDL_QueryTexture(textureID, &format, NULL, &w, &h) < 0) {
    1.19 -        return NULL;
    1.20 -    }
    1.21 -
    1.22 -    if (!SDL_PixelFormatEnumToMasks
    1.23 -        (format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
    1.24 -        SDL_SetError("Unknown texture format");
    1.25 -        return NULL;
    1.26 -    }
    1.27 -
    1.28 -    if (SDL_QueryTexturePixels(textureID, &pixels, &pitch) == 0) {
    1.29 -        surface =
    1.30 -            SDL_CreateRGBSurfaceFrom(pixels, w, h, bpp, pitch, Rmask, Gmask,
    1.31 -                                     Bmask, Amask);
    1.32 -    } else {
    1.33 -        surface =
    1.34 -            SDL_CreateRGBSurface(0, 0, 0, bpp, Rmask, Gmask, Bmask, Amask);
    1.35 -        if (surface) {
    1.36 -            surface->flags |= SDL_HWSURFACE;
    1.37 -            surface->w = w;
    1.38 -            surface->h = h;
    1.39 -            surface->pitch = SDL_CalculatePitch(surface);
    1.40 -            SDL_SetClipRect(surface, NULL);
    1.41 -        }
    1.42 -    }
    1.43 -    if (surface) {
    1.44 -        surface->textureID = textureID;
    1.45 -    }
    1.46 -
    1.47 -    return surface;
    1.48 -}
    1.49 -
    1.50  static int
    1.51  SDL_SurfacePaletteChanged(void *userdata, SDL_Palette * palette)
    1.52  {
    1.53      SDL_Surface *surface = (SDL_Surface *) userdata;
    1.54  
    1.55 -    if (surface->textureID) {
    1.56 -        if (SDL_SetTexturePalette
    1.57 -            (surface->textureID, palette->colors, 0, palette->ncolors) < 0) {
    1.58 -            SDL_GetTexturePalette(surface->textureID, palette->colors, 0,
    1.59 -                                  palette->ncolors);
    1.60 -            return -1;
    1.61 -        }
    1.62 -    }
    1.63      SDL_FormatChanged(surface);
    1.64  
    1.65      return 0;
    1.66 @@ -627,74 +576,9 @@
    1.67                  row += dst->pitch;
    1.68              }
    1.69          } else {
    1.70 -#ifdef __powerpc__
    1.71 -            /*
    1.72 -             * SDL_memset() on PPC (both glibc and codewarrior) uses
    1.73 -             * the dcbz (Data Cache Block Zero) instruction, which
    1.74 -             * causes an alignment exception if the destination is
    1.75 -             * uncachable, so only use it on software surfaces
    1.76 -             */
    1.77 -            if (dst->flags & SDL_HWSURFACE) {
    1.78 -                if (dstrect->w >= 8) {
    1.79 -                    /*
    1.80 -                     * 64-bit stores are probably most
    1.81 -                     * efficient to uncached video memory
    1.82 -                     */
    1.83 -                    double fill;
    1.84 -                    SDL_memset(&fill, color, (sizeof fill));
    1.85 -                    for (y = dstrect->h; y; y--) {
    1.86 -                        Uint8 *d = row;
    1.87 -                        unsigned n = x;
    1.88 -                        unsigned nn;
    1.89 -                        Uint8 c = color;
    1.90 -                        double f = fill;
    1.91 -                        while ((unsigned long) d & (sizeof(double) - 1)) {
    1.92 -                            *d++ = c;
    1.93 -                            n--;
    1.94 -                        }
    1.95 -                        nn = n / (sizeof(double) * 4);
    1.96 -                        while (nn) {
    1.97 -                            ((double *) d)[0] = f;
    1.98 -                            ((double *) d)[1] = f;
    1.99 -                            ((double *) d)[2] = f;
   1.100 -                            ((double *) d)[3] = f;
   1.101 -                            d += 4 * sizeof(double);
   1.102 -                            nn--;
   1.103 -                        }
   1.104 -                        n &= ~(sizeof(double) * 4 - 1);
   1.105 -                        nn = n / sizeof(double);
   1.106 -                        while (nn) {
   1.107 -                            *(double *) d = f;
   1.108 -                            d += sizeof(double);
   1.109 -                            nn--;
   1.110 -                        }
   1.111 -                        n &= ~(sizeof(double) - 1);
   1.112 -                        while (n) {
   1.113 -                            *d++ = c;
   1.114 -                            n--;
   1.115 -                        }
   1.116 -                        row += dst->pitch;
   1.117 -                    }
   1.118 -                } else {
   1.119 -                    /* narrow boxes */
   1.120 -                    for (y = dstrect->h; y; y--) {
   1.121 -                        Uint8 *d = row;
   1.122 -                        Uint8 c = color;
   1.123 -                        int n = x;
   1.124 -                        while (n) {
   1.125 -                            *d++ = c;
   1.126 -                            n--;
   1.127 -                        }
   1.128 -                        row += dst->pitch;
   1.129 -                    }
   1.130 -                }
   1.131 -            } else
   1.132 -#endif /* __powerpc__ */
   1.133 -            {
   1.134 -                for (y = dstrect->h; y; y--) {
   1.135 -                    SDL_memset(row, color, x);
   1.136 -                    row += dst->pitch;
   1.137 -                }
   1.138 +            for (y = dstrect->h; y; y--) {
   1.139 +                SDL_memset(row, color, x);
   1.140 +                row += dst->pitch;
   1.141              }
   1.142          }
   1.143      } else {
   1.144 @@ -753,13 +637,6 @@
   1.145  {
   1.146      if (!surface->locked) {
   1.147          /* Perform the lock */
   1.148 -        if (surface->flags & SDL_HWSURFACE) {
   1.149 -            if (SDL_LockTexture
   1.150 -                (surface->textureID, NULL, 1, &surface->pixels,
   1.151 -                 &surface->pitch) < 0) {
   1.152 -                return (-1);
   1.153 -            }
   1.154 -        }
   1.155          if (surface->flags & SDL_RLEACCEL) {
   1.156              SDL_UnRLESurface(surface, 1);
   1.157              surface->flags |= SDL_RLEACCEL;     /* save accel'd state */
   1.158 @@ -784,11 +661,6 @@
   1.159          return;
   1.160      }
   1.161  
   1.162 -    /* Unlock hardware or accelerated surfaces */
   1.163 -    if (surface->flags & SDL_HWSURFACE) {
   1.164 -        SDL_UnlockTexture(surface->textureID);
   1.165 -    }
   1.166 -
   1.167      /* Update RLE encoded surface with new data */
   1.168      if ((surface->flags & SDL_RLEACCEL) == SDL_RLEACCEL) {
   1.169          surface->flags &= ~SDL_RLEACCEL;        /* stop lying */
   1.170 @@ -928,11 +800,6 @@
   1.171          SDL_FreeBlitMap(surface->map);
   1.172          surface->map = NULL;
   1.173      }
   1.174 -    /* Should we destroy the texture too?
   1.175 -       if (surface->textureID) {
   1.176 -       SDL_DestroyTexture(surface->textureID);
   1.177 -       }
   1.178 -     */
   1.179      if (surface->pixels && ((surface->flags & SDL_PREALLOC) != SDL_PREALLOC)) {
   1.180          SDL_free(surface->pixels);
   1.181      }