mirror of https://github.com/encounter/SDL.git
parent
ec58a817ef
commit
389ffab733
23
src/SDL.c
23
src/SDL.c
|
@ -124,18 +124,19 @@ static Uint8 SDL_SubsystemRefCount[ 32 ];
|
|||
static void
|
||||
SDL_PrivateSubsystemRefCountIncr(Uint32 subsystem)
|
||||
{
|
||||
int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
||||
SDL_assert(subsystem_index < 0 || SDL_SubsystemRefCount[subsystem_index] < 255);
|
||||
if (subsystem_index >= 0)
|
||||
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
||||
SDL_assert((subsystem_index < 0) || (SDL_SubsystemRefCount[subsystem_index] < 255));
|
||||
if (subsystem_index >= 0) {
|
||||
++SDL_SubsystemRefCount[subsystem_index];
|
||||
}
|
||||
}
|
||||
|
||||
/* Private helper to decrement a subsystem's ref counter. */
|
||||
static void
|
||||
SDL_PrivateSubsystemRefCountDecr(Uint32 subsystem)
|
||||
{
|
||||
int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
||||
if (subsystem_index >= 0 && SDL_SubsystemRefCount[subsystem_index] > 0) {
|
||||
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
||||
if ((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] > 0)) {
|
||||
--SDL_SubsystemRefCount[subsystem_index];
|
||||
}
|
||||
}
|
||||
|
@ -144,23 +145,23 @@ SDL_PrivateSubsystemRefCountDecr(Uint32 subsystem)
|
|||
static SDL_bool
|
||||
SDL_PrivateShouldInitSubsystem(Uint32 subsystem)
|
||||
{
|
||||
int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
||||
SDL_assert(subsystem_index < 0 || SDL_SubsystemRefCount[subsystem_index] < 255);
|
||||
return (subsystem_index >= 0 && SDL_SubsystemRefCount[subsystem_index] == 0) ? SDL_TRUE : SDL_FALSE;
|
||||
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
||||
SDL_assert((subsystem_index < 0) || (SDL_SubsystemRefCount[subsystem_index] < 255));
|
||||
return ((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 0)) ? SDL_TRUE : SDL_FALSE;
|
||||
}
|
||||
|
||||
/* Private helper to check if a system needs to be quit. */
|
||||
static SDL_bool
|
||||
SDL_PrivateShouldQuitSubsystem(Uint32 subsystem) {
|
||||
int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
||||
if (subsystem_index >= 0 && SDL_SubsystemRefCount[subsystem_index] == 0) {
|
||||
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
||||
if ((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 0)) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
/* If we're in SDL_Quit, we shut down every subsystem, even if refcount
|
||||
* 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
|
||||
|
|
|
@ -169,8 +169,9 @@ HIDAPI_DriverShield_SendCommand(SDL_HIDAPI_Device *device, Uint8 cmd, const void
|
|||
}
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
||||
if (SDL_HIDAPI_SendRumbleAndUnlock(device, (Uint8*)&cmd_pkt, sizeof(cmd_pkt)) != sizeof(cmd_pkt)) {
|
||||
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,
|
||||
(const Uint8 **)&plane_y, (const Uint8 **)&plane_u, (const Uint8 **)&plane_v,
|
||||
&y_stride, &uv_stride) != 0)
|
||||
&y_stride, &uv_stride) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
plane_interleaved_uv = (plane_y + height * y_stride);
|
||||
y_skip = (y_stride - width);
|
||||
|
||||
|
|
|
@ -398,8 +398,7 @@ IME_Init(SDL_VideoData *videodata, HWND hwnd)
|
|||
if (SUCCEEDED(WIN_CoInitialize())) {
|
||||
videodata->ime_com_initialized = SDL_TRUE;
|
||||
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;
|
||||
SDL_SetError("CoCreateInstance() failed, HRESULT is %08X", (unsigned int)hResult);
|
||||
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
|
||||
* screen position; so the top/left values of rcClient are always {0,0} and bottom/right are {height,width} */
|
||||
if (!GetClientRect(hwnd, &rcClient))
|
||||
SDL_SetError("GetClientRect() failed, error %08X", (unsigned int)GetLastError());
|
||||
if (!GetWindowRect(hwnd, &rcWindow))
|
||||
SDL_SetError("GetWindowRect() failed, error %08X", (unsigned int)GetLastError());
|
||||
if (!GetClientRect(hwnd, &rcClient)) {
|
||||
return SDL_SetError("GetClientRect() 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
|
||||
* the window; they will end up being slightly negative */
|
||||
ptDiff.y = rcWindow.top;
|
||||
ptDiff.x = rcWindow.left;
|
||||
|
||||
if (!ScreenToClient(hwnd, &ptDiff))
|
||||
SDL_SetError("ScreenToClient() failed, error %08X", (unsigned int)GetLastError());
|
||||
if (!ScreenToClient(hwnd, &ptDiff)) {
|
||||
return SDL_SetError("ScreenToClient() failed, error %08X", (unsigned int)GetLastError());
|
||||
}
|
||||
|
||||
rcWindow.top = ptDiff.y;
|
||||
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.x = rcWindow.right;
|
||||
|
||||
if (!ScreenToClient(hwnd, &ptDiff))
|
||||
SDL_SetError("ScreenToClient() failed, error %08X", (unsigned int)GetLastError());
|
||||
if (!ScreenToClient(hwnd, &ptDiff)) {
|
||||
return SDL_SetError("ScreenToClient() failed, error %08X", (unsigned int)GetLastError());
|
||||
}
|
||||
|
||||
rcWindow.bottom = ptDiff.y;
|
||||
rcWindow.right = ptDiff.x;
|
||||
|
|
Loading…
Reference in New Issue