Create SDL backed SkOSWindow

BUG=skia:

Review URL: https://codereview.chromium.org/1413593007
This commit is contained in:
joshualitt 2015-11-04 13:41:02 -08:00 committed by Commit bot
parent 6f45c17147
commit 65d6fbb576
9 changed files with 393 additions and 335 deletions

View File

@ -9,6 +9,9 @@
# * Basic widgets and controls. # * Basic widgets and controls.
{ {
'variables': {
'skia_use_sdl%': 0,
},
'targets': [ 'targets': [
{ {
'target_name': 'views', 'target_name': 'views',
@ -60,6 +63,11 @@
'../src/views/SkViewPriv.h', '../src/views/SkViewPriv.h',
'../src/views/SkWidgets.cpp', '../src/views/SkWidgets.cpp',
'../src/views/SkWindow.cpp', '../src/views/SkWindow.cpp',
# Unix
'../src/views/unix/SkOSWindow_Unix.cpp',
'../src/views/unix/keysym2ucs.c',
'../src/views/unix/skia_unix.cpp',
# Mac # Mac
'../src/views/mac/SkEventNotifier.h', '../src/views/mac/SkEventNotifier.h',
@ -71,21 +79,9 @@
'../src/views/mac/SkOSWindow_Mac.mm', '../src/views/mac/SkOSWindow_Mac.mm',
'../src/views/mac/skia_mac.mm', '../src/views/mac/skia_mac.mm',
# SDL
'../src/views/sdl/SkOSWindow_SDL.cpp',
# *nix
'../src/views/unix/SkOSWindow_Unix.cpp',
'../src/views/unix/keysym2ucs.c',
'../src/views/unix/skia_unix.cpp',
# Windows # Windows
'../src/views/win/SkOSWindow_win.cpp', '../src/views/win/SkOSWindow_win.cpp',
'../src/views/win/skia_win.cpp', '../src/views/win/skia_win.cpp',
],
'sources!' : [
'../src/views/sdl/SkOSWindow_SDL.cpp',
], ],
'conditions': [ 'conditions': [
[ 'skia_gpu == 1', { [ 'skia_gpu == 1', {
@ -141,6 +137,25 @@
'../include/gpu', '../include/gpu',
], ],
}], }],
[ 'skia_use_sdl == 1', {
'defines': [
'SK_USE_SDL',
],
'dependencies': [
'sdl.gyp:sdl',
],
'sources!': [
'../src/views/unix/SkOSWindow_Unix.cpp',
'../src/views/unix/keysym2ucs.c',
'../src/views/unix/skia_unix.cpp',
],
'sources': [
'../src/views/sdl/SkOSWindow_SDL.cpp',
],
'export_dependent_settings': [
'sdl.gyp:sdl',
],
}],
], ],
'direct_dependent_settings': { 'direct_dependent_settings': {
'include_dirs': [ 'include_dirs': [

View File

@ -18,8 +18,6 @@
class SK_API SkGLContext : public SkRefCnt { class SK_API SkGLContext : public SkRefCnt {
public: public:
~SkGLContext() override; ~SkGLContext() override;
bool isValid() const { return NULL != gl(); } bool isValid() const { return NULL != gl(); }

View File

@ -11,32 +11,51 @@
#define SkOSWindow_SDL_DEFINED #define SkOSWindow_SDL_DEFINED
#include "SDL.h" #include "SDL.h"
#include "SDL_opengl.h"
#include "SkWindow.h" #include "SkWindow.h"
class SkGLCanvas;
class SkOSWindow : public SkWindow { class SkOSWindow : public SkWindow {
public: public:
SkOSWindow(void* screen); SkOSWindow(void* screen);
virtual ~SkOSWindow(); virtual ~SkOSWindow();
static bool PostEvent(SkEvent* evt, SkEventSinkID, SkMSec delay); static bool PostEvent(SkEvent* evt, SkEventSinkID, SkMSec delay) { SkFAIL("not implemented\n");
return false;
}
void handleSDLEvent(const SDL_Event& event); enum SkBackEndTypes {
kNone_BackEndType,
kNativeGL_BackEndType,
#if SK_ANGLE
kANGLE_BackEndType,
#endif // SK_ANGLE
#if SK_COMMAND_BUFFER
kCommandBuffer_BackEndType,
#endif // SK_COMMAND_BUFFER
};
void detach();
bool attach(SkBackEndTypes attachType, int msaaSampleCount, AttachmentInfo*);
void present();
bool makeFullscreen();
void setVsync(bool);
void closeWindow();
void loop() {
while (!fQuit) {
this->handleEvents();
this->update(nullptr);
}
}
protected: protected:
// overrides from SkWindow void onSetTitle(const char title[]) override;
virtual void onHandleInval(const SkIRect&);
// overrides from SkView
virtual void onAddMenu(const SkOSMenu*);
virtual void onSetTitle(const char[]);
private: private:
SDL_Surface* fScreen; void handleEvents();
SDL_Surface* fSurface; bool fQuit;
SkGLCanvas* fGLCanvas; SDL_Window* fWindow;
SDL_GLContext fGLContext;
void doDraw();
typedef SkWindow INHERITED; typedef SkWindow INHERITED;
}; };

View File

@ -1,4 +1,3 @@
/* /*
* Copyright 2011 Google Inc. * Copyright 2011 Google Inc.
* *
@ -7,221 +6,228 @@
*/ */
#include "SkOSWindow_SDL.h" #include "SkOSWindow_SDL.h"
#include "SkCanvas.h" #include "SkCanvas.h"
#include "SkColorPriv.h"
#include "SkGLCanvas.h"
#include "SkOSMenu.h"
#include "SkTime.h"
static void post_SkEvent_event() { #include <GL/gl.h>
SDL_Event evt;
evt.type = SDL_USEREVENT; const int SCREEN_WIDTH = 640;
evt.user.type = SDL_USEREVENT; const int SCREEN_HEIGHT = 480;
evt.user.code = 0;
evt.user.data1 = nullptr; static void handle_error() {
evt.user.data2 = nullptr; const char* error = SDL_GetError();
SDL_PushEvent(&evt); SkDebugf("SDL Error: %s\n", error);
SDL_ClearError();
} }
static bool skia_setBitmapFromSurface(SkBitmap* dst, SDL_Surface* src) { SkOSWindow::SkOSWindow(void* screen) : fQuit(false) , fGLContext(nullptr) {
SkColorType ct; //Create window
SkAlphaType at; SDL_Init(SDL_INIT_VIDEO|SDL_INIT_GAMECONTROLLER|SDL_INIT_EVENTS);
fWindow = SDL_CreateWindow("SDL Window", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
switch (src->format->BytesPerPixel) { SCREEN_WIDTH, SCREEN_HEIGHT,
case 2: SDL_WINDOW_OPENGL|SDL_WINDOW_SHOWN );
ct = kRGB_565_SkColorType; if (!fWindow) {
at = kOpaque_SkAlphaType; handle_error();
break; return;
case 4:
ct = kN32_SkColorType;
at = kPremul_SkAlphaType;
break;
default:
return false;
}
return dst->installPixels(SkImageInfo::Make(src->w, src->h, ct, at), src->pixels, src->pitch);
}
SkOSWindow::SkOSWindow(void* screen) {
fScreen = reinterpret_cast<SDL_Surface*>(screen);
this->resize(fScreen->w, fScreen->h);
uint32_t rmask = SK_R32_MASK << SK_R32_SHIFT;
uint32_t gmask = SK_G32_MASK << SK_G32_SHIFT;
uint32_t bmask = SK_B32_MASK << SK_B32_SHIFT;
uint32_t amask = SK_A32_MASK << SK_A32_SHIFT;
if (fScreen->flags & SDL_OPENGL) {
fSurface = nullptr;
fGLCanvas = new SkGLCanvas;
fGLCanvas->setViewport(fScreen->w, fScreen->h);
} else {
fGLCanvas = nullptr;
fSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, fScreen->w, fScreen->h,
32, rmask, gmask, bmask, amask);
} }
SDL_StartTextInput();
this->resize(SCREEN_WIDTH, SCREEN_HEIGHT);
} }
SkOSWindow::~SkOSWindow() { SkOSWindow::~SkOSWindow() {
delete fGLCanvas; if (fGLContext) {
if (fSurface) { SDL_GL_DeleteContext(fGLContext);
SDL_FreeSurface(fSurface); }
//Destroy window
SDL_DestroyWindow(fWindow);
//Quit SDL subsystems
SDL_Quit();
}
void SkOSWindow::detach() {
if (fGLContext) {
SDL_GL_DeleteContext(fGLContext);
fGLContext = nullptr;
} }
} }
#include <OpenGL/gl.h> bool SkOSWindow::attach(SkBackEndTypes attachType, int msaaSampleCount, AttachmentInfo*) {
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
void SkOSWindow::doDraw() { SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
if (fGLCanvas) { SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
glEnable(GL_BLEND); SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE);
glEnable(GL_TEXTURE_2D);
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT);
int count = fGLCanvas->save(); if (msaaSampleCount > 0) {
this->draw(fGLCanvas); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
fGLCanvas->restoreToCount(count); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, msaaSampleCount);
SDL_GL_SwapBuffers( ); }
} else {
if ( SDL_MUSTLOCK(fSurface) ) {
if ( SDL_LockSurface(fSurface) < 0 ) {
return;
}
}
SkBitmap bitmap; fGLContext = SDL_GL_CreateContext(fWindow);
if (!fGLContext) {
handle_error();
return false;
}
if (skia_setBitmapFromSurface(&bitmap, fSurface)) { int success = SDL_GL_MakeCurrent(fWindow, fGLContext);
SkCanvas canvas(bitmap); if (success != 0) {
this->draw(&canvas); handle_error();
} return false;
}
if ( SDL_MUSTLOCK(fSurface) ) { glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
SDL_UnlockSurface(fSurface); glClearColor(1, 1, 1, 1);
} glClearStencil(0);
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
int result = SDL_BlitSurface(fSurface, nullptr, fScreen, nullptr); return true;
if (result) { }
SkDebugf("------- SDL_BlitSurface returned %d\n", result);
} void SkOSWindow::present() {
SDL_UpdateRect(fScreen, 0, 0, fScreen->w, fScreen->h); SDL_GL_SwapWindow(fWindow);
}
bool SkOSWindow::makeFullscreen() {
SDL_SetWindowFullscreen(fWindow, SDL_WINDOW_FULLSCREEN);
return true;
}
void SkOSWindow::setVsync(bool vsync) {
SDL_GL_SetSwapInterval(vsync ? 1 : 0);
}
void SkOSWindow::closeWindow() {
fQuit = true;
}
static SkKey convert_sdlkey_to_skkey(SDL_Keycode src) {
switch (src) {
case SDLK_UP:
return kUp_SkKey;
case SDLK_DOWN:
return kDown_SkKey;
case SDLK_LEFT:
return kLeft_SkKey;
case SDLK_RIGHT:
return kRight_SkKey;
case SDLK_HOME:
return kHome_SkKey;
case SDLK_END:
return kEnd_SkKey;
case SDLK_ASTERISK:
return kStar_SkKey;
case SDLK_HASH:
return kHash_SkKey;
case SDLK_0:
return k0_SkKey;
case SDLK_1:
return k1_SkKey;
case SDLK_2:
return k2_SkKey;
case SDLK_3:
return k3_SkKey;
case SDLK_4:
return k4_SkKey;
case SDLK_5:
return k5_SkKey;
case SDLK_6:
return k6_SkKey;
case SDLK_7:
return k7_SkKey;
case SDLK_8:
return k8_SkKey;
case SDLK_9:
return k9_SkKey;
default:
return kNONE_SkKey;
} }
} }
static SkKey find_skkey(SDLKey src) { void SkOSWindow::handleEvents() {
// this array must match the enum order in SkKey.h SkEvent::ServiceQueueTimer();
static const SDLKey gKeys[] = { SkEvent::ProcessEvent();
SDLK_UNKNOWN,
SDLK_UNKNOWN, // left softkey
SDLK_UNKNOWN, // right softkey
SDLK_UNKNOWN, // home
SDLK_UNKNOWN, // back
SDLK_UNKNOWN, // send
SDLK_UNKNOWN, // end
SDLK_0,
SDLK_1,
SDLK_2,
SDLK_3,
SDLK_4,
SDLK_5,
SDLK_6,
SDLK_7,
SDLK_8,
SDLK_9,
SDLK_ASTERISK,
SDLK_HASH,
SDLK_UP,
SDLK_DOWN,
SDLK_LEFT,
SDLK_RIGHT,
SDLK_RETURN, // OK
SDLK_UNKNOWN, // volume up
SDLK_UNKNOWN, // volume down
SDLK_UNKNOWN, // power
SDLK_UNKNOWN, // camera
};
const SDLKey* array = gKeys; SDL_Event event;
for (size_t i = 0; i < SK_ARRAY_COUNT(gKeys); i++) { while(SDL_PollEvent(&event)) {
if (array[i] == src) { switch (event.type) {
return static_cast<SkKey>(i); case SDL_MOUSEMOTION:
} if (event.motion.state == SDL_PRESSED) {
} this->handleClick(event.motion.x, event.motion.y,
return kNONE_SkKey; SkView::Click::kMoved_State, nullptr);
}
void SkOSWindow::handleSDLEvent(const SDL_Event& event) {
switch (event.type) {
case SDL_VIDEORESIZE:
this->resize(event.resize.w, event.resize.h);
break;
case SDL_VIDEOEXPOSE:
this->doDraw();
break;
case SDL_MOUSEMOTION:
if (event.motion.state == SDL_PRESSED) {
this->handleClick(event.motion.x, event.motion.y,
SkView::Click::kMoved_State);
}
break;
case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP:
this->handleClick(event.button.x, event.button.y,
event.button.state == SDL_PRESSED ?
SkView::Click::kDown_State :
SkView::Click::kUp_State);
break;
case SDL_KEYDOWN: {
SkKey sk = find_skkey(event.key.keysym.sym);
if (kNONE_SkKey != sk) {
if (event.key.state == SDL_PRESSED) {
this->handleKey(sk);
} else {
this->handleKeyUp(sk);
} }
break;
case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP:
this->handleClick(event.button.x, event.button.y,
event.button.state == SDL_PRESSED ?
SkView::Click::kDown_State :
SkView::Click::kUp_State, nullptr);
break;
case SDL_KEYDOWN: {
SDL_Keycode key = event.key.keysym.sym;
SkKey sk = convert_sdlkey_to_skkey(key);
if (kNONE_SkKey != sk) {
if (event.key.state == SDL_PRESSED) {
this->handleKey(sk);
} else {
this->handleKeyUp(sk);
}
} else if (key == SDLK_ESCAPE) {
fQuit = true;
}
break;
} }
break; case SDL_TEXTINPUT: {
size_t len = strlen(event.text.text);
for (size_t i = 0; i < len; i++) {
this->handleChar((SkUnichar)event.text.text[i]);
}
break;
}
case SDL_QUIT:
fQuit = true;
break;
default:
break;
} }
case SDL_USEREVENT:
if (SkEvent::ProcessEvent()) {
post_SkEvent_event();
}
break;
} }
} }
void SkOSWindow::onHandleInval(const SkIRect& r) {
SDL_Event evt;
evt.type = SDL_VIDEOEXPOSE;
evt.expose.type = SDL_VIDEOEXPOSE;
SDL_PushEvent(&evt);
}
void SkOSWindow::onSetTitle(const char title[]) { void SkOSWindow::onSetTitle(const char title[]) {
SDL_WM_SetCaption(title, nullptr); SDL_SetWindowTitle(fWindow, title);
} }
void SkOSWindow::onAddMenu(const SkOSMenu* sk_menu) {}
/////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////
void SkEvent::SignalNonEmptyQueue() { void SkEvent::SignalNonEmptyQueue() {
SkDebugf("-------- signal nonempty\n"); // nothing to do, since we spin on our event-queue
post_SkEvent_event();
} }
static Uint32 timer_callback(Uint32 interval) { void SkEvent::SignalQueueTimer(SkMSec delay) {
// SkDebugf("-------- timercallback %d\n", interval); // just need to record the delay time. We handle waking up for it in
SkEvent::ServiceQueueTimer(); }
//////////////////////////////////////////////////////////////////////////////////////////////
#include "SkApplication.h"
#include "SkEvent.h"
#include "SkWindow.h"
int main(int argc, char** argv){
SkOSWindow* window = create_sk_window(nullptr, argc, argv);
// drain any events that occurred before |window| was assigned.
while (SkEvent::ProcessEvent());
// Start normal Skia sequence
application_init();
window->loop();
delete window;
application_term();
return 0; return 0;
} }
void SkEvent::SignalQueueTimer(SkMSec delay)
{
SDL_SetTimer(0, nullptr);
if (delay) {
SDL_SetTimer(delay, timer_callback);
}
}

View File

@ -1,5 +1,5 @@
To generate SDL_config.h run: To generate SDL_config.h run:
1) ../../externals/sdl/configure 1) ../../externals/sdl/configure --disable-audio --disable-joystick --disable-haptic --disable-power --disable-video-wayland --disable-video-mir --disable-video-dummy --disable-dbus --disable-ibus --disable-libudev
2) make -j32 2) make -j32
3) if you save the awk output, then you can get a list of files required for 3) if you save the awk output, then you can get a list of files required for
the build with this awk one liner: the build with this awk one liner:

