summaryrefslogtreecommitdiff
path: root/src/os
diff options
context:
space:
mode:
authoregladil <egladil@openttd.org>2007-10-25 23:45:03 +0000
committeregladil <egladil@openttd.org>2007-10-25 23:45:03 +0000
commit134227aa8ccd822e2a836042ba734213c5b15023 (patch)
treea484a12de4b70fae825135f5d743a269cfb627c0 /src/os
parent287a4a8049121c65288899a82dca08856b116dc5 (diff)
downloadopenttd-134227aa8ccd822e2a836042ba734213c5b15023.tar.xz
(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.
Diffstat (limited to 'src/os')
-rw-r--r--src/os/macosx/splash.cpp60
1 files changed, 42 insertions, 18 deletions
diff --git a/src/os/macosx/splash.cpp b/src/os/macosx/splash.cpp
index 30eed880d..45973c781 100644
--- a/src/os/macosx/splash.cpp
+++ b/src/os/macosx/splash.cpp
@@ -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,32 +104,55 @@ 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;
- 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;
- }
+ 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);
+ }
- _cur_palette[0xff].r = 0;
- _cur_palette[0xff].g = 0;
- _cur_palette[0xff].b = 0;
+ 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;
+ }
- _pal_first_dirty = 0;
- _pal_count_dirty = 256;
+ _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;
+ }
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
fclose(f);