From e89a1f9157a938b0184c3a530134e3dec351c582 Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Tue, 22 Nov 2022 20:10:47 +0300 Subject: [PATCH] removed NaCL support. --- build-scripts/nacl-buildbot.sh | 61 --- build-scripts/naclbuild.sh | 105 ------ configure.ac | 50 --- docs/README-nacl.md | 103 ----- docs/README.md | 1 - include/SDL_assert.h | 2 +- include/SDL_config.h.in | 3 - include/SDL_main.h | 9 - include/SDL_platform.h | 16 - src/SDL_log.c | 3 - src/audio/SDL_audio.c | 3 - src/audio/SDL_sysaudio.h | 1 - src/audio/nacl/SDL_naclaudio.c | 160 -------- src/audio/nacl/SDL_naclaudio.h | 42 --- src/dynapi/SDL_dynapi.h | 2 - src/file/SDL_rwops.c | 4 - src/filesystem/nacl/SDL_sysfilesystem.c | 43 --- src/main/nacl/SDL_nacl_main.c | 93 ----- src/render/opengles2/SDL_gles2funcs.h | 4 - src/thread/pthread/SDL_systhread.c | 14 +- src/video/SDL_sysvideo.h | 1 - src/video/SDL_video.c | 5 +- src/video/nacl/SDL_naclevents.c | 440 ---------------------- src/video/nacl/SDL_naclevents_c.h | 30 -- src/video/nacl/SDL_naclglue.c | 24 -- src/video/nacl/SDL_naclopengles.c | 174 --------- src/video/nacl/SDL_naclopengles.h | 38 -- src/video/nacl/SDL_naclvideo.c | 187 ---------- src/video/nacl/SDL_naclvideo.h | 67 ---- src/video/nacl/SDL_naclwindow.c | 78 ---- src/video/nacl/SDL_naclwindow.h | 32 -- test/nacl/Makefile | 63 ---- test/nacl/background.js | 40 -- test/nacl/common.js | 474 ------------------------ test/nacl/index.html | 21 -- test/nacl/manifest.json | 22 -- test/testgles2.c | 7 +- test/testgles2_sdf.c | 7 +- 38 files changed, 11 insertions(+), 2418 deletions(-) delete mode 100755 build-scripts/nacl-buildbot.sh delete mode 100755 build-scripts/naclbuild.sh delete mode 100644 docs/README-nacl.md delete mode 100644 src/audio/nacl/SDL_naclaudio.c delete mode 100644 src/audio/nacl/SDL_naclaudio.h delete mode 100644 src/filesystem/nacl/SDL_sysfilesystem.c delete mode 100644 src/main/nacl/SDL_nacl_main.c delete mode 100644 src/video/nacl/SDL_naclevents.c delete mode 100644 src/video/nacl/SDL_naclevents_c.h delete mode 100644 src/video/nacl/SDL_naclglue.c delete mode 100644 src/video/nacl/SDL_naclopengles.c delete mode 100644 src/video/nacl/SDL_naclopengles.h delete mode 100644 src/video/nacl/SDL_naclvideo.c delete mode 100644 src/video/nacl/SDL_naclvideo.h delete mode 100644 src/video/nacl/SDL_naclwindow.c delete mode 100644 src/video/nacl/SDL_naclwindow.h delete mode 100644 test/nacl/Makefile delete mode 100644 test/nacl/background.js delete mode 100644 test/nacl/common.js delete mode 100644 test/nacl/index.html delete mode 100644 test/nacl/manifest.json diff --git a/build-scripts/nacl-buildbot.sh b/build-scripts/nacl-buildbot.sh deleted file mode 100755 index efd345b9ac..0000000000 --- a/build-scripts/nacl-buildbot.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/bash - -# This is the script buildbot.libsdl.org uses to cross-compile SDL3 from -# amd64 Linux to NaCl. - -# PLEASE NOTE that we have reports that SDL built with pepper_49 (current -# stable release as of November 10th, 2016) is broken. Please retest -# when something newer becomes stable and then decide if this was SDL's -# bug or NaCl's bug. --ryan. -export NACL_SDK_ROOT="/nacl_sdk/pepper_47" - -TARBALL="$1" -if [ -z $1 ]; then - TARBALL=sdl-nacl.tar.xz -fi - -OSTYPE=`uname -s` -if [ "$OSTYPE" != "Linux" ]; then - # !!! FIXME - echo "This only works on x86 or x64-64 Linux at the moment." 1>&2 - exit 1 -fi - -if [ "x$MAKE" == "x" ]; then - NCPU=`cat /proc/cpuinfo |grep vendor_id |wc -l` - let NCPU=$NCPU+1 - MAKE="make -j$NCPU" -fi - -BUILDBOTDIR="nacl-buildbot" -PARENTDIR="$PWD" - -set -e -set -x -rm -f $TARBALL -rm -rf $BUILDBOTDIR -mkdir -p $BUILDBOTDIR -pushd $BUILDBOTDIR - -# !!! FIXME: ccache? -export CC="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-clang" -export CFLAGS="$CFLAGS -I$NACL_SDK_ROOT/include -I$NACL_SDK_ROOT/include/pnacl" -export AR="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-ar" -export LD="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-ar" -export RANLIB="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-ranlib" - -../configure --host=pnacl --prefix=$PWD/nacl-sdl3-installed -$MAKE -$MAKE install -# Fix up a few things to a real install path -perl -w -pi -e "s#$PWD/nacl-sdl3-installed#/usr/local#g;" ./nacl-sdl3-installed/lib/libSDL3.la ./nacl-sdl3-installed/lib/pkgconfig/sdl3.pc ./nacl-sdl3-installed/bin/sdl3-config -mkdir -p ./usr -mv ./nacl-sdl3-installed ./usr/local - -popd -tar -cJvvf $TARBALL -C $BUILDBOTDIR usr -rm -rf $BUILDBOTDIR - -set +x -echo "All done. Final installable is in $TARBALL ..."; - diff --git a/build-scripts/naclbuild.sh b/build-scripts/naclbuild.sh deleted file mode 100755 index ad284d0e95..0000000000 --- a/build-scripts/naclbuild.sh +++ /dev/null @@ -1,105 +0,0 @@ -#!/bin/bash -if [ -z "$1" ] && [ -z "$NACL_SDK_ROOT" ]; then - echo "Usage: ./naclbuild ~/nacl/pepper_35" - echo "This will build SDL for Native Client, and testgles2.c as a demo" - echo "You can set env vars CC, AR, LD and RANLIB to override the default PNaCl toolchain used" - echo "You can set env var SOURCES to select a different source file than testgles2.c" - exit 1 -fi - -if [ -n "$1" ]; then - NACL_SDK_ROOT="$1" -fi - -CC="" - -if [ -n "$2" ]; then - CC="$2" -fi - -echo "Using SDK at $NACL_SDK_ROOT" - -export NACL_SDK_ROOT="$NACL_SDK_ROOT" -export CFLAGS="$CFLAGS -I$NACL_SDK_ROOT/include -I$NACL_SDK_ROOT/include/pnacl" - -NCPUS="1" -case "$OSTYPE" in - darwin*) - NCPU=`sysctl -n hw.ncpu` - ;; - linux*) - if [ -n `which nproc` ]; then - NCPUS=`nproc` - fi - ;; - *);; -esac - -CURDIR=`pwd -P` -SDLPATH="$( cd "$(dirname "$0")/.." ; pwd -P )" -BUILDPATH="$SDLPATH/build/nacl" -TESTBUILDPATH="$BUILDPATH/test" -SDL3_STATIC="$BUILDPATH/build/.libs/libSDL3.a" -mkdir -p $BUILDPATH -mkdir -p $TESTBUILDPATH - -if [ -z "$CC" ]; then - export CC="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-clang" -fi -if [ -z "$AR" ]; then - export AR="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-ar" -fi -if [ -z "$LD" ]; then - export LD="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-ar" -fi -if [ -z "$RANLIB" ]; then - export RANLIB="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-ranlib" -fi - -if [ -z "$SOURCES" ]; then - export SOURCES="$SDLPATH/test/testgles2.c" -fi - -if [ ! -f "$CC" ]; then - echo "Could not find compiler at $CC" - exit 1 -fi - - - - -cd $BUILDPATH -$SDLPATH/configure --host=pnacl --prefix $TESTBUILDPATH -make -j$NCPUS CFLAGS="$CFLAGS -I./include" -make install - -if [ ! -f "$SDL3_STATIC" ]; then - echo "Build failed! $SDL3_STATIC" - exit 1 -fi - -echo "Building test" -cp -f $SDLPATH/test/nacl/* $TESTBUILDPATH -# Some tests need these resource files -cp -f $SDLPATH/test/*.bmp $TESTBUILDPATH -cp -f $SDLPATH/test/*.wav $TESTBUILDPATH -cp -f $SDL3_STATIC $TESTBUILDPATH - -# Copy user sources -_SOURCES=($SOURCES) -for src in "${_SOURCES[@]}" -do - cp $src $TESTBUILDPATH -done -export SOURCES="$SOURCES" - -cd $TESTBUILDPATH -make -j$NCPUS CONFIG="Release" CFLAGS="$CFLAGS -I$TESTBUILDPATH/include/SDL3 -I$SDLPATH/include" -make -j$NCPUS CONFIG="Debug" CFLAGS="$CFLAGS -I$TESTBUILDPATH/include/SDL3 -I$SDLPATH/include" - -echo -echo "Run the test with: " -echo "cd $TESTBUILDPATH;python -m SimpleHTTPServer" -echo "Then visit http://localhost:8000 with Chrome" - -cd $CURDIR diff --git a/configure.ac b/configure.ac index b92d0b8c9f..8371faa2ce 100644 --- a/configure.ac +++ b/configure.ac @@ -1529,33 +1529,6 @@ dnl See if libdecor is available fi } -dnl Check for Native Client stuff -CheckNativeClient() -{ - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - #if !defined(__native_client__) - #error "NO NACL" - #endif - ]],[])], [ - AC_DEFINE(SDL_VIDEO_DRIVER_NACL, 1, [ ]) - AC_DEFINE(SDL_AUDIO_DRIVER_NACL, 1, [ ]) - AC_DEFINE(HAVE_POW, 1, [ ]) - AC_DEFINE(HAVE_OPENGLES2, 1, [ ]) - AC_DEFINE(SDL_VIDEO_OPENGL_ES2, 1, [ ]) - AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES2, 1, [ ]) - - SDL_LIBS="-lppapi_simple -lppapi_gles2 $SDL_LIBS" - - SDLMAIN_SOURCES="$srcdir/src/main/nacl/*.c" - SOURCES="$SOURCES $srcdir/src/audio/nacl/*.c" - SUMMARY_audio="${SUMMARY_audio} nacl" - have_audio=yes - SOURCES="$SOURCES $srcdir/src/video/nacl/*.c" - SUMMARY_video="${SUMMARY_video} nacl opengles2" - have_video=yes - ],[]) -} - CheckRPI() { AC_ARG_ENABLE(video-rpi, @@ -4147,29 +4120,6 @@ dnl BeOS support removed after SDL 2.0.1. Haiku still works. --ryan. EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-weak_framework,QuartzCore -Wl,-weak_framework,Metal" fi ;; - *-nacl|*-pnacl) - ARCH=nacl - CheckNativeClient - CheckDummyAudio - CheckDummyVideo - CheckOffscreenVideo - CheckInputEvents - CheckPTHREAD - CheckO_CLOEXEC - - # Set up files for the timer library - if test x$enable_timers = xyes; then - AC_DEFINE(SDL_TIMER_UNIX, 1, [ ]) - SOURCES="$SOURCES $srcdir/src/timer/unix/*.c" - have_timers=yes - fi - - if test x$enable_filesystem = xyes; then - AC_DEFINE(SDL_FILESYSTEM_NACL, 1, [ ]) - SOURCES="$SOURCES $srcdir/src/filesystem/nacl/*.c" - have_filesystem=yes - fi - ;; *-*-emscripten* ) if test x$enable_video = xyes; then AC_DEFINE(SDL_VIDEO_DRIVER_EMSCRIPTEN, 1, [ ]) diff --git a/docs/README-nacl.md b/docs/README-nacl.md deleted file mode 100644 index 53ada33c31..0000000000 --- a/docs/README-nacl.md +++ /dev/null @@ -1,103 +0,0 @@ -Native Client -================================================================================ - -Requirements: - -* Native Client SDK (https://developer.chrome.com/native-client), - (tested with Pepper version 33 or higher). - -The SDL backend for Chrome's Native Client has been tested only with the PNaCl -toolchain, which generates binaries designed to run on ARM and x86_32/64 -platforms. This does not mean it won't work with the other toolchains! - -================================================================================ -Building SDL for NaCl -================================================================================ - -Set up the right environment variables (see naclbuild.sh), then configure SDL with: - - configure --host=pnacl --prefix some/install/destination - -Then "make". - -As an example of how to create a deployable app a Makefile project is provided -in test/nacl/Makefile, which includes some monkey patching of the common.mk file -provided by NaCl, without which linking properly to SDL won't work (the search -path can't be modified externally, so the linker won't find SDL's binaries unless -you dump them into the SDK path, which is inconvenient). -Also provided in test/nacl is the required support file, such as index.html, -manifest.json, etc. -SDL apps for NaCl run on a worker thread using the ppapi_simple infrastructure. -This allows for blocking calls on all the relevant systems (OpenGL ES, filesystem), -hiding the asynchronous nature of the browser behind the scenes...which is not the -same as making it disappear! - - -================================================================================ -Running tests -================================================================================ - -Due to the nature of NaCl programs, building and running SDL tests is not as -straightforward as one would hope. The script naclbuild.sh in build-scripts -automates the process and should serve as a guide for users of SDL trying to build -their own applications. - -Basic usage: - - ./naclbuild.sh path/to/pepper/toolchain (i.e. ~/naclsdk/pepper_35) - -This will build testgles2.c by default. - -If you want to build a different test, for example testrendercopyex.c: - - SOURCES=~/sdl/SDL/test/testrendercopyex.c ./naclbuild.sh ~/naclsdk/pepper_35 - -Once the build finishes, you have to serve the contents with a web server (the -script will give you instructions on how to do that with Python). - -================================================================================ -RWops and nacl_io -================================================================================ - -SDL_RWops work transparently with nacl_io. Two functions control the mount points: - - int mount(const char* source, const char* target, - const char* filesystemtype, - unsigned long mountflags, const void *data); - int umount(const char *target); - - For convenience, SDL will by default mount an httpfs tree at / before calling -the app's main function. Such setting can be overridden by calling: - - umount("/"); - -And then mounting a different filesystem at / - -It's important to consider that the asynchronous nature of file operations on a -browser is hidden from the application, effectively providing the developer with -a set of blocking file operations just like you get in a regular desktop -environment, which eases the job of porting to Native Client, but also introduces -a set of challenges of its own, in particular when big file sizes and slow -connections are involved. - -For more information on how nacl_io and mount points work, see: - - https://developer.chrome.com/native-client/devguide/coding/nacl_io - https://src.chromium.org/chrome/trunk/src/native_client_sdk/src/libraries/nacl_io/nacl_io.h - -To be able to save into the directory "/save/" (like backup of game) : - - mount("", "/save", "html5fs", 0, "type=PERSISTENT"); - -And add to manifest.json : - - "permissions": [ - "unlimitedStorage" - ] - -================================================================================ -TODO - Known Issues -================================================================================ -* Testing of all systems with a real application (something other than SDL's tests) -* Key events don't seem to work properly - diff --git a/docs/README.md b/docs/README.md index 9af1ceb6bb..99220ff916 100644 --- a/docs/README.md +++ b/docs/README.md @@ -34,7 +34,6 @@ More documentation and FAQs are available online at [the wiki](http://wiki.libsd - [iOS](README-ios.md) - [Linux](README-linux.md) - [macOS](README-macos.md) -- [Native Client](README-nacl.md) - [Supported Platforms](README-platforms.md) - [Porting information](README-porting.md) - [PSP](README-psp.md) diff --git a/include/SDL_assert.h b/include/SDL_assert.h index e71cf9792d..df399b5dd6 100644 --- a/include/SDL_assert.h +++ b/include/SDL_assert.h @@ -53,7 +53,7 @@ assert can have unique static variables associated with it. #define SDL_TriggerBreakpoint() __debugbreak() #elif _SDL_HAS_BUILTIN(__builtin_debugtrap) #define SDL_TriggerBreakpoint() __builtin_debugtrap() -#elif ( (!defined(__NACL__)) && ((defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__))) ) +#elif (defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__)) #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "int $3\n\t" ) #elif ( defined(__APPLE__) && (defined(__arm64__) || defined(__aarch64__)) ) /* this might work on other ARM targets, but this is a known quantity... */ #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "brk #22\n\t" ) diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in index 1c6fcbdcc5..c9904c683f 100644 --- a/include/SDL_config.h.in +++ b/include/SDL_config.h.in @@ -285,7 +285,6 @@ #undef SDL_AUDIO_DRIVER_DUMMY #undef SDL_AUDIO_DRIVER_EMSCRIPTEN #undef SDL_AUDIO_DRIVER_HAIKU -#undef SDL_AUDIO_DRIVER_NACL #undef SDL_AUDIO_DRIVER_NETBSD #undef SDL_AUDIO_DRIVER_OPENSLES #undef SDL_AUDIO_DRIVER_OSS @@ -387,7 +386,6 @@ #undef SDL_VIDEO_DRIVER_X11_XSHAPE #undef SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS #undef SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM -#undef SDL_VIDEO_DRIVER_NACL #undef SDL_VIDEO_DRIVER_VIVANTE #undef SDL_VIDEO_DRIVER_VIVANTE_VDK #undef SDL_VIDEO_DRIVER_QNX @@ -437,7 +435,6 @@ #undef SDL_FILESYSTEM_RISCOS #undef SDL_FILESYSTEM_UNIX #undef SDL_FILESYSTEM_WINDOWS -#undef SDL_FILESYSTEM_NACL #undef SDL_FILESYSTEM_EMSCRIPTEN #undef SDL_FILESYSTEM_VITA #undef SDL_FILESYSTEM_PSP diff --git a/include/SDL_main.h b/include/SDL_main.h index b35b075366..3c702c06ca 100644 --- a/include/SDL_main.h +++ b/include/SDL_main.h @@ -83,15 +83,6 @@ /* We need to export SDL_main so it can be launched from Java */ #define SDLMAIN_DECLSPEC DECLSPEC -#elif defined(__NACL__) -/* On NACL we use ppapi_simple to set up the application helper code, - then wait for the first PSE_INSTANCE_DIDCHANGEVIEW event before - starting the user main function. - All user code is run in a separate thread by ppapi_simple, thus - allowing for blocking io to take place via nacl_io -*/ -#define SDL_MAIN_NEEDED - #elif defined(__PSP__) /* On PSP SDL provides a main function that sets the module info, activates the GPU and starts the thread required to be able to exit diff --git a/include/SDL_platform.h b/include/SDL_platform.h index a8e3ac225e..02093bc8cd 100644 --- a/include/SDL_platform.h +++ b/include/SDL_platform.h @@ -201,22 +201,6 @@ #define __PS2__ 1 #endif -/* The NACL compiler defines __native_client__ and __pnacl__ - * Ref: http://www.chromium.org/nativeclient/pnacl/stability-of-the-pnacl-bitcode-abi - */ -#if defined(__native_client__) -#undef __LINUX__ -#undef __NACL__ -#define __NACL__ 1 -#endif -#if defined(__pnacl__) -#undef __LINUX__ -#undef __PNACL__ -#define __PNACL__ 1 -/* PNACL with newlib supports static linking only */ -#define __SDL_NOGETPROCADDR__ -#endif - #if defined(__vita__) #define __VITA__ 1 #endif diff --git a/src/SDL_log.c b/src/SDL_log.c index c01e31d8a9..9a407fd72c 100644 --- a/src/SDL_log.c +++ b/src/SDL_log.c @@ -496,9 +496,6 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority, #if HAVE_STDIO_H && \ !(defined(__APPLE__) && (defined(SDL_VIDEO_DRIVER_COCOA) || defined(SDL_VIDEO_DRIVER_UIKIT))) fprintf(stderr, "%s: %s\n", SDL_priority_prefixes[priority], message); -#if __NACL__ - fflush(stderr); -#endif #endif } diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index f40cdd2dcf..0916ad24a0 100644 --- a/src/audio/SDL_audio.c +++ b/src/audio/SDL_audio.c @@ -48,9 +48,6 @@ static const AudioBootStrap *const bootstrap[] = { #if SDL_AUDIO_DRIVER_QSA &QSAAUDIO_bootstrap, #endif -#if SDL_AUDIO_DRIVER_NACL - &NACLAUDIO_bootstrap, -#endif #if SDL_AUDIO_DRIVER_WASAPI &WASAPI_bootstrap, #endif diff --git a/src/audio/SDL_sysaudio.h b/src/audio/SDL_sysaudio.h index e908986e77..dcdc5a00b7 100644 --- a/src/audio/SDL_sysaudio.h +++ b/src/audio/SDL_sysaudio.h @@ -187,7 +187,6 @@ extern AudioBootStrap ALSA_bootstrap; extern AudioBootStrap NETBSDAUDIO_bootstrap; extern AudioBootStrap DSP_bootstrap; extern AudioBootStrap QSAAUDIO_bootstrap; -extern AudioBootStrap NACLAUDIO_bootstrap; extern AudioBootStrap WASAPI_bootstrap; extern AudioBootStrap DSOUND_bootstrap; extern AudioBootStrap WINMM_bootstrap; diff --git a/src/audio/nacl/SDL_naclaudio.c b/src/audio/nacl/SDL_naclaudio.c deleted file mode 100644 index c38070d8d8..0000000000 --- a/src/audio/nacl/SDL_naclaudio.c +++ /dev/null @@ -1,160 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2022 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#include "../../SDL_internal.h" - -#if SDL_AUDIO_DRIVER_NACL - -#include "SDL_naclaudio.h" - -#include "SDL_audio.h" -#include "SDL_mutex.h" -#include "../SDL_audio_c.h" -#include "../SDL_audiodev_c.h" - -#include "ppapi/c/pp_errors.h" -#include "ppapi/c/pp_instance.h" -#include "ppapi_simple/ps.h" -#include "ppapi_simple/ps_interface.h" -#include "ppapi_simple/ps_event.h" - -/* The tag name used by NACL audio */ -#define NACLAUDIO_DRIVER_NAME "nacl" - -#define SAMPLE_FRAME_COUNT 4096 - -/* Audio driver functions */ -static void nacl_audio_callback(void* samples, uint32_t buffer_size, PP_TimeDelta latency, void* data); - -/* FIXME: Make use of latency if needed */ -static void nacl_audio_callback(void* stream, uint32_t buffer_size, PP_TimeDelta latency, void* data) { - const int len = (int) buffer_size; - SDL_AudioDevice* _this = (SDL_AudioDevice*) data; - SDL_AudioCallback callback = _this->callbackspec.callback; - - SDL_LockMutex(_this->mixer_lock); - - /* Only do something if audio is enabled */ - if (!SDL_AtomicGet(&_this->enabled) || SDL_AtomicGet(&_this->paused)) { - if (_this->stream) { - SDL_AudioStreamClear(_this->stream); - } - SDL_memset(stream, _this->spec.silence, len); - } else { - SDL_assert(_this->spec.size == len); - - if (_this->stream == NULL) { /* no conversion necessary. */ - callback(_this->callbackspec.userdata, stream, len); - } else { /* streaming/converting */ - const int stream_len = _this->callbackspec.size; - while (SDL_AudioStreamAvailable(_this->stream) < len) { - callback(_this->callbackspec.userdata, _this->work_buffer, stream_len); - if (SDL_AudioStreamPut(_this->stream, _this->work_buffer, stream_len) == -1) { - SDL_AudioStreamClear(_this->stream); - SDL_AtomicSet(&_this->enabled, 0); - break; - } - } - - const int got = SDL_AudioStreamGet(_this->stream, stream, len); - SDL_assert((got < 0) || (got == len)); - if (got != len) { - SDL_memset(stream, _this->spec.silence, len); - } - } - } - - SDL_UnlockMutex(_this->mixer_lock); -} - -static void NACLAUDIO_CloseDevice(SDL_AudioDevice *device) { - const PPB_Core *core = PSInterfaceCore(); - const PPB_Audio *ppb_audio = PSInterfaceAudio(); - SDL_PrivateAudioData *hidden = (SDL_PrivateAudioData *) device->hidden; - - ppb_audio->StopPlayback(hidden->audio); - core->ReleaseResource(hidden->audio); -} - -static int -NACLAUDIO_OpenDevice(_THIS, const char *devname) { - PP_Instance instance = PSGetInstanceId(); - const PPB_Audio *ppb_audio = PSInterfaceAudio(); - const PPB_AudioConfig *ppb_audiocfg = PSInterfaceAudioConfig(); - - private = (SDL_PrivateAudioData *) SDL_calloc(1, (sizeof *private)); - if (private == NULL) { - return SDL_OutOfMemory(); - } - - _this->spec.freq = 44100; - _this->spec.format = AUDIO_S16LSB; - _this->spec.channels = 2; - _this->spec.samples = ppb_audiocfg->RecommendSampleFrameCount( - instance, - PP_AUDIOSAMPLERATE_44100, - SAMPLE_FRAME_COUNT); - - /* Calculate the final parameters for this audio specification */ - SDL_CalculateAudioSpec(&_this->spec); - - private->audio = ppb_audio->Create( - instance, - ppb_audiocfg->CreateStereo16Bit(instance, PP_AUDIOSAMPLERATE_44100, _this->spec.samples), - nacl_audio_callback, - _this); - - /* Start audio playback while we are still on the main thread. */ - ppb_audio->StartPlayback(private->audio); - - return 0; -} - -static SDL_bool -NACLAUDIO_Init(SDL_AudioDriverImpl * impl) -{ - if (PSGetInstanceId() == 0) { - return SDL_FALSE; - } - - /* Set the function pointers */ - impl->OpenDevice = NACLAUDIO_OpenDevice; - impl->CloseDevice = NACLAUDIO_CloseDevice; - impl->OnlyHasDefaultOutputDevice = SDL_TRUE; - impl->ProvidesOwnCallbackThread = SDL_TRUE; - /* - * impl->WaitDevice = NACLAUDIO_WaitDevice; - * impl->GetDeviceBuf = NACLAUDIO_GetDeviceBuf; - * impl->PlayDevice = NACLAUDIO_PlayDevice; - * impl->Deinitialize = NACLAUDIO_Deinitialize; - */ - - return SDL_TRUE; -} - -AudioBootStrap NACLAUDIO_bootstrap = { - NACLAUDIO_DRIVER_NAME, "SDL NaCl Audio Driver", - NACLAUDIO_Init, SDL_FALSE -}; - -#endif /* SDL_AUDIO_DRIVER_NACL */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/audio/nacl/SDL_naclaudio.h b/src/audio/nacl/SDL_naclaudio.h deleted file mode 100644 index 13d8f8ca46..0000000000 --- a/src/audio/nacl/SDL_naclaudio.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2022 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#include "../../SDL_internal.h" - -#ifndef SDL_naclaudio_h_ -#define SDL_naclaudio_h_ - -#include "SDL_audio.h" -#include "../SDL_sysaudio.h" -#include "SDL_mutex.h" - -#include "ppapi/c/ppb_audio.h" - -#define _THIS SDL_AudioDevice *_this -#define private _this->hidden - -typedef struct SDL_PrivateAudioData { - PP_Resource audio; -} SDL_PrivateAudioData; - -#endif /* SDL_naclaudio_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/dynapi/SDL_dynapi.h b/src/dynapi/SDL_dynapi.h index d719462137..1182b637ef 100644 --- a/src/dynapi/SDL_dynapi.h +++ b/src/dynapi/SDL_dynapi.h @@ -47,8 +47,6 @@ #define SDL_DYNAMIC_API 0 #elif defined(__ANDROID__) /* probably not useful on Android. */ #define SDL_DYNAMIC_API 0 -#elif defined(__native_client__) && __native_client__ /* probably not useful on NACL. */ -#define SDL_DYNAMIC_API 0 #elif defined(__EMSCRIPTEN__) && __EMSCRIPTEN__ /* probably not useful on Emscripten. */ #define SDL_DYNAMIC_API 0 #elif defined(SDL_BUILDING_WINRT) && SDL_BUILDING_WINRT /* probably not useful on WinRT, given current .dll loading restrictions */ diff --git a/src/file/SDL_rwops.c b/src/file/SDL_rwops.c index ead504c10a..24058350d6 100644 --- a/src/file/SDL_rwops.c +++ b/src/file/SDL_rwops.c @@ -62,10 +62,6 @@ #include "SDL_system.h" #endif -#if __NACL__ -#include "nacl_io/nacl_io.h" -#endif - #if defined(__WIN32__) || defined(__GDK__) /* Functions to read/write Win32 API file pointers */ diff --git a/src/filesystem/nacl/SDL_sysfilesystem.c b/src/filesystem/nacl/SDL_sysfilesystem.c deleted file mode 100644 index b5bbe9841f..0000000000 --- a/src/filesystem/nacl/SDL_sysfilesystem.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2022 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "../../SDL_internal.h" -#include "SDL_error.h" -#include "SDL_filesystem.h" - -#ifdef SDL_FILESYSTEM_NACL - -char * -SDL_GetBasePath(void) -{ - SDL_Unsupported(); - return NULL; -} - -char * -SDL_GetPrefPath(const char *org, const char *app) -{ - SDL_Unsupported(); - return NULL; -} - -#endif /* SDL_FILESYSTEM_NACL */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/main/nacl/SDL_nacl_main.c b/src/main/nacl/SDL_nacl_main.c deleted file mode 100644 index a0838b184b..0000000000 --- a/src/main/nacl/SDL_nacl_main.c +++ /dev/null @@ -1,93 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2022 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "../../SDL_internal.h" - -#if SDL_VIDEO_DRIVER_NACL - -/* Include the SDL main definition header */ -#include "SDL_main.h" - -#include "ppapi_simple/ps_main.h" -#include "ppapi_simple/ps_event.h" -#include "ppapi_simple/ps_interface.h" -#include "nacl_io/nacl_io.h" -#include "sys/mount.h" - -extern void NACL_SetScreenResolution(int width, int height, Uint32 format); - -int -nacl_main(int argc, char *argv[]) -{ - int status; - PSEvent* ps_event; - PP_Resource event; - struct PP_Rect rect; - int ready = 0; - const PPB_View *ppb_view = PSInterfaceView(); - - /* This is started in a worker thread by ppapi_simple! */ - - /* Wait for the first PSE_INSTANCE_DIDCHANGEVIEW event before starting the app */ - - PSEventSetFilter(PSE_INSTANCE_DIDCHANGEVIEW); - while (!ready) { - /* Process all waiting events without blocking */ - while (!ready && (ps_event = PSEventWaitAcquire()) != NULL) { - event = ps_event->as_resource; - switch(ps_event->type) { - /* From DidChangeView, contains a view resource */ - case PSE_INSTANCE_DIDCHANGEVIEW: - ppb_view->GetRect(event, &rect); - NACL_SetScreenResolution(rect.size.width, rect.size.height, 0); - ready = 1; - break; - default: - break; - } - PSEventRelease(ps_event); - } - } - - /* Do a default httpfs mount on /, - * apps can override this by unmounting / - * and remounting with the desired configuration - */ - nacl_io_init_ppapi(PSGetInstanceId(), PSGetInterface); - - umount("/"); - mount( - "", /* source */ - "/", /* target */ - "httpfs", /* filesystemtype */ - 0, /* mountflags */ - ""); /* data specific to the html5fs type */ - - /* Everything is ready, start the user main function */ - SDL_SetMainReady(); - status = SDL_main(argc, argv); - - return 0; -} - -/* ppapi_simple will start nacl_main in a worker thread */ -PPAPI_SIMPLE_REGISTER_MAIN(nacl_main); - -#endif /* SDL_VIDEO_DRIVER_NACL */ diff --git a/src/render/opengles2/SDL_gles2funcs.h b/src/render/opengles2/SDL_gles2funcs.h index ab8bf85bb9..0efb6a5875 100644 --- a/src/render/opengles2/SDL_gles2funcs.h +++ b/src/render/opengles2/SDL_gles2funcs.h @@ -53,11 +53,7 @@ SDL_PROC(void, glPixelStorei, (GLenum, GLint)) SDL_PROC(void, glReadPixels, (GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid*)) SDL_PROC(void, glScissor, (GLint, GLint, GLsizei, GLsizei)) SDL_PROC(void, glShaderBinary, (GLsizei, const GLuint *, GLenum, const void *, GLsizei)) -#if __NACL__ -SDL_PROC(void, glShaderSource, (GLuint, GLsizei, const GLchar **, const GLint *)) -#else SDL_PROC(void, glShaderSource, (GLuint, GLsizei, const GLchar* const*, const GLint *)) -#endif SDL_PROC(void, glTexImage2D, (GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const void *)) SDL_PROC(void, glTexParameteri, (GLenum, GLenum, GLint)) SDL_PROC(void, glTexSubImage2D, (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *)) diff --git a/src/thread/pthread/SDL_systhread.c b/src/thread/pthread/SDL_systhread.c index 3b3f40fa18..8c086bfed6 100644 --- a/src/thread/pthread/SDL_systhread.c +++ b/src/thread/pthread/SDL_systhread.c @@ -60,13 +60,11 @@ #endif -#ifndef __NACL__ /* List of signals to mask in the subthreads */ static const int sig_list[] = { SIGHUP, SIGINT, SIGQUIT, SIGPIPE, SIGALRM, SIGTERM, SIGCHLD, SIGWINCH, SIGVTALRM, SIGPROF, 0 }; -#endif static void * RunThread(void *data) @@ -125,10 +123,8 @@ SDL_SYS_CreateThread(SDL_Thread * thread) void SDL_SYS_SetupThread(const char *name) { -#if !defined(__NACL__) int i; sigset_t mask; -#endif /* !__NACL__ */ if (name != NULL) { #if (defined(__MACOSX__) || defined(__IPHONEOS__) || defined(__LINUX__)) && defined(HAVE_DLOPEN) @@ -164,16 +160,12 @@ SDL_SYS_SetupThread(const char *name) #endif } - /* NativeClient does not yet support signals.*/ -#if !defined(__NACL__) /* Mask asynchronous signals for this thread */ sigemptyset(&mask); for (i = 0; sig_list[i]; ++i) { sigaddset(&mask, sig_list[i]); } pthread_sigmask(SIG_BLOCK, &mask, 0); -#endif /* !__NACL__ */ - #ifdef PTHREAD_CANCEL_ASYNCHRONOUS /* Allow ourselves to be asynchronously cancelled */ @@ -193,8 +185,8 @@ SDL_ThreadID(void) int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) { -#if __NACL__ || __RISCOS__ || __OS2__ - /* FIXME: Setting thread priority does not seem to be supported in NACL */ +#if __RISCOS__ + /* FIXME: Setting thread priority does not seem to be supported */ return 0; #else struct sched_param sched; @@ -287,7 +279,7 @@ SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) } return 0; #endif /* linux */ -#endif /* #if __NACL__ || __RISCOS__ */ +#endif /* #if __RISCOS__ */ } void diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index 8f2a9308a9..ba2e622f37 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -468,7 +468,6 @@ extern VideoBootStrap KMSDRM_LEGACY_bootstrap; extern VideoBootStrap DUMMY_bootstrap; extern VideoBootStrap DUMMY_evdev_bootstrap; extern VideoBootStrap Wayland_bootstrap; -extern VideoBootStrap NACL_bootstrap; extern VideoBootStrap VIVANTE_bootstrap; extern VideoBootStrap Emscripten_bootstrap; extern VideoBootStrap QNX_bootstrap; diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 019aa78aee..ab4edad952 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -116,9 +116,6 @@ static VideoBootStrap *bootstrap[] = { #if SDL_VIDEO_DRIVER_RPI &RPI_bootstrap, #endif -#if SDL_VIDEO_DRIVER_NACL - &NACL_bootstrap, -#endif #if SDL_VIDEO_DRIVER_EMSCRIPTEN &Emscripten_bootstrap, #endif @@ -198,7 +195,7 @@ typedef struct { static Uint32 SDL_DefaultGraphicsBackends(SDL_VideoDevice *_this) { -#if (SDL_VIDEO_OPENGL && __MACOSX__) || (__IPHONEOS__ && !TARGET_OS_MACCATALYST) || __ANDROID__ || __NACL__ +#if (SDL_VIDEO_OPENGL && __MACOSX__) || (__IPHONEOS__ && !TARGET_OS_MACCATALYST) || __ANDROID__ if (_this->GL_CreateContext != NULL) { return SDL_WINDOW_OPENGL; } diff --git a/src/video/nacl/SDL_naclevents.c b/src/video/nacl/SDL_naclevents.c deleted file mode 100644 index dbfce081b3..0000000000 --- a/src/video/nacl/SDL_naclevents.c +++ /dev/null @@ -1,440 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2022 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "../../SDL_internal.h" - -#if SDL_VIDEO_DRIVER_NACL - -#include "SDL.h" -#include "../../events/SDL_events_c.h" -#include "../SDL_sysvideo.h" -#include "SDL_naclevents_c.h" -#include "SDL_naclvideo.h" -#include "ppapi_simple/ps_event.h" - -/* Ref: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent */ - -static SDL_Scancode NACL_Keycodes[] = { - SDL_SCANCODE_UNKNOWN, /* 0 */ - SDL_SCANCODE_UNKNOWN, /* 1 */ - SDL_SCANCODE_UNKNOWN, /* 2 */ - SDL_SCANCODE_CANCEL, /* DOM_VK_CANCEL 3 */ - SDL_SCANCODE_UNKNOWN, /* 4 */ - SDL_SCANCODE_UNKNOWN, /* 5 */ - SDL_SCANCODE_HELP, /* DOM_VK_HELP 6 */ - SDL_SCANCODE_UNKNOWN, /* 7 */ - SDL_SCANCODE_BACKSPACE, /* DOM_VK_BACK_SPACE 8 */ - SDL_SCANCODE_TAB, /* DOM_VK_TAB 9 */ - SDL_SCANCODE_UNKNOWN, /* 10 */ - SDL_SCANCODE_UNKNOWN, /* 11 */ - SDL_SCANCODE_CLEAR, /* DOM_VK_CLEAR 12 */ - SDL_SCANCODE_RETURN, /* DOM_VK_RETURN 13 */ - SDL_SCANCODE_RETURN, /* DOM_VK_ENTER 14 */ - SDL_SCANCODE_UNKNOWN, /* 15 */ - SDL_SCANCODE_LSHIFT, /* DOM_VK_SHIFT 16 */ - SDL_SCANCODE_LCTRL, /* DOM_VK_CONTROL 17 */ - SDL_SCANCODE_LALT, /* DOM_VK_ALT 18 */ - SDL_SCANCODE_UNKNOWN, /* DOM_VK_PAUSE 19 */ - SDL_SCANCODE_CAPSLOCK, /* DOM_VK_CAPS_LOCK 20 */ - SDL_SCANCODE_LANG1, /* DOM_VK_KANA DOM_VK_HANGUL 21 */ - SDL_SCANCODE_UNKNOWN, /* DOM_VK_EISU 22 */ - SDL_SCANCODE_UNKNOWN, /* DOM_VK_JUNJA 23 */ - SDL_SCANCODE_UNKNOWN, /* DOM_VK_FINAL 24 */ - SDL_SCANCODE_LANG2, /* DOM_VK_HANJA DOM_VK_KANJI 25 */ - SDL_SCANCODE_UNKNOWN, /* 26 */ - SDL_SCANCODE_ESCAPE, /* DOM_VK_ESCAPE 27 */ - SDL_SCANCODE_UNKNOWN, /* DOM_VK_CONVERT 28 */ - SDL_SCANCODE_UNKNOWN, /* DOM_VK_NONCONVERT 29 */ - SDL_SCANCODE_UNKNOWN, /* DOM_VK_ACCEPT 30 */ - SDL_SCANCODE_MODE, /* DOM_VK_MODECHANGE 31 */ - SDL_SCANCODE_SPACE, /* DOM_VK_SPACE 32 */ - SDL_SCANCODE_PAGEUP, /* DOM_VK_PAGE_UP 33 */ - SDL_SCANCODE_PAGEDOWN, /* DOM_VK_PAGE_DOWN 34 */ - SDL_SCANCODE_END, /* DOM_VK_END 35 */ - SDL_SCANCODE_HOME, /* DOM_VK_HOME 36 */ - SDL_SCANCODE_LEFT, /* DOM_VK_LEFT 37 */ - SDL_SCANCODE_UP, /* DOM_VK_UP 38 */ - SDL_SCANCODE_RIGHT, /* DOM_VK_RIGHT 39 */ - SDL_SCANCODE_DOWN, /* DOM_VK_DOWN 40 */ - SDL_SCANCODE_SELECT, /* DOM_VK_SELECT 41 */ - SDL_SCANCODE_UNKNOWN, /* DOM_VK_PRINT 42 */ - SDL_SCANCODE_EXECUTE, /* DOM_VK_EXECUTE 43 */ - SDL_SCANCODE_PRINTSCREEN, /* DOM_VK_PRINTSCREEN 44 */ - SDL_SCANCODE_INSERT, /* DOM_VK_INSERT 45 */ - SDL_SCANCODE_DELETE, /* DOM_VK_DELETE 46 */ - SDL_SCANCODE_UNKNOWN, /* 47 */ - SDL_SCANCODE_0, /* DOM_VK_0 48 */ - SDL_SCANCODE_1, /* DOM_VK_1 49 */ - SDL_SCANCODE_2, /* DOM_VK_2 50 */ - SDL_SCANCODE_3, /* DOM_VK_3 51 */ - SDL_SCANCODE_4, /* DOM_VK_4 52 */ - SDL_SCANCODE_5, /* DOM_VK_5 53 */ - SDL_SCANCODE_6, /* DOM_VK_6 54 */ - SDL_SCANCODE_7, /* DOM_VK_7 55 */ - SDL_SCANCODE_8, /* DOM_VK_8 56 */ - SDL_SCANCODE_9, /* DOM_VK_9 57 */ - SDL_SCANCODE_KP_COLON, /* DOM_VK_COLON 58 */ - SDL_SCANCODE_SEMICOLON, /* DOM_VK_SEMICOLON 59 */ - SDL_SCANCODE_KP_LESS, /* DOM_VK_LESS_THAN 60 */ - SDL_SCANCODE_EQUALS, /* DOM_VK_EQUALS 61 */ - SDL_SCANCODE_KP_GREATER, /* DOM_VK_GREATER_THAN 62 */ - SDL_SCANCODE_UNKNOWN, /* DOM_VK_QUESTION_MARK 63 */ - SDL_SCANCODE_KP_AT, /* DOM_VK_AT 64 */ - SDL_SCANCODE_A, /* DOM_VK_A 65 */ - SDL_SCANCODE_B, /* DOM_VK_B 66 */ - SDL_SCANCODE_C, /* DOM_VK_C 67 */ - SDL_SCANCODE_D, /* DOM_VK_D 68 */ - SDL_SCANCODE_E, /* DOM_VK_E 69 */ - SDL_SCANCODE_F, /* DOM_VK_F 70 */ - SDL_SCANCODE_G, /* DOM_VK_G 71 */ - SDL_SCANCODE_H, /* DOM_VK_H 72 */ - SDL_SCANCODE_I, /* DOM_VK_I 73 */ - SDL_SCANCODE_J, /* DOM_VK_J 74 */ - SDL_SCANCODE_K, /* DOM_VK_K 75 */ - SDL_SCANCODE_L, /* DOM_VK_L 76 */ - SDL_SCANCODE_M, /* DOM_VK_M 77 */ - SDL_SCANCODE_N, /* DOM_VK_N 78 */ - SDL_SCANCODE_O, /* DOM_VK_O 79 */ - SDL_SCANCODE_P, /* DOM_VK_P 80 */ - SDL_SCANCODE_Q, /* DOM_VK_Q 81 */ - SDL_SCANCODE_R, /* DOM_VK_R 82 */ - SDL_SCANCODE_S, /* DOM_VK_S 83 */ - SDL_SCANCODE_T, /* DOM_VK_T 84 */ - SDL_SCANCODE_U, /* DOM_VK_U 85 */ - SDL_SCANCODE_V, /* DOM_VK_V 86 */ - SDL_SCANCODE_W, /* DOM_VK_W 87 */ - SDL_SCANCODE_X, /* DOM_VK_X 88 */ - SDL_SCANCODE_Y, /* DOM_VK_Y 89 */ - SDL_SCANCODE_Z, /* DOM_VK_Z 90 */ - SDL_SCANCODE_LGUI, /* DOM_VK_WIN 91 */ - SDL_SCANCODE_UNKNOWN, /* 92 */ - SDL_SCANCODE_APPLICATION, /* DOM_VK_CONTEXT_MENU 93 */ - SDL_SCANCODE_UNKNOWN, /* 94 */ - SDL_SCANCODE_SLEEP, /* DOM_VK_SLEEP 95 */ - SDL_SCANCODE_KP_0, /* DOM_VK_NUMPAD0 96 */ - SDL_SCANCODE_KP_1, /* DOM_VK_NUMPAD1 97 */ - SDL_SCANCODE_KP_2, /* DOM_VK_NUMPAD2 98 */ - SDL_SCANCODE_KP_3, /* DOM_VK_NUMPAD3 99 */ - SDL_SCANCODE_KP_4, /* DOM_VK_NUMPAD4 100 */ - SDL_SCANCODE_KP_5, /* DOM_VK_NUMPAD5 101 */ - SDL_SCANCODE_KP_6, /* DOM_VK_NUMPAD6 102 */ - SDL_SCANCODE_KP_7, /* DOM_VK_NUMPAD7 103 */ - SDL_SCANCODE_KP_8, /* DOM_VK_NUMPAD8 104 */ - SDL_SCANCODE_KP_9, /* DOM_VK_NUMPAD9 105 */ - SDL_SCANCODE_KP_MULTIPLY, /* DOM_VK_MULTIPLY 106 */ - SDL_SCANCODE_KP_PLUS, /* DOM_VK_ADD 107 */ - SDL_SCANCODE_KP_COMMA, /* DOM_VK_SEPARATOR 108 */ - SDL_SCANCODE_KP_MINUS, /* DOM_VK_SUBTRACT 109 */ - SDL_SCANCODE_KP_PERIOD, /* DOM_VK_DECIMAL 110 */ - SDL_SCANCODE_KP_DIVIDE, /* DOM_VK_DIVIDE 111 */ - SDL_SCANCODE_F1, /* DOM_VK_F1 112 */ - SDL_SCANCODE_F2, /* DOM_VK_F2 113 */ - SDL_SCANCODE_F3, /* DOM_VK_F3 114 */ - SDL_SCANCODE_F4, /* DOM_VK_F4 115 */ - SDL_SCANCODE_F5, /* DOM_VK_F5 116 */ - SDL_SCANCODE_F6, /* DOM_VK_F6 117 */ - SDL_SCANCODE_F7, /* DOM_VK_F7 118 */ - SDL_SCANCODE_F8, /* DOM_VK_F8 119 */ - SDL_SCANCODE_F9, /* DOM_VK_F9 120 */ - SDL_SCANCODE_F10, /* DOM_VK_F10 121 */ - SDL_SCANCODE_F11, /* DOM_VK_F11 122 */ - SDL_SCANCODE_F12, /* DOM_VK_F12 123 */ - SDL_SCANCODE_F13, /* DOM_VK_F13 124 */ - SDL_SCANCODE_F14, /* DOM_VK_F14 125 */ - SDL_SCANCODE_F15, /* DOM_VK_F15 126 */ - SDL_SCANCODE_F16, /* DOM_VK_F16 127 */ - SDL_SCANCODE_F17, /* DOM_VK_F17 128 */ - SDL_SCANCODE_F18, /* DOM_VK_F18 129 */ - SDL_SCANCODE_F19, /* DOM_VK_F19 130 */ - SDL_SCANCODE_F20, /* DOM_VK_F20 131 */ - SDL_SCANCODE_F21, /* DOM_VK_F21 132 */ - SDL_SCANCODE_F22, /* DOM_VK_F22 133 */ - SDL_SCANCODE_F23, /* DOM_VK_F23 134 */ - SDL_SCANCODE_F24, /* DOM_VK_F24 135 */ - SDL_SCANCODE_UNKNOWN, /* 136 */ - SDL_SCANCODE_UNKNOWN, /* 137 */ - SDL_SCANCODE_UNKNOWN, /* 138 */ - SDL_SCANCODE_UNKNOWN, /* 139 */ - SDL_SCANCODE_UNKNOWN, /* 140 */ - SDL_SCANCODE_UNKNOWN, /* 141 */ - SDL_SCANCODE_UNKNOWN, /* 142 */ - SDL_SCANCODE_UNKNOWN, /* 143 */ - SDL_SCANCODE_NUMLOCKCLEAR, /* DOM_VK_NUM_LOCK 144 */ - SDL_SCANCODE_SCROLLLOCK, /* DOM_VK_SCROLL_LOCK 145 */ - SDL_SCANCODE_UNKNOWN, /* DOM_VK_WIN_OEM_FJ_JISHO 146 */ - SDL_SCANCODE_UNKNOWN, /* DOM_VK_WIN_OEM_FJ_MASSHOU 147 */ - SDL_SCANCODE_UNKNOWN, /* DOM_VK_WIN_OEM_FJ_TOUROKU 148 */ - SDL_SCANCODE_UNKNOWN, /* DOM_VK_WIN_OEM_FJ_LOYA 149 */ - SDL_SCANCODE_UNKNOWN, /* DOM_VK_WIN_OEM_FJ_ROYA 150 */ - SDL_SCANCODE_UNKNOWN, /* 151 */ - SDL_SCANCODE_UNKNOWN, /* 152 */ - SDL_SCANCODE_UNKNOWN, /* 153 */ - SDL_SCANCODE_UNKNOWN, /* 154 */ - SDL_SCANCODE_UNKNOWN, /* 155 */ - SDL_SCANCODE_UNKNOWN, /* 156 */ - SDL_SCANCODE_UNKNOWN, /* 157 */ - SDL_SCANCODE_UNKNOWN, /* 158 */ - SDL_SCANCODE_UNKNOWN, /* 159 */ - SDL_SCANCODE_GRAVE, /* DOM_VK_CIRCUMFLEX 160 */ - SDL_SCANCODE_KP_EXCLAM, /* DOM_VK_EXCLAMATION 161 */ - SDL_SCANCODE_UNKNOWN, /* DOM_VK_DOUBLE_QUOTE 162 */ - SDL_SCANCODE_KP_HASH, /* DOM_VK_HASH 163 */ - SDL_SCANCODE_CURRENCYUNIT, /* DOM_VK_DOLLAR 164 */ - SDL_SCANCODE_KP_PERCENT, /* DOM_VK_PERCENT 165 */ - SDL_SCANCODE_KP_AMPERSAND, /* DOM_VK_AMPERSAND 166 */ - SDL_SCANCODE_UNKNOWN, /* DOM_VK_UNDERSCORE 167 */ - SDL_SCANCODE_KP_LEFTPAREN, /* DOM_VK_OPEN_PAREN 168 */ - SDL_SCANCODE_KP_RIGHTPAREN, /* DOM_VK_CLOSE_PAREN 169 */ - SDL_SCANCODE_KP_MULTIPLY, /* DOM_VK_ASTERISK 170 */ - SDL_SCANCODE_KP_PLUS, /* DOM_VK_PLUS 171 */ - SDL_SCANCODE_KP_PLUS, /* DOM_VK_PIPE 172 */ - SDL_SCANCODE_MINUS, /* DOM_VK_HYPHEN_MINUS 173 */ - SDL_SCANCODE_UNKNOWN, /* DOM_VK_OPEN_CURLY_BRACKET 174 */ - SDL_SCANCODE_UNKNOWN, /* DOM_VK_CLOSE_CURLY_BRACKET 175 */ - SDL_SCANCODE_NONUSBACKSLASH, /* DOM_VK_TILDE 176 */ - SDL_SCANCODE_UNKNOWN, /* 177 */ - SDL_SCANCODE_UNKNOWN, /* 178 */ - SDL_SCANCODE_UNKNOWN, /* 179 */ - SDL_SCANCODE_UNKNOWN, /* 180 */ - SDL_SCANCODE_MUTE, /* DOM_VK_VOLUME_MUTE 181 */ - SDL_SCANCODE_VOLUMEDOWN, /* DOM_VK_VOLUME_DOWN 182 */ - SDL_SCANCODE_VOLUMEUP, /* DOM_VK_VOLUME_UP 183 */ - SDL_SCANCODE_UNKNOWN, /* 184 */ - SDL_SCANCODE_UNKNOWN, /* 185 */ - SDL_SCANCODE_UNKNOWN, /* 186 */ - SDL_SCANCODE_UNKNOWN, /* 187 */ - SDL_SCANCODE_COMMA, /* DOM_VK_COMMA 188 */ - SDL_SCANCODE_UNKNOWN, /* 189 */ - SDL_SCANCODE_PERIOD, /* DOM_VK_PERIOD 190 */ - SDL_SCANCODE_SLASH, /* DOM_VK_SLASH 191 */ - SDL_SCANCODE_UNKNOWN, /* DOM_VK_BACK_QUOTE 192 */ - SDL_SCANCODE_UNKNOWN, /* 193 */ - SDL_SCANCODE_UNKNOWN, /* 194 */ - SDL_SCANCODE_UNKNOWN, /* 195 */ - SDL_SCANCODE_UNKNOWN, /* 196 */ - SDL_SCANCODE_UNKNOWN, /* 197 */ - SDL_SCANCODE_UNKNOWN, /* 198 */ - SDL_SCANCODE_UNKNOWN, /* 199 */ - SDL_SCANCODE_UNKNOWN, /* 200 */ - SDL_SCANCODE_UNKNOWN, /* 201 */ - SDL_SCANCODE_UNKNOWN, /* 202 */ - SDL_SCANCODE_UNKNOWN, /* 203 */ - SDL_SCANCODE_UNKNOWN, /* 204 */ - SDL_SCANCODE_UNKNOWN, /* 205 */ - SDL_SCANCODE_UNKNOWN, /* 206 */ - SDL_SCANCODE_UNKNOWN, /* 207 */ - SDL_SCANCODE_UNKNOWN, /* 208 */ - SDL_SCANCODE_UNKNOWN, /* 209 */ - SDL_SCANCODE_UNKNOWN, /* 210 */ - SDL_SCANCODE_UNKNOWN, /* 211 */ - SDL_SCANCODE_UNKNOWN, /* 212 */ - SDL_SCANCODE_UNKNOWN, /* 213 */ - SDL_SCANCODE_UNKNOWN, /* 214 */ - SDL_SCANCODE_UNKNOWN, /* 215 */ - SDL_SCANCODE_UNKNOWN, /* 216 */ - SDL_SCANCODE_UNKNOWN, /* 217 */ - SDL_SCANCODE_UNKNOWN, /* 218 */ - SDL_SCANCODE_LEFTBRACKET, /* DOM_VK_OPEN_BRACKET 219 */ - SDL_SCANCODE_BACKSLASH, /* DOM_VK_BACK_SLASH 220 */ - SDL_SCANCODE_RIGHTBRACKET, /* DOM_VK_CLOSE_BRACKET 221 */ - SDL_SCANCODE_APOSTROPHE, /* DOM_VK_QUOTE 222 */ - SDL_SCANCODE_UNKNOWN, /* 223 */ - SDL_SCANCODE_RGUI, /* DOM_VK_META 224 */ - SDL_SCANCODE_RALT, /* DOM_VK_ALTGR 225 */ - SDL_SCANCODE_UNKNOWN, /* 226 */ - SDL_SCANCODE_UNKNOWN, /* DOM_VK_WIN_ICO_HELP 227 */ - SDL_SCANCODE_UNKNOWN, /* DOM_VK_WIN_ICO_00 228 */ - SDL_SCANCODE_UNKNOWN, /* 229 */ - SDL_SCANCODE_UNKNOWN, /* DOM_VK_WIN_ICO_CLEAR 230 */ - SDL_SCANCODE_UNKNOWN, /* 231 */ - SDL_SCANCODE_UNKNOWN, /* 232 */ - SDL_SCANCODE_UNKNOWN, /* DOM_VK_WIN_OEM_RESET 233 */ - SDL_SCANCODE_UNKNOWN, /* DOM_VK_WIN_OEM_JUMP 234 */ - SDL_SCANCODE_UNKNOWN, /* DOM_VK_WIN_OEM_PA1 235 */ - SDL_SCANCODE_UNKNOWN, /* DOM_VK_WIN_OEM_PA2 236 */ - SDL_SCANCODE_UNKNOWN, /* DOM_VK_WIN_OEM_PA3 237 */ - SDL_SCANCODE_UNKNOWN, /* DOM_VK_WIN_OEM_WSCTRL 238 */ - SDL_SCANCODE_UNKNOWN, /* DOM_VK_WIN_OEM_CUSEL 239 */ - SDL_SCANCODE_UNKNOWN, /* DOM_VK_WIN_OEM_ATTN 240 */ - SDL_SCANCODE_UNKNOWN, /* DOM_VK_WIN_OEM_FINISH 241 */ - SDL_SCANCODE_UNKNOWN, /* DOM_VK_WIN_OEM_COPY 242 */ - SDL_SCANCODE_UNKNOWN, /* DOM_VK_WIN_OEM_AUTO 243 */ - SDL_SCANCODE_UNKNOWN, /* DOM_VK_WIN_OEM_ENLW 244 */ - SDL_SCANCODE_UNKNOWN, /* DOM_VK_WIN_OEM_BACKTAB 245 */ - SDL_SCANCODE_UNKNOWN, /* DOM_VK_ATTN 246 */ - SDL_SCANCODE_UNKNOWN, /* DOM_VK_CRSEL 247 */ - SDL_SCANCODE_UNKNOWN, /* DOM_VK_EXSEL 248 */ - SDL_SCANCODE_UNKNOWN, /* DOM_VK_EREOF 249 */ - SDL_SCANCODE_AUDIOPLAY, /* DOM_VK_PLAY 250 */ - SDL_SCANCODE_UNKNOWN, /* DOM_VK_ZOOM 251 */ - SDL_SCANCODE_UNKNOWN, /* 252 */ - SDL_SCANCODE_UNKNOWN, /* DOM_VK_PA1 253 */ - SDL_SCANCODE_UNKNOWN, /* DOM_VK_WIN_OEM_CLEAR 254 */ - SDL_SCANCODE_UNKNOWN, /* 255 */ -}; - -static Uint8 SDL_NACL_translate_mouse_button(int32_t button) { - switch (button) { - case PP_INPUTEVENT_MOUSEBUTTON_LEFT: - return SDL_BUTTON_LEFT; - case PP_INPUTEVENT_MOUSEBUTTON_MIDDLE: - return SDL_BUTTON_MIDDLE; - case PP_INPUTEVENT_MOUSEBUTTON_RIGHT: - return SDL_BUTTON_RIGHT; - - case PP_INPUTEVENT_MOUSEBUTTON_NONE: - default: - return 0; - } -} - -static SDL_Scancode -SDL_NACL_translate_keycode(int keycode) -{ - SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN; - - if (keycode < SDL_arraysize(NACL_Keycodes)) { - scancode = NACL_Keycodes[keycode]; - } -#ifdef DEBUG_SCANCODES - if (scancode == SDL_SCANCODE_UNKNOWN) { - SDL_Log("The key you just pressed is not recognized by SDL. To help get this fixed, please report this to the SDL forums/mailing list NACL KeyCode %d", keycode); - } -#endif - return scancode; -} - -void NACL_PumpEvents(_THIS) { - PSEvent* ps_event; - PP_Resource event; - PP_InputEvent_Type type; - PP_InputEvent_Modifier modifiers; - struct PP_Rect rect; - struct PP_FloatPoint fp; - struct PP_Point location; - struct PP_Var var; - const char *str; - char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; - Uint32 str_len; - SDL_VideoData *driverdata = (SDL_VideoData *) _this->driverdata; - SDL_Mouse *mouse = SDL_GetMouse(); - - if (driverdata->window) { - while ((ps_event = PSEventTryAcquire()) != NULL) { - event = ps_event->as_resource; - switch(ps_event->type) { - /* From DidChangeView, contains a view resource */ - case PSE_INSTANCE_DIDCHANGEVIEW: - driverdata->ppb_view->GetRect(event, &rect); - NACL_SetScreenResolution(rect.size.width, rect.size.height, SDL_PIXELFORMAT_UNKNOWN); - // FIXME: Rebuild context? See life.c UpdateContext - break; - - /* From HandleInputEvent, contains an input resource. */ - case PSE_INSTANCE_HANDLEINPUT: - type = driverdata->ppb_input_event->GetType(event); - modifiers = driverdata->ppb_input_event->GetModifiers(event); - switch(type) { - case PP_INPUTEVENT_TYPE_MOUSEDOWN: - SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_PRESSED, SDL_NACL_translate_mouse_button(driverdata->ppb_mouse_input_event->GetButton(event))); - break; - case PP_INPUTEVENT_TYPE_MOUSEUP: - SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_RELEASED, SDL_NACL_translate_mouse_button(driverdata->ppb_mouse_input_event->GetButton(event))); - break; - case PP_INPUTEVENT_TYPE_WHEEL: - /* FIXME: GetTicks provides high resolution scroll events */ - fp = driverdata->ppb_wheel_input_event->GetDelta(event); - SDL_SendMouseWheel(mouse->focus, mouse->mouseID, fp.x, fp.y, SDL_MOUSEWHEEL_NORMAL); - break; - - case PP_INPUTEVENT_TYPE_MOUSEENTER: - case PP_INPUTEVENT_TYPE_MOUSELEAVE: - /* FIXME: Mouse Focus */ - break; - - - case PP_INPUTEVENT_TYPE_MOUSEMOVE: - location = driverdata->ppb_mouse_input_event->GetPosition(event); - SDL_SendMouseMotion(mouse->focus, mouse->mouseID, SDL_FALSE, location.x, location.y); - break; - - case PP_INPUTEVENT_TYPE_TOUCHSTART: - case PP_INPUTEVENT_TYPE_TOUCHMOVE: - case PP_INPUTEVENT_TYPE_TOUCHEND: - case PP_INPUTEVENT_TYPE_TOUCHCANCEL: - /* FIXME: Touch events */ - break; - - case PP_INPUTEVENT_TYPE_KEYDOWN: - SDL_SendKeyboardKey(SDL_PRESSED, SDL_NACL_translate_keycode(driverdata->ppb_keyboard_input_event->GetKeyCode(event))); - break; - - case PP_INPUTEVENT_TYPE_KEYUP: - SDL_SendKeyboardKey(SDL_RELEASED, SDL_NACL_translate_keycode(driverdata->ppb_keyboard_input_event->GetKeyCode(event))); - break; - - case PP_INPUTEVENT_TYPE_CHAR: - var = driverdata->ppb_keyboard_input_event->GetCharacterText(event); - str = driverdata->ppb_var->VarToUtf8(var, &str_len); - /* str is not null terminated! */ - if ( str_len >= SDL_arraysize(text) ) { - str_len = SDL_arraysize(text) - 1; - } - SDL_strlcpy(text, str, str_len ); - text[str_len] = '\0'; - - SDL_SendKeyboardText(text); - /* FIXME: Do we have to handle ref counting? driverdata->ppb_var->Release(var);*/ - break; - - default: - break; - } - break; - - - /* From HandleMessage, contains a PP_Var. */ - case PSE_INSTANCE_HANDLEMESSAGE: - break; - - /* From DidChangeFocus, contains a PP_Bool with the current focus state. */ - case PSE_INSTANCE_DIDCHANGEFOCUS: - break; - - /* When the 3D context is lost, no resource. */ - case PSE_GRAPHICS3D_GRAPHICS3DCONTEXTLOST: - break; - - /* When the mouse lock is lost. */ - case PSE_MOUSELOCK_MOUSELOCKLOST: - break; - - default: - break; - } - - PSEventRelease(ps_event); - } - } -} - -#endif /* SDL_VIDEO_DRIVER_NACL */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/nacl/SDL_naclevents_c.h b/src/video/nacl/SDL_naclevents_c.h deleted file mode 100644 index e8d44f41b7..0000000000 --- a/src/video/nacl/SDL_naclevents_c.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2022 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "../../SDL_internal.h" - -#ifndef SDL_naclevents_c_h_ -#define SDL_naclevents_c_h_ - -#include "SDL_naclvideo.h" - -extern void NACL_PumpEvents(_THIS); - -#endif /* SDL_naclevents_c_h_ */ diff --git a/src/video/nacl/SDL_naclglue.c b/src/video/nacl/SDL_naclglue.c deleted file mode 100644 index ac1e160296..0000000000 --- a/src/video/nacl/SDL_naclglue.c +++ /dev/null @@ -1,24 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2022 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "../../SDL_internal.h" - -#if SDL_VIDEO_DRIVER_NACL -#endif /* SDL_VIDEO_DRIVER_NACL */ diff --git a/src/video/nacl/SDL_naclopengles.c b/src/video/nacl/SDL_naclopengles.c deleted file mode 100644 index ca5b75f992..0000000000 --- a/src/video/nacl/SDL_naclopengles.c +++ /dev/null @@ -1,174 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2022 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "../../SDL_internal.h" - -#if SDL_VIDEO_DRIVER_NACL - -/* NaCl SDL video GLES 2 driver implementation */ - -#include "SDL_video.h" -#include "SDL_naclvideo.h" - -#ifdef HAVE_DLOPEN -#include "dlfcn.h" -#endif - -#include "ppapi/gles2/gl2ext_ppapi.h" -#include "ppapi_simple/ps.h" - -/* GL functions */ -int -NACL_GLES_LoadLibrary(_THIS, const char *path) -{ - /* FIXME: Support dynamic linking when PNACL supports it */ - return glInitializePPAPI(PSGetInterface) == 0; -} - -void * -NACL_GLES_GetProcAddress(_THIS, const char *proc) -{ -#ifdef HAVE_DLOPEN - return dlsym( 0 /* RTLD_DEFAULT */, proc); -#else - return NULL; -#endif -} - -void -NACL_GLES_UnloadLibrary(_THIS) -{ - /* FIXME: Support dynamic linking when PNACL supports it */ - glTerminatePPAPI(); -} - -int -NACL_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext sdl_context) -{ - SDL_VideoData *driverdata = (SDL_VideoData *) _this->driverdata; - /* FIXME: Check threading issues...otherwise use a hardcoded _this->context across all threads */ - driverdata->ppb_instance->BindGraphics(driverdata->instance, (PP_Resource) sdl_context); - glSetCurrentContextPPAPI((PP_Resource) sdl_context); - return 0; -} - -SDL_GLContext -NACL_GLES_CreateContext(_THIS, SDL_Window * window) -{ - SDL_VideoData *driverdata = (SDL_VideoData *) _this->driverdata; - PP_Resource context, share_context = 0; - /* 64 seems nice. */ - Sint32 attribs[64]; - int i = 0; - - if (_this->gl_config.share_with_current_context) { - share_context = (PP_Resource) SDL_GL_GetCurrentContext(); - } - - /* FIXME: Some ATTRIBS from PP_Graphics3DAttrib are not set here */ - - attribs[i++] = PP_GRAPHICS3DATTRIB_WIDTH; - attribs[i++] = window->w; - attribs[i++] = PP_GRAPHICS3DATTRIB_HEIGHT; - attribs[i++] = window->h; - attribs[i++] = PP_GRAPHICS3DATTRIB_RED_SIZE; - attribs[i++] = _this->gl_config.red_size; - attribs[i++] = PP_GRAPHICS3DATTRIB_GREEN_SIZE; - attribs[i++] = _this->gl_config.green_size; - attribs[i++] = PP_GRAPHICS3DATTRIB_BLUE_SIZE; - attribs[i++] = _this->gl_config.blue_size; - - if (_this->gl_config.alpha_size) { - attribs[i++] = PP_GRAPHICS3DATTRIB_ALPHA_SIZE; - attribs[i++] = _this->gl_config.alpha_size; - } - - /*if (_this->gl_config.buffer_size) { - attribs[i++] = EGL_BUFFER_SIZE; - attribs[i++] = _this->gl_config.buffer_size; - }*/ - - attribs[i++] = PP_GRAPHICS3DATTRIB_DEPTH_SIZE; - attribs[i++] = _this->gl_config.depth_size; - - if (_this->gl_config.stencil_size) { - attribs[i++] = PP_GRAPHICS3DATTRIB_STENCIL_SIZE; - attribs[i++] = _this->gl_config.stencil_size; - } - - if (_this->gl_config.multisamplebuffers) { - attribs[i++] = PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS; - attribs[i++] = _this->gl_config.multisamplebuffers; - } - - if (_this->gl_config.multisamplesamples) { - attribs[i++] = PP_GRAPHICS3DATTRIB_SAMPLES; - attribs[i++] = _this->gl_config.multisamplesamples; - } - - attribs[i++] = PP_GRAPHICS3DATTRIB_NONE; - - context = driverdata->ppb_graphics->Create(driverdata->instance, share_context, attribs); - - if (context) { - /* We need to make the context current, otherwise nothing works */ - SDL_GL_MakeCurrent(window, (SDL_GLContext) context); - } - - return (SDL_GLContext) context; -} - - - -int -NACL_GLES_SetSwapInterval(_THIS, int interval) -{ - /* STUB */ - return SDL_Unsupported(); -} - -int -NACL_GLES_GetSwapInterval(_THIS) -{ - /* STUB */ - return 0; -} - -int -NACL_GLES_SwapWindow(_THIS, SDL_Window * window) -{ - SDL_VideoData *driverdata = (SDL_VideoData *) _this->driverdata; - struct PP_CompletionCallback callback = { NULL, 0, PP_COMPLETIONCALLBACK_FLAG_NONE }; - if (driverdata->ppb_graphics->SwapBuffers((PP_Resource) SDL_GL_GetCurrentContext(), callback ) != 0) { - return SDL_SetError("SwapBuffers failed"); - } - return 0; -} - -void -NACL_GLES_DeleteContext(_THIS, SDL_GLContext context) -{ - SDL_VideoData *driverdata = (SDL_VideoData *) _this->driverdata; - driverdata->ppb_core->ReleaseResource((PP_Resource) context); -} - -#endif /* SDL_VIDEO_DRIVER_NACL */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/nacl/SDL_naclopengles.h b/src/video/nacl/SDL_naclopengles.h deleted file mode 100644 index a3fee1f5b2..0000000000 --- a/src/video/nacl/SDL_naclopengles.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2022 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "../../SDL_internal.h" - -#ifndef SDL_naclopengles_h_ -#define SDL_naclopengles_h_ - -extern int NACL_GLES_LoadLibrary(_THIS, const char *path); -extern void *NACL_GLES_GetProcAddress(_THIS, const char *proc); -extern void NACL_GLES_UnloadLibrary(_THIS); -extern SDL_GLContext NACL_GLES_CreateContext(_THIS, SDL_Window * window); -extern int NACL_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); -extern int NACL_GLES_SetSwapInterval(_THIS, int interval); -extern int NACL_GLES_GetSwapInterval(_THIS); -extern int NACL_GLES_SwapWindow(_THIS, SDL_Window * window); -extern void NACL_GLES_DeleteContext(_THIS, SDL_GLContext context); - -#endif /* SDL_naclopengles_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/nacl/SDL_naclvideo.c b/src/video/nacl/SDL_naclvideo.c deleted file mode 100644 index 986bfb3126..0000000000 --- a/src/video/nacl/SDL_naclvideo.c +++ /dev/null @@ -1,187 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2022 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "../../SDL_internal.h" - -#if SDL_VIDEO_DRIVER_NACL - -#include "ppapi/c/pp_errors.h" -#include "ppapi/c/pp_instance.h" -#include "ppapi_simple/ps.h" -#include "ppapi_simple/ps_interface.h" -#include "ppapi_simple/ps_event.h" -#include "nacl_io/nacl_io.h" - -#include "SDL_naclvideo.h" -#include "SDL_naclwindow.h" -#include "SDL_naclevents_c.h" -#include "SDL_naclopengles.h" -#include "SDL_video.h" -#include "../SDL_sysvideo.h" -#include "../../events/SDL_events_c.h" - -#define NACLVID_DRIVER_NAME "nacl" - -/* Static init required because NACL_SetScreenResolution - * may appear even before SDL starts and we want to remember - * the window width and height - */ -static SDL_VideoData nacl = {0}; - -void -NACL_SetScreenResolution(int width, int height, Uint32 format) -{ - PP_Resource context; - - nacl.w = width; - nacl.h = height; - nacl.format = format; - - if (nacl.window) { - nacl.window->w = width; - nacl.window->h = height; - SDL_SendWindowEvent(nacl.window, SDL_WINDOWEVENT_RESIZED, width, height); - } - - /* FIXME: Check threading issues...otherwise use a hardcoded _this->context across all threads */ - context = (PP_Resource) SDL_GL_GetCurrentContext(); - if (context) { - PSInterfaceGraphics3D()->ResizeBuffers(context, width, height); - } - -} - - - -/* Initialization/Query functions */ -static int NACL_VideoInit(_THIS); -static void NACL_VideoQuit(_THIS); - -static int NACL_Available(void) { - return PSGetInstanceId() != 0; -} - -static void NACL_DeleteDevice(SDL_VideoDevice *device) { - SDL_VideoData *driverdata = (SDL_VideoData*) device->driverdata; - driverdata->ppb_core->ReleaseResource((PP_Resource) driverdata->ppb_message_loop); - /* device->driverdata is not freed because it points to static memory */ - SDL_free(device); -} - -static int -NACL_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) -{ - return 0; -} - -static SDL_VideoDevice *NACL_CreateDevice(void) { - SDL_VideoDevice *device; - - if (!NACL_Available()) { - return NULL; - } - - /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (!device) { - SDL_OutOfMemory(); - return NULL; - } - device->driverdata = &nacl; - - /* Set the function pointers */ - device->VideoInit = NACL_VideoInit; - device->VideoQuit = NACL_VideoQuit; - device->PumpEvents = NACL_PumpEvents; - - device->CreateSDLWindow = NACL_CreateWindow; - device->SetWindowTitle = NACL_SetWindowTitle; - device->DestroyWindow = NACL_DestroyWindow; - - device->SetDisplayMode = NACL_SetDisplayMode; - - device->free = NACL_DeleteDevice; - - /* GL pointers */ - device->GL_LoadLibrary = NACL_GLES_LoadLibrary; - device->GL_GetProcAddress = NACL_GLES_GetProcAddress; - device->GL_UnloadLibrary = NACL_GLES_UnloadLibrary; - device->GL_CreateContext = NACL_GLES_CreateContext; - device->GL_MakeCurrent = NACL_GLES_MakeCurrent; - device->GL_SetSwapInterval = NACL_GLES_SetSwapInterval; - device->GL_GetSwapInterval = NACL_GLES_GetSwapInterval; - device->GL_SwapWindow = NACL_GLES_SwapWindow; - device->GL_DeleteContext = NACL_GLES_DeleteContext; - - - return device; -} - -VideoBootStrap NACL_bootstrap = { - NACLVID_DRIVER_NAME, "SDL Native Client Video Driver", - NACL_CreateDevice -}; - -int NACL_VideoInit(_THIS) { - SDL_VideoData *driverdata = (SDL_VideoData *) _this->driverdata; - SDL_DisplayMode mode; - - SDL_zero(mode); - mode.format = driverdata->format; - mode.w = driverdata->w; - mode.h = driverdata->h; - mode.refresh_rate = 0; - mode.driverdata = NULL; - if (SDL_AddBasicVideoDisplay(&mode) < 0) { - return -1; - } - - SDL_AddDisplayMode(&_this->displays[0], &mode); - - PSInterfaceInit(); - driverdata->instance = PSGetInstanceId(); - driverdata->ppb_graphics = PSInterfaceGraphics3D(); - driverdata->ppb_message_loop = PSInterfaceMessageLoop(); - driverdata->ppb_core = PSInterfaceCore(); - driverdata->ppb_fullscreen = PSInterfaceFullscreen(); - driverdata->ppb_instance = PSInterfaceInstance(); - driverdata->ppb_image_data = PSInterfaceImageData(); - driverdata->ppb_view = PSInterfaceView(); - driverdata->ppb_var = PSInterfaceVar(); - driverdata->ppb_input_event = (PPB_InputEvent*) PSGetInterface(PPB_INPUT_EVENT_INTERFACE); - driverdata->ppb_keyboard_input_event = (PPB_KeyboardInputEvent*) PSGetInterface(PPB_KEYBOARD_INPUT_EVENT_INTERFACE); - driverdata->ppb_mouse_input_event = (PPB_MouseInputEvent*) PSGetInterface(PPB_MOUSE_INPUT_EVENT_INTERFACE); - driverdata->ppb_wheel_input_event = (PPB_WheelInputEvent*) PSGetInterface(PPB_WHEEL_INPUT_EVENT_INTERFACE); - driverdata->ppb_touch_input_event = (PPB_TouchInputEvent*) PSGetInterface(PPB_TOUCH_INPUT_EVENT_INTERFACE); - - - driverdata->message_loop = driverdata->ppb_message_loop->Create(driverdata->instance); - - PSEventSetFilter(PSE_ALL); - - /* We're done! */ - return 0; -} - -void NACL_VideoQuit(_THIS) { -} - -#endif /* SDL_VIDEO_DRIVER_NACL */ -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/nacl/SDL_naclvideo.h b/src/video/nacl/SDL_naclvideo.h deleted file mode 100644 index 3b08920493..0000000000 --- a/src/video/nacl/SDL_naclvideo.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2022 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "../../SDL_internal.h" - -#ifndef SDL_naclvideo_h_ -#define SDL_naclvideo_h_ - -#include "../SDL_sysvideo.h" -#include "ppapi_simple/ps_interface.h" -#include "ppapi/c/pp_input_event.h" - - -/* Hidden "this" pointer for the video functions */ -#define _THIS SDL_VideoDevice *_this - - -/* Private display data */ - -typedef struct SDL_VideoData { - Uint32 format; - int w, h; - SDL_Window *window; - - const PPB_Graphics3D *ppb_graphics; - const PPB_MessageLoop *ppb_message_loop; - const PPB_Core *ppb_core; - const PPB_Fullscreen *ppb_fullscreen; - const PPB_Instance *ppb_instance; - const PPB_ImageData *ppb_image_data; - const PPB_View *ppb_view; - const PPB_Var *ppb_var; - const PPB_InputEvent *ppb_input_event; - const PPB_KeyboardInputEvent *ppb_keyboard_input_event; - const PPB_MouseInputEvent *ppb_mouse_input_event; - const PPB_WheelInputEvent *ppb_wheel_input_event; - const PPB_TouchInputEvent *ppb_touch_input_event; - - PP_Resource message_loop; - PP_Instance instance; - - /* FIXME: Check threading issues...otherwise use a hardcoded _this->context across all threads */ - /* PP_Resource context; */ - -} SDL_VideoData; - -extern void NACL_SetScreenResolution(int width, int height, Uint32 format); - - -#endif /* SDL_naclvideo_h_ */ diff --git a/src/video/nacl/SDL_naclwindow.c b/src/video/nacl/SDL_naclwindow.c deleted file mode 100644 index f0245aef25..0000000000 --- a/src/video/nacl/SDL_naclwindow.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2022 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "../../SDL_internal.h" - -#if SDL_VIDEO_DRIVER_NACL - -#include "../SDL_sysvideo.h" - -#include "../../events/SDL_mouse_c.h" -#include "../../events/SDL_keyboard_c.h" -#include "SDL_naclvideo.h" -#include "SDL_naclwindow.h" - -int -NACL_CreateWindow(_THIS, SDL_Window * window) -{ - SDL_VideoData *driverdata = (SDL_VideoData *) _this->driverdata; - - if (driverdata->window) { - return SDL_SetError("NaCl only supports one window"); - } - driverdata->window = window; - - /* Adjust the window data to match the screen */ - window->x = 0; - window->y = 0; - window->w = driverdata->w; - window->h = driverdata->h; - - window->flags &= ~SDL_WINDOW_RESIZABLE; /* window is NEVER resizeable */ - window->flags |= SDL_WINDOW_FULLSCREEN; /* window is always fullscreen */ - window->flags &= ~SDL_WINDOW_HIDDEN; - window->flags |= SDL_WINDOW_SHOWN; /* only one window on NaCl */ - window->flags |= SDL_WINDOW_INPUT_FOCUS; /* always has input focus */ - window->flags |= SDL_WINDOW_OPENGL; - - SDL_SetMouseFocus(window); - SDL_SetKeyboardFocus(window); - - return 0; -} - -void -NACL_SetWindowTitle(_THIS, SDL_Window * window) -{ - /* TODO */ -} - -void -NACL_DestroyWindow(_THIS, SDL_Window * window) -{ - SDL_VideoData *driverdata = (SDL_VideoData *) _this->driverdata; - if (window == driverdata->window) { - driverdata->window = NULL; - } -} - -#endif /* SDL_VIDEO_DRIVER_NACL */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/nacl/SDL_naclwindow.h b/src/video/nacl/SDL_naclwindow.h deleted file mode 100644 index 65757c4120..0000000000 --- a/src/video/nacl/SDL_naclwindow.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2022 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "../../SDL_internal.h" - -#ifndef SDL_naclwindow_h_ -#define SDL_naclwindow_h_ - -extern int NACL_CreateWindow(_THIS, SDL_Window * window); -extern void NACL_SetWindowTitle(_THIS, SDL_Window * window); -extern void NACL_DestroyWindow(_THIS, SDL_Window * window); - -#endif /* SDL_naclwindow_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/test/nacl/Makefile b/test/nacl/Makefile deleted file mode 100644 index ca7a030471..0000000000 --- a/test/nacl/Makefile +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright (c) 2013 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# GNU Makefile based on shared rules provided by the Native Client SDK. -# See README.Makefiles for more details. - -VALID_TOOLCHAINS := pnacl - -# NACL_SDK_ROOT ?= $(abspath $(CURDIR)/../../..) -include $(NACL_SDK_ROOT)/tools/common.mk - - -TARGET = sdl_app -DEPS = ppapi_simple nacl_io -# ppapi_simple and SDL3 end up being listed twice due to dependency solving issues -- Gabriel -LIBS = SDL3_test SDL3 ppapi_simple SDL3main SDL3 $(DEPS) ppapi_gles2 ppapi_cpp ppapi pthread - -CFLAGS := -Wall -SOURCES ?= testgles2.c - -# Build rules generated by macros from common.mk: -# Overriden macro from NACL SDK to be able to customize the library search path -- Gabriel -# Specific Link Macro -# -# $1 = Target Name -# $2 = List of inputs -# $3 = List of libs -# $4 = List of deps -# $5 = List of lib dirs -# $6 = Other Linker Args -# -# For debugging, we translate the pre-finalized .bc file. -# -define LINKER_RULE -all: $(1).pexe -$(1)_x86_32.nexe : $(1).bc - $(call LOG,TRANSLATE,$$@,$(PNACL_TRANSLATE) --allow-llvm-bitcode-input -arch x86-32 $$^ -o $$@) - -$(1)_x86_64.nexe : $(1).bc - $(call LOG,TRANSLATE,$$@,$(PNACL_TRANSLATE) --allow-llvm-bitcode-input -arch x86-64 $$^ -o $$@) - -$(1)_arm.nexe : $(1).bc - $(call LOG,TRANSLATE,$$@,$(PNACL_TRANSLATE) --allow-llvm-bitcode-input -arch arm $$^ -o $$@) - -$(1).pexe: $(1).bc - $(call LOG,FINALIZE,$$@,$(PNACL_FINALIZE) -o $$@ $$^) - -$(1).bc: $(2) $(foreach dep,$(4),$(STAMPDIR)/$(dep).stamp) - $(call LOG,LINK,$$@,$(PNACL_LINK) -o $$@ $(2) $(PNACL_LDFLAGS) $(foreach path,$(5),-L$(path)/pnacl/$(CONFIG)) -L./lib $(foreach lib,$(3),-l$(lib)) $(6)) -endef - -$(foreach dep,$(DEPS),$(eval $(call DEPEND_RULE,$(dep)))) -$(foreach src,$(SOURCES),$(eval $(call COMPILE_RULE,$(src),$(CFLAGS)))) - -ifeq ($(CONFIG),Release) -$(eval $(call LINK_RULE,$(TARGET)_unstripped,$(SOURCES),$(LIBS),$(DEPS))) -$(eval $(call STRIP_RULE,$(TARGET),$(TARGET)_unstripped)) -else -$(eval $(call LINK_RULE,$(TARGET),$(SOURCES),$(LIBS),$(DEPS))) -endif - -$(eval $(call NMF_RULE,$(TARGET),)) diff --git a/test/nacl/background.js b/test/nacl/background.js deleted file mode 100644 index 5c3b1b7c94..0000000000 --- a/test/nacl/background.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -function makeURL(toolchain, config) { - return 'index.html?tc=' + toolchain + '&config=' + config; -} - -function createWindow(url) { - console.log('loading ' + url); - chrome.app.window.create(url, { - width: 1024, - height: 800, - frame: 'none' - }); -} - -function onLaunched(launchData) { - // Send and XHR to get the URL to load from a configuration file. - // Normally you won't need to do this; just call: - // - // chrome.app.window.create('', {...}); - // - // In the SDK we want to be able to load different URLs (for different - // toolchain/config combinations) from the commandline, so we to read - // this information from the file "run_package_config". - var xhr = new XMLHttpRequest(); - xhr.open('GET', 'run_package_config', true); - xhr.onload = function() { - var toolchain_config = this.responseText.split(' '); - createWindow(makeURL.apply(null, toolchain_config)); - }; - xhr.onerror = function() { - // Can't find the config file, just load the default. - createWindow('index.html'); - }; - xhr.send(); -} - -chrome.app.runtime.onLaunched.addListener(onLaunched); diff --git a/test/nacl/common.js b/test/nacl/common.js deleted file mode 100644 index a700015513..0000000000 --- a/test/nacl/common.js +++ /dev/null @@ -1,474 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Set to true when the Document is loaded IFF "test=true" is in the query -// string. -var isTest = false; - -// Set to true when loading a "Release" NaCl module, false when loading a -// "Debug" NaCl module. -var isRelease = true; - -// Javascript module pattern: -// see http://en.wikipedia.org/wiki/Unobtrusive_JavaScript#Namespaces -// In essence, we define an anonymous function which is immediately called and -// returns a new object. The new object contains only the exported definitions; -// all other definitions in the anonymous function are inaccessible to external -// code. -var common = (function() { - - function isHostToolchain(tool) { - return tool == 'win' || tool == 'linux' || tool == 'mac'; - } - - /** - * Return the mime type for NaCl plugin. - * - * @param {string} tool The name of the toolchain, e.g. "glibc", "newlib" etc. - * @return {string} The mime-type for the kind of NaCl plugin matching - * the given toolchain. - */ - function mimeTypeForTool(tool) { - // For NaCl modules use application/x-nacl. - var mimetype = 'application/x-nacl'; - if (isHostToolchain(tool)) { - // For non-NaCl PPAPI plugins use the x-ppapi-debug/release - // mime type. - if (isRelease) - mimetype = 'application/x-ppapi-release'; - else - mimetype = 'application/x-ppapi-debug'; - } else if (tool == 'pnacl') { - mimetype = 'application/x-pnacl'; - } - return mimetype; - } - - /** - * Check if the browser supports NaCl plugins. - * - * @param {string} tool The name of the toolchain, e.g. "glibc", "newlib" etc. - * @return {bool} True if the browser supports the type of NaCl plugin - * produced by the given toolchain. - */ - function browserSupportsNaCl(tool) { - // Assume host toolchains always work with the given browser. - // The below mime-type checking might not work with - // --register-pepper-plugins. - if (isHostToolchain(tool)) { - return true; - } - var mimetype = mimeTypeForTool(tool); - return navigator.mimeTypes[mimetype] !== undefined; - } - - /** - * Inject a script into the DOM, and call a callback when it is loaded. - * - * @param {string} url The url of the script to load. - * @param {Function} onload The callback to call when the script is loaded. - * @param {Function} onerror The callback to call if the script fails to load. - */ - function injectScript(url, onload, onerror) { - var scriptEl = document.createElement('script'); - scriptEl.type = 'text/javascript'; - scriptEl.src = url; - scriptEl.onload = onload; - if (onerror) { - scriptEl.addEventListener('error', onerror, false); - } - document.head.appendChild(scriptEl); - } - - /** - * Run all tests for this example. - * - * @param {Object} moduleEl The module DOM element. - */ - function runTests(moduleEl) { - console.log('runTests()'); - common.tester = new Tester(); - - // All NaCl SDK examples are OK if the example exits cleanly; (i.e. the - // NaCl module returns 0 or calls exit(0)). - // - // Without this exception, the browser_tester thinks that the module - // has crashed. - common.tester.exitCleanlyIsOK(); - - common.tester.addAsyncTest('loaded', function(test) { - test.pass(); - }); - - if (typeof window.addTests !== 'undefined') { - window.addTests(); - } - - common.tester.waitFor(moduleEl); - common.tester.run(); - } - - /** - * Create the Native Client element as a child of the DOM element - * named "listener". - * - * @param {string} name The name of the example. - * @param {string} tool The name of the toolchain, e.g. "glibc", "newlib" etc. - * @param {string} path Directory name where .nmf file can be found. - * @param {number} width The width to create the plugin. - * @param {number} height The height to create the plugin. - * @param {Object} attrs Dictionary of attributes to set on the module. - */ - function createNaClModule(name, tool, path, width, height, attrs) { - var moduleEl = document.createElement('embed'); - moduleEl.setAttribute('name', 'nacl_module'); - moduleEl.setAttribute('id', 'nacl_module'); - moduleEl.setAttribute('width', width); - moduleEl.setAttribute('height', height); - moduleEl.setAttribute('path', path); - moduleEl.setAttribute('src', path + '/' + name + '.nmf'); - - // Add any optional arguments - if (attrs) { - for (var key in attrs) { - moduleEl.setAttribute(key, attrs[key]); - } - } - - var mimetype = mimeTypeForTool(tool); - moduleEl.setAttribute('type', mimetype); - - // The element is wrapped inside a
, which has both a 'load' - // and a 'message' event listener attached. This wrapping method is used - // instead of attaching the event listeners directly to the element - // to ensure that the listeners are active before the NaCl module 'load' - // event fires. - var listenerDiv = document.getElementById('listener'); - listenerDiv.appendChild(moduleEl); - - // Request the offsetTop property to force a relayout. As of Apr 10, 2014 - // this is needed if the module is being loaded on a Chrome App's - // background page (see crbug.com/350445). - moduleEl.offsetTop; - - // Host plugins don't send a moduleDidLoad message. We'll fake it here. - var isHost = isHostToolchain(tool); - if (isHost) { - window.setTimeout(function() { - moduleEl.readyState = 1; - moduleEl.dispatchEvent(new CustomEvent('loadstart')); - moduleEl.readyState = 4; - moduleEl.dispatchEvent(new CustomEvent('load')); - moduleEl.dispatchEvent(new CustomEvent('loadend')); - }, 100); // 100 ms - } - - // This is code that is only used to test the SDK. - if (isTest) { - var loadNaClTest = function() { - injectScript('nacltest.js', function() { - runTests(moduleEl); - }); - }; - - // Try to load test.js for the example. Whether or not it exists, load - // nacltest.js. - injectScript('test.js', loadNaClTest, loadNaClTest); - } - } - - /** - * Add the default "load" and "message" event listeners to the element with - * id "listener". - * - * The "load" event is sent when the module is successfully loaded. The - * "message" event is sent when the naclModule posts a message using - * PPB_Messaging.PostMessage() (in C) or pp::Instance().PostMessage() (in - * C++). - */ - function attachDefaultListeners() { - var listenerDiv = document.getElementById('listener'); - listenerDiv.addEventListener('load', moduleDidLoad, true); - listenerDiv.addEventListener('message', handleMessage, true); - listenerDiv.addEventListener('error', handleError, true); - listenerDiv.addEventListener('crash', handleCrash, true); - if (typeof window.attachListeners !== 'undefined') { - window.attachListeners(); - } - } - - /** - * Called when the NaCl module fails to load. - * - * This event listener is registered in createNaClModule above. - */ - function handleError(event) { - // We can't use common.naclModule yet because the module has not been - // loaded. - var moduleEl = document.getElementById('nacl_module'); - updateStatus('ERROR [' + moduleEl.lastError + ']'); - } - - /** - * Called when the Browser can not communicate with the Module - * - * This event listener is registered in attachDefaultListeners above. - */ - function handleCrash(event) { - if (common.naclModule.exitStatus == -1) { - updateStatus('CRASHED'); - } else { - updateStatus('EXITED [' + common.naclModule.exitStatus + ']'); - } - if (typeof window.handleCrash !== 'undefined') { - window.handleCrash(common.naclModule.lastError); - } - } - - /** - * Called when the NaCl module is loaded. - * - * This event listener is registered in attachDefaultListeners above. - */ - function moduleDidLoad() { - common.naclModule = document.getElementById('nacl_module'); - updateStatus('RUNNING'); - - if (typeof window.moduleDidLoad !== 'undefined') { - window.moduleDidLoad(); - } - } - - /** - * Hide the NaCl module's embed element. - * - * We don't want to hide by default; if we do, it is harder to determine that - * a plugin failed to load. Instead, call this function inside the example's - * "moduleDidLoad" function. - * - */ - function hideModule() { - // Setting common.naclModule.style.display = "None" doesn't work; the - // module will no longer be able to receive postMessages. - common.naclModule.style.height = '0'; - } - - /** - * Remove the NaCl module from the page. - */ - function removeModule() { - common.naclModule.parentNode.removeChild(common.naclModule); - common.naclModule = null; - } - - /** - * Return true when |s| starts with the string |prefix|. - * - * @param {string} s The string to search. - * @param {string} prefix The prefix to search for in |s|. - */ - function startsWith(s, prefix) { - // indexOf would search the entire string, lastIndexOf(p, 0) only checks at - // the first index. See: http://stackoverflow.com/a/4579228 - return s.lastIndexOf(prefix, 0) === 0; - } - - /** Maximum length of logMessageArray. */ - var kMaxLogMessageLength = 20; - - /** An array of messages to display in the element with id "log". */ - var logMessageArray = []; - - /** - * Add a message to an element with id "log". - * - * This function is used by the default "log:" message handler. - * - * @param {string} message The message to log. - */ - function logMessage(message) { - logMessageArray.push(message); - if (logMessageArray.length > kMaxLogMessageLength) - logMessageArray.shift(); - - document.getElementById('log').textContent = logMessageArray.join('\n'); - console.log(message); - } - - /** - */ - var defaultMessageTypes = { - 'alert': alert, - 'log': logMessage - }; - - /** - * Called when the NaCl module sends a message to JavaScript (via - * PPB_Messaging.PostMessage()) - * - * This event listener is registered in createNaClModule above. - * - * @param {Event} message_event A message event. message_event.data contains - * the data sent from the NaCl module. - */ - function handleMessage(message_event) { - if (typeof message_event.data === 'string') { - for (var type in defaultMessageTypes) { - if (defaultMessageTypes.hasOwnProperty(type)) { - if (startsWith(message_event.data, type + ':')) { - func = defaultMessageTypes[type]; - func(message_event.data.slice(type.length + 1)); - return; - } - } - } - } - - if (typeof window.handleMessage !== 'undefined') { - window.handleMessage(message_event); - return; - } - - logMessage('Unhandled message: ' + message_event.data); - } - - /** - * Called when the DOM content has loaded; i.e. the page's document is fully - * parsed. At this point, we can safely query any elements in the document via - * document.querySelector, document.getElementById, etc. - * - * @param {string} name The name of the example. - * @param {string} tool The name of the toolchain, e.g. "glibc", "newlib" etc. - * @param {string} path Directory name where .nmf file can be found. - * @param {number} width The width to create the plugin. - * @param {number} height The height to create the plugin. - * @param {Object} attrs Optional dictionary of additional attributes. - */ - function domContentLoaded(name, tool, path, width, height, attrs) { - // If the page loads before the Native Client module loads, then set the - // status message indicating that the module is still loading. Otherwise, - // do not change the status message. - updateStatus('Page loaded.'); - if (!browserSupportsNaCl(tool)) { - updateStatus( - 'Browser does not support NaCl (' + tool + '), or NaCl is disabled'); - } else if (common.naclModule == null) { - updateStatus('Creating embed: ' + tool); - - // We use a non-zero sized embed to give Chrome space to place the bad - // plug-in graphic, if there is a problem. - width = typeof width !== 'undefined' ? width : 200; - height = typeof height !== 'undefined' ? height : 200; - attachDefaultListeners(); - createNaClModule(name, tool, path, width, height, attrs); - } else { - // It's possible that the Native Client module onload event fired - // before the page's onload event. In this case, the status message - // will reflect 'SUCCESS', but won't be displayed. This call will - // display the current message. - updateStatus('Waiting.'); - } - } - - /** Saved text to display in the element with id 'statusField'. */ - var statusText = 'NO-STATUSES'; - - /** - * Set the global status message. If the element with id 'statusField' - * exists, then set its HTML to the status message as well. - * - * @param {string} opt_message The message to set. If null or undefined, then - * set element 'statusField' to the message from the last call to - * updateStatus. - */ - function updateStatus(opt_message) { - if (opt_message) { - statusText = opt_message; - } - var statusField = document.getElementById('statusField'); - if (statusField) { - statusField.innerHTML = statusText; - } - } - - // The symbols to export. - return { - /** A reference to the NaCl module, once it is loaded. */ - naclModule: null, - - attachDefaultListeners: attachDefaultListeners, - domContentLoaded: domContentLoaded, - createNaClModule: createNaClModule, - hideModule: hideModule, - removeModule: removeModule, - logMessage: logMessage, - updateStatus: updateStatus - }; - -}()); - -// Listen for the DOM content to be loaded. This event is fired when parsing of -// the page's document has finished. -document.addEventListener('DOMContentLoaded', function() { - var body = document.body; - - // The data-* attributes on the body can be referenced via body.dataset. - if (body.dataset) { - var loadFunction; - if (!body.dataset.customLoad) { - loadFunction = common.domContentLoaded; - } else if (typeof window.domContentLoaded !== 'undefined') { - loadFunction = window.domContentLoaded; - } - - // From https://developer.mozilla.org/en-US/docs/DOM/window.location - var searchVars = {}; - if (window.location.search.length > 1) { - var pairs = window.location.search.substr(1).split('&'); - for (var key_ix = 0; key_ix < pairs.length; key_ix++) { - var keyValue = pairs[key_ix].split('='); - searchVars[unescape(keyValue[0])] = - keyValue.length > 1 ? unescape(keyValue[1]) : ''; - } - } - - if (loadFunction) { - var toolchains = body.dataset.tools.split(' '); - var configs = body.dataset.configs.split(' '); - - var attrs = {}; - if (body.dataset.attrs) { - var attr_list = body.dataset.attrs.split(' '); - for (var key in attr_list) { - var attr = attr_list[key].split('='); - var key = attr[0]; - var value = attr[1]; - attrs[key] = value; - } - } - - var tc = toolchains.indexOf(searchVars.tc) !== -1 ? - searchVars.tc : toolchains[0]; - - // If the config value is included in the search vars, use that. - // Otherwise default to Release if it is valid, or the first value if - // Release is not valid. - if (configs.indexOf(searchVars.config) !== -1) - var config = searchVars.config; - else if (configs.indexOf('Release') !== -1) - var config = 'Release'; - else - var config = configs[0]; - - var pathFormat = body.dataset.path; - var path = pathFormat.replace('{tc}', tc).replace('{config}', config); - - isTest = searchVars.test === 'true'; - isRelease = path.toLowerCase().indexOf('release') != -1; - - loadFunction(body.dataset.name, tc, path, body.dataset.width, - body.dataset.height, attrs); - } - } -}); diff --git a/test/nacl/index.html b/test/nacl/index.html deleted file mode 100644 index 4695b7e9c0..0000000000 --- a/test/nacl/index.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - SDL NACL Test - - - -