View File

@ -1,7 +1,7 @@
/* include/SDL_config.h. Generated from SDL_config.h.in by configure. */ /* include/SDL_config.h. Generated from SDL_config.h.in by configure. */
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2015 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -50,7 +50,12 @@
#endif #endif
#define HAVE_GCC_ATOMICS 1 #define HAVE_GCC_ATOMICS 1
/* #undef HAVE_GCC_SYNC_LOCK_TEST_AND_SET */ /* #undef HAVE_GCC_SYNC_LOCK_TEST_AND_SET */
#define HAVE_PTHREAD_SPINLOCK 1
/* #undef HAVE_DDRAW_H */
/* #undef HAVE_DINPUT_H */
/* #undef HAVE_DSOUND_H */
/* #undef HAVE_DXGI_H */
/* #undef HAVE_XINPUT_H */
/* Comment this if you want to build without any C library requirements */ /* Comment this if you want to build without any C library requirements */
#define HAVE_LIBC 1 #define HAVE_LIBC 1
@ -75,9 +80,9 @@
#define HAVE_SIGNAL_H 1 #define HAVE_SIGNAL_H 1
/* #undef HAVE_ALTIVEC_H */ /* #undef HAVE_ALTIVEC_H */
/* #undef HAVE_PTHREAD_NP_H */ /* #undef HAVE_PTHREAD_NP_H */
// TODO we currently disable this, is this okay? /* #undef HAVE_LIBUDEV_H */
//#define HAVE_LIBUDEV_H 1 /* #undef HAVE_DBUS_DBUS_H */
//#define HAVE_DBUS_DBUS_H 1 /* #undef HAVE_IBUS_IBUS_H */
/* C library functions */ /* C library functions */
#define HAVE_MALLOC 1 #define HAVE_MALLOC 1
@ -136,7 +141,6 @@
#define HAVE_M_PI /**/ #define HAVE_M_PI /**/
#define HAVE_ATAN 1 #define HAVE_ATAN 1
#define HAVE_ATAN2 1 #define HAVE_ATAN2 1
#define HAVE_TAN 1
#define HAVE_ACOS 1 #define HAVE_ACOS 1
#define HAVE_ASIN 1 #define HAVE_ASIN 1
#define HAVE_CEIL 1 #define HAVE_CEIL 1
@ -151,6 +155,9 @@
#define HAVE_SIN 1 #define HAVE_SIN 1
#define HAVE_SINF 1 #define HAVE_SINF 1
#define HAVE_SQRT 1 #define HAVE_SQRT 1
#define HAVE_SQRTF 1
#define HAVE_TAN 1
#define HAVE_TANF 1
#define HAVE_FSEEKO 1 #define HAVE_FSEEKO 1
#define HAVE_FSEEKO64 1 #define HAVE_FSEEKO64 1
#define HAVE_SIGACTION 1 #define HAVE_SIGACTION 1
@ -182,14 +189,14 @@
/* #undef SDL_CPUINFO_DISABLED */ /* #undef SDL_CPUINFO_DISABLED */
/* #undef SDL_EVENTS_DISABLED */ /* #undef SDL_EVENTS_DISABLED */
/* #undef SDL_FILE_DISABLED */ /* #undef SDL_FILE_DISABLED */
/* #undef SDL_JOYSTICK_DISABLED */ #define SDL_JOYSTICK_DISABLED 1
/* #undef SDL_HAPTIC_DISABLED */ #define SDL_HAPTIC_DISABLED 1
/* #undef SDL_LOADSO_DISABLED */ /* #undef SDL_LOADSO_DISABLED */
/* #undef SDL_RENDER_DISABLED */ /* #undef SDL_RENDER_DISABLED */
/* #undef SDL_THREADS_DISABLED */ /* #undef SDL_THREADS_DISABLED */
/* #undef SDL_TIMERS_DISABLED */ /* #undef SDL_TIMERS_DISABLED */
/* #undef SDL_VIDEO_DISABLED */ /* #undef SDL_VIDEO_DISABLED */
/* #undef SDL_POWER_DISABLED */ #define SDL_POWER_DISABLED 1
/* #undef SDL_FILESYSTEM_DISABLED */ /* #undef SDL_FILESYSTEM_DISABLED */
/* Enable various audio drivers */ /* Enable various audio drivers */
@ -204,10 +211,12 @@
/* #undef SDL_AUDIO_DRIVER_COREAUDIO */ /* #undef SDL_AUDIO_DRIVER_COREAUDIO */
/* #undef SDL_AUDIO_DRIVER_DISK */ /* #undef SDL_AUDIO_DRIVER_DISK */
/* #undef SDL_AUDIO_DRIVER_DUMMY */ /* #undef SDL_AUDIO_DRIVER_DUMMY */
/* #undef SDL_AUDIO_DRIVER_ANDROID */
/* #undef SDL_AUDIO_DRIVER_XAUDIO2 */ /* #undef SDL_AUDIO_DRIVER_XAUDIO2 */
/* #undef SDL_AUDIO_DRIVER_DSOUND */ /* #undef SDL_AUDIO_DRIVER_DSOUND */
/* #undef SDL_AUDIO_DRIVER_ESD */ /* #undef SDL_AUDIO_DRIVER_ESD */
/* #undef SDL_AUDIO_DRIVER_ESD_DYNAMIC */ /* #undef SDL_AUDIO_DRIVER_ESD_DYNAMIC */
/* #undef SDL_AUDIO_DRIVER_NACL */
/* #undef SDL_AUDIO_DRIVER_NAS */ /* #undef SDL_AUDIO_DRIVER_NAS */
/* #undef SDL_AUDIO_DRIVER_NAS_DYNAMIC */ /* #undef SDL_AUDIO_DRIVER_NAS_DYNAMIC */
/* #undef SDL_AUDIO_DRIVER_SNDIO */ /* #undef SDL_AUDIO_DRIVER_SNDIO */
@ -220,6 +229,7 @@
/* #undef SDL_AUDIO_DRIVER_WINMM */ /* #undef SDL_AUDIO_DRIVER_WINMM */
/* #undef SDL_AUDIO_DRIVER_FUSIONSOUND */ /* #undef SDL_AUDIO_DRIVER_FUSIONSOUND */
/* #undef SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC */ /* #undef SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC */
/* #undef SDL_AUDIO_DRIVER_EMSCRIPTEN */
/* Enable various input drivers */ /* Enable various input drivers */
#define SDL_INPUT_LINUXEV 1 #define SDL_INPUT_LINUXEV 1
@ -227,16 +237,20 @@
/* #undef SDL_INPUT_TSLIB */ /* #undef SDL_INPUT_TSLIB */
/* #undef SDL_JOYSTICK_HAIKU */ /* #undef SDL_JOYSTICK_HAIKU */
/* #undef SDL_JOYSTICK_DINPUT */ /* #undef SDL_JOYSTICK_DINPUT */
/* #undef SDL_JOYSTICK_XINPUT */
/* #undef SDL_JOYSTICK_DUMMY */ /* #undef SDL_JOYSTICK_DUMMY */
/* #undef SDL_JOYSTICK_IOKIT */ /* #undef SDL_JOYSTICK_IOKIT */
#define SDL_JOYSTICK_LINUX 1 /* #undef SDL_JOYSTICK_LINUX */
/* #undef SDL_JOYSTICK_ANDROID */
/* #undef SDL_JOYSTICK_WINMM */ /* #undef SDL_JOYSTICK_WINMM */
/* #undef SDL_JOYSTICK_USBHID */ /* #undef SDL_JOYSTICK_USBHID */
/* #undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H */ /* #undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H */
/* #undef SDL_JOYSTICK_EMSCRIPTEN */
/* #undef SDL_HAPTIC_DUMMY */ /* #undef SDL_HAPTIC_DUMMY */
#define SDL_HAPTIC_LINUX 1 /* #undef SDL_HAPTIC_LINUX */
/* #undef SDL_HAPTIC_IOKIT */ /* #undef SDL_HAPTIC_IOKIT */
/* #undef SDL_HAPTIC_DINPUT */ /* #undef SDL_HAPTIC_DINPUT */
/* #undef SDL_HAPTIC_XINPUT */
/* Enable various shared object loading systems */ /* Enable various shared object loading systems */
/* #undef SDL_LOADSO_HAIKU */ /* #undef SDL_LOADSO_HAIKU */
@ -262,7 +276,7 @@
/* #undef SDL_VIDEO_DRIVER_COCOA */ /* #undef SDL_VIDEO_DRIVER_COCOA */
/* #undef SDL_VIDEO_DRIVER_DIRECTFB */ /* #undef SDL_VIDEO_DRIVER_DIRECTFB */
/* #undef SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC */ /* #undef SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC */
#define SDL_VIDEO_DRIVER_DUMMY 1 /* #undef SDL_VIDEO_DRIVER_DUMMY */
/* #undef SDL_VIDEO_DRIVER_WINDOWS */ /* #undef SDL_VIDEO_DRIVER_WINDOWS */
/* #undef SDL_VIDEO_DRIVER_WAYLAND */ /* #undef SDL_VIDEO_DRIVER_WAYLAND */
/* #undef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */ /* #undef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
@ -275,6 +289,8 @@
/* #undef SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON */ /* #undef SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON */
#define SDL_VIDEO_DRIVER_X11 1 #define SDL_VIDEO_DRIVER_X11 1
/* #undef SDL_VIDEO_DRIVER_RPI */ /* #undef SDL_VIDEO_DRIVER_RPI */
/* #undef SDL_VIDEO_DRIVER_ANDROID */
/* #undef SDL_VIDEO_DRIVER_EMSCRIPTEN */
#define SDL_VIDEO_DRIVER_X11_DYNAMIC "libX11.so.6" #define SDL_VIDEO_DRIVER_X11_DYNAMIC "libX11.so.6"
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "libXext.so.6" #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "libXext.so.6"
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR "libXcursor.so.1" #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR "libXcursor.so.1"
@ -284,6 +300,7 @@
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS "libXss.so.1" #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS "libXss.so.1"
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE "libXxf86vm.so.1" #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE "libXxf86vm.so.1"
#define SDL_VIDEO_DRIVER_X11_XCURSOR 1 #define SDL_VIDEO_DRIVER_X11_XCURSOR 1
#define SDL_VIDEO_DRIVER_X11_XDBE 1
#define SDL_VIDEO_DRIVER_X11_XINERAMA 1 #define SDL_VIDEO_DRIVER_X11_XINERAMA 1
#define SDL_VIDEO_DRIVER_X11_XINPUT2 1 #define SDL_VIDEO_DRIVER_X11_XINPUT2 1
#define SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH 1 #define SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH 1
@ -292,9 +309,11 @@
#define SDL_VIDEO_DRIVER_X11_XSHAPE 1 #define SDL_VIDEO_DRIVER_X11_XSHAPE 1
#define SDL_VIDEO_DRIVER_X11_XVIDMODE 1 #define SDL_VIDEO_DRIVER_X11_XVIDMODE 1
#define SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS 1 #define SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS 1
#define SDL_VIDEO_DRIVER_X11_CONST_PARAM_XDATA32 1
#define SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY 1 #define SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY 1
#define SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM 1 #define SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM 1
/* #undef SDL_VIDEO_DRIVER_NACL */
/* #undef SDL_VIDEO_DRIVER_VIVANTE */
/* #undef SDL_VIDEO_DRIVER_VIVANTE_VDK */
/* #undef SDL_VIDEO_RENDER_D3D */ /* #undef SDL_VIDEO_RENDER_D3D */
/* #undef SDL_VIDEO_RENDER_D3D11 */ /* #undef SDL_VIDEO_RENDER_D3D11 */
@ -316,10 +335,12 @@
/* #undef SDL_VIDEO_OPENGL_OSMESA_DYNAMIC */ /* #undef SDL_VIDEO_OPENGL_OSMESA_DYNAMIC */
/* Enable system power support */ /* Enable system power support */
#define SDL_POWER_LINUX 1 /* #undef SDL_POWER_LINUX */
/* #undef SDL_POWER_WINDOWS */ /* #undef SDL_POWER_WINDOWS */
/* #undef SDL_POWER_MACOSX */ /* #undef SDL_POWER_MACOSX */
/* #undef SDL_POWER_HAIKU */ /* #undef SDL_POWER_HAIKU */
/* #undef SDL_POWER_ANDROID */
/* #undef SDL_POWER_EMSCRIPTEN */
/* #undef SDL_POWER_HARDWIRED */ /* #undef SDL_POWER_HARDWIRED */
/* Enable system filesystem support */ /* Enable system filesystem support */
@ -328,6 +349,9 @@
/* #undef SDL_FILESYSTEM_DUMMY */ /* #undef SDL_FILESYSTEM_DUMMY */
#define SDL_FILESYSTEM_UNIX 1 #define SDL_FILESYSTEM_UNIX 1
/* #undef SDL_FILESYSTEM_WINDOWS */ /* #undef SDL_FILESYSTEM_WINDOWS */
/* #undef SDL_FILESYSTEM_NACL */
/* #undef SDL_FILESYSTEM_ANDROID */
/* #undef SDL_FILESYSTEM_EMSCRIPTEN */
/* Enable assembly routines */ /* Enable assembly routines */
#define SDL_ASSEMBLY_ROUTINES 1 #define SDL_ASSEMBLY_ROUTINES 1

