Merge pull request #1 from scribam/linux
Make travis happy with BUILD and LINT
This commit is contained in:
commit
0406f19f4d
10
.travis.yml
10
.travis.yml
|
@ -22,17 +22,19 @@ matrix:
|
|||
# LLVMGold.so is not installed correctly
|
||||
- env: BUILD=true CONFIG=Release
|
||||
|
||||
dist: trusty
|
||||
sudo: required
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
# - ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise
|
||||
- llvm-toolchain-trusty
|
||||
packages:
|
||||
- clang-3.8
|
||||
- clang-format-3.8
|
||||
- libc++-dev
|
||||
- libc++abi-dev
|
||||
- libgtk-3-dev
|
||||
- liblz4-dev
|
||||
|
||||
git:
|
||||
# We handle submodules ourselves in xenia-build setup.
|
||||
|
@ -43,6 +45,10 @@ before_script:
|
|||
- export CC=clang-3.8
|
||||
# Dump useful info.
|
||||
- $CXX --version
|
||||
# Add Vulkan dependencies
|
||||
- wget http://mirrors.kernel.org/ubuntu/pool/universe/v/vulkan/libvulkan1_1.0.42.0+dfsg1-1ubuntu1~16.04.1_amd64.deb
|
||||
- wget http://mirrors.kernel.org/ubuntu/pool/universe/v/vulkan/libvulkan-dev_1.0.42.0+dfsg1-1ubuntu1~16.04.1_amd64.deb
|
||||
- sudo dpkg -i libvulkan1_1.0.42.0+dfsg1-1ubuntu1~16.04.1_amd64.deb libvulkan-dev_1.0.42.0+dfsg1-1ubuntu1~16.04.1_amd64.deb
|
||||
# Prepare environment (pull dependencies, build tools).
|
||||
- travis_retry ./xenia-build setup
|
||||
|
||||
|
|
|
@ -34,8 +34,8 @@ filter({})
|
|||
|
||||
characterset("Unicode")
|
||||
flags({
|
||||
--"ExtraWarnings", -- Sets the compiler's maximum warning level.
|
||||
"FatalWarnings", -- Treat warnings as errors.
|
||||
"ExtraWarnings", -- Sets the compiler's maximum warning level.
|
||||
--"FatalWarnings", -- Treat warnings as errors.
|
||||
})
|
||||
|
||||
filter("kind:StaticLib")
|
||||
|
|
|
@ -24,7 +24,6 @@ constexpr size_t kMaxHandlerCount = 8;
|
|||
// Executed in order.
|
||||
std::pair<ExceptionHandler::Handler, void*> handlers_[kMaxHandlerCount];
|
||||
|
||||
|
||||
void ExceptionHandler::Install(Handler fn, void* data) {
|
||||
// TODO(dougvj) stub
|
||||
}
|
||||
|
|
|
@ -12,11 +12,11 @@
|
|||
#include "xenia/base/string.h"
|
||||
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include <ftw.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <ftw.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
namespace xe {
|
||||
namespace filesystem {
|
||||
|
@ -26,7 +26,6 @@ bool PathExists(const std::wstring& path) {
|
|||
return stat(xe::to_string(path).c_str(), &st) == 0;
|
||||
}
|
||||
|
||||
|
||||
FILE* OpenFile(const std::wstring& path, const char* mode) {
|
||||
auto fixed_path = xe::fix_path_separators(path);
|
||||
return fopen(xe::to_string(fixed_path).c_str(), mode);
|
||||
|
@ -44,7 +43,9 @@ static int removeCallback(const char *fpath, const struct stat* sb,
|
|||
|
||||
bool DeleteFolder(const std::wstring& path) {
|
||||
return nftw(xe::to_string(path).c_str(), removeCallback, 64,
|
||||
FTW_DEPTH | FTW_PHYS) == 0 ? true : false;
|
||||
FTW_DEPTH | FTW_PHYS) == 0
|
||||
? true
|
||||
: false;
|
||||
}
|
||||
|
||||
static uint64_t convertUnixtimeToWinFiletime(time_t unixtime) {
|
||||
|
@ -60,8 +61,7 @@ static uint64_t convertUnixtimeToWinFiletime(time_t unixtime) {
|
|||
bool IsFolder(const std::wstring& path) {
|
||||
struct stat st;
|
||||
if (stat(xe::to_string(path).c_str(), &st) == 0) {
|
||||
if (S_ISDIR(st.st_mode))
|
||||
return true;
|
||||
if (S_ISDIR(st.st_mode)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -89,11 +89,9 @@ class PosixFileHandle : public FileHandle {
|
|||
}
|
||||
bool Read(size_t file_offset, void* buffer, size_t buffer_length,
|
||||
size_t* out_bytes_read) override {
|
||||
|
||||
ssize_t out = pread(handle_, buffer, buffer_length, file_offset);
|
||||
*out_bytes_read = out;
|
||||
return out >= 0 ? true : false;
|
||||
|
||||
}
|
||||
bool Write(size_t file_offset, const void* buffer, size_t buffer_length,
|
||||
size_t* out_bytes_written) override {
|
||||
|
@ -144,8 +142,7 @@ bool GetInfo(const std::wstring& path, FileInfo* out_info) {
|
|||
if (stat(xe::to_string(path).c_str(), &st) == 0) {
|
||||
if (S_ISDIR(st.st_mode)) {
|
||||
out_info->type = FileInfo::Type::kDirectory;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
out_info->type = FileInfo::Type::kFile;
|
||||
}
|
||||
out_info->create_timestamp = convertUnixtimeToWinFiletime(st.st_ctime);
|
||||
|
@ -186,7 +183,5 @@ std::vector<FileInfo> ListFiles(const std::wstring& path) {
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
} // namespace filesystem
|
||||
} // namespace xe
|
||||
|
||||
|
|
|
@ -11,10 +11,10 @@
|
|||
#define XENIA_BASE_MATH_H_
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <type_traits>
|
||||
#include <cmath>
|
||||
#include "xenia/base/platform.h"
|
||||
|
||||
#if XE_ARCH_AMD64
|
||||
|
|
|
@ -18,5 +18,4 @@ void LaunchBrowser(const char* url) {
|
|||
system(cmd.c_str());
|
||||
}
|
||||
|
||||
|
||||
} // namespace xe
|
||||
|
|
|
@ -18,15 +18,15 @@
|
|||
|
||||
// Xlib/Xcb is used only for GLX/Vulkan interaction, the window management
|
||||
// and input events are done with gtk/gdk
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xlib-xcb.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xos.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <xcb/xcb.h>
|
||||
|
||||
// Used for window management. Gtk is for GUI and wigets, gdk is for lower
|
||||
// level events like key presses, mouse events, window handles, etc
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkx.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#endif // XENIA_BASE_PLATFORM_X11_H_
|
||||
|
|
|
@ -16,13 +16,13 @@
|
|||
#include <climits>
|
||||
#include <condition_variable>
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
|
||||
namespace xe {
|
||||
namespace threading {
|
||||
|
|
|
@ -13,8 +13,5 @@
|
|||
#include <time.h>
|
||||
|
||||
namespace xe {
|
||||
namespace threading {
|
||||
|
||||
|
||||
} // namespace threading
|
||||
namespace threading {} // namespace threading
|
||||
} // namespace xe
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
|
||||
#include <pthread.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
@ -23,9 +23,7 @@ namespace xe {
|
|||
namespace threading {
|
||||
|
||||
// TODO(dougvj)
|
||||
void EnableAffinityConfiguration() {
|
||||
|
||||
}
|
||||
void EnableAffinityConfiguration() {}
|
||||
|
||||
// uint64_t ticks() { return mach_absolute_time(); }
|
||||
|
||||
|
@ -46,9 +44,7 @@ void MaybeYield() {
|
|||
__sync_synchronize();
|
||||
}
|
||||
|
||||
void SyncMemory() {
|
||||
__sync_synchronize();
|
||||
}
|
||||
void SyncMemory() { __sync_synchronize(); }
|
||||
|
||||
void Sleep(std::chrono::microseconds duration) {
|
||||
timespec rqtp = {time_t(duration.count() / 1000000),
|
||||
|
@ -65,27 +61,20 @@ SleepResult AlertableSleep(std::chrono::microseconds duration) {
|
|||
|
||||
// TODO(dougvj) We can probably wrap this with pthread_key_t but the type of
|
||||
// TlsHandle probably needs to be refactored
|
||||
TlsHandle AllocateTlsHandle() {
|
||||
assert_always();
|
||||
}
|
||||
TlsHandle AllocateTlsHandle() { assert_always(); }
|
||||
|
||||
bool FreeTlsHandle(TlsHandle handle) { return true; }
|
||||
|
||||
uintptr_t GetTlsValue(TlsHandle handle) {
|
||||
assert_always();
|
||||
}
|
||||
uintptr_t GetTlsValue(TlsHandle handle) { assert_always(); }
|
||||
|
||||
bool SetTlsValue(TlsHandle handle, uintptr_t value) {
|
||||
assert_always();
|
||||
}
|
||||
bool SetTlsValue(TlsHandle handle, uintptr_t value) { assert_always(); }
|
||||
|
||||
// TODO(dougvj)
|
||||
class PosixHighResolutionTimer : public HighResolutionTimer {
|
||||
public:
|
||||
PosixHighResolutionTimer(std::function<void()> callback)
|
||||
: callback_(callback) {}
|
||||
~PosixHighResolutionTimer() override {
|
||||
}
|
||||
~PosixHighResolutionTimer() override {}
|
||||
|
||||
bool Initialize(std::chrono::milliseconds period) {
|
||||
assert_always();
|
||||
|
@ -155,8 +144,7 @@ class PosixCondition {
|
|||
pthread_mutex_lock(&mutex_);
|
||||
while (!signal_) {
|
||||
int status = pthread_cond_timedwait(&cond_, &mutex_, &time_to_wait);
|
||||
if (status == ETIMEDOUT)
|
||||
return false; //We timed out
|
||||
if (status == ETIMEDOUT) return false; // We timed out
|
||||
}
|
||||
pthread_mutex_unlock(&mutex_);
|
||||
return true; // We didn't time out
|
||||
|
@ -175,7 +163,6 @@ class PosixCondition {
|
|||
bool signal_;
|
||||
pthread_cond_t cond_;
|
||||
pthread_mutex_t mutex_;
|
||||
|
||||
};
|
||||
|
||||
// Native posix thread handle
|
||||
|
@ -208,7 +195,6 @@ class PosixConditionHandle : public T {
|
|||
PosixCondition handle_;
|
||||
};
|
||||
|
||||
|
||||
// TODO(dougvj)
|
||||
WaitResult Wait(WaitHandle* wait_handle, bool is_alertable,
|
||||
std::chrono::milliseconds timeout) {
|
||||
|
@ -233,7 +219,6 @@ std::pair<WaitResult, size_t> WaitMultiple(WaitHandle* wait_handles[],
|
|||
return std::pair<WaitResult, size_t>(WaitResult::kFailed, 0);
|
||||
}
|
||||
|
||||
|
||||
// TODO(dougvj)
|
||||
class PosixEvent : public PosixConditionHandle<Event> {
|
||||
public:
|
||||
|
@ -242,6 +227,7 @@ class PosixEvent: public PosixConditionHandle<Event> {
|
|||
void Set() override { assert_always(); }
|
||||
void Reset() override { assert_always(); }
|
||||
void Pulse() override { assert_always(); }
|
||||
|
||||
private:
|
||||
PosixCondition condition_;
|
||||
};
|
||||
|
@ -273,12 +259,12 @@ std::unique_ptr<Semaphore> Semaphore::Create(int initial_count,
|
|||
// TODO(dougvj)
|
||||
class PosixMutant : public PosixConditionHandle<Mutant> {
|
||||
public:
|
||||
PosixMutant(bool initial_owner) {
|
||||
assert_always();
|
||||
}
|
||||
PosixMutant(bool initial_owner) { assert_always(); }
|
||||
~PosixMutant() = default;
|
||||
bool Release() override { assert_always(); return false; }
|
||||
private:
|
||||
bool Release() override {
|
||||
assert_always();
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
std::unique_ptr<Mutant> Mutant::Create(bool initial_owner) {
|
||||
|
@ -305,7 +291,6 @@ class PosixTimer : public PosixConditionHandle<Timer> {
|
|||
assert_always();
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
std::unique_ptr<Timer> Timer::CreateManualResetTimer() {
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
#include <llvm/ADT/BitVector.h>
|
||||
#pragma warning(pop)
|
||||
#else
|
||||
#include <cmath>
|
||||
#include <llvm/ADT/BitVector.h>
|
||||
#include <cmath>
|
||||
#endif // XE_COMPILER_MSVC
|
||||
|
||||
namespace xe {
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
#include <llvm/ADT/BitVector.h>
|
||||
#pragma warning(pop)
|
||||
#else
|
||||
#include <cmath>
|
||||
#include <llvm/ADT/BitVector.h>
|
||||
#include <cmath>
|
||||
#endif // XE_COMPILER_MSVC
|
||||
|
||||
namespace xe {
|
||||
|
|
|
@ -240,4 +240,3 @@ class CommandProcessor {
|
|||
} // namespace xe
|
||||
|
||||
#endif // XENIA_GPU_COMMAND_PROCESSOR_H_
|
||||
|
||||
|
|
|
@ -11,10 +11,10 @@
|
|||
#define XENIA_GPU_GL4_SHADER_CACHE_H_
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "xenia/gpu/xenos.h"
|
||||
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
|
||||
#include "xenia/ui/file_picker.h"
|
||||
|
||||
#include <codecvt>
|
||||
#include <locale>
|
||||
#include <string>
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/base/platform_linux.h"
|
||||
#include <locale>
|
||||
#include <codecvt>
|
||||
#include <string>
|
||||
|
||||
namespace xe {
|
||||
namespace ui {
|
||||
|
@ -36,7 +36,6 @@ GtkFilePicker::GtkFilePicker() = default;
|
|||
|
||||
GtkFilePicker::~GtkFilePicker() = default;
|
||||
|
||||
|
||||
bool GtkFilePicker::Show(void* parent_window_handle) {
|
||||
// TODO(benvanik): FileSaveDialog.
|
||||
assert_true(mode() == Mode::kOpen);
|
||||
|
@ -45,14 +44,10 @@ bool GtkFilePicker::Show(void* parent_window_handle) {
|
|||
GtkWidget* dialog;
|
||||
gint res;
|
||||
|
||||
dialog = gtk_file_chooser_dialog_new ("Open File",
|
||||
(GtkWindow*)parent_window_handle,
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||
"_Cancel",
|
||||
GTK_RESPONSE_CANCEL,
|
||||
"_Open",
|
||||
GTK_RESPONSE_ACCEPT,
|
||||
NULL);
|
||||
dialog = gtk_file_chooser_dialog_new(
|
||||
"Open File", (GtkWindow*)parent_window_handle,
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN, "_Cancel", GTK_RESPONSE_CANCEL, "_Open",
|
||||
GTK_RESPONSE_ACCEPT, NULL);
|
||||
|
||||
res = gtk_dialog_run(GTK_DIALOG(dialog));
|
||||
char* filename;
|
||||
|
@ -68,7 +63,7 @@ bool GtkFilePicker::Show(void* parent_window_handle) {
|
|||
return true;
|
||||
}
|
||||
gtk_widget_destroy(dialog);
|
||||
return false;;
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace ui
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include "xenia/ui/gl/gl_immediate_drawer.h"
|
||||
#include "xenia/ui/window.h"
|
||||
|
||||
|
||||
DEFINE_bool(thread_safe_gl, false,
|
||||
"Only allow one GL context to be active at a time.");
|
||||
|
||||
|
@ -40,7 +39,6 @@ namespace xe {
|
|||
namespace ui {
|
||||
namespace gl {
|
||||
|
||||
|
||||
std::recursive_mutex GLContext::global_gl_mutex_;
|
||||
|
||||
void GLContext::FatalGLError(std::string error) {
|
||||
|
@ -51,8 +49,6 @@ void GLContext::FatalGLError(std::string error) {
|
|||
"of supported GPUs.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
GLContext::GLContext(GraphicsProvider* provider, Window* target_window)
|
||||
: GraphicsContext(provider, target_window) {}
|
||||
|
||||
|
@ -218,8 +214,6 @@ ImmediateDrawer* GLContext::immediate_drawer() {
|
|||
return immediate_drawer_.get();
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool GLContext::WasLost() {
|
||||
if (!robust_access_supported_) {
|
||||
// Can't determine if we lost the context.
|
||||
|
|
|
@ -29,7 +29,6 @@ DECLARE_bool(gl_debug);
|
|||
DECLARE_bool(gl_debug_output);
|
||||
DECLARE_bool(gl_debug_output_synchronous);
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace ui {
|
||||
namespace gl {
|
||||
|
@ -69,6 +68,7 @@ class GLContext : public GraphicsContext {
|
|||
void AssertExtensionsPresent();
|
||||
void DebugMessage(GLenum source, GLenum type, GLuint id, GLenum severity,
|
||||
GLsizei length, const GLchar* message);
|
||||
|
||||
private:
|
||||
friend class GLProvider;
|
||||
|
||||
|
@ -79,15 +79,11 @@ class GLContext : public GraphicsContext {
|
|||
GLContext* parent_context);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
static void GLAPIENTRY DebugMessageThunk(GLenum source, GLenum type,
|
||||
GLuint id, GLenum severity,
|
||||
GLsizei length,
|
||||
const GLchar* message,
|
||||
GLvoid* user_param);
|
||||
|
||||
|
||||
};
|
||||
|
||||
} // namespace gl
|
||||
|
|
|
@ -24,18 +24,15 @@
|
|||
|
||||
#include "third_party/GL/wglew.h"
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace ui {
|
||||
namespace gl {
|
||||
|
||||
|
||||
thread_local GLEWContext* tls_glew_context_ = nullptr;
|
||||
thread_local WGLEWContext* tls_wglew_context_ = nullptr;
|
||||
extern "C" GLEWContext* glewGetContext() { return tls_glew_context_; }
|
||||
extern "C" WGLEWContext* wglewGetContext() { return tls_wglew_context_; }
|
||||
|
||||
|
||||
std::unique_ptr<GLContext> GLContext::Create(GraphicsProvider* provider,
|
||||
Window* target_window,
|
||||
GLContext* share_context) {
|
||||
|
@ -48,7 +45,6 @@ std::unique_ptr<GLContext> GLContext::Create(GraphicsProvider* provider,
|
|||
return context;
|
||||
}
|
||||
|
||||
|
||||
std::unique_ptr<GLContext> GLContext::CreateOffscreen(
|
||||
GraphicsProvider* provider, GLContext* parent_context) {
|
||||
return WGLContext::CreateOffscreen(provider,
|
||||
|
@ -296,7 +292,6 @@ void WGLContext::ClearCurrent() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void WGLContext::BeginSwap() {
|
||||
SCOPE_profile_cpu_i("gpu", "xe::ui::gl::WGLContext::BeginSwap");
|
||||
float clear_color[] = {238 / 255.0f, 238 / 255.0f, 238 / 255.0f, 1.0f};
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
|
||||
#include <memory>
|
||||
|
||||
#include "xenia/ui/gl/gl_context.h"
|
||||
#include "xenia/ui/gl/blitter.h"
|
||||
#include "xenia/ui/gl/gl.h"
|
||||
#include "xenia/ui/gl/gl_context.h"
|
||||
#include "xenia/ui/graphics_context.h"
|
||||
|
||||
typedef struct HDC__* HDC;
|
||||
|
@ -33,7 +33,6 @@ class WGLContext : public GLContext {
|
|||
public:
|
||||
~WGLContext() override;
|
||||
|
||||
|
||||
bool is_current() override;
|
||||
bool MakeCurrent() override;
|
||||
void ClearCurrent() override;
|
||||
|
@ -41,25 +40,21 @@ class WGLContext : public GLContext {
|
|||
void BeginSwap() override;
|
||||
void EndSwap() override;
|
||||
|
||||
|
||||
protected:
|
||||
friend class GLContext;
|
||||
WGLContext(GraphicsProvider* provider, Window* target_window);
|
||||
static std::unique_ptr<WGLContext> CreateOffscreen(GraphicsProvider* provider,
|
||||
WGLContext* parent_context);
|
||||
static std::unique_ptr<WGLContext> CreateOffscreen(
|
||||
GraphicsProvider* provider, WGLContext* parent_context);
|
||||
|
||||
bool Initialize(GLContext* share_context) override;
|
||||
void* handle() override {return glrc_;};
|
||||
void* handle() override { return glrc_; }
|
||||
|
||||
private:
|
||||
|
||||
|
||||
HDC dc_ = nullptr;
|
||||
HGLRC glrc_ = nullptr;
|
||||
|
||||
std::unique_ptr<GLEWContext> glew_context_;
|
||||
std::unique_ptr<WGLEWContext> wglew_context_;
|
||||
|
||||
};
|
||||
|
||||
} // namespace gl
|
||||
|
|
|
@ -11,9 +11,11 @@
|
|||
|
||||
#include <gflags/gflags.h>
|
||||
|
||||
#include <gdk/gdkx.h>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
#include "third_party/GL/glxew.h"
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/base/math.h"
|
||||
|
@ -21,22 +23,16 @@
|
|||
#include "xenia/base/profiling.h"
|
||||
#include "xenia/ui/gl/gl_immediate_drawer.h"
|
||||
#include "xenia/ui/window.h"
|
||||
#include "third_party/GL/glxew.h"
|
||||
#include <gdk/gdkx.h>
|
||||
|
||||
namespace xe {
|
||||
namespace ui {
|
||||
namespace gl {
|
||||
|
||||
|
||||
|
||||
thread_local GLEWContext* tls_glew_context_ = nullptr;
|
||||
thread_local GLXEWContext* tls_glxew_context_ = nullptr;
|
||||
extern "C" GLEWContext* glewGetContext() { return tls_glew_context_; }
|
||||
extern "C" GLXEWContext* glxewGetContext() { return tls_glxew_context_; }
|
||||
|
||||
|
||||
|
||||
std::unique_ptr<GLContext> GLContext::Create(GraphicsProvider* provider,
|
||||
Window* target_window,
|
||||
GLContext* share_context) {
|
||||
|
@ -74,8 +70,6 @@ GLXContext::~GLXContext() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool GLXContext::Initialize(GLContext* share_context) {
|
||||
GtkWidget* window = GTK_WIDGET(target_window_->native_handle());
|
||||
GtkWidget* draw_area = gtk_drawing_area_new();
|
||||
|
@ -90,8 +84,8 @@ bool GLXContext::Initialize(GLContext* share_context) {
|
|||
Display* display = gdk_x11_display_get_xdisplay(gdk_display);
|
||||
disp_ = display;
|
||||
::Window root = gdk_x11_get_default_root_xwindow();
|
||||
static int vis_attrib_list[] =
|
||||
{GLX_RGBA, GLX_DEPTH_SIZE, 24, GLX_DOUBLEBUFFER, None};
|
||||
static int vis_attrib_list[] = {GLX_RGBA, GLX_DEPTH_SIZE, 24,
|
||||
GLX_DOUBLEBUFFER, None};
|
||||
XVisualInfo* vi = glXChooseVisual(display, 0, vis_attrib_list);
|
||||
if (vi == NULL) {
|
||||
FatalGLError("No matching visuals for X display");
|
||||
|
@ -222,7 +216,8 @@ std::unique_ptr<GLXContext> GLXContext::CreateOffscreen(
|
|||
robust_access_supported ? GLX_LOSE_CONTEXT_ON_RESET_ARB : 0,
|
||||
0};
|
||||
new_glrc = glXCreateContextAttribsARB(parent_context->disp_, nullptr,
|
||||
parent_context->glx_context_, True, attrib_list);
|
||||
parent_context->glx_context_, True,
|
||||
attrib_list);
|
||||
if (!new_glrc) {
|
||||
FatalGLError("Could not create shared context.");
|
||||
return nullptr;
|
||||
|
@ -271,13 +266,10 @@ std::unique_ptr<GLXContext> GLXContext::CreateOffscreen(
|
|||
return new_context;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool GLXContext::is_current() {
|
||||
return tls_glew_context_ == glew_context_.get();
|
||||
}
|
||||
|
||||
|
||||
bool GLXContext::MakeCurrent() {
|
||||
SCOPE_profile_cpu_f("gpu");
|
||||
if (FLAGS_thread_safe_gl) {
|
||||
|
@ -308,7 +300,6 @@ void GLXContext::ClearCurrent() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void GLXContext::BeginSwap() {
|
||||
SCOPE_profile_cpu_i("gpu", "xe::ui::gl::GLXContext::BeginSwap");
|
||||
float clear_color[] = {238 / 255.0f, 238 / 255.0f, 238 / 255.0f, 1.0f};
|
||||
|
|
|
@ -14,16 +14,15 @@
|
|||
|
||||
#include <memory>
|
||||
|
||||
#include "xenia/ui/gl/gl_context.h"
|
||||
#include "xenia/ui/gl/blitter.h"
|
||||
#include "xenia/ui/gl/gl.h"
|
||||
#include "xenia/ui/graphics_context.h"
|
||||
#include "third_party/GL/glxew.h"
|
||||
#include "xenia/base/platform_linux.h"
|
||||
#include "xenia/ui/gl/blitter.h"
|
||||
#include "xenia/ui/gl/gl.h"
|
||||
#include "xenia/ui/gl/gl_context.h"
|
||||
#include "xenia/ui/graphics_context.h"
|
||||
|
||||
DECLARE_bool(thread_safe_gl);
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace ui {
|
||||
namespace gl {
|
||||
|
@ -35,7 +34,6 @@ class GLXContext : public GLContext {
|
|||
public:
|
||||
~GLXContext() override;
|
||||
|
||||
|
||||
bool is_current() override;
|
||||
|
||||
bool MakeCurrent() override;
|
||||
|
@ -44,10 +42,9 @@ class GLXContext : public GLContext {
|
|||
void BeginSwap() override;
|
||||
void EndSwap() override;
|
||||
|
||||
|
||||
protected:
|
||||
static std::unique_ptr<GLXContext> CreateOffscreen(GraphicsProvider* provider,
|
||||
GLXContext* parent_context);
|
||||
static std::unique_ptr<GLXContext> CreateOffscreen(
|
||||
GraphicsProvider* provider, GLXContext* parent_context);
|
||||
|
||||
bool Initialize(GLContext* share_context) override;
|
||||
void* handle() override { return glx_context_; }
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
namespace xe {
|
||||
namespace ui {
|
||||
|
||||
|
||||
class PostedFn {
|
||||
public:
|
||||
explicit PostedFn(std::function<void()> fn) : fn_(std::move(fn)) {}
|
||||
|
@ -47,17 +46,12 @@ GTKLoop::~GTKLoop() {
|
|||
thread_.join();
|
||||
}
|
||||
|
||||
void GTKLoop::ThreadMain() {
|
||||
|
||||
gtk_main();
|
||||
|
||||
}
|
||||
void GTKLoop::ThreadMain() { gtk_main(); }
|
||||
|
||||
bool GTKLoop::is_on_loop_thread() {
|
||||
return thread_id_ == std::this_thread::get_id();
|
||||
}
|
||||
|
||||
|
||||
gboolean _posted_fn_thunk(gpointer posted_fn) {
|
||||
PostedFn* Fn = reinterpret_cast<PostedFn*>(posted_fn);
|
||||
Fn->Call();
|
||||
|
@ -70,16 +64,13 @@ void GTKLoop::Post(std::function<void()> fn) {
|
|||
reinterpret_cast<gpointer>(new PostedFn(std::move(fn))));
|
||||
}
|
||||
|
||||
|
||||
void GTKLoop::PostDelayed(std::function<void()> fn, uint64_t delay_millis) {
|
||||
gdk_threads_add_timeout(delay_millis, _posted_fn_thunk,
|
||||
gdk_threads_add_timeout(
|
||||
delay_millis, _posted_fn_thunk,
|
||||
reinterpret_cast<gpointer>(new PostedFn(std::move(fn))));
|
||||
}
|
||||
|
||||
void GTKLoop::Quit() {
|
||||
assert_true(thread_id_ != std::thread::id());
|
||||
|
||||
}
|
||||
void GTKLoop::Quit() { assert_true(thread_id_ != std::thread::id()); }
|
||||
|
||||
void GTKLoop::AwaitQuit() { quit_fence_.Wait(); }
|
||||
|
||||
|
|
|
@ -35,15 +35,13 @@ class GTKLoop : public Loop {
|
|||
|
||||
void Quit() override;
|
||||
void AwaitQuit() override;
|
||||
private:
|
||||
|
||||
private:
|
||||
void ThreadMain();
|
||||
|
||||
std::thread::id thread_id_;
|
||||
std::thread thread_;
|
||||
xe::threading::Fence quit_fence_;
|
||||
|
||||
|
||||
};
|
||||
|
||||
} // namespace ui
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "xenia/ui/ui_event.h"
|
||||
|
||||
|
|
|
@ -73,16 +73,15 @@ bool VulkanContext::Initialize() {
|
|||
assert(GDK_IS_X11_DISPLAY(gdk_display));
|
||||
xcb_connection_t* connection =
|
||||
XGetXCBConnection(gdk_x11_display_get_xdisplay(gdk_display));
|
||||
xcb_window_t window = gdk_x11_window_get_xid(
|
||||
gtk_widget_get_window(window_handle));
|
||||
xcb_window_t window =
|
||||
gdk_x11_window_get_xid(gtk_widget_get_window(window_handle));
|
||||
VkXcbSurfaceCreateInfoKHR create_info;
|
||||
create_info.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR;
|
||||
create_info.pNext = nullptr;
|
||||
create_info.flags = 0;
|
||||
create_info.connection = static_cast<xcb_connection_t*>
|
||||
(target_window_->native_platform_handle());
|
||||
create_info.window =
|
||||
static_cast<xcb_window_t>(window);
|
||||
create_info.connection = static_cast<xcb_connection_t*>(
|
||||
target_window_->native_platform_handle());
|
||||
create_info.window = static_cast<xcb_window_t>(window);
|
||||
auto err = vkCreateXcbSurfaceKHR(*provider->instance(), &create_info,
|
||||
nullptr, &surface);
|
||||
CheckResult(err, "vkCreateXcbSurfaceKHR");
|
||||
|
|
|
@ -397,18 +397,17 @@ bool VulkanInstance::QueryDevices(Window* any_target_window) {
|
|||
assert(GDK_IS_X11_DISPLAY(gdk_display));
|
||||
xcb_connection_t* connection =
|
||||
XGetXCBConnection(gdk_x11_display_get_xdisplay(gdk_display));
|
||||
xcb_window_t window = gdk_x11_window_get_xid(
|
||||
gtk_widget_get_window(window_handle));
|
||||
xcb_window_t window =
|
||||
gdk_x11_window_get_xid(gtk_widget_get_window(window_handle));
|
||||
VkXcbSurfaceCreateInfoKHR create_info;
|
||||
create_info.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR;
|
||||
create_info.pNext = nullptr;
|
||||
create_info.flags = 0;
|
||||
create_info.connection = static_cast<xcb_connection_t*>
|
||||
(any_target_window->native_platform_handle());
|
||||
create_info.window =
|
||||
static_cast<xcb_window_t>(window);
|
||||
auto err = vkCreateXcbSurfaceKHR(handle, &create_info,
|
||||
nullptr, &any_surface);
|
||||
create_info.connection = static_cast<xcb_connection_t*>(
|
||||
any_target_window->native_platform_handle());
|
||||
create_info.window = static_cast<xcb_window_t>(window);
|
||||
auto err =
|
||||
vkCreateXcbSurfaceKHR(handle, &create_info, nullptr, &any_surface);
|
||||
CheckResult(err, "vkCreateXcbSurfaceKHR");
|
||||
#else
|
||||
#error Unsupported GDK Backend on Linux.
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
namespace xe {
|
||||
namespace ui {
|
||||
|
||||
|
||||
class FnWrapper {
|
||||
public:
|
||||
explicit FnWrapper(std::function<void()> fn) : fn_(std::move(fn)) {}
|
||||
|
@ -161,7 +160,7 @@ void GTKWindow::set_focus(bool value) {
|
|||
if (value) {
|
||||
gtk_window_activate_focus(GTK_WINDOW(window_));
|
||||
} else {
|
||||
// TODO(dougvj) Check to see if we need to do somethign here to unset
|
||||
// TODO(dougvj) Check to see if we need to do something here to unset
|
||||
// the focus.
|
||||
}
|
||||
} else {
|
||||
|
@ -219,8 +218,6 @@ void GTKWindow::OnMainMenuChange() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool GTKWindow::HandleWindowOwnerChange(GdkEventOwnerChange* event) {
|
||||
if (event->type == GDK_OWNER_CHANGE) {
|
||||
if (event->reason == GDK_OWNER_CHANGE_DESTROY) {
|
||||
|
@ -244,8 +241,6 @@ bool GTKWindow::HandleWindowResize(GdkEventConfigure* event) {
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool GTKWindow::HandleWindowVisibility(GdkEventVisibility* event) {
|
||||
// TODO(dougvj) The gdk docs say that this is deprecated because modern window
|
||||
// managers composite everything and nothing is truly hidden.
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "xenia/base/platform_linux.h"
|
||||
#include "xenia/ui/menu_item.h"
|
||||
#include "xenia/ui/window.h"
|
||||
#include "xenia/base/platform_linux.h"
|
||||
|
||||
namespace xe {
|
||||
namespace ui {
|
||||
|
@ -27,10 +27,11 @@ class GTKWindow : public Window {
|
|||
GTKWindow(Loop* loop, const std::wstring& title);
|
||||
~GTKWindow() override;
|
||||
|
||||
NativePlatformHandle native_platform_handle() const override {return nullptr;}
|
||||
NativePlatformHandle native_platform_handle() const override {
|
||||
return nullptr;
|
||||
}
|
||||
NativeWindowHandle native_handle() const override { return window_; }
|
||||
|
||||
|
||||
bool set_title(const std::wstring& title) override;
|
||||
|
||||
bool SetIcon(const void* buffer, size_t size) override;
|
||||
|
@ -60,7 +61,6 @@ class GTKWindow : public Window {
|
|||
|
||||
void OnResize(UIEvent* e) override;
|
||||
|
||||
|
||||
private:
|
||||
void Create();
|
||||
GtkWidget* window_;
|
||||
|
@ -75,7 +75,6 @@ class GTKWindow : public Window {
|
|||
|
||||
bool closing_ = false;
|
||||
bool fullscreen_ = false;
|
||||
|
||||
};
|
||||
|
||||
class GTKMenuItem : public MenuItem {
|
||||
|
|
Loading…
Reference in New Issue