early-access version 2325

This commit is contained in:
pineappleEA
2021-12-18 11:14:57 +01:00
parent 66c22ff5a2
commit cdbc28f0d4
74 changed files with 7922 additions and 5076 deletions

View File

@@ -25,6 +25,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <malloc.h> /* memalign() */
#include "SDL_audio.h"
#include "SDL_error.h"
@@ -38,7 +39,7 @@
#include <pspthreadman.h>
/* The tag name used by PSP audio */
#define PSPAUDIO_DRIVER_NAME "psp"
#define PSPAUDIO_DRIVER_NAME "psp"
static int
PSPAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
@@ -116,6 +117,7 @@ static void PSPAUDIO_WaitDevice(_THIS)
{
/* Because we block when sending audio, there's no need for this function to do anything. */
}
static Uint8 *PSPAUDIO_GetDeviceBuf(_THIS)
{
return this->hidden->mixbufs[this->hidden->next_buffer];
@@ -126,7 +128,7 @@ static void PSPAUDIO_CloseDevice(_THIS)
if (this->hidden->channel >= 0) {
sceAudioChRelease(this->hidden->channel);
}
free(this->hidden->rawbuf); /* this uses memalign(), not SDL_malloc(). */
free(this->hidden->rawbuf); /* this uses memalign(), not SDL_malloc(). */
SDL_free(this->hidden);
}
@@ -143,7 +145,6 @@ static void PSPAUDIO_ThreadInit(_THIS)
}
}
static int
PSPAUDIO_Init(SDL_AudioDriverImpl * impl)
{
@@ -157,14 +158,9 @@ PSPAUDIO_Init(SDL_AudioDriverImpl * impl)
/* PSP audio device */
impl->OnlyHasDefaultOutputDevice = 1;
/*
impl->HasCaptureSupport = 1;
impl->OnlyHasDefaultCaptureDevice = 1;
*/
/*
impl->DetectDevices = DSOUND_DetectDevices;
impl->Deinitialize = DSOUND_Deinitialize;
impl->HasCaptureSupport = 1;
impl->OnlyHasDefaultCaptureDevice = 1;
*/
return 1; /* this audio target is available. */
}
@@ -173,8 +169,6 @@ AudioBootStrap PSPAUDIO_bootstrap = {
"psp", "PSP audio driver", PSPAUDIO_Init, 0
};
/* SDL_AUDI */
#endif /* SDL_AUDIO_DRIVER_PSP */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -25,6 +25,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <malloc.h> /* memalign() */
#include "SDL_audio.h"
#include "SDL_error.h"
@@ -38,10 +39,10 @@
#include <psp2/audioout.h>
#define SCE_AUDIO_SAMPLE_ALIGN(s) (((s) + 63) & ~63)
#define SCE_AUDIO_MAX_VOLUME 0x8000
#define SCE_AUDIO_MAX_VOLUME 0x8000
/* The tag name used by VITA audio */
#define VITAAUD_DRIVER_NAME "vita"
#define VITAAUD_DRIVER_NAME "vita"
static int
VITAAUD_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
@@ -135,10 +136,11 @@ static void VITAAUD_CloseDevice(_THIS)
}
if (this->hidden->rawbuf != NULL) {
free(this->hidden->rawbuf);
free(this->hidden->rawbuf); /* this uses memalign(), not SDL_malloc(). */
this->hidden->rawbuf = NULL;
}
}
static void VITAAUD_ThreadInit(_THIS)
{
/* Increase the priority of this audio thread by 1 to put it
@@ -152,11 +154,9 @@ static void VITAAUD_ThreadInit(_THIS)
}
}
static int
VITAAUD_Init(SDL_AudioDriverImpl * impl)
{
/* Set the function pointers */
impl->OpenDevice = VITAAUD_OpenDevice;
impl->PlayDevice = VITAAUD_PlayDevice;
@@ -167,11 +167,10 @@ VITAAUD_Init(SDL_AudioDriverImpl * impl)
/* VITA audio device */
impl->OnlyHasDefaultOutputDevice = 1;
/*
/*
impl->HasCaptureSupport = 1;
impl->OnlyHasDefaultInputDevice = 1;
*/
*/
return 1; /* this audio target is available. */
}
@@ -179,8 +178,6 @@ AudioBootStrap VITAAUD_bootstrap = {
"vita", "VITA audio driver", VITAAUD_Init, 0
};
/* SDL_AUDI */
#endif /* SDL_AUDIO_DRIVER_VITA */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -425,7 +425,6 @@ ReleaseWasapiDevice(_THIS)
{
if (this->hidden->client) {
IAudioClient_Stop(this->hidden->client);
IAudioClient_SetEventHandle(this->hidden->client, NULL);
IAudioClient_Release(this->hidden->client);
this->hidden->client = NULL;
}

View File

@@ -57,6 +57,10 @@
#define ABS_MT_TRACKING_ID 0x39
#define ABS_MT_PRESSURE 0x3a
#endif
#ifndef REL_WHEEL_HI_RES
#define REL_WHEEL_HI_RES 0x0b
#define REL_HWHEEL_HI_RES 0x0c
#endif
typedef struct SDL_evdevlist_item
{
@@ -92,6 +96,9 @@ typedef struct SDL_evdevlist_item
} * touchscreen_data;
SDL_bool high_res_wheel;
SDL_bool high_res_hwheel;
struct SDL_evdevlist_item *next;
} SDL_evdevlist_item;
@@ -378,10 +385,20 @@ SDL_EVDEV_Poll(void)
SDL_SendMouseMotion(mouse->focus, mouse->mouseID, SDL_TRUE, 0, events[i].value);
break;
case REL_WHEEL:
SDL_SendMouseWheel(mouse->focus, mouse->mouseID, 0, events[i].value, SDL_MOUSEWHEEL_NORMAL);
if (!item->high_res_wheel)
SDL_SendMouseWheel(mouse->focus, mouse->mouseID, 0, events[i].value, SDL_MOUSEWHEEL_NORMAL);
break;
case REL_WHEEL_HI_RES:
SDL_assert(item->high_res_wheel);
SDL_SendMouseWheel(mouse->focus, mouse->mouseID, 0, events[i].value / 120.0f, SDL_MOUSEWHEEL_NORMAL);
break;
case REL_HWHEEL:
SDL_SendMouseWheel(mouse->focus, mouse->mouseID, events[i].value, 0, SDL_MOUSEWHEEL_NORMAL);
if (!item->high_res_hwheel)
SDL_SendMouseWheel(mouse->focus, mouse->mouseID, events[i].value, 0, SDL_MOUSEWHEEL_NORMAL);
break;
case REL_HWHEEL_HI_RES:
SDL_assert(item->high_res_hwheel);
SDL_SendMouseWheel(mouse->focus, mouse->mouseID, events[i].value / 120.0f, 0, SDL_MOUSEWHEEL_NORMAL);
break;
default:
break;
@@ -715,6 +732,7 @@ SDL_EVDEV_device_added(const char *dev_path, int udev_class)
{
int ret;
SDL_evdevlist_item *item;
unsigned long relbit[NBITS(REL_MAX)] = { 0 };
/* Check to make sure it's not already in list. */
for (item = _this->first; item != NULL; item = item->next) {
@@ -741,11 +759,17 @@ SDL_EVDEV_device_added(const char *dev_path, int udev_class)
return SDL_OutOfMemory();
}
if (ioctl(item->fd, EVIOCGBIT(EV_REL, sizeof(relbit)), relbit) >= 0) {
item->high_res_wheel = test_bit(REL_WHEEL_HI_RES, relbit);
item->high_res_hwheel = test_bit(REL_HWHEEL_HI_RES, relbit);
}
if (udev_class & SDL_UDEV_DEVICE_TOUCHSCREEN) {
item->is_touchscreen = 1;
if ((ret = SDL_EVDEV_init_touchscreen(item)) < 0) {
close(item->fd);
SDL_free(item->path);
SDL_free(item);
return ret;
}

View File

@@ -205,7 +205,7 @@ Fcitx_SetCapabilities(void *data,
const char *internal_editing)
{
FcitxClient *client = (FcitxClient *)data;
Uint32 caps = 0;
Uint64 caps = 0;
if (!client->ic_path) {
return;
}

View File

@@ -23,7 +23,7 @@
#if defined(__OS2__)
#include "geniconv/geniconv.h"
#include "SDL_os2.h"
/* SDL_OS2Quit() will be called from SDL_QuitSubSystem() */
void SDL_OS2Quit(void)

View File

@@ -23,7 +23,6 @@
#include "SDL_log.h"
#include "SDL_stdinc.h"
#include "geniconv/geniconv.h"
#ifdef OS2DEBUG
#if (OS2DEBUG-0 >= 2)
@@ -39,10 +38,16 @@
#endif /* OS2DEBUG */
#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H)
#define OS2_SysToUTF8(S) SDL_iconv_string("UTF-8", "", (char *)(S), SDL_strlen(S)+1)
#define OS2_UTF8ToSys(S) SDL_iconv_string("", "UTF-8", (char *)(S), SDL_strlen(S)+1)
#define libiconv_clean() do {} while(0)
#else
/* StrUTF8New() - geniconv/sys2utf8.c */
#include "geniconv/geniconv.h"
#define OS2_SysToUTF8(S) StrUTF8New(1, (S), SDL_strlen((S)) + 1)
#define OS2_UTF8ToSys(S) StrUTF8New(0, (char *)(S), SDL_strlen((S)) + 1)
#endif
/* SDL_OS2Quit() will be called from SDL_QuitSubSystem() */
void SDL_OS2Quit(void);

View File

@@ -28,7 +28,7 @@
#ifndef GENICONV_H
#define GENICONV_H
#include <iconv.h>
#include "iconv.h"
#ifdef iconv_open
#undef iconv_open

4
externals/SDL/src/core/os2/iconv2.lbc vendored Executable file
View File

@@ -0,0 +1,4 @@
# OpenWatcom exports file for libiconv
++'libiconv'.'ICONV2'..'_libiconv'
++'libiconv_close'.'ICONV2'..'_libiconv_close'
++'libiconv_open'.'ICONV2'..'_libiconv_open'

View File

@@ -287,9 +287,10 @@ SDL_LogEvent(const SDL_Event *event)
SDL_EVENT_CASE(SDL_MOUSEWHEEL)
SDL_snprintf(details, sizeof (details), " (timestamp=%u windowid=%u which=%u x=%d y=%d direction=%s)",
SDL_snprintf(details, sizeof (details), " (timestamp=%u windowid=%u which=%u x=%d y=%d preciseX=%f preciseY=%f direction=%s)",
(uint) event->wheel.timestamp, (uint) event->wheel.windowID,
(uint) event->wheel.which, (int) event->wheel.x, (int) event->wheel.y,
event->wheel.preciseX, event->wheel.preciseY,
event->wheel.direction == SDL_MOUSEWHEEL_NORMAL ? "normal" : "flipped");
break;

View File

@@ -25,9 +25,9 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* System dependent filesystem routines */
#include "../../core/os2/SDL_os2.h"
#include "SDL_error.h"
#include "SDL_filesystem.h"
#include "../../core/os2/SDL_os2.h"
#define INCL_DOSFILEMGR
#define INCL_DOSPROCESS
@@ -43,7 +43,7 @@ SDL_GetBasePath(void)
ULONG ulRC = DosGetInfoBlocks(&tib, &pib);
PCHAR pcEnd;
ULONG cbResult;
CHAR acBuf[_MAX_PATH];
CHAR acBuf[CCHMAXPATH];
if (ulRC != NO_ERROR) {
debug_os2("DosGetInfoBlocks() failed, rc = %u", ulRC);
@@ -73,7 +73,7 @@ char *
SDL_GetPrefPath(const char *org, const char *app)
{
PSZ pszPath;
CHAR acBuf[_MAX_PATH];
CHAR acBuf[CCHMAXPATH];
int lPosApp, lPosOrg;
PSZ pszApp, pszOrg;

View File

@@ -53,7 +53,6 @@ typedef LONG NTSTATUS;
#define memset SDL_memset
#define strcmp SDL_strcmp
#define strlen SDL_strlen
#define strncpy SDL_strlcpy
#define strstr SDL_strstr
#define strtol SDL_strtol
#define wcscmp SDL_wcscmp
@@ -105,9 +104,6 @@ extern "C" {
#define MIN(x,y) ((x) < (y)? (x): (y))
#ifdef _MSC_VER
/* Thanks Microsoft, but I know how to use strncpy(). */
#pragma warning(disable:4996)
/* Yes, we have some unreferenced formal parameters */
#pragma warning(disable:4100)
#endif
@@ -550,8 +546,7 @@ struct hid_device_info HID_API_EXPORT * HID_API_CALL hid_enumerate(unsigned shor
if (str) {
len = strlen(str);
cur_dev->path = (char*) calloc(len+1, sizeof(char));
strncpy(cur_dev->path, str, len+1);
cur_dev->path[len] = '\0';
memcpy(cur_dev->path, str, len+1);
}
else
cur_dev->path = NULL;

View File

@@ -895,6 +895,9 @@ static const char *s_ControllerMappings [] =
#endif
#if defined(SDL_JOYSTICK_VITA)
"50535669746120436f6e74726f6c6c65,PSVita Controller,a:b2,b:b1,back:b10,dpdown:b6,dpleft:b7,dpright:b9,dpup:b8,leftshoulder:b4,leftstick:b14,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b15,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b3,y:b0,",
#endif
#if defined(SDL_JOYSTICK_PSP)
"505350206275696c74696e206a6f7970,PSP builtin joypad,y:b0,b:b1,a:b2,x:b3,leftshoulder:b4,rightshoulder:b5,dpdown:b6,dpleft:b7,dpup:b8,dpright:b9,back:b10,start:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,",
#endif
"hidapi,*,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,",
NULL

View File

@@ -66,6 +66,9 @@ static NSString *GCInputXboxShareButton = @"Button Share";
#if defined(__MACOSX__) && (__MAC_OS_X_VERSION_MAX_ALLOWED <= 101600)
+ (BOOL)supportsHIDDevice:(IOHIDDeviceRef)device;
#endif
#if !((__IPHONE_OS_VERSION_MAX_ALLOWED >= 130000) || (__APPLETV_OS_VERSION_MAX_ALLOWED >= 130000) || (__MAC_OS_VERSION_MAX_ALLOWED >= 1500000))
@property(nonatomic, readonly) NSString *productCategory;
#endif
@end
@interface GCExtendedGamepad (SDL)
#if !((__IPHONE_OS_VERSION_MAX_ALLOWED >= 121000) || (__APPLETV_OS_VERSION_MAX_ALLOWED >= 121000) || (__MAC_OS_VERSION_MAX_ALLOWED >= 1401000))

View File

@@ -63,10 +63,10 @@ static point c = { 78, 32767 };
static point d = { 128, 32767 };
/* simple linear interpolation between two points */
static SDL_INLINE void lerp (point *dest, point *a, point *b, float t)
static SDL_INLINE void lerp (point *dest, point *pt_a, point *pt_b, float t)
{
dest->x = a->x + (b->x - a->x)*t;
dest->y = a->y + (b->y - a->y)*t;
dest->x = pt_a->x + (pt_b->x - pt_a->x)*t;
dest->y = pt_a->y + (pt_b->y - pt_a->y)*t;
}
/* evaluate a point on a bezier-curve. t goes from 0 to 1.0 */

View File

@@ -27,7 +27,7 @@
#define libm_hidden_def(x)
#define strong_alias(x, y)
#ifndef __HAIKU__ /* already defined in a system header. */
#if !defined(__HAIKU__) && !defined(__PSP__) /* already defined in a system header. */
typedef unsigned int u_int32_t;
#endif

View File

@@ -7,11 +7,11 @@
#include "SDL_main.h"
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspsdk.h>
#include <pspthreadman.h>
#include <stdlib.h>
#include <stdio.h>
#ifdef main
#undef main
#endif
/* If application's main() is redefined as SDL_main, and libSDLmain is
linked, then this file will create the standard exit callback,
@@ -23,11 +23,12 @@
PSP_MAIN_THREAD_STACK_SIZE, etc.
*/
PSP_MODULE_INFO("SDL App", 0, 1, 1);
PSP_MODULE_INFO("SDL App", 0, 1, 0);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_VFPU | THREAD_ATTR_USER);
int sdl_psp_exit_callback(int arg1, int arg2, void *common)
{
exit(0);
sceKernelExitGame();
return 0;
}
@@ -43,7 +44,7 @@ int sdl_psp_callback_thread(SceSize args, void *argp)
int sdl_psp_setup_callbacks(void)
{
int thid = 0;
int thid;
thid = sceKernelCreateThread("update_thread",
sdl_psp_callback_thread, 0x11, 0xFA0, 0, 0);
if(thid >= 0)
@@ -53,12 +54,8 @@ int sdl_psp_setup_callbacks(void)
int main(int argc, char *argv[])
{
pspDebugScreenInit();
sdl_psp_setup_callbacks();
/* Register sceKernelExitGame() to be called when we exit */
atexit(sceKernelExitGame);
SDL_SetMainReady();
(void)SDL_main(argc, argv);

View File

@@ -9,8 +9,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,0,18,0
PRODUCTVERSION 2,0,18,0
FILEVERSION 2,0,19,0
PRODUCTVERSION 2,0,19,0
FILEFLAGSMASK 0x3fL
FILEFLAGS 0x0L
FILEOS 0x40004L
@@ -23,12 +23,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "\0"
VALUE "FileDescription", "SDL\0"
VALUE "FileVersion", "2, 0, 18, 0\0"
VALUE "FileVersion", "2, 0, 19, 0\0"
VALUE "InternalName", "SDL\0"
VALUE "LegalCopyright", "Copyright (C) 2021 Sam Lantinga\0"
VALUE "OriginalFilename", "SDL2.dll\0"
VALUE "ProductName", "Simple DirectMedia Layer\0"
VALUE "ProductVersion", "2, 0, 18, 0\0"
VALUE "ProductVersion", "2, 0, 19, 0\0"
END
END
BLOCK "VarFileInfo"

View File

@@ -356,7 +356,11 @@ QueueCmdSetViewport(SDL_Renderer *renderer)
if (cmd != NULL) {
cmd->command = SDL_RENDERCMD_SETVIEWPORT;
cmd->data.viewport.first = 0; /* render backend will fill this in. */
SDL_memcpy(&cmd->data.viewport.rect, &renderer->viewport, sizeof (renderer->viewport));
/* Convert SDL_FRect to SDL_Rect */
cmd->data.viewport.rect.x = (int)SDL_floor(renderer->viewport.x);
cmd->data.viewport.rect.y = (int)SDL_floor(renderer->viewport.y);
cmd->data.viewport.rect.w = (int)SDL_floor(renderer->viewport.w);
cmd->data.viewport.rect.h = (int)SDL_floor(renderer->viewport.h);
retval = renderer->QueueSetViewport(renderer, cmd);
if (retval < 0) {
cmd->command = SDL_RENDERCMD_NO_OP;
@@ -382,7 +386,11 @@ QueueCmdSetClipRect(SDL_Renderer *renderer)
} else {
cmd->command = SDL_RENDERCMD_SETCLIPRECT;
cmd->data.cliprect.enabled = renderer->clipping_enabled;
SDL_memcpy(&cmd->data.cliprect.rect, &renderer->clip_rect, sizeof (cmd->data.cliprect.rect));
/* Convert SDL_FRect to SDL_Rect */
cmd->data.cliprect.rect.x = (int)SDL_floor(renderer->clip_rect.x);
cmd->data.cliprect.rect.y = (int)SDL_floor(renderer->clip_rect.y);
cmd->data.cliprect.rect.w = (int)SDL_floor(renderer->clip_rect.w);
cmd->data.cliprect.rect.h = (int)SDL_floor(renderer->clip_rect.h);
SDL_memcpy(&renderer->last_queued_cliprect, &renderer->clip_rect, sizeof (SDL_Rect));
renderer->last_queued_cliprect_enabled = renderer->clipping_enabled;
renderer->cliprect_queued = SDL_TRUE;
@@ -667,7 +675,7 @@ SDL_GetRenderDriverInfo(int index, SDL_RendererInfo * info)
#endif
}
static void GetWindowViewportValues(SDL_Renderer *renderer, int *logical_w, int *logical_h, SDL_Rect *viewport, SDL_FPoint *scale)
static void GetWindowViewportValues(SDL_Renderer *renderer, int *logical_w, int *logical_h, SDL_FRect *viewport, SDL_FPoint *scale)
{
SDL_LockMutex(renderer->target_mutex);
*logical_w = renderer->target ? renderer->logical_w_backup : renderer->logical_w;
@@ -756,7 +764,7 @@ SDL_RendererEventWatch(void *userdata, SDL_Event *event)
SDL_Window *window = SDL_GetWindowFromID(event->motion.windowID);
if (window == renderer->window) {
int logical_w, logical_h;
SDL_Rect viewport;
SDL_FRect viewport;
SDL_FPoint scale;
GetWindowViewportValues(renderer, &logical_w, &logical_h, &viewport, &scale);
if (logical_w) {
@@ -783,7 +791,7 @@ SDL_RendererEventWatch(void *userdata, SDL_Event *event)
SDL_Window *window = SDL_GetWindowFromID(event->button.windowID);
if (window == renderer->window) {
int logical_w, logical_h;
SDL_Rect viewport;
SDL_FRect viewport;
SDL_FPoint scale;
GetWindowViewportValues(renderer, &logical_w, &logical_h, &viewport, &scale);
if (logical_w) {
@@ -798,7 +806,7 @@ SDL_RendererEventWatch(void *userdata, SDL_Event *event)
event->type == SDL_FINGERMOTION) {
int logical_w, logical_h;
float physical_w, physical_h;
SDL_Rect viewport;
SDL_FRect viewport;
SDL_FPoint scale;
GetWindowViewportValues(renderer, &logical_w, &logical_h, &viewport, &scale);
@@ -2183,8 +2191,8 @@ SDL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
}
if (texture) {
renderer->viewport.x = 0;
renderer->viewport.y = 0;
renderer->viewport.x = 0.0f;
renderer->viewport.y = 0.0f;
renderer->viewport.w = texture->w;
renderer->viewport.h = texture->h;
SDL_zero(renderer->clip_rect);
@@ -2393,16 +2401,19 @@ SDL_RenderSetViewport(SDL_Renderer * renderer, const SDL_Rect * rect)
CHECK_RENDERER_MAGIC(renderer, -1);
if (rect) {
renderer->viewport.x = (int)SDL_floor(rect->x * renderer->scale.x);
renderer->viewport.y = (int)SDL_floor(rect->y * renderer->scale.y);
renderer->viewport.w = (int)SDL_floor(rect->w * renderer->scale.x);
renderer->viewport.h = (int)SDL_floor(rect->h * renderer->scale.y);
renderer->viewport.x = rect->x * renderer->scale.x;
renderer->viewport.y = rect->y * renderer->scale.y;
renderer->viewport.w = rect->w * renderer->scale.x;
renderer->viewport.h = rect->h * renderer->scale.y;
} else {
renderer->viewport.x = 0;
renderer->viewport.y = 0;
if (SDL_GetRendererOutputSize(renderer, &renderer->viewport.w, &renderer->viewport.h) < 0) {
int w, h;
renderer->viewport.x = 0.0f;
renderer->viewport.y = 0.0f;
if (SDL_GetRendererOutputSize(renderer, &w, &h) < 0) {
return -1;
}
renderer->viewport.w = w;
renderer->viewport.h = h;
}
retval = QueueCmdSetViewport(renderer);
return retval < 0 ? retval : FlushRenderCommandsIfNotBatching(renderer);
@@ -2414,10 +2425,10 @@ SDL_RenderGetViewport(SDL_Renderer * renderer, SDL_Rect * rect)
CHECK_RENDERER_MAGIC(renderer, );
if (rect) {
rect->x = (int)(renderer->viewport.x / renderer->scale.x);
rect->y = (int)(renderer->viewport.y / renderer->scale.y);
rect->w = (int)(renderer->viewport.w / renderer->scale.x);
rect->h = (int)(renderer->viewport.h / renderer->scale.y);
rect->x = (int)SDL_floor(renderer->viewport.x / renderer->scale.x);
rect->y = (int)SDL_floor(renderer->viewport.y / renderer->scale.y);
rect->w = (int)SDL_floor(renderer->viewport.w / renderer->scale.x);
rect->h = (int)SDL_floor(renderer->viewport.h / renderer->scale.y);
}
}
@@ -2438,10 +2449,10 @@ SDL_RenderSetClipRect(SDL_Renderer * renderer, const SDL_Rect * rect)
if (rect) {
renderer->clipping_enabled = SDL_TRUE;
renderer->clip_rect.x = (int)SDL_floor(rect->x * renderer->scale.x);
renderer->clip_rect.y = (int)SDL_floor(rect->y * renderer->scale.y);
renderer->clip_rect.w = (int)SDL_floor(rect->w * renderer->scale.x);
renderer->clip_rect.h = (int)SDL_floor(rect->h * renderer->scale.y);
renderer->clip_rect.x = rect->x * renderer->scale.x;
renderer->clip_rect.y = rect->y * renderer->scale.y;
renderer->clip_rect.w = rect->w * renderer->scale.x;
renderer->clip_rect.h = rect->h * renderer->scale.y;
} else {
renderer->clipping_enabled = SDL_FALSE;
SDL_zero(renderer->clip_rect);
@@ -2457,10 +2468,10 @@ SDL_RenderGetClipRect(SDL_Renderer * renderer, SDL_Rect * rect)
CHECK_RENDERER_MAGIC(renderer, )
if (rect) {
rect->x = (int)(renderer->clip_rect.x / renderer->scale.x);
rect->y = (int)(renderer->clip_rect.y / renderer->scale.y);
rect->w = (int)(renderer->clip_rect.w / renderer->scale.x);
rect->h = (int)(renderer->clip_rect.h / renderer->scale.y);
rect->x = (int)SDL_floor(renderer->clip_rect.x / renderer->scale.x);
rect->y = (int)SDL_floor(renderer->clip_rect.y / renderer->scale.y);
rect->w = (int)SDL_floor(renderer->clip_rect.w / renderer->scale.x);
rect->h = (int)SDL_floor(renderer->clip_rect.h / renderer->scale.y);
}
}
@@ -2727,7 +2738,7 @@ SDL_RenderDrawPointsF(SDL_Renderer * renderer,
CHECK_RENDERER_MAGIC(renderer, -1);
if (!points) {
return SDL_SetError("SDL_RenderDrawFPoints(): Passed NULL points");
return SDL_SetError("SDL_RenderDrawPointsF(): Passed NULL points");
}
if (count < 1) {
return 0;
@@ -2929,31 +2940,29 @@ SDL_RenderDrawLines(SDL_Renderer * renderer,
if (!fpoints) {
return SDL_OutOfMemory();
}
for (i = 0; i < count; ++i) {
fpoints[i].x = points[i].x * renderer->scale.x;
fpoints[i].y = points[i].y * renderer->scale.y;
fpoints[i].x = points[i].x;
fpoints[i].y = points[i].y;
}
retval = QueueCmdDrawLines(renderer, fpoints, count);
retval = SDL_RenderDrawLinesF(renderer, fpoints, count);
SDL_small_free(fpoints, isstack);
return retval < 0 ? retval : FlushRenderCommandsIfNotBatching(renderer);
return retval;
}
int
SDL_RenderDrawLinesF(SDL_Renderer * renderer,
const SDL_FPoint * points, int count)
{
SDL_FPoint *fpoints;
int i;
int retval;
SDL_bool isstack;
CHECK_RENDERER_MAGIC(renderer, -1);
if (!points) {
return SDL_SetError("SDL_RenderDrawLines(): Passed NULL points");
return SDL_SetError("SDL_RenderDrawLinesF(): Passed NULL points");
}
if (count < 2) {
return 0;
@@ -2970,18 +2979,7 @@ SDL_RenderDrawLinesF(SDL_Renderer * renderer,
return RenderDrawLinesWithRectsF(renderer, points, count);
}
fpoints = SDL_small_alloc(SDL_FPoint, count, &isstack);
if (!fpoints) {
return SDL_OutOfMemory();
}
for (i = 0; i < count; ++i) {
fpoints[i].x = points[i].x * renderer->scale.x;
fpoints[i].y = points[i].y * renderer->scale.y;
}
retval = QueueCmdDrawLines(renderer, fpoints, count);
SDL_small_free(fpoints, isstack);
retval = QueueCmdDrawLines(renderer, points, count);
return retval < 0 ? retval : FlushRenderCommandsIfNotBatching(renderer);
}
@@ -4069,10 +4067,10 @@ SDL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
format = SDL_GetWindowPixelFormat(renderer->window);
}
real_rect.x = renderer->viewport.x;
real_rect.y = renderer->viewport.y;
real_rect.w = renderer->viewport.w;
real_rect.h = renderer->viewport.h;
real_rect.x = (int)SDL_floor(renderer->viewport.x);
real_rect.y = (int)SDL_floor(renderer->viewport.y);
real_rect.w = (int)SDL_floor(renderer->viewport.w);
real_rect.h = (int)SDL_floor(renderer->viewport.h);
if (rect) {
if (!SDL_IntersectRect(rect, &real_rect, &real_rect)) {
return 0;

View File

@@ -186,12 +186,12 @@ struct SDL_Renderer
SDL_bool integer_scale;
/* The drawable area within the window */
SDL_Rect viewport;
SDL_Rect viewport_backup;
SDL_FRect viewport;
SDL_FRect viewport_backup;
/* The clip rectangle within the window */
SDL_Rect clip_rect;
SDL_Rect clip_rect_backup;
SDL_FRect clip_rect;
SDL_FRect clip_rect_backup;
/* Wether or not the clipping rectangle is used. */
SDL_bool clipping_enabled;
@@ -226,8 +226,8 @@ struct SDL_Renderer
SDL_RenderCommand *render_commands_pool;
Uint32 render_command_generation;
Uint32 last_queued_color;
SDL_Rect last_queued_viewport;
SDL_Rect last_queued_cliprect;
SDL_FRect last_queued_viewport;
SDL_FRect last_queued_cliprect;
SDL_bool last_queued_cliprect_enabled;
SDL_bool color_queued;
SDL_bool viewport_queued;

View File

@@ -700,7 +700,10 @@ D3D11_GetRotationForCurrentRenderTarget(SDL_Renderer * renderer)
static int
D3D11_GetViewportAlignedD3DRect(SDL_Renderer * renderer, const SDL_Rect * sdlRect, D3D11_RECT * outRect, BOOL includeViewportOffset)
{
D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
const int rotation = D3D11_GetRotationForCurrentRenderTarget(renderer);
const SDL_Rect *viewport = &data->currentViewport;
switch (rotation) {
case DXGI_MODE_ROTATION_IDENTITY:
outRect->left = sdlRect->x;
@@ -708,27 +711,27 @@ D3D11_GetViewportAlignedD3DRect(SDL_Renderer * renderer, const SDL_Rect * sdlRec
outRect->top = sdlRect->y;
outRect->bottom = sdlRect->y + sdlRect->h;
if (includeViewportOffset) {
outRect->left += renderer->viewport.x;
outRect->right += renderer->viewport.x;
outRect->top += renderer->viewport.y;
outRect->bottom += renderer->viewport.y;
outRect->left += viewport->x;
outRect->right += viewport->x;
outRect->top += viewport->y;
outRect->bottom += viewport->y;
}
break;
case DXGI_MODE_ROTATION_ROTATE270:
outRect->left = sdlRect->y;
outRect->right = sdlRect->y + sdlRect->h;
outRect->top = renderer->viewport.w - sdlRect->x - sdlRect->w;
outRect->bottom = renderer->viewport.w - sdlRect->x;
outRect->top = viewport->w - sdlRect->x - sdlRect->w;
outRect->bottom = viewport->w - sdlRect->x;
break;
case DXGI_MODE_ROTATION_ROTATE180:
outRect->left = renderer->viewport.w - sdlRect->x - sdlRect->w;
outRect->right = renderer->viewport.w - sdlRect->x;
outRect->top = renderer->viewport.h - sdlRect->y - sdlRect->h;
outRect->bottom = renderer->viewport.h - sdlRect->y;
outRect->left = viewport->w - sdlRect->x - sdlRect->w;
outRect->right = viewport->w - sdlRect->x;
outRect->top = viewport->h - sdlRect->y - sdlRect->h;
outRect->bottom = viewport->h - sdlRect->y;
break;
case DXGI_MODE_ROTATION_ROTATE90:
outRect->left = renderer->viewport.h - sdlRect->y - sdlRect->h;
outRect->right = renderer->viewport.h - sdlRect->y;
outRect->left = viewport->h - sdlRect->y - sdlRect->h;
outRect->right = viewport->h - sdlRect->y;
outRect->top = sdlRect->x;
outRect->bottom = sdlRect->x + sdlRect->h;
break;

View File

@@ -165,11 +165,10 @@ void Swap(float *a, float *b)
static int
TextureNextPow2(unsigned int w)
{
unsigned int n = 2;
if(w == 0)
return 0;
unsigned int n = 2;
while(w > n)
n <<= 1;
@@ -209,30 +208,32 @@ StartDrawing(SDL_Renderer * renderer)
int
TextureSwizzle(PSP_TextureData *psp_texture)
{
int bytewidth, height;
int rowblocks, rowblocksadd;
int i, j;
unsigned int blockaddress = 0;
unsigned int *src = NULL;
unsigned char *data = NULL;
if(psp_texture->swizzled)
return 1;
int bytewidth = psp_texture->textureWidth*(psp_texture->bits>>3);
int height = psp_texture->size / bytewidth;
bytewidth = psp_texture->textureWidth*(psp_texture->bits>>3);
height = psp_texture->size / bytewidth;
int rowblocks = (bytewidth>>4);
int rowblocksadd = (rowblocks-1)<<7;
unsigned int blockaddress = 0;
unsigned int *src = (unsigned int*) psp_texture->data;
rowblocks = (bytewidth>>4);
rowblocksadd = (rowblocks-1)<<7;
src = (unsigned int*) psp_texture->data;
unsigned char *data = NULL;
data = SDL_malloc(psp_texture->size);
int j;
for(j = 0; j < height; j++, blockaddress += 16)
{
unsigned int *block;
block = (unsigned int*)&data[blockaddress];
int i;
for(i = 0; i < rowblocks; i++)
{
*block++ = *src++;
@@ -254,23 +255,28 @@ TextureSwizzle(PSP_TextureData *psp_texture)
}
int TextureUnswizzle(PSP_TextureData *psp_texture)
{
int bytewidth, height;
int widthblocks, heightblocks;
int dstpitch, dstrow;
int blockx, blocky;
int j;
unsigned int *src = NULL;
unsigned char *data = NULL;
unsigned char *ydst = NULL;
if(!psp_texture->swizzled)
return 1;
int blockx, blocky;
bytewidth = psp_texture->textureWidth*(psp_texture->bits>>3);
height = psp_texture->size / bytewidth;
int bytewidth = psp_texture->textureWidth*(psp_texture->bits>>3);
int height = psp_texture->size / bytewidth;
widthblocks = bytewidth/16;
heightblocks = height/8;
int widthblocks = bytewidth/16;
int heightblocks = height/8;
dstpitch = (bytewidth - 16)/4;
dstrow = bytewidth * 8;
int dstpitch = (bytewidth - 16)/4;
int dstrow = bytewidth * 8;
unsigned int *src = (unsigned int*) psp_texture->data;
unsigned char *data = NULL;
src = (unsigned int*) psp_texture->data;
data = SDL_malloc(psp_texture->size);
@@ -279,9 +285,7 @@ int TextureUnswizzle(PSP_TextureData *psp_texture)
sceKernelDcacheWritebackAll();
int j;
unsigned char *ydst = (unsigned char *)data;
ydst = (unsigned char *)data;
for(blocky = 0; blocky < heightblocks; ++blocky)
{
@@ -655,7 +659,7 @@ PSP_QueueCopy(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * tex
cmd->data.draw.count = count;
verts = (VertTV *) SDL_AllocateRenderVertices(renderer, count * sizeof (VertTV), 4, &cmd->data.draw.first);
verts = (VertTV *) SDL_AllocateRenderVertices(renderer, count * 2 * sizeof (VertTV), 4, &cmd->data.draw.first);
if (!verts) {
return -1;
}
@@ -673,6 +677,7 @@ PSP_QueueCopy(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * tex
verts->x = curX;
verts->y = y;
verts->z = 0;
verts++;
curU += sourceWidth;
curX += polyWidth;
@@ -682,6 +687,7 @@ PSP_QueueCopy(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * tex
verts->x = curX;
verts->y = (y + height);
verts->z = 0;
verts++;
}
}
@@ -701,6 +707,7 @@ PSP_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * t
const float width = dstrect->w - centerx;
const float height = dstrect->h - centery;
float s, c;
float cw, sw, ch, sh;
float u0 = srcrect->x;
float v0 = srcrect->y;
@@ -708,6 +715,7 @@ PSP_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * t
float v1 = srcrect->y + srcrect->h;
if (!verts) {
return -1;
}
@@ -716,10 +724,10 @@ PSP_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * t
MathSincos(degToRad(angle), &s, &c);
const float cw = c * width;
const float sw = s * width;
const float ch = c * height;
const float sh = s * height;
cw = c * width;
sw = s * width;
ch = c * height;
sh = s * height;
if (flip & SDL_FLIP_VERTICAL) {
Swap(&v0, &v1);
@@ -799,7 +807,7 @@ static int
PSP_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
{
PSP_RenderData *data = (PSP_RenderData *) renderer->driverdata;
Uint8 *gpumem = NULL;
StartDrawing(renderer);
/* note that before the renderer interface change, this would do extrememly small
@@ -808,7 +816,7 @@ PSP_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *verti
I don't know what the limits on PSP hardware are. It might be useful to have
rendering backends report a reasonable maximum, so the higher level can flush
if we appear to be exceeding that. */
Uint8 *gpumem = (Uint8 *) sceGuGetMemory(vertsize);
gpumem = (Uint8 *) sceGuGetMemory(vertsize);
if (!gpumem) {
return SDL_SetError("Couldn't obtain a %d-byte vertex buffer!", (int) vertsize);
}

View File

@@ -214,18 +214,9 @@ SW_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FP
cmd->data.draw.count = count;
if (renderer->viewport.x || renderer->viewport.y) {
const int x = renderer->viewport.x;
const int y = renderer->viewport.y;
for (i = 0; i < count; i++, verts++, points++) {
verts->x = (int)(x + points->x);
verts->y = (int)(y + points->y);
}
} else {
for (i = 0; i < count; i++, verts++, points++) {
verts->x = (int)points->x;
verts->y = (int)points->y;
}
for (i = 0; i < count; i++, verts++, points++) {
verts->x = (int)points->x;
verts->y = (int)points->y;
}
return 0;
@@ -243,23 +234,11 @@ SW_QueueFillRects(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FRe
cmd->data.draw.count = count;
if (renderer->viewport.x || renderer->viewport.y) {
const int x = renderer->viewport.x;
const int y = renderer->viewport.y;
for (i = 0; i < count; i++, verts++, rects++) {
verts->x = (int)(x + rects->x);
verts->y = (int)(y + rects->y);
verts->w = SDL_max((int)rects->w, 1);
verts->h = SDL_max((int)rects->h, 1);
}
} else {
for (i = 0; i < count; i++, verts++, rects++) {
verts->x = (int)rects->x;
verts->y = (int)rects->y;
verts->w = SDL_max((int)rects->w, 1);
verts->h = SDL_max((int)rects->h, 1);
}
for (i = 0; i < count; i++, verts++, rects++) {
verts->x = (int)rects->x;
verts->y = (int)rects->y;
verts->w = SDL_max((int)rects->w, 1);
verts->h = SDL_max((int)rects->h, 1);
}
return 0;
@@ -280,13 +259,8 @@ SW_QueueCopy(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * text
SDL_memcpy(verts, srcrect, sizeof (SDL_Rect));
verts++;
if (renderer->viewport.x || renderer->viewport.y) {
verts->x = (int)(renderer->viewport.x + dstrect->x);
verts->y = (int)(renderer->viewport.y + dstrect->y);
} else {
verts->x = (int)dstrect->x;
verts->y = (int)dstrect->y;
}
verts->x = (int)dstrect->x;
verts->y = (int)dstrect->y;
verts->w = (int)dstrect->w;
verts->h = (int)dstrect->h;
@@ -317,13 +291,8 @@ SW_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * te
SDL_memcpy(&verts->srcrect, srcrect, sizeof (SDL_Rect));
if (renderer->viewport.x || renderer->viewport.y) {
verts->dstrect.x = (int)(renderer->viewport.x + dstrect->x);
verts->dstrect.y = (int)(renderer->viewport.y + dstrect->y);
} else {
verts->dstrect.x = (int)dstrect->x;
verts->dstrect.y = (int)dstrect->y;
}
verts->dstrect.x = (int)dstrect->x;
verts->dstrect.y = (int)dstrect->y;
verts->dstrect.w = (int)dstrect->w;
verts->dstrect.h = (int)dstrect->h;
verts->angle = angle;
@@ -618,8 +587,8 @@ SW_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *te
ptr->src.x = (int)(uv_[0] * texture->w);
ptr->src.y = (int)(uv_[1] * texture->h);
ptr->dst.x = (int)(xy_[0] * scale_x + renderer->viewport.x);
ptr->dst.y = (int)(xy_[1] * scale_y + renderer->viewport.y);
ptr->dst.x = (int)(xy_[0] * scale_x);
ptr->dst.y = (int)(xy_[1] * scale_y);
trianglepoint_2_fixedpoint(&ptr->dst);
ptr->color = col_;
@@ -646,8 +615,8 @@ SW_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *te
xy_ = (float *)((char*)xy + j * xy_stride);
col_ = *(SDL_Color *)((char*)color + j * color_stride);
ptr->dst.x = (int)(xy_[0] * scale_x + renderer->viewport.x);
ptr->dst.y = (int)(xy_[1] * scale_y + renderer->viewport.y);
ptr->dst.x = (int)(xy_[0] * scale_x);
ptr->dst.y = (int)(xy_[1] * scale_y);
trianglepoint_2_fixedpoint(&ptr->dst);
ptr->color = col_;
@@ -755,9 +724,19 @@ SW_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertic
const Uint8 b = cmd->data.draw.b;
const Uint8 a = cmd->data.draw.a;
const int count = (int) cmd->data.draw.count;
const SDL_Point *verts = (SDL_Point *) (((Uint8 *) vertices) + cmd->data.draw.first);
SDL_Point *verts = (SDL_Point *) (((Uint8 *) vertices) + cmd->data.draw.first);
const SDL_BlendMode blend = cmd->data.draw.blend;
SetDrawState(surface, &drawstate);
/* Apply viewport */
if (drawstate.viewport->x || drawstate.viewport->y) {
int i;
for (i = 0; i < count; i++) {
verts[i].x += drawstate.viewport->x;
verts[i].y += drawstate.viewport->y;
}
}
if (blend == SDL_BLENDMODE_NONE) {
SDL_DrawPoints(surface, verts, count, SDL_MapRGBA(surface->format, r, g, b, a));
} else {
@@ -772,9 +751,19 @@ SW_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertic
const Uint8 b = cmd->data.draw.b;
const Uint8 a = cmd->data.draw.a;
const int count = (int) cmd->data.draw.count;
const SDL_Point *verts = (SDL_Point *) (((Uint8 *) vertices) + cmd->data.draw.first);
SDL_Point *verts = (SDL_Point *) (((Uint8 *) vertices) + cmd->data.draw.first);
const SDL_BlendMode blend = cmd->data.draw.blend;
SetDrawState(surface, &drawstate);
/* Apply viewport */
if (drawstate.viewport->x || drawstate.viewport->y) {
int i;
for (i = 0; i < count; i++) {
verts[i].x += drawstate.viewport->x;
verts[i].y += drawstate.viewport->y;
}
}
if (blend == SDL_BLENDMODE_NONE) {
SDL_DrawLines(surface, verts, count, SDL_MapRGBA(surface->format, r, g, b, a));
} else {
@@ -789,9 +778,19 @@ SW_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertic
const Uint8 b = cmd->data.draw.b;
const Uint8 a = cmd->data.draw.a;
const int count = (int) cmd->data.draw.count;
const SDL_Rect *verts = (SDL_Rect *) (((Uint8 *) vertices) + cmd->data.draw.first);
SDL_Rect *verts = (SDL_Rect *) (((Uint8 *) vertices) + cmd->data.draw.first);
const SDL_BlendMode blend = cmd->data.draw.blend;
SetDrawState(surface, &drawstate);
/* Apply viewport */
if (drawstate.viewport->x || drawstate.viewport->y) {
int i;
for (i = 0; i < count; i++) {
verts[i].x += drawstate.viewport->x;
verts[i].y += drawstate.viewport->y;
}
}
if (blend == SDL_BLENDMODE_NONE) {
SDL_FillRects(surface, verts, count, SDL_MapRGBA(surface->format, r, g, b, a));
} else {
@@ -811,6 +810,12 @@ SW_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertic
PrepTextureForCopy(cmd);
/* Apply viewport */
if (drawstate.viewport->x || drawstate.viewport->y) {
dstrect->x += drawstate.viewport->x;
dstrect->y += drawstate.viewport->y;
}
if ( srcrect->w == dstrect->w && srcrect->h == dstrect->h ) {
SDL_BlitSurface(src, srcrect, surface, dstrect);
} else {
@@ -824,9 +829,16 @@ SW_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertic
}
case SDL_RENDERCMD_COPY_EX: {
const CopyExData *copydata = (CopyExData *) (((Uint8 *) vertices) + cmd->data.draw.first);
CopyExData *copydata = (CopyExData *) (((Uint8 *) vertices) + cmd->data.draw.first);
SetDrawState(surface, &drawstate);
PrepTextureForCopy(cmd);
/* Apply viewport */
if (drawstate.viewport->x || drawstate.viewport->y) {
copydata->dstrect.x += drawstate.viewport->x;
copydata->dstrect.y += drawstate.viewport->y;
}
SW_RenderCopyEx(renderer, surface, cmd->data.draw.texture, &copydata->srcrect,
&copydata->dstrect, copydata->angle, &copydata->center, copydata->flip);
break;
@@ -847,6 +859,19 @@ SW_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertic
GeometryCopyData *ptr = (GeometryCopyData *) verts;
PrepTextureForCopy(cmd);
/* Apply viewport */
if (drawstate.viewport->x || drawstate.viewport->y) {
SDL_Point vp;
vp.x = drawstate.viewport->x;
vp.y = drawstate.viewport->y;
trianglepoint_2_fixedpoint(&vp);
for (i = 0; i < count; i++) {
ptr[i].dst.x += vp.x;
ptr[i].dst.y += vp.y;
}
}
for (i = 0; i < count; i += 3, ptr += 3) {
SDL_SW_BlitTriangle(
src,
@@ -857,6 +882,19 @@ SW_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertic
}
} else {
GeometryFillData *ptr = (GeometryFillData *) verts;
/* Apply viewport */
if (drawstate.viewport->x || drawstate.viewport->y) {
SDL_Point vp;
vp.x = drawstate.viewport->x;
vp.y = drawstate.viewport->y;
trianglepoint_2_fixedpoint(&vp);
for (i = 0; i < count; i++) {
ptr[i].dst.x += vp.x;
ptr[i].dst.y += vp.y;
}
}
for (i = 0; i < count; i += 3, ptr += 3) {
SDL_SW_FillTriangle(surface, &(ptr[0].dst), &(ptr[1].dst), &(ptr[2].dst), blend, ptr[0].color, ptr[1].color, ptr[2].color);
}
@@ -992,17 +1030,24 @@ SW_CreateRenderer(SDL_Window * window, Uint32 flags)
{
const char *hint;
SDL_Surface *surface;
SDL_bool no_hint_set;
/* Set the vsync hint based on our flags, if it's not already set */
hint = SDL_GetHint(SDL_HINT_RENDER_VSYNC);
if (!hint || !*hint) {
no_hint_set = SDL_TRUE;
} else {
no_hint_set = SDL_FALSE;
}
if (no_hint_set) {
SDL_SetHint(SDL_HINT_RENDER_VSYNC, (flags & SDL_RENDERER_PRESENTVSYNC) ? "1" : "0");
}
surface = SDL_GetWindowSurface(window);
/* Reset the vsync hint if we set it above */
if (!hint || !*hint) {
if (no_hint_set) {
SDL_SetHint(SDL_HINT_RENDER_VSYNC, "");
}

View File

@@ -146,7 +146,7 @@ static struct
{ "US-ASCII", ENCODING_ASCII },
{ "8859-1", ENCODING_LATIN1 },
{ "ISO-8859-1", ENCODING_LATIN1 },
#ifdef __WIN32__
#if defined(__WIN32__) || defined(__OS2__)
{ "WCHAR_T", ENCODING_UTF16LE },
#else
{ "WCHAR_T", ENCODING_UCS4NATIVE },
@@ -867,6 +867,7 @@ SDL_iconv_string(const char *tocode, const char *fromcode, const char *inbuf,
stringsize *= 2;
string = (char *) SDL_realloc(string, stringsize);
if (!string) {
SDL_free(oldstring);
SDL_iconv_close(cd);
return NULL;
}
@@ -887,8 +888,7 @@ SDL_iconv_string(const char *tocode, const char *fromcode, const char *inbuf,
break;
}
/* Avoid infinite loops when nothing gets converted */
if (oldinbytesleft == inbytesleft)
{
if (oldinbytesleft == inbytesleft) {
break;
}
}

View File

@@ -1292,7 +1292,7 @@ SDLTest_CommonInit(SDLTest_CommonState * state)
SDL_GetWindowSize(state->windows[i], &w, &h);
if (!(state->window_flags & SDL_WINDOW_RESIZABLE) &&
(w != state->window_w || h != state->window_h)) {
printf("Window requested size %dx%d, got %dx%d\n", state->window_w, state->window_h, w, h);
SDL_Log("Window requested size %dx%d, got %dx%d\n", state->window_w, state->window_h, w, h);
state->window_w = w;
state->window_h = h;
}
@@ -1970,7 +1970,7 @@ SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done)
if (withControl) {
/* Ctrl-C copy awesome text! */
SDL_SetClipboardText("SDL rocks!\nYou know it!");
printf("Copied text to clipboard\n");
SDL_Log("Copied text to clipboard\n");
}
if (withAlt) {
/* Alt-C toggle a render clip rectangle */
@@ -2006,9 +2006,9 @@ SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done)
/* Ctrl-V paste awesome text! */
char *text = SDL_GetClipboardText();
if (*text) {
printf("Clipboard: %s\n", text);
SDL_Log("Clipboard: %s\n", text);
} else {
printf("Clipboard is empty\n");
SDL_Log("Clipboard is empty\n");
}
SDL_free(text);
}

View File

@@ -20,7 +20,7 @@
*/
#include "../../SDL_internal.h"
#ifdef SDL_TIMERS_PSP
#ifdef SDL_TIMER_PSP
#include "SDL_thread.h"
#include "SDL_timer.h"
@@ -84,7 +84,7 @@ void SDL_Delay(Uint32 ms)
sceKernelDelayThreadCB(ms * 1000);
}
#endif /* SDL_TIMERS_PSP */
#endif /* SDL_TIMER_PSP */
/* vim: ts=4 sw=4
*/

View File

@@ -947,7 +947,7 @@ Map1to1(SDL_Palette * src, SDL_Palette * dst, int *identical)
}
*identical = 0;
}
map = (Uint8 *) SDL_malloc(src->ncolors);
map = (Uint8 *) SDL_calloc(256, sizeof(Uint8));
if (map == NULL) {
SDL_OutOfMemory();
return (NULL);
@@ -971,7 +971,7 @@ Map1toN(SDL_PixelFormat * src, Uint8 Rmod, Uint8 Gmod, Uint8 Bmod, Uint8 Amod,
SDL_Palette *pal = src->palette;
bpp = ((dst->BytesPerPixel == 3) ? 4 : dst->BytesPerPixel);
map = (Uint8 *) SDL_malloc(pal->ncolors * bpp);
map = (Uint8 *) SDL_calloc(256, bpp);
if (map == NULL) {
SDL_OutOfMemory();
return (NULL);

View File

@@ -473,15 +473,19 @@ Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event)
}
}
if (x > 0) {
x = SDL_ceil(x);
} else if (x < 0) {
x = SDL_floor(x);
}
if (y > 0) {
y = SDL_ceil(y);
} else if (y < 0) {
y = SDL_floor(y);
/* For discrete scroll events from conventional mice, always send a full tick.
For continuous scroll events from trackpads, send fractional deltas for smoother scrolling. */
if (![event respondsToSelector:@selector(hasPreciseScrollingDeltas)] || ![event hasPreciseScrollingDeltas]) {
if (x > 0) {
x = SDL_ceil(x);
} else if (x < 0) {
x = SDL_floor(x);
}
if (y > 0) {
y = SDL_ceil(y);
} else if (y < 0) {
y = SDL_floor(y);
}
}
SDL_SendMouseWheel(window, mouseID, x, y, direction);

View File

@@ -109,7 +109,10 @@ Cocoa_GLES_SetupWindow(_THIS, SDL_Window * window)
if (_this->egl_data == NULL) {
/* !!! FIXME: commenting out this assertion is (I think) incorrect; figure out why driver_loaded is wrong for ANGLE instead. --ryan. */
#if 0 /* When hint SDL_HINT_OPENGL_ES_DRIVER is set to "1" (e.g. for ANGLE support), _this->gl_config.driver_loaded can be 1, while the below lines function. */
SDL_assert(!_this->gl_config.driver_loaded);
#endif
if (SDL_EGL_LoadLibrary(_this, NULL, EGL_DEFAULT_DISPLAY, 0) < 0) {
SDL_EGL_UnloadLibrary(_this);
return -1;

View File

@@ -73,6 +73,7 @@ KMSDRM_DestroyCursorBO (_THIS, SDL_VideoDisplay *display)
if (dispdata->cursor_bo) {
KMSDRM_gbm_bo_destroy(dispdata->cursor_bo);
dispdata->cursor_bo = NULL;
dispdata->cursor_bo_drm_fd = -1;
}
}
@@ -116,6 +117,8 @@ KMSDRM_CreateCursorBO (SDL_VideoDisplay *display) {
SDL_SetError("Could not create GBM cursor BO");
return;
}
dispdata->cursor_bo_drm_fd = viddata->drm_fd;
}
/* Remove a cursor buffer from a display's DRM cursor BO. */
@@ -384,11 +387,9 @@ KMSDRM_WarpMouseGlobal(int x, int y)
/* And now update the cursor graphic position on screen. */
if (dispdata->cursor_bo) {
int drm_fd;
int ret = 0;
drm_fd = KMSDRM_gbm_device_get_fd(KMSDRM_gbm_bo_get_device(dispdata->cursor_bo));
ret = KMSDRM_drmModeMoveCursor(drm_fd, dispdata->crtc->crtc_id, x, y);
ret = KMSDRM_drmModeMoveCursor(dispdata->cursor_bo_drm_fd, dispdata->crtc->crtc_id, x, y);
if (ret) {
SDL_SetError("drmModeMoveCursor() failed.");
@@ -437,7 +438,6 @@ static void
KMSDRM_MoveCursor(SDL_Cursor * cursor)
{
SDL_Mouse *mouse = SDL_GetMouse();
int drm_fd;
int ret = 0;
/* We must NOT call SDL_SendMouseMotion() here or we will enter recursivity!
@@ -452,9 +452,7 @@ KMSDRM_MoveCursor(SDL_Cursor * cursor)
return;
}
drm_fd = KMSDRM_gbm_device_get_fd(KMSDRM_gbm_bo_get_device(dispdata->cursor_bo));
ret = KMSDRM_drmModeMoveCursor(drm_fd, dispdata->crtc->crtc_id, mouse->x, mouse->y);
ret = KMSDRM_drmModeMoveCursor(dispdata->cursor_bo_drm_fd, dispdata->crtc->crtc_id, mouse->x, mouse->y);
if (ret) {
SDL_SetError("drmModeMoveCursor() failed.");

View File

@@ -95,7 +95,6 @@ SDL_KMSDRM_SYM(int,drmModeSetPlane,(int fd, uint32_t plane_id, uint32_t crtc_id,
/* Planes stuff ends. */
SDL_KMSDRM_MODULE(GBM)
SDL_KMSDRM_SYM(int,gbm_device_get_fd,(struct gbm_device *gbm))
SDL_KMSDRM_SYM(int,gbm_device_is_format_supported,(struct gbm_device *gbm,
uint32_t format, uint32_t usage))
SDL_KMSDRM_SYM(void,gbm_device_destroy,(struct gbm_device *gbm))

View File

@@ -555,6 +555,7 @@ KMSDRM_AddDisplay (_THIS, drmModeConnector *connector, drmModeRes *resources) {
/* Initialize some of the members of the new display's driverdata
to sane values. */
dispdata->cursor_bo = NULL;
dispdata->cursor_bo_drm_fd = -1;
/* Since we create and show the default cursor on KMSDRM_InitMouse(),
and we call KMSDRM_InitMouse() when we create a window, we have to know

View File

@@ -77,6 +77,7 @@ typedef struct SDL_DisplayData
where we may not have an SDL_Cursor at all (so no SDL_Cursor driverdata).
There's only one cursor GBM BO because we only support one cursor. */
struct gbm_bo *cursor_bo;
int cursor_bo_drm_fd;
uint64_t cursor_w, cursor_h;
SDL_bool default_cursor_init;

View File

@@ -320,10 +320,15 @@ static VOID _wmChar(WINDATA *pWinData, MPARAM mp1, MPARAM mp2)
}
if ((ulFlags & KC_CHAR) != 0) {
CHAR acUTF8[4];
LONG lRC = StrUTF8(1, acUTF8, sizeof(acUTF8), (PSZ)&ulCharCode, 1);
SDL_SendKeyboardText((lRC > 0)? acUTF8 : (PSZ)&ulCharCode);
#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H)
char *utf8 = SDL_iconv_string("UTF-8", "", (char *)&ulCharCode, 1);
SDL_SendKeyboardText((utf8 && *utf8) ? utf8 : (char *)&ulCharCode);
SDL_free(utf8);
#else
char utf8[4];
int rc = StrUTF8(1, utf8, sizeof(utf8), (char *)&ulCharCode, 1);
SDL_SendKeyboardText((rc > 0) ? utf8 : (char *) &ulCharCode);
#endif
}
}
@@ -389,7 +394,7 @@ static MRESULT _wmDrop(WINDATA *pWinData, PDRAGINFO pDragInfo)
{
ULONG ulIdx;
PDRAGITEM pDragItem;
CHAR acFName[_MAX_PATH];
CHAR acFName[CCHMAXPATH];
PCHAR pcFName;
if (!DrgAccessDraginfo(pDragInfo))

View File

@@ -34,6 +34,7 @@
#include "SDL_keyboard.h"
#include "../../thread/SDL_systhread.h"
#include <psphprm.h>
#include <pspthreadman.h>
#ifdef PSPIRKEYB
#include <pspirkeyb.h>

View File

@@ -214,6 +214,7 @@ PSP_CreateWindow(_THIS, SDL_Window * window)
/* Setup driver data for this window */
window->driverdata = wdata;
SDL_SetKeyboardFocus(window);
/* Window has been successfully created */
return 0;

View File

@@ -95,6 +95,8 @@ void SDL_WAYLAND_UnloadSymbols(void);
#define wl_proxy_marshal_constructor_versioned (*WAYLAND_wl_proxy_marshal_constructor_versioned)
#define wl_proxy_set_tag (*WAYLAND_wl_proxy_set_tag)
#define wl_proxy_get_tag (*WAYLAND_wl_proxy_get_tag)
#define wl_proxy_marshal_flags (*WAYLAND_wl_proxy_marshal_flags)
#define wl_proxy_marshal_array_flags (*WAYLAND_wl_proxy_marshal_array_flags)
#define wl_seat_interface (*WAYLAND_wl_seat_interface)
#define wl_surface_interface (*WAYLAND_wl_surface_interface)

View File

@@ -66,6 +66,25 @@
/* Weston uses a ratio of 10 units per scroll tick */
#define WAYLAND_WHEEL_AXIS_UNIT 10
static const struct {
xkb_keysym_t keysym;
SDL_KeyCode keycode;
} KeySymToSDLKeyCode[] = {
{ XKB_KEY_Shift_L, SDLK_LSHIFT },
{ XKB_KEY_Shift_R, SDLK_RSHIFT },
{ XKB_KEY_Control_L, SDLK_LCTRL },
{ XKB_KEY_Control_R, SDLK_RCTRL },
{ XKB_KEY_Caps_Lock, SDLK_CAPSLOCK },
{ XKB_KEY_Alt_L, SDLK_LALT },
{ XKB_KEY_Alt_R, SDLK_RALT },
{ XKB_KEY_Meta_L, SDLK_LGUI },
{ XKB_KEY_Meta_R, SDLK_RGUI },
{ XKB_KEY_Super_L, SDLK_LGUI },
{ XKB_KEY_Super_R, SDLK_RGUI },
{ XKB_KEY_Hyper_L, SDLK_LGUI },
{ XKB_KEY_Hyper_R, SDLK_RGUI },
};
struct SDL_WaylandTouchPoint {
SDL_TouchID id;
float x;
@@ -83,6 +102,19 @@ struct SDL_WaylandTouchPointList {
static struct SDL_WaylandTouchPointList touch_points = {NULL, NULL};
static SDL_KeyCode
Wayland_KeySymToSDLKeyCode(xkb_keysym_t keysym)
{
int i;
for (i = 0; i < SDL_arraysize(KeySymToSDLKeyCode); ++i) {
if (keysym == KeySymToSDLKeyCode[i].keysym) {
return KeySymToSDLKeyCode[i].keycode;
}
}
return SDLK_UNKNOWN;
}
static void
touch_add(SDL_TouchID id, float x, float y, struct wl_surface *surface)
{
@@ -969,6 +1001,11 @@ Wayland_keymap_iter(struct xkb_keymap *keymap, xkb_keycode_t key, void *data)
if (WAYLAND_xkb_keymap_key_get_syms_by_level(keymap, key, sdlKeymap->layout, 0, &syms) > 0) {
uint32_t keycode = SDL_KeySymToUcs4(syms[0]);
if (!keycode) {
keycode = Wayland_KeySymToSDLKeyCode(syms[0]);
}
if (keycode) {
sdlKeymap->keymap[scancode] = keycode;
} else {

View File

@@ -84,6 +84,10 @@ SDL_WAYLAND_MODULE(WAYLAND_CLIENT_1_18)
SDL_WAYLAND_SYM(void, wl_proxy_set_tag, (struct wl_proxy *, const char * const *))
SDL_WAYLAND_SYM(const char * const *, wl_proxy_get_tag, (struct wl_proxy *))
SDL_WAYLAND_MODULE(WAYLAND_CLIENT_1_20)
SDL_WAYLAND_SYM(struct wl_proxy*, wl_proxy_marshal_flags, (struct wl_proxy *proxy, uint32_t opcode, const struct wl_interface *interfac, uint32_t version, uint32_t flags, ...))
SDL_WAYLAND_SYM(struct wl_proxy*, wl_proxy_marshal_array_flags, (struct wl_proxy *proxy, uint32_t opcode, const struct wl_interface *interface, uint32_t version, uint32_t flags, union wl_argument *args))
SDL_WAYLAND_INTERFACE(wl_seat_interface)
SDL_WAYLAND_INTERFACE(wl_surface_interface)
SDL_WAYLAND_INTERFACE(wl_shm_pool_interface)

View File

@@ -290,8 +290,10 @@ handle_configure_xdg_toplevel(void *data,
/* For fullscreen, foolishly do what the compositor says. If it's wrong,
* don't blame us, we were explicitly instructed to do this.
*/
window->w = width;
window->h = height;
if (width != 0 && height != 0) {
window->w = width;
window->h = height;
}
/* This part is good though. */
if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) {

View File

@@ -109,7 +109,7 @@ WIN_GLES_SetupWindow(_THIS, SDL_Window * window)
if (_this->egl_data == NULL) {
/* !!! FIXME: commenting out this assertion is (I think) incorrect; figure out why driver_loaded is wrong for ANGLE instead. --ryan. */
#if 0 /* When hint SDL_HINT_OPENGL_ES_DRIVER is set to "1" (e.g. for ANGLE support), _this->gl_config.driver_loaded can be 0, while the below lines function. */
#if 0 /* When hint SDL_HINT_OPENGL_ES_DRIVER is set to "1" (e.g. for ANGLE support), _this->gl_config.driver_loaded can be 1, while the below lines function. */
SDL_assert(!_this->gl_config.driver_loaded);
#endif
if (SDL_EGL_LoadLibrary(_this, NULL, EGL_DEFAULT_DISPLAY, 0) < 0) {

View File

@@ -115,6 +115,7 @@ X11_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format,
shmdt(shminfo->shmaddr);
} else {
/* Done! */
data->ximage->byte_order = (SDL_BYTEORDER == SDL_BIG_ENDIAN) ? MSBFirst : LSBFirst;
data->use_mitshm = SDL_TRUE;
*pixels = shminfo->shmaddr;
return 0;
@@ -135,6 +136,7 @@ X11_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format,
SDL_free(*pixels);
return SDL_SetError("Couldn't create XImage");
}
data->ximage->byte_order = (SDL_BYTEORDER == SDL_BIG_ENDIAN) ? MSBFirst : LSBFirst;
return 0;
}

View File

@@ -163,7 +163,7 @@ SDL_X11_SYM(Status,XmbTextListToTextProperty,(Display* a,char** b,int c,XICCEnco
SDL_X11_MODULE(XFIXES)
SDL_X11_SYM(PointerBarrier, XFixesCreatePointerBarrier, (Display* a, Window b, int c, int d, int e, int f, int g, int h, int *i),(a,b,c,d,e,f,g,h,i),return)
SDL_X11_SYM(void, XFixesDestroyPointerBarrier, (Display* a, PointerBarrier b), (a,b),)
SDL_X11_SYM(int, XIBarrierReleasePointer,(Display* a, int b, PointerBarrier c, BarrierEventID d), (a,b,c,d), return)
SDL_X11_SYM(int, XIBarrierReleasePointer,(Display* a, int b, PointerBarrier c, BarrierEventID d), (a,b,c,d), return) /* this is actually Xinput2 */
SDL_X11_SYM(Status, XFixesQueryVersion,(Display* a, int* b, int* c), (a,b,c), return)
#endif

View File

@@ -91,7 +91,7 @@ static uint8_t clampU8(int32_t v)
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
};
return lut[(v+128*PRECISION_FACTOR)>>PRECISION];
return lut[((v+128*PRECISION_FACTOR)>>PRECISION)&511];
}