src/os/macosx/splash.cpp
author smatz
Wed, 18 Jun 2008 21:19:04 +0000
changeset 11015 cf4b53f23fde
parent 10429 1b99254f9607
permissions -rw-r--r--
(svn r13571) -Codechange: define channels in struct Colour in different order on LE and BE machines
2847
5c667829bc67 (svn r3395) Add Id tag (and svn property) to macosx files.
peter1138
parents: 2736
diff changeset
     1
/* $Id$ */
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
     2
10429
1b99254f9607 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents: 8627
diff changeset
     3
/** @file splash.cpp Splash screen support for OSX. */
1b99254f9607 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents: 8627
diff changeset
     4
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
     5
#include "../../stdafx.h"
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
     6
#include "../../openttd.h"
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
     7
#include "../../variables.h"
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
     8
#include "../../debug.h"
8619
c2434269c3eb (svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents: 8611
diff changeset
     9
#include "../../gfx_func.h"
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    10
#include "../../fileio.h"
8288
56aec202d6f9 (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.
egladil
parents: 7888
diff changeset
    11
#include "../../blitter/factory.hpp"
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    12
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    13
#include "splash.h"
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    14
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    15
#ifdef WITH_PNG
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    16
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    17
#include <png.h>
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    18
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    19
static void PNGAPI png_my_error(png_structp png_ptr, png_const_charp message)
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    20
{
5576
1507181db210 (svn r7577) -Fix (r7565): Missed out some OSX files (Bjarni)
Darkvater
parents: 4300
diff changeset
    21
	DEBUG(misc, 0, "[libpng] error: %s - %s", message, (char *)png_get_error_ptr(png_ptr));
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    22
	longjmp(png_ptr->jmpbuf, 1);
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    23
}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    24
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    25
static void PNGAPI png_my_warning(png_structp png_ptr, png_const_charp message)
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    26
{
5576
1507181db210 (svn r7577) -Fix (r7565): Missed out some OSX files (Bjarni)
Darkvater
parents: 4300
diff changeset
    27
	DEBUG(misc, 1, "[libpng] warning: %s - %s", message, (char *)png_get_error_ptr(png_ptr));
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    28
}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    29
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 5835
diff changeset
    30
void DisplaySplashImage()
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    31
{
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    32
	png_byte header[8];
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    33
	FILE *f;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    34
	png_structp png_ptr;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    35
	png_infop info_ptr, end_info;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    36
	uint width, height, bit_depth, color_type;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    37
	png_colorp palette;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    38
	int num_palette;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    39
	png_bytep *row_pointers;
8288
56aec202d6f9 (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.
egladil
parents: 7888
diff changeset
    40
	uint8 *src;
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    41
	uint y;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    42
	uint xoff, yoff;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    43
	int i;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    44
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    45
	f = FioFOpenFile(SPLASH_IMAGE_FILE);
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    46
	if (f == NULL) return;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    47
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    48
	fread(header, 1, 8, f);
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    49
	if (png_sig_cmp(header, 0, 8) != 0) {
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    50
		fclose(f);
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    51
		return;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    52
	}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    53
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    54
	png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING, (png_voidp) NULL, png_my_error, png_my_warning);
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    55
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    56
	if (png_ptr == NULL) {
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    57
		fclose(f);
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    58
		return;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    59
	}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    60
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    61
	info_ptr = png_create_info_struct(png_ptr);
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    62
	if (info_ptr == NULL) {
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    63
		png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL);
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    64
		fclose(f);
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    65
		return;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    66
	}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    67
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    68
	end_info = png_create_info_struct(png_ptr);
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    69
	if (end_info == NULL) {
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    70
		png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    71
		fclose(f);
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    72
		return;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    73
	}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    74
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    75
	if (setjmp(png_jmpbuf(png_ptr))) {
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    76
		png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    77
		fclose(f);
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    78
		return;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    79
	}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    80
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    81
	png_init_io(png_ptr, f);
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    82
	png_set_sig_bytes(png_ptr, 8);
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    83
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    84
	png_read_png(png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, NULL);
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    85
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    86
	width            = png_get_image_width(png_ptr, info_ptr);
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    87
	height           = png_get_image_height(png_ptr, info_ptr);
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    88
	bit_depth        = png_get_bit_depth(png_ptr, info_ptr);
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    89
	color_type       = png_get_color_type(png_ptr, info_ptr);
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    90
2953
310f58987d7b (svn r3512) Yet more whitespace fixes (mostly by Rubidium)
peter1138
parents: 2847
diff changeset
    91
	if (color_type != PNG_COLOR_TYPE_PALETTE || bit_depth != 8) {
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    92
		png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    93
		fclose(f);
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    94
		return;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    95
	}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    96
2953
310f58987d7b (svn r3512) Yet more whitespace fixes (mostly by Rubidium)
peter1138
parents: 2847
diff changeset
    97
	if (!png_get_valid(png_ptr, info_ptr, PNG_INFO_PLTE)) {
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    98
		png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
    99
		fclose(f);
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   100
		return;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   101
	}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   102
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   103
	png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette);
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   104
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   105
	row_pointers = png_get_rows(png_ptr, info_ptr);
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   106
2953
310f58987d7b (svn r3512) Yet more whitespace fixes (mostly by Rubidium)
peter1138
parents: 2847
diff changeset
   107
	if (width > (uint) _screen.width) width = _screen.width;
310f58987d7b (svn r3512) Yet more whitespace fixes (mostly by Rubidium)
peter1138
parents: 2847
diff changeset
   108
	if (height > (uint) _screen.height) height = _screen.height;
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   109
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   110
	xoff = (_screen.width - width) / 2;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   111
	yoff = (_screen.height - height) / 2;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   112
8288
56aec202d6f9 (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.
egladil
parents: 7888
diff changeset
   113
	switch (BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth()) {
56aec202d6f9 (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.
egladil
parents: 7888
diff changeset
   114
		case 8: {
56aec202d6f9 (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.
egladil
parents: 7888
diff changeset
   115
				uint8 *dst;
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   116
8288
56aec202d6f9 (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.
egladil
parents: 7888
diff changeset
   117
				memset(_screen.dst_ptr, 0xff, _screen.pitch * _screen.height);
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   118
8288
56aec202d6f9 (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.
egladil
parents: 7888
diff changeset
   119
				for (y = 0; y < height; y++) {
56aec202d6f9 (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.
egladil
parents: 7888
diff changeset
   120
					src = row_pointers[y];
56aec202d6f9 (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.
egladil
parents: 7888
diff changeset
   121
					dst = ((uint8 *) _screen.dst_ptr) + (yoff + y) * _screen.pitch + xoff;
56aec202d6f9 (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.
egladil
parents: 7888
diff changeset
   122
56aec202d6f9 (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.
egladil
parents: 7888
diff changeset
   123
					memcpy(dst, src, width);
56aec202d6f9 (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.
egladil
parents: 7888
diff changeset
   124
				}
56aec202d6f9 (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.
egladil
parents: 7888
diff changeset
   125
56aec202d6f9 (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.
egladil
parents: 7888
diff changeset
   126
				for (i = 0; i < num_palette; i++) {
11015
cf4b53f23fde (svn r13571) -Codechange: define channels in struct Colour in different order on LE and BE machines
smatz
parents: 10429
diff changeset
   127
					_cur_palette[i].a = i == 0 ? 0 : 0xff;
8288
56aec202d6f9 (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.
egladil
parents: 7888
diff changeset
   128
					_cur_palette[i].r = palette[i].red;
56aec202d6f9 (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.
egladil
parents: 7888
diff changeset
   129
					_cur_palette[i].g = palette[i].green;
56aec202d6f9 (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.
egladil
parents: 7888
diff changeset
   130
					_cur_palette[i].b = palette[i].blue;
56aec202d6f9 (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.
egladil
parents: 7888
diff changeset
   131
				}
56aec202d6f9 (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.
egladil
parents: 7888
diff changeset
   132
11015
cf4b53f23fde (svn r13571) -Codechange: define channels in struct Colour in different order on LE and BE machines
smatz
parents: 10429
diff changeset
   133
				_cur_palette[0xff].a = 0xff;
8288
56aec202d6f9 (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.
egladil
parents: 7888
diff changeset
   134
				_cur_palette[0xff].r = 0;
56aec202d6f9 (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.
egladil
parents: 7888
diff changeset
   135
				_cur_palette[0xff].g = 0;
56aec202d6f9 (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.
egladil
parents: 7888
diff changeset
   136
				_cur_palette[0xff].b = 0;
56aec202d6f9 (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.
egladil
parents: 7888
diff changeset
   137
56aec202d6f9 (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.
egladil
parents: 7888
diff changeset
   138
				_pal_first_dirty = 0;
56aec202d6f9 (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.
egladil
parents: 7888
diff changeset
   139
				_pal_count_dirty = 256;
56aec202d6f9 (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.
egladil
parents: 7888
diff changeset
   140
			}
56aec202d6f9 (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.
egladil
parents: 7888
diff changeset
   141
			break;
56aec202d6f9 (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.
egladil
parents: 7888
diff changeset
   142
		case 32: {
56aec202d6f9 (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.
egladil
parents: 7888
diff changeset
   143
				uint32 *dst;
8297
42ea2efa179f (svn r11351) -Fix (r11342): [OSX] killed a warning
bjarni
parents: 8288
diff changeset
   144
				uint x;
8288
56aec202d6f9 (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.
egladil
parents: 7888
diff changeset
   145
56aec202d6f9 (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.
egladil
parents: 7888
diff changeset
   146
				memset(_screen.dst_ptr, 0xff000000, _screen.pitch * _screen.height * 4);
56aec202d6f9 (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.
egladil
parents: 7888
diff changeset
   147
56aec202d6f9 (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.
egladil
parents: 7888
diff changeset
   148
				for (y = 0; y < height; y++) {
56aec202d6f9 (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.
egladil
parents: 7888
diff changeset
   149
					src = row_pointers[y];
56aec202d6f9 (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.
egladil
parents: 7888
diff changeset
   150
					dst = ((uint32 *) _screen.dst_ptr) + (yoff + y) * _screen.pitch + xoff;
56aec202d6f9 (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.
egladil
parents: 7888
diff changeset
   151
56aec202d6f9 (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.
egladil
parents: 7888
diff changeset
   152
					for (x = 0; x < width; x++)
56aec202d6f9 (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.
egladil
parents: 7888
diff changeset
   153
						dst[x] = palette[src[x]].blue | (palette[src[x]].green << 8) | (palette[src[x]].red << 16) | 0xff000000;
56aec202d6f9 (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.
egladil
parents: 7888
diff changeset
   154
				}
56aec202d6f9 (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.
egladil
parents: 7888
diff changeset
   155
			}
56aec202d6f9 (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.
egladil
parents: 7888
diff changeset
   156
			break;
56aec202d6f9 (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.
egladil
parents: 7888
diff changeset
   157
	}
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   158
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   159
	png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   160
	fclose(f);
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   161
	return;
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   162
}
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   163
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   164
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   165
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 2953
diff changeset
   166
#else /* WITH_PNG */
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   167
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 5835
diff changeset
   168
void DisplaySplashImage() {}
2736
1ea068235989 (svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
diff changeset
   169
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 2953
diff changeset
   170
#endif /* WITH_PNG */