annotate src/os/macosx/splash.cpp @ 15533:b6a87cffd56b draft

(svn r20192) -Cleanup: bye bye variables.h, bye bye VARDEF... you won't be missed :)
author rubidium <rubidium@openttd.org>
date Mon, 19 Jul 2010 17:28:27 +0000
parents 4263b5bd13da
children 84f84dbcec20
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1 /* $Id$ */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2
12778
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 10040
diff changeset
3 /*
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 10040
diff changeset
4 * This file is part of OpenTTD.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 10040
diff changeset
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 10040
diff changeset
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 10040
diff changeset
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 10040
diff changeset
8 */
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 10040
diff changeset
9
9111
d48433370037 (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 <rubidium@openttd.org>
parents: 8131
diff changeset
10 /** @file splash.cpp Splash screen support for OSX. */
d48433370037 (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 <rubidium@openttd.org>
parents: 8131
diff changeset
11
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
12 #include "../../stdafx.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
13 #include "../../openttd.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
14 #include "../../debug.h"
8123
c26c28875749 (svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents: 8115
diff changeset
15 #include "../../gfx_func.h"
10040
8cb9b58b1030 (svn r14200) -Fix (r14199): some OSes failed to compile. Furthermore I hate wrong comments!
rubidium <rubidium@openttd.org>
parents: 9551
diff changeset
16 #include "../../fileio_func.h"
7792
6810bd9fc1dc (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 <egladil@openttd.org>
parents: 7392
diff changeset
17 #include "../../blitter/factory.hpp"
13362
b14687ab0a88 (svn r17871) -Fix (r11342): memset() accepts only 1-byte argument
smatz <smatz@openttd.org>
parents: 12778
diff changeset
18 #include "../../core/mem_func.hpp"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
19
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
20 #include "splash.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
21
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
22 #ifdef WITH_PNG
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
23
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
24 #include <png.h>
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
25
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
26 static void PNGAPI png_my_error(png_structp png_ptr, png_const_charp message)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
27 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
28 DEBUG(misc, 0, "[libpng] error: %s - %s", message, (char *)png_get_error_ptr(png_ptr));
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
29 longjmp(png_ptr->jmpbuf, 1);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
30 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
31
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
32 static void PNGAPI png_my_warning(png_structp png_ptr, png_const_charp message)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
33 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
34 DEBUG(misc, 1, "[libpng] warning: %s - %s", message, (char *)png_get_error_ptr(png_ptr));
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
35 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
36
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
37 void DisplaySplashImage()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
38 {
13363
4263b5bd13da (svn r17872) -Codechange: apply coding style to splash.cpp
smatz <smatz@openttd.org>
parents: 13362
diff changeset
39 FILE *f = FioFOpenFile(SPLASH_IMAGE_FILE);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
40 if (f == NULL) return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
41
13363
4263b5bd13da (svn r17872) -Codechange: apply coding style to splash.cpp
smatz <smatz@openttd.org>
parents: 13362
diff changeset
42 png_byte header[8];
4263b5bd13da (svn r17872) -Codechange: apply coding style to splash.cpp
smatz <smatz@openttd.org>
parents: 13362
diff changeset
43 fread(header, sizeof(png_byte), 8, f);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
44 if (png_sig_cmp(header, 0, 8) != 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
45 fclose(f);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
46 return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
47 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
48
13363
4263b5bd13da (svn r17872) -Codechange: apply coding style to splash.cpp
smatz <smatz@openttd.org>
parents: 13362
diff changeset
49 png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, (png_voidp) NULL, png_my_error, png_my_warning);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
50
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
51 if (png_ptr == NULL) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
52 fclose(f);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
53 return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
54 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
55
13363
4263b5bd13da (svn r17872) -Codechange: apply coding style to splash.cpp
smatz <smatz@openttd.org>
parents: 13362
diff changeset
56 png_infop info_ptr = png_create_info_struct(png_ptr);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
57 if (info_ptr == NULL) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
58 png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
59 fclose(f);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
60 return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
61 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
62
13363
4263b5bd13da (svn r17872) -Codechange: apply coding style to splash.cpp
smatz <smatz@openttd.org>
parents: 13362
diff changeset
63 png_infop end_info = png_create_info_struct(png_ptr);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
64 if (end_info == NULL) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
65 png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
66 fclose(f);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
67 return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
68 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
69
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
70 if (setjmp(png_jmpbuf(png_ptr))) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
71 png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
72 fclose(f);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
73 return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
74 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
75
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
76 png_init_io(png_ptr, f);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
77 png_set_sig_bytes(png_ptr, 8);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
78
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
79 png_read_png(png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, NULL);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
80
13363
4263b5bd13da (svn r17872) -Codechange: apply coding style to splash.cpp
smatz <smatz@openttd.org>
parents: 13362
diff changeset
81 uint width = png_get_image_width(png_ptr, info_ptr);
4263b5bd13da (svn r17872) -Codechange: apply coding style to splash.cpp
smatz <smatz@openttd.org>
parents: 13362
diff changeset
82 uint height = png_get_image_height(png_ptr, info_ptr);
4263b5bd13da (svn r17872) -Codechange: apply coding style to splash.cpp
smatz <smatz@openttd.org>
parents: 13362
diff changeset
83 uint bit_depth = png_get_bit_depth(png_ptr, info_ptr);
4263b5bd13da (svn r17872) -Codechange: apply coding style to splash.cpp
smatz <smatz@openttd.org>
parents: 13362
diff changeset
84 uint color_type = png_get_color_type(png_ptr, info_ptr);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
85
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
86 if (color_type != PNG_COLOR_TYPE_PALETTE || bit_depth != 8) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
87 png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
88 fclose(f);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
89 return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
90 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
91
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
92 if (!png_get_valid(png_ptr, info_ptr, PNG_INFO_PLTE)) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
93 png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
94 fclose(f);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
95 return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
96 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
97
13363
4263b5bd13da (svn r17872) -Codechange: apply coding style to splash.cpp
smatz <smatz@openttd.org>
parents: 13362
diff changeset
98 png_colorp palette;
4263b5bd13da (svn r17872) -Codechange: apply coding style to splash.cpp
smatz <smatz@openttd.org>
parents: 13362
diff changeset
99 int num_palette;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
100 png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
101
13363
4263b5bd13da (svn r17872) -Codechange: apply coding style to splash.cpp
smatz <smatz@openttd.org>
parents: 13362
diff changeset
102 png_bytep *row_pointers = png_get_rows(png_ptr, info_ptr);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
103
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
104 if (width > (uint) _screen.width) width = _screen.width;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
105 if (height > (uint) _screen.height) height = _screen.height;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
106
13363
4263b5bd13da (svn r17872) -Codechange: apply coding style to splash.cpp
smatz <smatz@openttd.org>
parents: 13362
diff changeset
107 uint xoff = (_screen.width - width) / 2;
4263b5bd13da (svn r17872) -Codechange: apply coding style to splash.cpp
smatz <smatz@openttd.org>
parents: 13362
diff changeset
108 uint yoff = (_screen.height - height) / 2;
7792
6810bd9fc1dc (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 <egladil@openttd.org>
parents: 7392
diff changeset
109
6810bd9fc1dc (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 <egladil@openttd.org>
parents: 7392
diff changeset
110 switch (BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth()) {
6810bd9fc1dc (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 <egladil@openttd.org>
parents: 7392
diff changeset
111 case 8: {
13362
b14687ab0a88 (svn r17871) -Fix (r11342): memset() accepts only 1-byte argument
smatz <smatz@openttd.org>
parents: 12778
diff changeset
112 uint8 *dst_ptr = (uint8 *)_screen.dst_ptr;
b14687ab0a88 (svn r17871) -Fix (r11342): memset() accepts only 1-byte argument
smatz <smatz@openttd.org>
parents: 12778
diff changeset
113 /* Initialize buffer */
b14687ab0a88 (svn r17871) -Fix (r11342): memset() accepts only 1-byte argument
smatz <smatz@openttd.org>
parents: 12778
diff changeset
114 MemSetT(dst_ptr, 0xff, _screen.pitch * _screen.height);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
115
13363
4263b5bd13da (svn r17872) -Codechange: apply coding style to splash.cpp
smatz <smatz@openttd.org>
parents: 13362
diff changeset
116 for (uint y = 0; y < height; y++) {
13362
b14687ab0a88 (svn r17871) -Fix (r11342): memset() accepts only 1-byte argument
smatz <smatz@openttd.org>
parents: 12778
diff changeset
117 uint8 *src = row_pointers[y];
b14687ab0a88 (svn r17871) -Fix (r11342): memset() accepts only 1-byte argument
smatz <smatz@openttd.org>
parents: 12778
diff changeset
118 uint8 *dst = dst_ptr + (yoff + y) * _screen.pitch + xoff;
7792
6810bd9fc1dc (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 <egladil@openttd.org>
parents: 7392
diff changeset
119
6810bd9fc1dc (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 <egladil@openttd.org>
parents: 7392
diff changeset
120 memcpy(dst, src, width);
6810bd9fc1dc (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 <egladil@openttd.org>
parents: 7392
diff changeset
121 }
6810bd9fc1dc (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 <egladil@openttd.org>
parents: 7392
diff changeset
122
13363
4263b5bd13da (svn r17872) -Codechange: apply coding style to splash.cpp
smatz <smatz@openttd.org>
parents: 13362
diff changeset
123 for (int i = 0; i < num_palette; i++) {
9551
8849c20f82c0 (svn r13571) -Codechange: define channels in struct Colour in different order on LE and BE machines
smatz <smatz@openttd.org>
parents: 9111
diff changeset
124 _cur_palette[i].a = i == 0 ? 0 : 0xff;
7792
6810bd9fc1dc (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 <egladil@openttd.org>
parents: 7392
diff changeset
125 _cur_palette[i].r = palette[i].red;
6810bd9fc1dc (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 <egladil@openttd.org>
parents: 7392
diff changeset
126 _cur_palette[i].g = palette[i].green;
6810bd9fc1dc (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 <egladil@openttd.org>
parents: 7392
diff changeset
127 _cur_palette[i].b = palette[i].blue;
6810bd9fc1dc (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 <egladil@openttd.org>
parents: 7392
diff changeset
128 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
129
9551
8849c20f82c0 (svn r13571) -Codechange: define channels in struct Colour in different order on LE and BE machines
smatz <smatz@openttd.org>
parents: 9111
diff changeset
130 _cur_palette[0xff].a = 0xff;
7792
6810bd9fc1dc (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 <egladil@openttd.org>
parents: 7392
diff changeset
131 _cur_palette[0xff].r = 0;
6810bd9fc1dc (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 <egladil@openttd.org>
parents: 7392
diff changeset
132 _cur_palette[0xff].g = 0;
6810bd9fc1dc (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 <egladil@openttd.org>
parents: 7392
diff changeset
133 _cur_palette[0xff].b = 0;
6810bd9fc1dc (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 <egladil@openttd.org>
parents: 7392
diff changeset
134
6810bd9fc1dc (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 <egladil@openttd.org>
parents: 7392
diff changeset
135 _pal_first_dirty = 0;
6810bd9fc1dc (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 <egladil@openttd.org>
parents: 7392
diff changeset
136 _pal_count_dirty = 256;
6810bd9fc1dc (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 <egladil@openttd.org>
parents: 7392
diff changeset
137 }
6810bd9fc1dc (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 <egladil@openttd.org>
parents: 7392
diff changeset
138 break;
6810bd9fc1dc (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 <egladil@openttd.org>
parents: 7392
diff changeset
139 case 32: {
13362
b14687ab0a88 (svn r17871) -Fix (r11342): memset() accepts only 1-byte argument
smatz <smatz@openttd.org>
parents: 12778
diff changeset
140 uint32 *dst_ptr = (uint32 *)_screen.dst_ptr;
b14687ab0a88 (svn r17871) -Fix (r11342): memset() accepts only 1-byte argument
smatz <smatz@openttd.org>
parents: 12778
diff changeset
141 /* Initialize buffer */
b14687ab0a88 (svn r17871) -Fix (r11342): memset() accepts only 1-byte argument
smatz <smatz@openttd.org>
parents: 12778
diff changeset
142 MemSetT(dst_ptr, 0, _screen.pitch * _screen.height);
7792
6810bd9fc1dc (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 <egladil@openttd.org>
parents: 7392
diff changeset
143
13363
4263b5bd13da (svn r17872) -Codechange: apply coding style to splash.cpp
smatz <smatz@openttd.org>
parents: 13362
diff changeset
144 for (uint y = 0; y < height; y++) {
13362
b14687ab0a88 (svn r17871) -Fix (r11342): memset() accepts only 1-byte argument
smatz <smatz@openttd.org>
parents: 12778
diff changeset
145 uint8 *src = row_pointers[y];
b14687ab0a88 (svn r17871) -Fix (r11342): memset() accepts only 1-byte argument
smatz <smatz@openttd.org>
parents: 12778
diff changeset
146 uint32 *dst = dst_ptr + (yoff + y) * _screen.pitch + xoff;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
147
13363
4263b5bd13da (svn r17872) -Codechange: apply coding style to splash.cpp
smatz <smatz@openttd.org>
parents: 13362
diff changeset
148 for (uint x = 0; x < width; x++) {
7792
6810bd9fc1dc (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 <egladil@openttd.org>
parents: 7392
diff changeset
149 dst[x] = palette[src[x]].blue | (palette[src[x]].green << 8) | (palette[src[x]].red << 16) | 0xff000000;
13362
b14687ab0a88 (svn r17871) -Fix (r11342): memset() accepts only 1-byte argument
smatz <smatz@openttd.org>
parents: 12778
diff changeset
150 }
7792
6810bd9fc1dc (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 <egladil@openttd.org>
parents: 7392
diff changeset
151 }
6810bd9fc1dc (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 <egladil@openttd.org>
parents: 7392
diff changeset
152 }
6810bd9fc1dc (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 <egladil@openttd.org>
parents: 7392
diff changeset
153 break;
6810bd9fc1dc (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 <egladil@openttd.org>
parents: 7392
diff changeset
154 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
155
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
156 png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
157 fclose(f);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
158 return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
159 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
160
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
161
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
162
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
163 #else /* WITH_PNG */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
164
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
165 void DisplaySplashImage() {}
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
166
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
167 #endif /* WITH_PNG */