=== modified file 'src/main.cpp'
@@ -41,6 +41,8 @@
#include "native-state-x11.h"
#elif GLMARK2_USE_DRM
#include "native-state-drm.h"
+#elif GLMARK2_USE_MIR
+#include "native-state-mir.h"
#endif
#if GLMARK2_USE_EGL
@@ -192,6 +194,8 @@
NativeStateX11 native_state;
#elif GLMARK2_USE_DRM
NativeStateDRM native_state;
+#elif GLMARK2_USE_MIR
+ NativeStateMir native_state;
#endif
#if GLMARK2_USE_EGL
=== added file 'src/native-state-mir.cpp'
@@ -0,0 +1,178 @@
+/*
+ * Copyright © 2013 Canonical Ltd
+ *
+ * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
+ *
+ * glmark2 is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * glmark2. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Alexandros Frantzis
+ */
+#include "native-state-mir.h"
+#include "log.h"
+
+/******************
+ * Public methods *
+ ******************/
+
+namespace
+{
+
+void
+connected_callback(MirConnection *connection, void *client_context)
+{
+ MirConnection **con = static_cast<MirConnection**>(client_context);
+ *con = connection;
+}
+
+void
+surface_created_callback(MirSurface *surface, void *client_context)
+{
+ MirSurface **surf = static_cast<MirSurface**>(client_context);
+ *surf = surface;
+}
+
+void
+null_surface_callback(MirSurface * /*obj*/, void * /*client_context*/)
+{
+}
+
+}
+
+volatile sig_atomic_t NativeStateMir::should_quit_(false);
+
+NativeStateMir::~NativeStateMir()
+{
+ if (mir_surface_)
+ mir_wait_for(mir_surface_release(mir_surface_, null_surface_callback, 0));
+ if (mir_connection_is_valid(mir_connection_))
+ mir_connection_release(mir_connection_);
+}
+
+bool
+NativeStateMir::init_display()
+{
+ struct sigaction sa;
+ sa.sa_handler = &NativeStateMir::quit_handler;
+ sa.sa_flags = 0;
+ sigemptyset(&sa.sa_mask);
+
+ sigaction(SIGINT, &sa, NULL);
+ sigaction(SIGTERM, &sa, NULL);
+
+ mir_wait_for(mir_connect("/tmp/mir_socket", "glmark2",
+ connected_callback, &mir_connection_));
+
+ if (!mir_connection_is_valid(mir_connection_)) {
+ Log::error("Failed to connect to mir\n");
+ return false;
+ }
+
+ return true;
+}
+
+void*
+NativeStateMir::display()
+{
+ if (mir_connection_is_valid(mir_connection_))
+ return static_cast<void*>(mir_connection_get_egl_native_display(mir_connection_));
+
+ return 0;
+}
+
+bool
+NativeStateMir::create_window(WindowProperties const& properties)
+{
+ static const char *win_name("glmark2 "GLMARK_VERSION);
+
+ if (!mir_connection_is_valid(mir_connection_)) {
+ Log::error("No connection to mir!\n");
+ return false;
+ }
+
+ /* Recreate an existing window only if it has actually been resized */
+ if (mir_surface_) {
+ if (properties_.fullscreen != properties.fullscreen ||
+ (properties.fullscreen == false &&
+ (properties_.width != properties.width ||
+ properties_.height != properties.height)))
+ {
+ mir_wait_for(mir_surface_release(mir_surface_, null_surface_callback, 0));
+ mir_surface_ = 0;
+ }
+ else
+ {
+ return true;
+ }
+ }
+
+ MirDisplayInfo display_info;
+ mir_connection_get_display_info(mir_connection_, &display_info);
+
+ properties_ = properties;
+
+ if (properties_.fullscreen) {
+ properties_.width = display_info.width;
+ properties_.height = display_info.height;
+ }
+
+ MirSurfaceParameters surface_parameters = {
+ win_name,
+ properties_.width, properties_.height,
+ display_info.supported_pixel_format[0],
+ mir_buffer_usage_hardware
+ };
+
+ mir_wait_for(mir_surface_create(mir_connection_, &surface_parameters,
+ surface_created_callback, &mir_surface_));
+
+ if (!mir_surface_) {
+ Log::error("Failed to create mir surface!\n");
+ return false;
+ }
+
+ return true;
+}
+
+void*
+NativeStateMir::window(WindowProperties& properties)
+{
+ properties = properties_;
+
+ if (mir_surface_)
+ return static_cast<void*>(mir_surface_get_egl_native_window(mir_surface_));
+
+ return 0;
+}
+
+void
+NativeStateMir::visible(bool /*visible*/)
+{
+}
+
+bool
+NativeStateMir::should_quit()
+{
+ return should_quit_;
+}
+
+/*******************
+ * Private methods *
+ *******************/
+
+void
+NativeStateMir::quit_handler(int /*signum*/)
+{
+ should_quit_ = true;
+}
=== added file 'src/native-state-mir.h'
@@ -0,0 +1,52 @@
+/*
+ * Copyright © 2013 Canonical Ltd
+ *
+ * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
+ *
+ * glmark2 is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * glmark2. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Alexandros Frantzis
+ */
+#ifndef GLMARK2_NATIVE_STATE_MIR_H_
+#define GLMARK2_NATIVE_STATE_MIR_H_
+
+#include "native-state.h"
+#include <mir_client_library.h>
+#include <csignal>
+
+class NativeStateMir : public NativeState
+{
+public:
+ NativeStateMir() : mir_connection_(0), mir_surface_(0), properties_() {}
+ ~NativeStateMir();
+
+ bool init_display();
+ void* display();
+ bool create_window(WindowProperties const& properties);
+ void* window(WindowProperties& properties);
+ void visible(bool v);
+ bool should_quit();
+ void flip() { }
+
+private:
+ static void quit_handler(int signum);
+ static volatile std::sig_atomic_t should_quit_;
+
+ MirConnection* mir_connection_;
+ MirSurface* mir_surface_;
+ WindowProperties properties_;
+};
+
+#endif /* GLMARK2_NATIVE_STATE_MIR_H_ */
=== modified file 'src/wscript_build'
@@ -12,19 +12,25 @@
'x11-gl' : ['canvas-generic.cpp', 'native-state-x11.cpp', 'gl-state-glx.cpp'],
'x11-glesv2' : ['canvas-generic.cpp', 'native-state-x11.cpp', 'gl-state-egl.cpp'],
'drm-gl' : ['canvas-generic.cpp', 'native-state-drm.cpp', 'gl-state-egl.cpp'],
- 'drm-glesv2' : ['canvas-generic.cpp', 'native-state-drm.cpp', 'gl-state-egl.cpp']
+ 'drm-glesv2' : ['canvas-generic.cpp', 'native-state-drm.cpp', 'gl-state-egl.cpp'],
+ 'mir-gl' : ['canvas-generic.cpp', 'native-state-mir.cpp', 'gl-state-egl.cpp'],
+ 'mir-glesv2' : ['canvas-generic.cpp', 'native-state-mir.cpp', 'gl-state-egl.cpp']
}
flavor_uselibs = {
'x11-gl' : ['x11', 'gl', 'matrix-gl'],
'x11-glesv2' : ['x11', 'egl', 'glesv2', 'matrix-glesv2'],
'drm-gl' : ['drm', 'gbm', 'egl', 'gl', 'matrix-gl'],
'drm-glesv2' : ['drm', 'gbm', 'egl', 'glesv2', 'matrix-gl'],
+ 'mir-gl' : ['mirclient', 'egl', 'gl', 'matrix-gl'],
+ 'mir-glesv2' : ['mirclient', 'egl', 'glesv2', 'matrix-gl']
}
flavor_defines = {
'x11-gl' : ['GLMARK2_USE_X11', 'GLMARK2_USE_GL', 'GLMARK2_USE_GLX'],
'x11-glesv2' : ['GLMARK2_USE_X11', 'GLMARK2_USE_GLESv2', 'GLMARK2_USE_EGL'],
'drm-gl' : ['GLMARK2_USE_DRM', 'GLMARK2_USE_GL', 'GLMARK2_USE_EGL', '__GBM__'],
- 'drm-glesv2' : ['GLMARK2_USE_DRM', 'GLMARK2_USE_GLESv2', 'GLMARK2_USE_EGL', '__GBM__']
+ 'drm-glesv2' : ['GLMARK2_USE_DRM', 'GLMARK2_USE_GLESv2', 'GLMARK2_USE_EGL', '__GBM__'],
+ 'mir-gl' : ['GLMARK2_USE_MIR', 'GLMARK2_USE_GL', 'GLMARK2_USE_EGL'],
+ 'mir-glesv2' : ['GLMARK2_USE_MIR', 'GLMARK2_USE_GLESv2', 'GLMARK2_USE_EGL']
}
includes = ['.', 'scene-ideas', 'scene-terrain']
=== modified file 'wscript'
@@ -15,7 +15,9 @@
'x11-gl' : 'glmark2',
'x11-glesv2' : 'glmark2-es2',
'drm-gl' : 'glmark2-drm',
- 'drm-glesv2' : 'glmark2-es2-drm'
+ 'drm-glesv2' : 'glmark2-es2-drm',
+ 'mir-gl' : 'glmark2-mir',
+ 'mir-glesv2' : 'glmark2-es2-mir'
}
FLAVORS_STR = ", ".join(FLAVORS.keys())
@@ -101,7 +103,8 @@
('egl', 'egl', list_contains(Options.options.flavors, 'glesv2$')),
('glesv2', 'glesv2', list_contains(Options.options.flavors, 'glesv2$')),
('libdrm','drm', list_contains(Options.options.flavors, 'drm')),
- ('gbm','gbm', list_contains(Options.options.flavors, 'drm'))]
+ ('gbm','gbm', list_contains(Options.options.flavors, 'drm')),
+ ('mirclient','mirclient', list_contains(Options.options.flavors, 'mir'))]
for (pkg, uselib, mandatory) in opt_pkgs:
ctx.check_cfg(package = pkg, uselib_store = uselib,
args = '--cflags --libs', mandatory = mandatory)