src/video/SDL_video.c
branchSDL-1.2
changeset 3995 604321d3575e
parent 3976 8582c6a5ca16
child 4140 fc69b552ee32
equal deleted inserted replaced
3994:720c59bd38ac 3995:604321d3575e
  1140 	if ( colors != (pal->colors + firstcolor) ) {
  1140 	if ( colors != (pal->colors + firstcolor) ) {
  1141 		SDL_memcpy(pal->colors + firstcolor, colors,
  1141 		SDL_memcpy(pal->colors + firstcolor, colors,
  1142 		       ncolors * sizeof(*colors));
  1142 		       ncolors * sizeof(*colors));
  1143 	}
  1143 	}
  1144 
  1144 
  1145 	vidpal = SDL_VideoSurface->format->palette;
  1145 	if ( current_video && SDL_VideoSurface ) {
  1146 	if ( (screen == SDL_ShadowSurface) && vidpal ) {
  1146 		vidpal = SDL_VideoSurface->format->palette;
  1147 		/*
  1147 		if ( (screen == SDL_ShadowSurface) && vidpal ) {
  1148 		 * This is a shadow surface, and the physical
  1148 			/*
  1149 		 * framebuffer is also indexed. Propagate the
  1149 			 * This is a shadow surface, and the physical
  1150 		 * changes to its logical palette so that
  1150 			 * framebuffer is also indexed. Propagate the
  1151 		 * updates are always identity blits
  1151 			 * changes to its logical palette so that
  1152 		 */
  1152 			 * updates are always identity blits
  1153 		SDL_memcpy(vidpal->colors + firstcolor, colors,
  1153 			 */
  1154 		       ncolors * sizeof(*colors));
  1154 			SDL_memcpy(vidpal->colors + firstcolor, colors,
       
  1155 			       ncolors * sizeof(*colors));
       
  1156 		}
  1155 	}
  1157 	}
  1156 	SDL_FormatChanged(screen);
  1158 	SDL_FormatChanged(screen);
  1157 }
  1159 }
  1158 
  1160 
  1159 static int SetPalette_physical(SDL_Surface *screen,
  1161 static int SetPalette_physical(SDL_Surface *screen,
  1242 {
  1244 {
  1243 	SDL_Palette *pal;
  1245 	SDL_Palette *pal;
  1244 	int gotall;
  1246 	int gotall;
  1245 	int palsize;
  1247 	int palsize;
  1246 
  1248 
  1247 	if ( ! current_video ) {
  1249 	if ( !screen ) {
  1248 		return 0;
  1250 		return 0;
  1249 	}
  1251 	}
  1250 	if ( screen != SDL_PublicSurface ) {
  1252 	if ( !current_video || screen != SDL_PublicSurface ) {
  1251 		/* only screens have physical palettes */
  1253 		/* only screens have physical palettes */
  1252 		which &= ~SDL_PHYSPAL;
  1254 		which &= ~SDL_PHYSPAL;
  1253 	} else if( (screen->flags & SDL_HWPALETTE) != SDL_HWPALETTE ) {
  1255 	} else if ( (screen->flags & SDL_HWPALETTE) != SDL_HWPALETTE ) {
  1254 		/* hardware palettes required for split colormaps */
  1256 		/* hardware palettes required for split colormaps */
  1255 		which |= SDL_PHYSPAL | SDL_LOGPAL;
  1257 		which |= SDL_PHYSPAL | SDL_LOGPAL;
  1256 	}
  1258 	}
  1257 
  1259 
  1258 	/* Verify the parameters */
  1260 	/* Verify the parameters */
  1281 		/*
  1283 		/*
  1282 		 * Physical palette change: This doesn't affect the
  1284 		 * Physical palette change: This doesn't affect the
  1283 		 * program's idea of what the screen looks like, but changes
  1285 		 * program's idea of what the screen looks like, but changes
  1284 		 * its actual appearance.
  1286 		 * its actual appearance.
  1285 		 */
  1287 		 */
  1286 		if(!video)
  1288 		if ( !video->physpal && !(which & SDL_LOGPAL) ) {
  1287 			return gotall;	/* video not yet initialized */
       
  1288 		if(!video->physpal && !(which & SDL_LOGPAL) ) {
       
  1289 			/* Lazy physical palette allocation */
  1289 			/* Lazy physical palette allocation */
  1290 			int size;
  1290 			int size;
  1291 			SDL_Palette *pp = SDL_malloc(sizeof(*pp));
  1291 			SDL_Palette *pp = SDL_malloc(sizeof(*pp));
  1292 			if ( !pp ) {
  1292 			if ( !pp ) {
  1293 				return 0;
  1293 				return 0;
  1294 			}
  1294 			}
  1295 			current_video->physpal = pp;
  1295 			video->physpal = pp;
  1296 			pp->ncolors = pal->ncolors;
  1296 			pp->ncolors = pal->ncolors;
  1297 			size = pp->ncolors * sizeof(SDL_Color);
  1297 			size = pp->ncolors * sizeof(SDL_Color);
  1298 			pp->colors = SDL_malloc(size);
  1298 			pp->colors = SDL_malloc(size);
  1299 			if ( !pp->colors ) {
  1299 			if ( !pp->colors ) {
  1300 				return 0;
  1300 				return 0;