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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
// license:BSD-3-Clause
// copyright-holders:Aaron Giles, Vas Crabb
/***************************************************************************
rendertypes.h
Core renderer constants and structures for MAME.
***************************************************************************/
#ifndef MAME_EMU_RENDERTYPES_H
#define MAME_EMU_RENDERTYPES_H
#pragma once
#include <algorithm>
//**************************************************************************
// CONSTANTS
//**************************************************************************
// texture formats
enum texture_format
{
TEXFORMAT_UNDEFINED = 0, // require a format to be specified
TEXFORMAT_PALETTE16, // 16bpp palettized, no alpha
TEXFORMAT_RGB32, // 32bpp 8-8-8 RGB
TEXFORMAT_ARGB32, // 32bpp 8-8-8-8 ARGB
TEXFORMAT_YUY16 // 16bpp 8-8 Y/Cb, Y/Cr in sequence
};
// blending modes
enum
{
BLENDMODE_NONE = 0, // no blending
BLENDMODE_ALPHA, // standard alpha blend
BLENDMODE_RGB_MULTIPLY, // apply source alpha to source pix, then multiply RGB values
BLENDMODE_ADD, // apply source alpha to source pix, then add to destination
BLENDMODE_COUNT
};
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
// render_bounds - floating point bounding rectangle
struct render_bounds
{
float x0; // leftmost X coordinate
float y0; // topmost Y coordinate
float x1; // rightmost X coordinate
float y1; // bottommost Y coordinate
constexpr float width() const { return x1 - x0; }
constexpr float height() const { return y1 - y0; }
constexpr float aspect() const { return width() / height(); }
constexpr bool includes(float x, float y) const { return (x >= x0) && (x <= x1) && (y >= y0) && (y <= y1); }
// intersection
constexpr render_bounds operator&(render_bounds const &b) const
{
return render_bounds{ (std::max)(x0, b.x0), (std::max)(y0, b.y0), (std::min)(x1, b.x1), (std::min)(y1, b.y1) };
}
render_bounds &operator&=(render_bounds const &b)
{
x0 = (std::max)(x0, b.x0);
y0 = (std::max)(y0, b.y0);
x1 = (std::min)(x1, b.x1);
y1 = (std::min)(y1, b.y1);
return *this;
}
// union
constexpr render_bounds operator|(render_bounds const &b) const
{
return render_bounds{ (std::min)(x0, b.x0), (std::min)(y0, b.y0), (std::max)(x1, b.x1), (std::max)(y1, b.y1) };
}
render_bounds &operator|=(render_bounds const &b)
{
x0 = (std::min)(x0, b.x0);
y0 = (std::min)(y0, b.y0);
x1 = (std::max)(x1, b.x1);
y1 = (std::max)(y1, b.y1);
return *this;
}
render_bounds &set_xy(float left, float top, float right, float bottom)
{
x0 = left;
y0 = top;
x1 = right;
y1 = bottom;
return *this;
}
render_bounds &set_wh(float left, float top, float width, float height)
{
x0 = left;
y0 = top;
x1 = left + width;
y1 = top + height;
return *this;
}
};
// render_color - floating point set of ARGB values
struct render_color
{
float a; // alpha component (0.0 = transparent, 1.0 = opaque)
float r; // red component (0.0 = none, 1.0 = max)
float g; // green component (0.0 = none, 1.0 = max)
float b; // blue component (0.0 = none, 1.0 = max)
constexpr render_color operator*(render_color const &c) const
{
return render_color{ a * c.a, r * c.r, g * c.g, b * c.b };
}
render_color &operator*=(render_color const &c)
{
a *= c.a;
r *= c.r;
g *= c.g;
b *= c.b;
return *this;
}
render_color &set(float alpha, float red, float green, float blue)
{
a = alpha;
r = red;
g = green;
b = blue;
return *this;
}
};
// render_texuv - floating point set of UV texture coordinates
struct render_texuv
{
float u; // U coordinate (0.0-1.0)
float v; // V coordinate (0.0-1.0)
};
// render_quad_texuv - floating point set of UV texture coordinates
struct render_quad_texuv
{
render_texuv tl; // top-left UV coordinate
render_texuv tr; // top-right UV coordinate
render_texuv bl; // bottom-left UV coordinate
render_texuv br; // bottom-right UV coordinate
};
#endif // MAME_EMU_RENDERTYPES_H
|