mirror of https://github.com/encounter/SDL.git
parent
ec58a817ef
commit
389ffab733
25
src/SDL.c
25
src/SDL.c
|
@ -124,18 +124,19 @@ static Uint8 SDL_SubsystemRefCount[ 32 ];
|
||||||
static void
|
static void
|
||||||
SDL_PrivateSubsystemRefCountIncr(Uint32 subsystem)
|
SDL_PrivateSubsystemRefCountIncr(Uint32 subsystem)
|
||||||
{
|
{
|
||||||
int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
||||||
SDL_assert(subsystem_index < 0 || SDL_SubsystemRefCount[subsystem_index] < 255);
|
SDL_assert((subsystem_index < 0) || (SDL_SubsystemRefCount[subsystem_index] < 255));
|
||||||
if (subsystem_index >= 0)
|
if (subsystem_index >= 0) {
|
||||||
++SDL_SubsystemRefCount[subsystem_index];
|
++SDL_SubsystemRefCount[subsystem_index];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Private helper to decrement a subsystem's ref counter. */
|
/* Private helper to decrement a subsystem's ref counter. */
|
||||||
static void
|
static void
|
||||||
SDL_PrivateSubsystemRefCountDecr(Uint32 subsystem)
|
SDL_PrivateSubsystemRefCountDecr(Uint32 subsystem)
|
||||||
{
|
{
|
||||||
int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
||||||
if (subsystem_index >= 0 && SDL_SubsystemRefCount[subsystem_index] > 0) {
|
if ((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] > 0)) {
|
||||||
--SDL_SubsystemRefCount[subsystem_index];
|
--SDL_SubsystemRefCount[subsystem_index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,23 +145,23 @@ SDL_PrivateSubsystemRefCountDecr(Uint32 subsystem)
|
||||||
static SDL_bool
|
static SDL_bool
|
||||||
SDL_PrivateShouldInitSubsystem(Uint32 subsystem)
|
SDL_PrivateShouldInitSubsystem(Uint32 subsystem)
|
||||||
{
|
{
|
||||||
int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
||||||
SDL_assert(subsystem_index < 0 || SDL_SubsystemRefCount[subsystem_index] < 255);
|
SDL_assert((subsystem_index < 0) || (SDL_SubsystemRefCount[subsystem_index] < 255));
|
||||||
return (subsystem_index >= 0 && SDL_SubsystemRefCount[subsystem_index] == 0) ? SDL_TRUE : SDL_FALSE;
|
return ((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 0)) ? SDL_TRUE : SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Private helper to check if a system needs to be quit. */
|
/* Private helper to check if a system needs to be quit. */
|
||||||
static SDL_bool
|
static SDL_bool
|
||||||
SDL_PrivateShouldQuitSubsystem(Uint32 subsystem) {
|
SDL_PrivateShouldQuitSubsystem(Uint32 subsystem) {
|
||||||
int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
||||||
if (subsystem_index >= 0 && SDL_SubsystemRefCount[subsystem_index] == 0) {
|
if ((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 0)) {
|
||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we're in SDL_Quit, we shut down every subsystem, even if refcount
|
/* If we're in SDL_Quit, we shut down every subsystem, even if refcount
|
||||||
* isn't zero.
|
* isn't zero.
|
||||||
*/
|
*/
|
||||||
return ((subsystem_index >= 0 && SDL_SubsystemRefCount[subsystem_index] == 1) || SDL_bInMainQuit) ? SDL_TRUE : SDL_FALSE;
|
return (((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 1)) || SDL_bInMainQuit) ? SDL_TRUE : SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -169,8 +169,9 @@ HIDAPI_DriverShield_SendCommand(SDL_HIDAPI_Device *device, Uint8 cmd, const void
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Zero unused data in the payload */
|
/* Zero unused data in the payload */
|
||||||
if (size != sizeof(cmd_pkt.payload))
|
if (size != sizeof(cmd_pkt.payload)) {
|
||||||
SDL_memset(&cmd_pkt.payload[size], 0, sizeof(cmd_pkt.payload) - size);
|
SDL_memset(&cmd_pkt.payload[size], 0, sizeof(cmd_pkt.payload) - size);
|
||||||
|
}
|
||||||
|
|
||||||
if (SDL_HIDAPI_SendRumbleAndUnlock(device, (Uint8*)&cmd_pkt, sizeof(cmd_pkt)) != sizeof(cmd_pkt)) {
|
if (SDL_HIDAPI_SendRumbleAndUnlock(device, (Uint8*)&cmd_pkt, sizeof(cmd_pkt)) != sizeof(cmd_pkt)) {
|
||||||
return SDL_SetError("Couldn't send command packet");
|
return SDL_SetError("Couldn't send command packet");
|
||||||
|
|
|
@ -603,8 +603,10 @@ SDL_ConvertPixels_ARGB8888_to_YUV(int width, int height, const void *src, int sr
|
||||||
|
|
||||||
if (GetYUVPlanes(width, height, dst_format, dst, dst_pitch,
|
if (GetYUVPlanes(width, height, dst_format, dst, dst_pitch,
|
||||||
(const Uint8 **)&plane_y, (const Uint8 **)&plane_u, (const Uint8 **)&plane_v,
|
(const Uint8 **)&plane_y, (const Uint8 **)&plane_u, (const Uint8 **)&plane_v,
|
||||||
&y_stride, &uv_stride) != 0)
|
&y_stride, &uv_stride) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
plane_interleaved_uv = (plane_y + height * y_stride);
|
plane_interleaved_uv = (plane_y + height * y_stride);
|
||||||
y_skip = (y_stride - width);
|
y_skip = (y_stride - width);
|
||||||
|
|
||||||
|
|
|
@ -398,8 +398,7 @@ IME_Init(SDL_VideoData *videodata, HWND hwnd)
|
||||||
if (SUCCEEDED(WIN_CoInitialize())) {
|
if (SUCCEEDED(WIN_CoInitialize())) {
|
||||||
videodata->ime_com_initialized = SDL_TRUE;
|
videodata->ime_com_initialized = SDL_TRUE;
|
||||||
hResult = CoCreateInstance(&CLSID_TF_ThreadMgr, NULL, CLSCTX_INPROC_SERVER, &IID_ITfThreadMgr, (LPVOID *)&videodata->ime_threadmgr);
|
hResult = CoCreateInstance(&CLSID_TF_ThreadMgr, NULL, CLSCTX_INPROC_SERVER, &IID_ITfThreadMgr, (LPVOID *)&videodata->ime_threadmgr);
|
||||||
if (hResult != S_OK)
|
if (hResult != S_OK) {
|
||||||
{
|
|
||||||
videodata->ime_available = SDL_FALSE;
|
videodata->ime_available = SDL_FALSE;
|
||||||
SDL_SetError("CoCreateInstance() failed, HRESULT is %08X", (unsigned int)hResult);
|
SDL_SetError("CoCreateInstance() failed, HRESULT is %08X", (unsigned int)hResult);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -739,18 +739,22 @@ WIN_GetWindowBordersSize(_THIS, SDL_Window * window, int *top, int *left, int *b
|
||||||
|
|
||||||
/* rcClient stores the size of the inner window, while rcWindow stores the outer size relative to the top-left
|
/* rcClient stores the size of the inner window, while rcWindow stores the outer size relative to the top-left
|
||||||
* screen position; so the top/left values of rcClient are always {0,0} and bottom/right are {height,width} */
|
* screen position; so the top/left values of rcClient are always {0,0} and bottom/right are {height,width} */
|
||||||
if (!GetClientRect(hwnd, &rcClient))
|
if (!GetClientRect(hwnd, &rcClient)) {
|
||||||
SDL_SetError("GetClientRect() failed, error %08X", (unsigned int)GetLastError());
|
return SDL_SetError("GetClientRect() failed, error %08X", (unsigned int)GetLastError());
|
||||||
if (!GetWindowRect(hwnd, &rcWindow))
|
}
|
||||||
SDL_SetError("GetWindowRect() failed, error %08X", (unsigned int)GetLastError());
|
|
||||||
|
if (!GetWindowRect(hwnd, &rcWindow)) {
|
||||||
|
return SDL_SetError("GetWindowRect() failed, error %08X", (unsigned int)GetLastError());
|
||||||
|
}
|
||||||
|
|
||||||
/* convert the top/left values to make them relative to
|
/* convert the top/left values to make them relative to
|
||||||
* the window; they will end up being slightly negative */
|
* the window; they will end up being slightly negative */
|
||||||
ptDiff.y = rcWindow.top;
|
ptDiff.y = rcWindow.top;
|
||||||
ptDiff.x = rcWindow.left;
|
ptDiff.x = rcWindow.left;
|
||||||
|
|
||||||
if (!ScreenToClient(hwnd, &ptDiff))
|
if (!ScreenToClient(hwnd, &ptDiff)) {
|
||||||
SDL_SetError("ScreenToClient() failed, error %08X", (unsigned int)GetLastError());
|
return SDL_SetError("ScreenToClient() failed, error %08X", (unsigned int)GetLastError());
|
||||||
|
}
|
||||||
|
|
||||||
rcWindow.top = ptDiff.y;
|
rcWindow.top = ptDiff.y;
|
||||||
rcWindow.left = ptDiff.x;
|
rcWindow.left = ptDiff.x;
|
||||||
|
@ -760,8 +764,9 @@ WIN_GetWindowBordersSize(_THIS, SDL_Window * window, int *top, int *left, int *b
|
||||||
ptDiff.y = rcWindow.bottom;
|
ptDiff.y = rcWindow.bottom;
|
||||||
ptDiff.x = rcWindow.right;
|
ptDiff.x = rcWindow.right;
|
||||||
|
|
||||||
if (!ScreenToClient(hwnd, &ptDiff))
|
if (!ScreenToClient(hwnd, &ptDiff)) {
|
||||||
SDL_SetError("ScreenToClient() failed, error %08X", (unsigned int)GetLastError());
|
return SDL_SetError("ScreenToClient() failed, error %08X", (unsigned int)GetLastError());
|
||||||
|
}
|
||||||
|
|
||||||
rcWindow.bottom = ptDiff.y;
|
rcWindow.bottom = ptDiff.y;
|
||||||
rcWindow.right = ptDiff.x;
|
rcWindow.right = ptDiff.x;
|
||||||
|
|
Loading…
Reference in New Issue