src/SDL12_compat.c
changeset 110 967a0716df06
parent 109 946944397910
child 111 76364b4bafbb
equal deleted inserted replaced
109:946944397910 110:967a0716df06
  3261 }
  3261 }
  3262 
  3262 
  3263 DECLSPEC void SDLCALL
  3263 DECLSPEC void SDLCALL
  3264 SDL_WM_SetIcon(SDL12_Surface *icon12, Uint8 *mask)
  3264 SDL_WM_SetIcon(SDL12_Surface *icon12, Uint8 *mask)
  3265 {
  3265 {
  3266 SDL20_SetWindowIcon(VideoWindow20, icon12->surface20);
  3266         if (VideoWindow20) {
       
  3267             SDL20_SetWindowIcon(VideoWindow20, icon12->surface20);
       
  3268 
       
  3269         }
  3267 return;
  3270 return;
  3268 
  3271 
  3269     // take the mask and zero out those alpha values.
  3272     // take the mask and zero out those alpha values.
  3270     SDL_BlendMode blendmode = SDL_BLENDMODE_NONE;
  3273     SDL_BlendMode blendmode = SDL_BLENDMODE_NONE;
  3271     if (SDL20_GetSurfaceBlendMode(icon12->surface20, &blendmode) < 0) {
  3274     if (SDL20_GetSurfaceBlendMode(icon12->surface20, &blendmode) < 0) {
  3285 
  3288 
  3286     SDL20_SetSurfaceBlendMode(icon12->surface20, SDL_BLENDMODE_NONE);
  3289     SDL20_SetSurfaceBlendMode(icon12->surface20, SDL_BLENDMODE_NONE);
  3287     const int rc = SDL20_UpperBlit(icon12->surface20, NULL, icon20, NULL);
  3290     const int rc = SDL20_UpperBlit(icon12->surface20, NULL, icon20, NULL);
  3288     SDL20_SetSurfaceBlendMode(icon12->surface20, blendmode);
  3291     SDL20_SetSurfaceBlendMode(icon12->surface20, blendmode);
  3289     if (rc == 0) {
  3292     if (rc == 0) {
  3290         SDL_assert(icon20->format->BytesPerPixel == 4);
  3293         if (mask) {
  3291         SDL_assert(icon20->pitch == icon20->w * 4);
  3294             SDL_assert(icon20->format->BytesPerPixel == 4);
  3292         const int w = icon12->w;
  3295             SDL_assert(icon20->pitch == icon20->w * 4);
  3293         const int h = icon12->h;
  3296             const int w = icon12->w;
  3294         const int mpitch = (w + 7) / 8;
  3297             const int h = icon12->h;
  3295         Uint32 *ptr = (Uint32 *) icon20->pixels;
  3298             const int mpitch = (w + 7) / 8;
  3296         for (int y = 0; y < h; y++) {
  3299             Uint32 *ptr = (Uint32 *) icon20->pixels;
  3297             for (int x = 0; x < w; x++, ptr++) {
  3300             for (int y = 0; y < h; y++) {
  3298                 if (!(mask[y*mpitch + x/8] & (128 >> (x % 8)))) {
  3301                 for (int x = 0; x < w; x++, ptr++) {
  3299                     *ptr &= ~amask;
  3302                     if (!(mask[y*mpitch + x/8] & (128 >> (x % 8)))) {
       
  3303                         *ptr &= ~amask;
       
  3304 } else {
       
  3305 *ptr |= amask;
       
  3306                     }
  3300                 }
  3307                 }
  3301             }
  3308             }
  3302         }
  3309         }
  3303         SDL20_SetWindowIcon(VideoWindow20, icon20);
  3310 
       
  3311         if (VideoWindow20) {
       
  3312             SDL20_SetWindowIcon(VideoWindow20, icon20);
       
  3313         }
  3304         SDL20_FreeSurface(VideoIcon20);
  3314         SDL20_FreeSurface(VideoIcon20);
  3305         VideoIcon20 = icon20;
  3315         VideoIcon20 = icon20;
  3306     }
  3316     }
  3307 }
  3317 }
  3308 
  3318