View File

@ -14,12 +14,100 @@
'-lrt' '-lrt'
], ],
}, },
'include_dirs': [
# TODO we currently disable dbus, is this okay?
#'/usr/include/dbus-1.0',
#'/usr/lib/x86_64-linux-gnu/dbus-1.0/include',
],
'sources': [ 'sources': [
'<(src_dir)/src/SDL.c',
'<(src_dir)/src/SDL_assert.c',
'<(src_dir)/src/SDL_error.c',
'<(src_dir)/src/SDL_hints.c',
'<(src_dir)/src/SDL_log.c',
'<(src_dir)/src/atomic/SDL_atomic.c',
'<(src_dir)/src/atomic/SDL_spinlock.c',
'<(src_dir)/src/audio/SDL_audio.c',
'<(src_dir)/src/audio/SDL_audiocvt.c',
'<(src_dir)/src/audio/SDL_audiodev.c',
'<(src_dir)/src/audio/SDL_audiotypecvt.c',
'<(src_dir)/src/audio/SDL_mixer.c',
'<(src_dir)/src/audio/SDL_wave.c',
'<(src_dir)/src/cpuinfo/SDL_cpuinfo.c',
'<(src_dir)/src/dynapi/SDL_dynapi.c',
'<(src_dir)/src/events/SDL_clipboardevents.c',
'<(src_dir)/src/events/SDL_dropevents.c',
'<(src_dir)/src/events/SDL_events.c',
'<(src_dir)/src/events/SDL_gesture.c',
'<(src_dir)/src/events/SDL_keyboard.c',
'<(src_dir)/src/events/SDL_mouse.c',
'<(src_dir)/src/events/SDL_quit.c',
'<(src_dir)/src/events/SDL_touch.c',
'<(src_dir)/src/events/SDL_windowevents.c',
'<(src_dir)/src/file/SDL_rwops.c',
'<(src_dir)/src/haptic/SDL_haptic.c',
'<(src_dir)/src/joystick/SDL_gamecontroller.c',
'<(src_dir)/src/joystick/SDL_joystick.c',
'<(src_dir)/src/libm/e_atan2.c',
'<(src_dir)/src/libm/e_log.c',
'<(src_dir)/src/libm/e_pow.c',
'<(src_dir)/src/libm/e_rem_pio2.c',
'<(src_dir)/src/libm/e_sqrt.c',
'<(src_dir)/src/libm/k_cos.c',
'<(src_dir)/src/libm/k_rem_pio2.c',
'<(src_dir)/src/libm/k_sin.c',
'<(src_dir)/src/libm/k_tan.c',
'<(src_dir)/src/libm/s_atan.c',
'<(src_dir)/src/libm/s_copysign.c',
'<(src_dir)/src/libm/s_cos.c',
'<(src_dir)/src/libm/s_fabs.c',
'<(src_dir)/src/libm/s_floor.c',
'<(src_dir)/src/libm/s_scalbn.c',
'<(src_dir)/src/libm/s_sin.c',
'<(src_dir)/src/libm/s_tan.c',
'<(src_dir)/src/power/SDL_power.c',
'<(src_dir)/src/render/SDL_d3dmath.c',
'<(src_dir)/src/render/SDL_render.c',
'<(src_dir)/src/render/SDL_yuv_mmx.c',
'<(src_dir)/src/render/SDL_yuv_sw.c',
'<(src_dir)/src/render/direct3d/SDL_render_d3d.c',
'<(src_dir)/src/render/direct3d11/SDL_render_d3d11.c',
'<(src_dir)/src/render/opengl/SDL_render_gl.c',
'<(src_dir)/src/render/opengl/SDL_shaders_gl.c',
'<(src_dir)/src/render/opengles/SDL_render_gles.c',
'<(src_dir)/src/render/opengles2/SDL_render_gles2.c',
'<(src_dir)/src/render/opengles2/SDL_shaders_gles2.c',
'<(src_dir)/src/render/psp/SDL_render_psp.c',
'<(src_dir)/src/render/software/SDL_blendfillrect.c',
'<(src_dir)/src/render/software/SDL_blendline.c',
'<(src_dir)/src/render/software/SDL_blendpoint.c',
'<(src_dir)/src/render/software/SDL_drawline.c',
'<(src_dir)/src/render/software/SDL_drawpoint.c',
'<(src_dir)/src/render/software/SDL_render_sw.c',
'<(src_dir)/src/render/software/SDL_rotate.c',
'<(src_dir)/src/stdlib/SDL_getenv.c',
'<(src_dir)/src/stdlib/SDL_iconv.c',
'<(src_dir)/src/stdlib/SDL_malloc.c',
'<(src_dir)/src/stdlib/SDL_qsort.c',
'<(src_dir)/src/stdlib/SDL_stdlib.c',
'<(src_dir)/src/stdlib/SDL_string.c',
'<(src_dir)/src/thread/SDL_thread.c',
'<(src_dir)/src/timer/SDL_timer.c',
'<(src_dir)/src/video/SDL_RLEaccel.c',
'<(src_dir)/src/video/SDL_blit.c',
'<(src_dir)/src/video/SDL_blit_0.c',
'<(src_dir)/src/video/SDL_blit_1.c',
'<(src_dir)/src/video/SDL_blit_A.c',
'<(src_dir)/src/video/SDL_blit_N.c',
'<(src_dir)/src/video/SDL_blit_auto.c',
'<(src_dir)/src/video/SDL_blit_copy.c',
'<(src_dir)/src/video/SDL_blit_slow.c',
'<(src_dir)/src/video/SDL_bmp.c',
'<(src_dir)/src/video/SDL_clipboard.c',
'<(src_dir)/src/video/SDL_egl.c',
'<(src_dir)/src/video/SDL_fillrect.c',
'<(src_dir)/src/video/SDL_pixels.c',
'<(src_dir)/src/video/SDL_rect.c',
'<(src_dir)/src/video/SDL_shape.c',
'<(src_dir)/src/video/SDL_stretch.c',
'<(src_dir)/src/video/SDL_surface.c',
'<(src_dir)/src/video/SDL_video.c',
'<(src_dir)/src/loadso/dlopen/SDL_sysloadso.c',
'<(src_dir)/src/video/x11/SDL_x11clipboard.c', '<(src_dir)/src/video/x11/SDL_x11clipboard.c',
'<(src_dir)/src/video/x11/SDL_x11dyn.c', '<(src_dir)/src/video/x11/SDL_x11dyn.c',
'<(src_dir)/src/video/x11/SDL_x11events.c', '<(src_dir)/src/video/x11/SDL_x11events.c',
@ -42,18 +130,24 @@
'<(src_dir)/src/thread/pthread/SDL_sysmutex.c', '<(src_dir)/src/thread/pthread/SDL_sysmutex.c',
'<(src_dir)/src/thread/pthread/SDL_syscond.c', '<(src_dir)/src/thread/pthread/SDL_syscond.c',
'<(src_dir)/src/thread/pthread/SDL_systls.c', '<(src_dir)/src/thread/pthread/SDL_systls.c',
'<(src_dir)/src/joystick/linux/SDL_sysjoystick.c',
'<(src_dir)/src/haptic/linux/SDL_syshaptic.c',
'<(src_dir)/src/power/linux/SDL_syspower.c',
'<(src_dir)/src/filesystem/unix/SDL_sysfilesystem.c', '<(src_dir)/src/filesystem/unix/SDL_sysfilesystem.c',
'<(src_dir)/src/timer/unix/SDL_systimer.c', '<(src_dir)/src/timer/unix/SDL_systimer.c',
'<(src_dir)/src/core/linux/SDL_udev.c',
'<(src_dir)/src/core/linux/SDL_evdev.c', '<(src_dir)/src/core/linux/SDL_evdev.c',
'<(src_dir)/src/loadso/dlopen/SDL_sysloadso.c', '<(src_dir)/src/joystick/dummy/SDL_sysjoystick.c',
'<(src_dir)/src/haptic/dummy/SDL_syshaptic.c',
'<(src_dir)/src/main/dummy/SDL_dummy_main.c',
], ],
'defines': [ 'defines': [
'__LINUX__', '__LINUX__',
'_REENTRANT' '_REENTRANT'
], ],
'cflags': [ '-fPIC' ], 'cflags': [
'-fPIC',
'-O3',
'-mmmx',
'-m3dnow',
'-msse',
'-msse2',
'-fvisibility=hidden',
],
} }

