Merge lp:~osomon/oxide/form-factor-egl into lp:~oxide-developers/oxide/oxide.trunk

Proposed by Olivier Tilloy
Status: Merged
Merged at revision: 471
Proposed branch: lp:~osomon/oxide/form-factor-egl
Merge into: lp:~oxide-developers/oxide/oxide.trunk
Diff against target: 125 lines (+52/-37)
2 files modified
shared/browser/oxide_form_factor_linux.cc (+52/-36)
shared/shared.gyp (+0/-1)
To merge this branch: bzr merge lp:~osomon/oxide/form-factor-egl
Reviewer Review Type Date Requested Status
Chris Coulson Approve
Review via email: mp+214082@code.launchpad.net

Commit message

Use the EGL vendor string to infer the form factor.
This will prevent application confinement from getting in the way.

To post a comment you must log in.
Revision history for this message
Chris Coulson (chrisccoulson) wrote :

Thanks for this. A couple of comments:

- I'd remove the error message for failing to load libEGL, as it's not installed by default on the desktop
- I'd probably also remove the LOG(INFO) with the actual vendor string too
- You should be able to remove the udev dependency in shared.gyp as well

Other than that, it's good to go

review: Approve
lp:~osomon/oxide/form-factor-egl updated
470. By Olivier Tilloy

Remove the error message for failing to load libEGL, as it’s not installed by default on the desktop.

471. By Olivier Tilloy

Remove an unnecessary log.

472. By Olivier Tilloy

Remove the build dependency on udev.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'shared/browser/oxide_form_factor_linux.cc'
2--- shared/browser/oxide_form_factor_linux.cc 2014-02-19 20:47:24 +0000
3+++ shared/browser/oxide_form_factor_linux.cc 2014-04-04 08:39:37 +0000
4@@ -1,5 +1,5 @@
5 // vim:expandtab:shiftwidth=2:tabstop=2:
6-// Copyright (C) 2013 Canonical Ltd.
7+// Copyright (C) 2013-2014 Canonical Ltd.
8
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11@@ -18,10 +18,12 @@
12 #include "oxide_form_factor.h"
13
14 #include <algorithm>
15-#include <libudev.h>
16-#include <stdlib.h>
17
18+#include "base/files/file_path.h"
19 #include "base/logging.h"
20+#include "base/scoped_native_library.h"
21+#include "base/strings/string_util.h"
22+#include "third_party/khronos/EGL/egl.h"
23 #include "third_party/WebKit/public/platform/WebScreenInfo.h"
24
25 #include "shared/browser/oxide_default_screen_info.h"
26@@ -30,40 +32,54 @@
27
28 namespace {
29
30-class ScopedUdevContext {
31- public:
32- ScopedUdevContext() :
33- u_(udev_new()),
34- e_(udev_enumerate_new(u_)) {}
35-
36- ~ScopedUdevContext() {
37- udev_enumerate_unref(e_);
38- udev_unref(u_);
39- }
40-
41- operator struct udev_enumerate*() { return e_; }
42-
43- private:
44- struct udev* u_;
45- struct udev_enumerate* e_;
46-};
47-
48 bool IsUbuntuPhoneOrTablet() {
49- ScopedUdevContext u;
50-
51- if (udev_enumerate_add_match_subsystem(u, "android_usb") < 0) {
52- return false;
53- }
54-
55- if (udev_enumerate_scan_devices(u) < 0) {
56- return false;
57- }
58-
59- if (!udev_enumerate_get_list_entry(u)) {
60- return false;
61- }
62-
63- return true;
64+ base::ScopedNativeLibrary egl(
65+ base::LoadNativeLibrary(base::FilePath("libEGL.so.1"), NULL));
66+ if (!egl.is_valid()) {
67+ return false;
68+ }
69+
70+ typedef EGLDisplay (*f_eglGetDisplay)(NativeDisplayType);
71+ f_eglGetDisplay eglGetDisplay =
72+ reinterpret_cast<f_eglGetDisplay>(egl.GetFunctionPointer("eglGetDisplay"));
73+ if (!eglGetDisplay) {
74+ LOG(ERROR) << "Failed to resolve eglGetDisplay";
75+ return false;
76+ }
77+ EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
78+
79+ typedef EGLBoolean (*f_eglInitialize)(EGLDisplay, EGLint*, EGLint*);
80+ f_eglInitialize eglInitialize =
81+ reinterpret_cast<f_eglInitialize>(egl.GetFunctionPointer("eglInitialize"));
82+ if (!eglInitialize) {
83+ LOG(ERROR) << "Failed to resolve eglInitialize";
84+ return false;
85+ }
86+ if (!eglInitialize(display, NULL, NULL)) {
87+ LOG(ERROR) << "eglInitialize failed";
88+ return false;
89+ }
90+
91+ typedef const char* (*f_eglQueryString)(EGLDisplay, EGLint);
92+ f_eglQueryString eglQueryString =
93+ reinterpret_cast<f_eglQueryString>(egl.GetFunctionPointer("eglQueryString"));
94+ if (!eglQueryString) {
95+ LOG(ERROR) << "Failed to resolve eglQueryString";
96+ return false;
97+ }
98+ const char* vendor = eglQueryString(display, EGL_VENDOR);
99+
100+ typedef EGLBoolean (*f_eglTerminate)(EGLDisplay);
101+ f_eglTerminate eglTerminate =
102+ reinterpret_cast<f_eglTerminate>(egl.GetFunctionPointer("eglTerminate"));
103+ if (!eglTerminate) {
104+ LOG(ERROR) << "Failed to resolve eglTerminate";
105+ }
106+ if (!eglTerminate(display)) {
107+ LOG(ERROR) << "eglTerminate failed";
108+ }
109+
110+ return LowerCaseEqualsASCII(std::string(vendor), "android");
111 }
112
113 }
114
115=== modified file 'shared/shared.gyp'
116--- shared/shared.gyp 2014-03-31 17:40:30 +0000
117+++ shared/shared.gyp 2014-04-04 08:39:37 +0000
118@@ -107,7 +107,6 @@
119 'oxide_packed_resources',
120 'oxide_shared_resources',
121 '<(DEPTH)/base/base.gyp:base',
122- '<(DEPTH)/build/linux/system.gyp:udev',
123 '<(DEPTH)/content/content.gyp:content_app_both',
124 '<(DEPTH)/content/content.gyp:content_browser',
125 '<(DEPTH)/content/content.gyp:content_common',

Subscribers

People subscribed via source and target branches