annotate src/os/macosx/splash.cpp @ 18092:b00399731529 draft

(svn r22913) -Fix [OSX]: make splash work again and make it work without needing to bundle it first
author rubidium <rubidium@openttd.org>
date Fri, 09 Sep 2011 20:28:48 +0000
parents ea6373c142b4
children 8ac2645a140c
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
17882
28b460d98826 (svn r22678) -Doc: More doxygen sprinkles in MacOSX code and cocoa video driver
planetmaker <planetmaker@openttd.org>
parents: 16434
diff changeset
26 /**
28b460d98826 (svn r22678) -Doc: More doxygen sprinkles in MacOSX code and cocoa video driver
planetmaker <planetmaker@openttd.org>
parents: 16434
diff changeset
27 * Handle pnglib error.
28b460d98826 (svn r22678) -Doc: More doxygen sprinkles in MacOSX code and cocoa video driver
planetmaker <planetmaker@openttd.org>
parents: 16434
diff changeset
28 *
28b460d98826 (svn r22678) -Doc: More doxygen sprinkles in MacOSX code and cocoa video driver
planetmaker <planetmaker@openttd.org>
parents: 16434
diff changeset
29 * @param png_ptr Pointer to png struct.
28b460d98826 (svn r22678) -Doc: More doxygen sprinkles in MacOSX code and cocoa video driver
planetmaker <planetmaker@openttd.org>
parents: 16434
diff changeset
30 * @param message Error message text.
28b460d98826 (svn r22678) -Doc: More doxygen sprinkles in MacOSX code and cocoa video driver
planetmaker <planetmaker@openttd.org>
parents: 16434
diff changeset
31 */
5584
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_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
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, 0, "[libpng] error: %s - %s", message, (char *)png_get_error_ptr(png_ptr));
16434
3f7f29b10d96 (svn r21150) -Fix: [OSX] Deprecation warning with libpng 1.4
rubidium <rubidium@openttd.org>
parents: 15628
diff changeset
35 longjmp(png_jmpbuf(png_ptr), 1);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
36 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
37
17882
28b460d98826 (svn r22678) -Doc: More doxygen sprinkles in MacOSX code and cocoa video driver
planetmaker <planetmaker@openttd.org>
parents: 16434
diff changeset
38 /**
28b460d98826 (svn r22678) -Doc: More doxygen sprinkles in MacOSX code and cocoa video driver
planetmaker <planetmaker@openttd.org>
parents: 16434
diff changeset
39 * Handle warning in pnglib.
28b460d98826 (svn r22678) -Doc: More doxygen sprinkles in MacOSX code and cocoa video driver
planetmaker <planetmaker@openttd.org>
parents: 16434
diff changeset
40 *
28b460d98826 (svn r22678) -Doc: More doxygen sprinkles in MacOSX code and cocoa video driver
planetmaker <planetmaker@openttd.org>
parents: 16434
diff changeset
41 * @param png_ptr Pointer to png struct.
28b460d98826 (svn r22678) -Doc: More doxygen sprinkles in MacOSX code and cocoa video driver
planetmaker <planetmaker@openttd.org>
parents: 16434
diff changeset
42 * @param message Warning message text.
28b460d98826 (svn r22678) -Doc: More doxygen sprinkles in MacOSX code and cocoa video driver
planetmaker <planetmaker@openttd.org>
parents: 16434
diff changeset
43 */
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 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
45 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
46 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
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
17882
28b460d98826 (svn r22678) -Doc: More doxygen sprinkles in MacOSX code and cocoa video driver
planetmaker <planetmaker@openttd.org>
parents: 16434
diff changeset
49 /**
28b460d98826 (svn r22678) -Doc: More doxygen sprinkles in MacOSX code and cocoa video driver
planetmaker <planetmaker@openttd.org>
parents: 16434
diff changeset
50 * Display a splash image shown on startup (WITH_PNG).
28b460d98826 (svn r22678) -Doc: More doxygen sprinkles in MacOSX code and cocoa video driver
planetmaker <planetmaker@openttd.org>
parents: 16434
diff changeset
51 */
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
52 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
53 {
18092
b00399731529 (svn r22913) -Fix [OSX]: make splash work again and make it work without needing to bundle it first
rubidium <rubidium@openttd.org>
parents: 18024
diff changeset
54 FILE *f = FioFOpenFile(SPLASH_IMAGE_FILE, "r", BASESET_DIR);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
55 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
56
13363
4263b5bd13da (svn r17872) -Codechange: apply coding style to splash.cpp
smatz <smatz@openttd.org>
parents: 13362
diff changeset
57 png_byte header[8];
4263b5bd13da (svn r17872) -Codechange: apply coding style to splash.cpp
smatz <smatz@openttd.org>
parents: 13362
diff changeset
58 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
59 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
60 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
61 return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
62 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
63
13363
4263b5bd13da (svn r17872) -Codechange: apply coding style to splash.cpp
smatz <smatz@openttd.org>
parents: 13362
diff changeset
64 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
65
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
66 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
67 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
68 return;
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
13363
4263b5bd13da (svn r17872) -Codechange: apply coding style to splash.cpp
smatz <smatz@openttd.org>
parents: 13362
diff changeset
71 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
72 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
73 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
74 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
75 return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
76 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
77
13363
4263b5bd13da (svn r17872) -Codechange: apply coding style to splash.cpp
smatz <smatz@openttd.org>
parents: 13362
diff changeset
78 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
79 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
80 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
81 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
82 return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
83 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
84
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
85 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
86 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
87 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
88 return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
89 }
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 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
92 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
93
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
94 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
95
13363
4263b5bd13da (svn r17872) -Codechange: apply coding style to splash.cpp
smatz <smatz@openttd.org>
parents: 13362
diff changeset
96 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
97 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
98 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
99 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
100
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
101 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
102 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
103 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
104 return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
105 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
106
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
107 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
108 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
109 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
110 return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
111 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
112
13363
4263b5bd13da (svn r17872) -Codechange: apply coding style to splash.cpp
smatz <smatz@openttd.org>
parents: 13362
diff changeset
113 png_colorp palette;
4263b5bd13da (svn r17872) -Codechange: apply coding style to splash.cpp
smatz <smatz@openttd.org>
parents: 13362
diff changeset
114 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
115 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
116
13363
4263b5bd13da (svn r17872) -Codechange: apply coding style to splash.cpp
smatz <smatz@openttd.org>
parents: 13362
diff changeset
117 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
118
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
119 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
120 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
121
13363
4263b5bd13da (svn r17872) -Codechange: apply coding style to splash.cpp
smatz <smatz@openttd.org>
parents: 13362
diff changeset
122 uint xoff = (_screen.width - width) / 2;
4263b5bd13da (svn r17872) -Codechange: apply coding style to splash.cpp
smatz <smatz@openttd.org>
parents: 13362
diff changeset
123 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
124
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 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
126 case 8: {
13362
b14687ab0a88 (svn r17871) -Fix (r11342): memset() accepts only 1-byte argument
smatz <smatz@openttd.org>
parents: 12778
diff changeset
127 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
128 /* Initialize buffer */
b14687ab0a88 (svn r17871) -Fix (r11342): memset() accepts only 1-byte argument
smatz <smatz@openttd.org>
parents: 12778
diff changeset
129 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
130
13363
4263b5bd13da (svn r17872) -Codechange: apply coding style to splash.cpp
smatz <smatz@openttd.org>
parents: 13362
diff changeset
131 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
132 uint8 *src = row_pointers[y];
b14687ab0a88 (svn r17871) -Fix (r11342): memset() accepts only 1-byte argument
smatz <smatz@openttd.org>
parents: 12778
diff changeset
133 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
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 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
136 }
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
13363
4263b5bd13da (svn r17872) -Codechange: apply coding style to splash.cpp
smatz <smatz@openttd.org>
parents: 13362
diff changeset
138 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
139 _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
140 _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
141 _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
142 _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
143 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
144
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
145 _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
146 _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
147 _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
148 _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
149
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
150 _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
151 _pal_count_dirty = 256;
15628
84f84dbcec20 (svn r20291) -Codechange: Unify break coding style.
alberth <alberth@openttd.org>
parents: 15533
diff changeset
152 break;
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
153 }
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 case 32: {
13362
b14687ab0a88 (svn r17871) -Fix (r11342): memset() accepts only 1-byte argument
smatz <smatz@openttd.org>
parents: 12778
diff changeset
155 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
156 /* Initialize buffer */
b14687ab0a88 (svn r17871) -Fix (r11342): memset() accepts only 1-byte argument
smatz <smatz@openttd.org>
parents: 12778
diff changeset
157 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
158
13363
4263b5bd13da (svn r17872) -Codechange: apply coding style to splash.cpp
smatz <smatz@openttd.org>
parents: 13362
diff changeset
159 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
160 uint8 *src = row_pointers[y];
b14687ab0a88 (svn r17871) -Fix (r11342): memset() accepts only 1-byte argument
smatz <smatz@openttd.org>
parents: 12778
diff changeset
161 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
162
13363
4263b5bd13da (svn r17872) -Codechange: apply coding style to splash.cpp
smatz <smatz@openttd.org>
parents: 13362
diff changeset
163 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
164 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
165 }
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
166 }
15628
84f84dbcec20 (svn r20291) -Codechange: Unify break coding style.
alberth <alberth@openttd.org>
parents: 15533
diff changeset
167 break;
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
168 }
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
169 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
170
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
171 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
172 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
173 return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
174 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
175
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
176
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
177
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
178 #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
179
17882
28b460d98826 (svn r22678) -Doc: More doxygen sprinkles in MacOSX code and cocoa video driver
planetmaker <planetmaker@openttd.org>
parents: 16434
diff changeset
180 /**
28b460d98826 (svn r22678) -Doc: More doxygen sprinkles in MacOSX code and cocoa video driver
planetmaker <planetmaker@openttd.org>
parents: 16434
diff changeset
181 * Empty 'Display a splash image' routine (WITHOUT_PNG).
28b460d98826 (svn r22678) -Doc: More doxygen sprinkles in MacOSX code and cocoa video driver
planetmaker <planetmaker@openttd.org>
parents: 16434
diff changeset
182 */
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
183 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
184
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
185 #endif /* WITH_PNG */