(svn r11342) -Fix: [OSX] The cocoa driver incorrectly assumed that the blitter always was 8bpp. Now both 8bpp and 32bpp blitters can be used. The driver will check the blitter screen depth. In fullscreen it will select a proper video mode for this depth, and in windowed mode it will simply skip doing fake 8bpp.

This commit is contained in:
egladil
2007-10-25 23:45:03 +00:00
parent 08503f5ba5
commit a1c3d51f7f
2 changed files with 113 additions and 47 deletions

View File

@@ -8,6 +8,7 @@
#include "../../functions.h"
#include "../../gfx.h"
#include "../../fileio.h"
#include "../../blitter/factory.hpp"
#include "splash.h"
@@ -36,7 +37,7 @@ void DisplaySplashImage()
png_colorp palette;
int num_palette;
png_bytep *row_pointers;
uint8 *src, *dst;
uint8 *src;
uint y;
uint xoff, yoff;
int i;
@@ -103,33 +104,56 @@ void DisplaySplashImage()
row_pointers = png_get_rows(png_ptr, info_ptr);
memset(_screen.dst_ptr, 0xff, _screen.pitch * _screen.height);
if (width > (uint) _screen.width) width = _screen.width;
if (height > (uint) _screen.height) height = _screen.height;
xoff = (_screen.width - width) / 2;
yoff = (_screen.height - height) / 2;
for (y = 0; y < height; y++) {
src = row_pointers[y];
dst = ((uint8 *) _screen.dst_ptr) + (yoff + y) * _screen.pitch + xoff;
memcpy(dst, src, width);
switch (BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth()) {
case 8: {
uint8 *dst;
memset(_screen.dst_ptr, 0xff, _screen.pitch * _screen.height);
for (y = 0; y < height; y++) {
src = row_pointers[y];
dst = ((uint8 *) _screen.dst_ptr) + (yoff + y) * _screen.pitch + xoff;
memcpy(dst, src, width);
}
for (i = 0; i < num_palette; i++) {
_cur_palette[i].r = palette[i].red;
_cur_palette[i].g = palette[i].green;
_cur_palette[i].b = palette[i].blue;
}
_cur_palette[0xff].r = 0;
_cur_palette[0xff].g = 0;
_cur_palette[0xff].b = 0;
_pal_first_dirty = 0;
_pal_count_dirty = 256;
}
break;
case 32: {
uint32 *dst;
int x;
memset(_screen.dst_ptr, 0xff000000, _screen.pitch * _screen.height * 4);
for (y = 0; y < height; y++) {
src = row_pointers[y];
dst = ((uint32 *) _screen.dst_ptr) + (yoff + y) * _screen.pitch + xoff;
for (x = 0; x < width; x++)
dst[x] = palette[src[x]].blue | (palette[src[x]].green << 8) | (palette[src[x]].red << 16) | 0xff000000;
}
}
break;
}
for (i = 0; i < num_palette; i++) {
_cur_palette[i].r = palette[i].red;
_cur_palette[i].g = palette[i].green;
_cur_palette[i].b = palette[i].blue;
}
_cur_palette[0xff].r = 0;
_cur_palette[0xff].g = 0;
_cur_palette[0xff].b = 0;
_pal_first_dirty = 0;
_pal_count_dirty = 256;
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
fclose(f);
return;