-
Notifications
You must be signed in to change notification settings - Fork 9
/
PixelToaster.cpp
executable file
·120 lines (105 loc) · 4.45 KB
/
PixelToaster.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// PixelToaster Implementation
// Copyright © 2004-2007 Glenn Fiedler
// Part of the PixelToaster Framebuffer Library - http://www.pixeltoaster.com
#ifndef PIXELTOASTER_NO_CRT
# include <cassert>
#else
# define assert(condition)
#endif
#include "PixelToaster.h"
#include "PixelToasterCommon.h"
#include "PixelToasterConversion.h"
#if PIXELTOASTER_PLATFORM == PIXELTOASTER_UNIX
# include "PixelToasterUnix.h"
# define TimerClass UnixTimer
# define DisplayClass UnixDisplay
#endif
#if PIXELTOASTER_PLATFORM == PIXELTOASTER_APPLE
# include "PixelToasterApple.h"
# define TimerClass AppleTimer
# define DisplayClass AppleDisplay
#endif
#if PIXELTOASTER_PLATFORM == PIXELTOASTER_WINDOWS
# include "PixelToasterWindows.h"
# define TimerClass WindowsTimer
# define DisplayClass WindowsDisplay
#endif
#if PIXELTOASTER_PLATFORM == PIXELTOASTER_NULL
# define TimerClass PortableTimer
# define DisplayClass DisplayAdapter
#endif
#if !defined(DisplayClass) || !defined(TimerClass)
# error unknown pixeltoaster platform!
#endif
PIXELTOASTER_API PixelToaster::DisplayInterface* PixelToaster::createDisplay()
{
#ifdef DisplayClass
return new DisplayClass();
#else
return nullptr;
#endif
}
PIXELTOASTER_API PixelToaster::TimerInterface* PixelToaster::createTimer()
{
#ifdef TimerClass
return new TimerClass();
#else
return nullptr;
#endif
}
PixelToaster::Converter_XBGRFFFF_to_XBGRFFFF converter_XBGRFFFF_to_XBGRFFFF;
PixelToaster::Converter_XBGRFFFF_to_XRGB8888 converter_XBGRFFFF_to_XRGB8888;
PixelToaster::Converter_XBGRFFFF_to_XBGR8888 converter_XBGRFFFF_to_XBGR8888;
PixelToaster::Converter_XBGRFFFF_to_RGB888 converter_XBGRFFFF_to_RGB888;
PixelToaster::Converter_XBGRFFFF_to_BGR888 converter_XBGRFFFF_to_BGR888;
PixelToaster::Converter_XBGRFFFF_to_RGB565 converter_XBGRFFFF_to_RGB565;
PixelToaster::Converter_XBGRFFFF_to_BGR565 converter_XBGRFFFF_to_BGR565;
PixelToaster::Converter_XBGRFFFF_to_XRGB1555 converter_XBGRFFFF_to_XRGB1555;
PixelToaster::Converter_XBGRFFFF_to_XBGR1555 converter_XBGRFFFF_to_XBGR1555;
PixelToaster::Converter_XRGB8888_to_XBGRFFFF converter_XRGB8888_to_XBGRFFFF;
PixelToaster::Converter_XRGB8888_to_XRGB8888 converter_XRGB8888_to_XRGB8888;
PixelToaster::Converter_XRGB8888_to_XBGR8888 converter_XRGB8888_to_XBGR8888;
PixelToaster::Converter_XRGB8888_to_RGB888 converter_XRGB8888_to_RGB888;
PixelToaster::Converter_XRGB8888_to_BGR888 converter_XRGB8888_to_BGR888;
PixelToaster::Converter_XRGB8888_to_RGB565 converter_XRGB8888_to_RGB565;
PixelToaster::Converter_XRGB8888_to_BGR565 converter_XRGB8888_to_BGR565;
PixelToaster::Converter_XRGB8888_to_XRGB1555 converter_XRGB8888_to_XRGB1555;
PixelToaster::Converter_XRGB8888_to_XBGR1555 converter_XRGB8888_to_XBGR1555;
PIXELTOASTER_API PixelToaster::Converter* PixelToaster::requestConverter(PixelToaster::Format source, PixelToaster::Format destination)
{
if (source == Format::XBGRFFFF)
{
switch (destination)
{
case Format::XBGRFFFF: return &converter_XBGRFFFF_to_XBGRFFFF;
case Format::XRGB8888: return &converter_XBGRFFFF_to_XRGB8888;
case Format::XBGR8888: return &converter_XBGRFFFF_to_XBGR8888;
case Format::RGB888: return &converter_XBGRFFFF_to_RGB888;
case Format::BGR888: return &converter_XBGRFFFF_to_BGR888;
case Format::RGB565: return &converter_XBGRFFFF_to_RGB565;
case Format::BGR565: return &converter_XBGRFFFF_to_BGR565;
case Format::XRGB1555: return &converter_XBGRFFFF_to_XRGB1555;
case Format::XBGR1555: return &converter_XBGRFFFF_to_XBGR1555;
default:
return nullptr;
}
}
else if (source == Format::XRGB8888)
{
switch (destination)
{
case Format::XBGRFFFF: return &converter_XRGB8888_to_XBGRFFFF;
case Format::XRGB8888: return &converter_XRGB8888_to_XRGB8888;
case Format::XBGR8888: return &converter_XRGB8888_to_XBGR8888;
case Format::RGB888: return &converter_XRGB8888_to_RGB888;
case Format::BGR888: return &converter_XRGB8888_to_BGR888;
case Format::RGB565: return &converter_XRGB8888_to_RGB565;
case Format::BGR565: return &converter_XRGB8888_to_BGR565;
case Format::XRGB1555: return &converter_XRGB8888_to_XRGB1555;
case Format::XBGR1555: return &converter_XRGB8888_to_XBGR1555;
default:
return nullptr;
}
}
return nullptr;
}