SDL NACL Test

-

Status: NO-STATUS

- -
- - diff --git a/test/nacl/manifest.json b/test/nacl/manifest.json deleted file mode 100644 index df6772b4c4..0000000000 --- a/test/nacl/manifest.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "SDL testgles2", - "version": "33.0.1750.117", - "minimum_chrome_version": "33.0.1750.117", - "manifest_version": 2, - "description": "testgles2", - "offline_enabled": true, - "icons": { - "128": "icon128.png" - }, - "app": { - "background": { - "scripts": ["background.js"] - } - }, - "key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCMN716Qyu0l2EHNFqIJVqVysFcTR6urqhaGGqW4UK7slBaURz9+Sb1b4Ot5P1uQNE5c+CTU5Vu61wpqmSqMMxqHLWdPPMh8uRlyctsb2cxWwG6XoGSvpX29NsQVUFXd4v2tkJm3G9t+V0X8TYskrvWQmnyOW8OEIDvrBhUEfFxWQIDAQAB", - "oauth2": { - "client_id": "903965034255.apps.googleusercontent.com", - "scopes": ["https://www.googleapis.com/auth/drive"] - }, - "permissions": [] -} diff --git a/test/testgles2.c b/test/testgles2.c index 39a10869f3..49c4ec8304 100644 --- a/test/testgles2.c +++ b/test/testgles2.c @@ -20,8 +20,7 @@ #include "SDL_test_common.h" -#if defined(__IPHONEOS__) || defined(__ANDROID__) || defined(__EMSCRIPTEN__) || defined(__NACL__) \ - || defined(__WINDOWS__) || defined(__LINUX__) +#if defined(__IPHONEOS__) || defined(__ANDROID__) || defined(__EMSCRIPTEN__) || defined(__WINDOWS__) || defined(__LINUX__) #ifndef HAVE_OPENGLES2 #define HAVE_OPENGLES2 #endif @@ -810,9 +809,9 @@ main(int argc, char *argv[]) SDL_Log("%2.2f frames per second\n", ((double) frames * 1000) / (now - then)); } -#if !defined(__ANDROID__) && !defined(__NACL__) +#if !defined(__ANDROID__) quit(0); -#endif +#endif return 0; } diff --git a/test/testgles2_sdf.c b/test/testgles2_sdf.c index e66c188bca..ad1b00e679 100644 --- a/test/testgles2_sdf.c +++ b/test/testgles2_sdf.c @@ -20,8 +20,7 @@ #include "SDL_test_common.h" -#if defined(__IPHONEOS__) || defined(__ANDROID__) || defined(__EMSCRIPTEN__) || defined(__NACL__) \ - || defined(__WINDOWS__) || defined(__LINUX__) +#if defined(__IPHONEOS__) || defined(__ANDROID__) || defined(__EMSCRIPTEN__) || defined(__WINDOWS__) || defined(__LINUX__) #define HAVE_OPENGLES2 #endif @@ -795,9 +794,9 @@ main(int argc, char *argv[]) SDL_Log("%2.2f frames per second\n", ((double) frames * 1000) / (now - then)); } -#if !defined(__ANDROID__) && !defined(__NACL__) +#if !defined(__ANDROID__) quit(0); -#endif +#endif return 0; }