openMSX
SDLOutputSurface.cc
Go to the documentation of this file.
1#include "SDLOutputSurface.hh"
2#include "unreachable.hh"
3
4namespace openmsx {
5
7 : surface(surface_)
8{
9 assert(surface);
10 if (SDL_MUSTLOCK(surface)) {
11 // Note: we ignore the return value from SDL_LockSurface()
12 SDL_LockSurface(surface);
13 }
14}
15
17{
18 if (SDL_MUSTLOCK(surface)) {
19 SDL_UnlockSurface(surface);
20 }
21}
22
23
24void SDLOutputSurface::setSDLPixelFormat(const SDL_PixelFormat& format)
25{
26 auto bpp = format.BitsPerPixel;
27
28 auto Rmask = format.Rmask;
29 auto Rshift = format.Rshift;
30 auto Rloss = format.Rloss;
31
32 auto Gmask = format.Gmask;
33 auto Gshift = format.Gshift;
34 auto Gloss = format.Gloss;
35
36 auto Bmask = format.Bmask;
37 auto Bshift = format.Bshift;
38 auto Bloss = format.Bloss;
39
40 auto Amask = format.Amask;
41 auto Ashift = format.Ashift;
42 auto Aloss = format.Aloss;
43
44 // TODO is this still needed with SDL2?
45 // SDL sets an alpha channel only for GL modes. We want an alpha channel
46 // for all 32bpp output surfaces, so we add one ourselves if necessary.
47 if (bpp == 32 && Amask == 0) {
48 unsigned rgbMask = Rmask | Gmask | Bmask;
49 if ((rgbMask & 0x000000FF) == 0) {
50 Amask = 0x000000FF;
51 Ashift = 0;
52 Aloss = 0;
53 } else if ((rgbMask & 0xFF000000) == 0) {
54 Amask = 0xFF000000;
55 Ashift = 24;
56 Aloss = 0;
57 } else {
59 }
60 }
61
63 Rmask, Rshift, Rloss,
64 Gmask, Gshift, Gloss,
65 Bmask, Bshift, Bloss,
66 Amask, Ashift, Aloss));
67}
68
69} // namespace openmsx
void setPixelFormat(const PixelFormat &format)
SDLDirectPixelAccess(SDL_Surface *surface_)
void setSDLPixelFormat(const SDL_PixelFormat &format)
void format(SectorAccessibleDisk &disk, MSXBootSectorType bootType)
Format the given disk (= a single partition).
This file implemented 3 utility functions:
Definition: Autofire.cc:9
#define UNREACHABLE
Definition: unreachable.hh:38