From patchwork Tue Mar 5 18:07:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: alexandros.frantzis@linaro.org X-Patchwork-Id: 15244 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id DCCEC23E2E for ; Tue, 5 Mar 2013 18:07:20 +0000 (UTC) Received: from mail-vc0-f170.google.com (mail-vc0-f170.google.com [209.85.220.170]) by fiordland.canonical.com (Postfix) with ESMTP id 4EB92A1904D for ; Tue, 5 Mar 2013 18:07:20 +0000 (UTC) Received: by mail-vc0-f170.google.com with SMTP id p16so4338129vcq.15 for ; Tue, 05 Mar 2013 10:07:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:content-type:mime-version:x-launchpad-project :x-launchpad-branch:x-launchpad-message-rationale :x-launchpad-branch-revision-number:x-launchpad-notification-type:to :from:subject:message-id:date:reply-to:sender:errors-to:precedence :x-generated-by:x-launchpad-hash:x-gm-message-state; bh=TywzdsXRGDlk8TOGz8a2+NagckziaJi9ZWId/h4/ITI=; b=UDcBnnEGSMLgPiGYT14+D0CzAREEgK8sTD/E72VOPpilpJKeIvl75EiVCcoMwKjSjp acTq/bFpizETZrT7Oaot+MIWXT7BP681mOAvcQ3JBvPHa+09YKFDfKKEw2CgnKWjdlo4 U6csKFmA/Lm4qj9aSsSCS4H2+nuQYBM2+PQxmtCAXDgbMSPCizH06E12rW6uen3WigA+ kIdwvRMVh1YW6uVZBZ/6cHuA4HSaZMdoSAdPC7acivFb5kzJKM9xHuF94P62zrurbP1i waZq0IobLvFs4OOl78DH27OxuHATUYQnPbhzffS+6EzvIwTz+cgD0Uvl7rxQP51b+ZWd 2xnQ== X-Received: by 10.58.205.179 with SMTP id lh19mr10147513vec.7.1362506839795; Tue, 05 Mar 2013 10:07:19 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.127.98 with SMTP id nf2csp126061veb; Tue, 5 Mar 2013 10:07:15 -0800 (PST) X-Received: by 10.194.157.42 with SMTP id wj10mr41486204wjb.12.1362506834380; Tue, 05 Mar 2013 10:07:14 -0800 (PST) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id u3si11247313wjw.56.2013.03.05.10.07.13 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 05 Mar 2013 10:07:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) client-ip=91.189.90.7; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) smtp.mail=bounces@canonical.com Received: from ackee.canonical.com ([91.189.89.26]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1UCwGf-0007yX-IB for ; Tue, 05 Mar 2013 18:07:13 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 7486BE011D for ; Tue, 5 Mar 2013 18:07:13 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: glmark2 X-Launchpad-Branch: ~glmark2-dev/glmark2/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 265 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~glmark2-dev/glmark2/trunk] Rev 265: NativeStateMir: Add NativeState for Mir Message-Id: <20130305180713.17610.79007.launchpad@ackee.canonical.com> Date: Tue, 05 Mar 2013 18:07:13 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="16514"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: dac60ab51bff48412d381926bc681f7df10080ff X-Gm-Message-State: ALoCoQnfNHwLEPLjS0YO29dXaEAmTYftTqIzNL45dS+OnkJWjA620t9Mhr9cGI9ecKXYoGq0mDbe Merge authors: Alexandros Frantzis (afrantzis) Related merge proposals: https://code.launchpad.net/~glmark2-dev/glmark2/native-state-mir/+merge/151784 proposed by: Alexandros Frantzis (afrantzis) review: Approve - Jesse Barker (jesse-barker) ------------------------------------------------------------ revno: 265 [merge] committer: Alexandros Frantzis branch nick: trunk timestamp: Tue 2013-03-05 19:55:01 +0200 message: NativeStateMir: Add NativeState for Mir added: src/native-state-mir.cpp src/native-state-mir.h modified: src/main.cpp src/wscript_build wscript --- lp:glmark2 https://code.launchpad.net/~glmark2-dev/glmark2/trunk You are subscribed to branch lp:glmark2. To unsubscribe from this branch go to https://code.launchpad.net/~glmark2-dev/glmark2/trunk/+edit-subscription === modified file 'src/main.cpp' --- src/main.cpp 2013-03-04 19:07:07 +0000 +++ src/main.cpp 2013-03-05 15:48:10 +0000 @@ -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' --- src/native-state-mir.cpp 1970-01-01 00:00:00 +0000 +++ src/native-state-mir.cpp 2013-03-05 17:37:01 +0000 @@ -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 . + * + * 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(client_context); + *con = connection; +} + +void +surface_created_callback(MirSurface *surface, void *client_context) +{ + MirSurface **surf = static_cast(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(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(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' --- src/native-state-mir.h 1970-01-01 00:00:00 +0000 +++ src/native-state-mir.h 2013-03-05 17:04:09 +0000 @@ -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 . + * + * Authors: + * Alexandros Frantzis + */ +#ifndef GLMARK2_NATIVE_STATE_MIR_H_ +#define GLMARK2_NATIVE_STATE_MIR_H_ + +#include "native-state.h" +#include +#include + +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' --- src/wscript_build 2013-03-05 13:23:30 +0000 +++ src/wscript_build 2013-03-05 15:48:10 +0000 @@ -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' --- wscript 2013-03-05 13:23:30 +0000 +++ wscript 2013-03-05 15:48:10 +0000 @@ -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)