View File

@ -8,17 +8,11 @@
{ {
'target_name': 'sdl', 'target_name': 'sdl',
'product_name': 'sdl', 'product_name': 'sdl',
'type': 'shared_library', 'type': 'static_library',
'include_dirs': [ 'include_dirs': [
'<(base_dir)/<(skia_os)', '<(base_dir)/<(skia_os)',
'<(src_dir)/include', '<(src_dir)/include',
], ],
'includes': [
'sdl_sources.gypi',
],
'sources': [
'<@(sdl_sources)',
],
'direct_dependent_settings': { 'direct_dependent_settings': {
'include_dirs': [ 'include_dirs': [
'<(src_dir)/include', '<(src_dir)/include',

View File

@ -1,92 +0,0 @@
# Copyright 2015 Google Inc.
#
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# This file includes all of the general files for building sdl
# The parent gyp/gypi file must define
# 'src_dir' e.g. ../third_party/libsdl/src
#
{
'variables': {
'sdl_sources': [
'<(src_dir)/src/SDL_assert.c',
'<(src_dir)/src/SDL_error.c',
'<(src_dir)/src/SDL_hints.c',
'<(src_dir)/src/SDL_log.c',
'<(src_dir)/src/atomic/SDL_atomic.c',
'<(src_dir)/src/atomic/SDL_spinlock.c',
'<(src_dir)/src/audio/SDL_audio.c',
'<(src_dir)/src/audio/SDL_audiocvt.c',
'<(src_dir)/src/audio/SDL_audiodev.c',
'<(src_dir)/src/audio/SDL_audiotypecvt.c',
'<(src_dir)/src/audio/SDL_mixer.c',
'<(src_dir)/src/audio/SDL_wave.c',
'<(src_dir)/src/cpuinfo/SDL_cpuinfo.c',
'<(src_dir)/src/dynapi/SDL_dynapi.c',
'<(src_dir)/src/events/SDL_clipboardevents.c',
'<(src_dir)/src/events/SDL_dropevents.c',
'<(src_dir)/src/events/SDL_events.c',
'<(src_dir)/src/events/SDL_gesture.c',
'<(src_dir)/src/events/SDL_keyboard.c',
'<(src_dir)/src/events/SDL_mouse.c',
'<(src_dir)/src/events/SDL_quit.c',
'<(src_dir)/src/events/SDL_touch.c',
'<(src_dir)/src/events/SDL_windowevents.c',
'<(src_dir)/src/file/SDL_rwops.c',
'<(src_dir)/src/haptic/SDL_haptic.c',
'<(src_dir)/src/joystick/SDL_gamecontroller.c',
'<(src_dir)/src/joystick/SDL_joystick.c',
'<(src_dir)/src/power/SDL_power.c',
'<(src_dir)/src/render/SDL_d3dmath.c',
'<(src_dir)/src/render/SDL_render.c',
'<(src_dir)/src/render/SDL_yuv_mmx.c',
'<(src_dir)/src/render/SDL_yuv_sw.c',
'<(src_dir)/src/render/direct3d/SDL_render_d3d.c',
'<(src_dir)/src/render/direct3d11/SDL_render_d3d11.c',
'<(src_dir)/src/render/opengl/SDL_render_gl.c',
'<(src_dir)/src/render/opengl/SDL_shaders_gl.c',
'<(src_dir)/src/render/opengles/SDL_render_gles.c',
'<(src_dir)/src/render/opengles2/SDL_render_gles2.c',
'<(src_dir)/src/render/opengles2/SDL_shaders_gles2.c',
'<(src_dir)/src/render/psp/SDL_render_psp.c',
'<(src_dir)/src/render/software/SDL_blendfillrect.c',
'<(src_dir)/src/render/software/SDL_blendline.c',
'<(src_dir)/src/render/software/SDL_blendpoint.c',
'<(src_dir)/src/render/software/SDL_drawline.c',
'<(src_dir)/src/render/software/SDL_drawpoint.c',
'<(src_dir)/src/render/software/SDL_render_sw.c',
'<(src_dir)/src/render/software/SDL_rotate.c',
'<(src_dir)/src/stdlib/SDL_getenv.c',
'<(src_dir)/src/stdlib/SDL_iconv.c',
'<(src_dir)/src/stdlib/SDL_malloc.c',
'<(src_dir)/src/stdlib/SDL_qsort.c',
'<(src_dir)/src/stdlib/SDL_stdlib.c',
'<(src_dir)/src/stdlib/SDL_string.c',
'<(src_dir)/src/thread/SDL_thread.c',
'<(src_dir)/src/timer/SDL_timer.c',
'<(src_dir)/src/video/SDL_RLEaccel.c',
'<(src_dir)/src/video/SDL_blit.c',
'<(src_dir)/src/video/SDL_blit_0.c',
'<(src_dir)/src/video/SDL_blit_1.c',
'<(src_dir)/src/video/SDL_blit_A.c',
'<(src_dir)/src/video/SDL_blit_N.c',
'<(src_dir)/src/video/SDL_blit_auto.c',
'<(src_dir)/src/video/SDL_blit_copy.c',
'<(src_dir)/src/video/SDL_blit_slow.c',
'<(src_dir)/src/video/SDL_bmp.c',
'<(src_dir)/src/video/SDL_clipboard.c',
'<(src_dir)/src/video/SDL_egl.c',
'<(src_dir)/src/video/SDL_fillrect.c',
'<(src_dir)/src/video/SDL_pixels.c',
'<(src_dir)/src/video/SDL_rect.c',
'<(src_dir)/src/video/SDL_shape.c',
'<(src_dir)/src/video/SDL_stretch.c',
'<(src_dir)/src/video/SDL_surface.c',
'<(src_dir)/src/video/SDL_video.c',
'<(src_dir)/src/video/dummy/SDL_nullevents.c',
'<(src_dir)/src/video/dummy/SDL_nullframebuffer.c',
'<(src_dir)/src/video/dummy/SDL_nullvideo.c',
'<(src_dir)/src/SDL.c',
],
},
}