summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorspang@chromium.org <spang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-31 18:22:44 +0000
committerspang@chromium.org <spang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-31 18:22:44 +0000
commitf93c2c94d7fbe07746cc059d9ac9c27bea6e56fa (patch)
treefb586fe86db8920318a61db18c7a336aee78886f /ui
parent6fa5f6781038c63421b203556fa74efbe78e925f (diff)
downloadchromium_src-f93c2c94d7fbe07746cc059d9ac9c27bea6e56fa.zip
chromium_src-f93c2c94d7fbe07746cc059d9ac9c27bea6e56fa.tar.gz
chromium_src-f93c2c94d7fbe07746cc059d9ac9c27bea6e56fa.tar.bz2
Implement OzonePlatform
This provides a way to select an ozone implementation to use at build time. It replaces the previous ad-hoc requirement to inject implementations of ozone interfaces somewhere during initialization, such as by overriding ContentMainDelegate::PreSandboxStartup(). That requirement made it difficult for external ozone implementations to build internal targets such as content_shell because those targets do not initialize the external ozone implementation without additional patching. Enabling external ports of chromium is one of the main goals of ozone. The OzonePlatform code is located at ui/ozone and depends on code in ui/gfx and ui/events because it must inject implementations into those components. The ozone platform is initialized from ui/aura or ui/gl, as those components need the interfaces provided by ozone in order to function. There are two in-tree platforms currently: test (image dump) and dri (libdrm-based direct rendering). The platform is selected by the setting ozone_platform gyp variable and defaults to "test". Review URL: https://codereview.chromium.org/44933002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@232170 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/aura/DEPS1
-rw-r--r--ui/aura/aura.gyp5
-rw-r--r--ui/aura/root_window_host_ozone.cc8
-rw-r--r--ui/gfx/ozone/surface_factory_ozone.cc15
-rw-r--r--ui/gl/DEPS1
-rw-r--r--ui/gl/gl.gyp5
-rw-r--r--ui/gl/gl_implementation_ozone.cc2
-rw-r--r--ui/ozone/DEPS4
-rw-r--r--ui/ozone/OWNERS1
-rw-r--r--ui/ozone/ozone.gyp50
-rw-r--r--ui/ozone/ozone_export.h29
-rw-r--r--ui/ozone/ozone_platform.cc33
-rw-r--r--ui/ozone/ozone_platform.h55
-rw-r--r--ui/ozone/ozone_switches.cc12
-rw-r--r--ui/ozone/ozone_switches.h17
-rw-r--r--ui/ozone/platform/dri/ozone_platform_dri.cc25
-rw-r--r--ui/ozone/platform/dri/ozone_platform_dri.h35
-rw-r--r--ui/ozone/platform/test/ozone_platform_test.cc35
-rw-r--r--ui/ozone/platform/test/ozone_platform_test.h35
19 files changed, 350 insertions, 18 deletions
diff --git a/ui/aura/DEPS b/ui/aura/DEPS
index a5cb260..c252218 100644
--- a/ui/aura/DEPS
+++ b/ui/aura/DEPS
@@ -9,5 +9,6 @@ include_rules = [
"+ui/gfx",
"+ui/metro_viewer", # TODO(beng): investigate moving remote_root_window_host
# to ui/metro_viewer.
+ "+ui/ozone",
]
diff --git a/ui/aura/aura.gyp b/ui/aura/aura.gyp
index 70334fe..e9d2733 100644
--- a/ui/aura/aura.gyp
+++ b/ui/aura/aura.gyp
@@ -125,6 +125,11 @@
'input_state_lookup.cc',
],
}],
+ ['use_ozone==1', {
+ 'dependencies': [
+ '../ozone/ozone.gyp:ozone',
+ ],
+ }],
],
},
{
diff --git a/ui/aura/root_window_host_ozone.cc b/ui/aura/root_window_host_ozone.cc
index dbdd762..66cfdd5 100644
--- a/ui/aura/root_window_host_ozone.cc
+++ b/ui/aura/root_window_host_ozone.cc
@@ -6,14 +6,14 @@
#include "ui/aura/root_window.h"
#include "ui/gfx/ozone/surface_factory_ozone.h"
+#include "ui/ozone/ozone_platform.h"
namespace aura {
RootWindowHostOzone::RootWindowHostOzone(const gfx::Rect& bounds)
- : delegate_(NULL),
- widget_(0),
- bounds_(bounds),
- factory_(ui::EventFactoryOzone::GetInstance()) {
+ : delegate_(NULL), widget_(0), bounds_(bounds) {
+ ui::OzonePlatform::Initialize();
+ factory_.reset(ui::EventFactoryOzone::GetInstance());
factory_->StartProcessingEvents();
gfx::SurfaceFactoryOzone* surface_factory =
gfx::SurfaceFactoryOzone::GetInstance();
diff --git a/ui/gfx/ozone/surface_factory_ozone.cc b/ui/gfx/ozone/surface_factory_ozone.cc
index 5ba8de0..a43c025 100644
--- a/ui/gfx/ozone/surface_factory_ozone.cc
+++ b/ui/gfx/ozone/surface_factory_ozone.cc
@@ -50,20 +50,7 @@ SurfaceFactoryOzone::~SurfaceFactoryOzone() {
}
SurfaceFactoryOzone* SurfaceFactoryOzone::GetInstance() {
- if (!impl_) {
- const char kOzoneFileSurface[] = "ozone-dump-file";
- CommandLine* cmd = CommandLine::ForCurrentProcess();
- if (cmd->HasSwitch(kOzoneFileSurface)) {
- base::FilePath location = cmd->GetSwitchValuePath(kOzoneFileSurface);
- if (location.empty())
- location = base::FilePath("/dev/null");
- impl_ = new FileSurfaceFactoryOzone(location);
- } else {
- LOG(WARNING) << "No SurfaceFactoryOzone implementation set. Using default"
- " gfx::SoftwareSurfaceFactoryOzone.";
- impl_ = new SoftwareSurfaceFactoryOzone();
- }
- }
+ CHECK(impl_) << "No SurfaceFactoryOzone implementation set.";
return impl_;
}
diff --git a/ui/gl/DEPS b/ui/gl/DEPS
index ec3c129..d0d2812 100644
--- a/ui/gl/DEPS
+++ b/ui/gl/DEPS
@@ -3,4 +3,5 @@ include_rules = [
"+third_party/mesa/src/include",
"+third_party/skia",
"+ui/gfx",
+ "+ui/ozone",
]
diff --git a/ui/gl/gl.gyp b/ui/gl/gl.gyp
index 95db809..1b58ef9 100644
--- a/ui/gl/gl.gyp
+++ b/ui/gl/gl.gyp
@@ -282,6 +282,11 @@
['OS!="android"', {
'sources/': [ ['exclude', '^android/'] ],
}],
+ ['use_ozone==1', {
+ 'dependencies': [
+ '../ozone/ozone.gyp:ozone',
+ ],
+ }],
],
},
{
diff --git a/ui/gl/gl_implementation_ozone.cc b/ui/gl/gl_implementation_ozone.cc
index 2ca30a4..10ab44d 100644
--- a/ui/gl/gl_implementation_ozone.cc
+++ b/ui/gl/gl_implementation_ozone.cc
@@ -10,6 +10,7 @@
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_implementation_linux.h"
#include "ui/gl/gl_osmesa_api_implementation.h"
+#include "ui/ozone/ozone_platform.h"
namespace gfx {
@@ -42,6 +43,7 @@ bool InitializeGLBindings(GLImplementation implementation) {
case kGLImplementationOSMesaGL:
return InitializeGLBindingsOSMesaGL();
case kGLImplementationEGLGLES2:
+ ui::OzonePlatform::Initialize();
if (!gfx::SurfaceFactoryOzone::GetInstance()->LoadEGLGLES2Bindings(
base::Bind(&AddGLNativeLibrary),
base::Bind(&SetGLGetProcAddressProc)))
diff --git a/ui/ozone/DEPS b/ui/ozone/DEPS
new file mode 100644
index 0000000..8cb61f5
--- /dev/null
+++ b/ui/ozone/DEPS
@@ -0,0 +1,4 @@
+include_rules = [
+ "+ui/events",
+ "+ui/gfx",
+]
diff --git a/ui/ozone/OWNERS b/ui/ozone/OWNERS
new file mode 100644
index 0000000..77f21b5
--- /dev/null
+++ b/ui/ozone/OWNERS
@@ -0,0 +1 @@
+rjkroege@chromium.org
diff --git a/ui/ozone/ozone.gyp b/ui/ozone/ozone.gyp
new file mode 100644
index 0000000..32008b7
--- /dev/null
+++ b/ui/ozone/ozone.gyp
@@ -0,0 +1,50 @@
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+ 'variables': {
+ 'chromium_code': 1,
+ 'external_ozone_platform_files': [],
+ 'external_ozone_platform_deps': [],
+ },
+ 'targets': [
+ {
+ 'target_name': 'ozone',
+ 'type': '<(component)',
+ 'dependencies': [
+ '<(DEPTH)/base/base.gyp:base',
+ '<(DEPTH)/ui/gfx/gfx.gyp:gfx',
+ '<(DEPTH)/ui/events/events.gyp:events',
+ '<(DEPTH)/skia/skia.gyp:skia',
+ '<@(external_ozone_platform_deps)',
+ ],
+ 'defines': [
+ 'OZONE_IMPLEMENTATION',
+ ],
+ 'sources': [
+ 'ozone_platform.cc',
+ 'ozone_platform.h',
+ 'ozone_switches.cc',
+ 'ozone_switches.h',
+ 'platform/dri/ozone_platform_dri.cc',
+ 'platform/dri/ozone_platform_dri.h',
+ 'platform/test/ozone_platform_test.cc',
+ 'platform/test/ozone_platform_test.h',
+ '<@(external_ozone_platform_files)',
+ ],
+ 'conditions': [
+ ['ozone_platform != "dri"', {
+ 'sources/': [
+ ['exclude', '^platform/dri/'],
+ ]
+ }],
+ ['ozone_platform != "test"', {
+ 'sources/': [
+ ['exclude', '^platform/test/'],
+ ]
+ }],
+ ]
+ },
+ ],
+}
diff --git a/ui/ozone/ozone_export.h b/ui/ozone/ozone_export.h
new file mode 100644
index 0000000..cc587a5
--- /dev/null
+++ b/ui/ozone/ozone_export.h
@@ -0,0 +1,29 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_OZONE_OZONE_EXPORT_H_
+#define UI_OZONE_OZONE_EXPORT_H_
+
+#if defined(COMPONENT_BUILD)
+#if defined(WIN32)
+
+#if defined(OZONE_IMPLEMENTATION)
+#define OZONE_EXPORT __declspec(dllexport)
+#else
+#define OZONE_EXPORT __declspec(dllimport)
+#endif // defined(OZONE_IMPLEMENTATION)
+
+#else // defined(WIN32)
+#if defined(OZONE_IMPLEMENTATION)
+#define OZONE_EXPORT __attribute__((visibility("default")))
+#else
+#define OZONE_EXPORT
+#endif
+#endif
+
+#else // defined(COMPONENT_BUILD)
+#define OZONE_EXPORT
+#endif
+
+#endif // UI_OZONE_OZONE_EXPORT_H_
diff --git a/ui/ozone/ozone_platform.cc b/ui/ozone/ozone_platform.cc
new file mode 100644
index 0000000..9715e13
--- /dev/null
+++ b/ui/ozone/ozone_platform.cc
@@ -0,0 +1,33 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/command_line.h"
+#include "base/logging.h"
+#include "ui/ozone/ozone_platform.h"
+
+namespace ui {
+
+OzonePlatform::OzonePlatform() {}
+
+OzonePlatform::~OzonePlatform() {
+ gfx::SurfaceFactoryOzone::SetInstance(NULL);
+ ui::EventFactoryOzone::SetInstance(NULL);
+}
+
+// static
+void OzonePlatform::Initialize() {
+ if (instance_)
+ return;
+
+ instance_ = CreateDefaultOzonePlatform();
+
+ // Inject ozone interfaces.
+ gfx::SurfaceFactoryOzone::SetInstance(instance_->GetSurfaceFactoryOzone());
+ ui::EventFactoryOzone::SetInstance(instance_->GetEventFactoryOzone());
+}
+
+// static
+OzonePlatform* OzonePlatform::instance_;
+
+} // namespace ui
diff --git a/ui/ozone/ozone_platform.h b/ui/ozone/ozone_platform.h
new file mode 100644
index 0000000..2426b23
--- /dev/null
+++ b/ui/ozone/ozone_platform.h
@@ -0,0 +1,55 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_OZONE_OZONE_PLATFORM_H_
+#define UI_OZONE_OZONE_PLATFORM_H_
+
+#include "base/memory/scoped_ptr.h"
+#include "ui/events/ozone/event_factory_ozone.h"
+#include "ui/gfx/ozone/surface_factory_ozone.h"
+#include "ui/ozone/ozone_export.h"
+
+namespace ui {
+
+// Base class for Ozone platform implementations.
+//
+// Ozone platforms must override this class and implement the virtual
+// GetFooFactoryOzone() methods to provide implementations of the
+// various ozone interfaces.
+//
+// The OzonePlatform subclass can own any state needed by the
+// implementation that is shared between the various ozone interfaces,
+// such as a connection to the windowing system.
+//
+// A platform is free to use different implementations of each
+// interface depending on the context. You can, for example, create
+// different objects depending on the underlying hardware, command
+// line flags, or whatever is appropriate for the platform.
+class OZONE_EXPORT OzonePlatform {
+ public:
+ OzonePlatform();
+ virtual ~OzonePlatform();
+
+ // Initialize the platform. Once complete, SurfaceFactoryOzone &
+ // EventFactoryOzone will be set.
+ static void Initialize();
+
+ // Factory getters to override in subclasses. The returned objects will be
+ // injected into the appropriate layer at startup. Subclasses should not
+ // inject these objects themselves. Ownership is retained by OzonePlatform.
+ virtual gfx::SurfaceFactoryOzone* GetSurfaceFactoryOzone() = 0;
+ virtual ui::EventFactoryOzone* GetEventFactoryOzone() = 0;
+
+ private:
+ static OzonePlatform* instance_;
+
+ DISALLOW_COPY_AND_ASSIGN(OzonePlatform);
+};
+
+// Hook to be provided by the built-in default implementation.
+OzonePlatform* CreateDefaultOzonePlatform();
+
+} // namespace ui
+
+#endif // UI_OZONE_OZONE_PLATFORM_H_
diff --git a/ui/ozone/ozone_switches.cc b/ui/ozone/ozone_switches.cc
new file mode 100644
index 0000000..bd30dee
--- /dev/null
+++ b/ui/ozone/ozone_switches.cc
@@ -0,0 +1,12 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/ozone/ozone_switches.h"
+
+namespace switches {
+
+// Specify location for image dumps.
+const char kOzoneDumpFile[] = "ozone-dump-file";
+
+} // namespace switches
diff --git a/ui/ozone/ozone_switches.h b/ui/ozone/ozone_switches.h
new file mode 100644
index 0000000..7aa18af
--- /dev/null
+++ b/ui/ozone/ozone_switches.h
@@ -0,0 +1,17 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_OZONE_OZONE_SWITCHES_H_
+#define UI_OZONE_OZONE_SWITCHES_H_
+
+#include "base/compiler_specific.h"
+#include "ui/ozone/ozone_export.h"
+
+namespace switches {
+
+OZONE_EXPORT extern const char kOzoneDumpFile[];
+
+} // namespace switches
+
+#endif // UI_OZONE_OZONE_SWITCHES_H_
diff --git a/ui/ozone/platform/dri/ozone_platform_dri.cc b/ui/ozone/platform/dri/ozone_platform_dri.cc
new file mode 100644
index 0000000..3d248b6
--- /dev/null
+++ b/ui/ozone/platform/dri/ozone_platform_dri.cc
@@ -0,0 +1,25 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/ozone/platform/dri/ozone_platform_dri.h"
+
+#include "ui/ozone/ozone_platform.h"
+
+namespace ui {
+
+OzonePlatformDri::OzonePlatformDri() {}
+
+OzonePlatformDri::~OzonePlatformDri() {}
+
+gfx::SurfaceFactoryOzone* OzonePlatformDri::GetSurfaceFactoryOzone() {
+ return &surface_factory_ozone_;
+}
+
+ui::EventFactoryOzone* OzonePlatformDri::GetEventFactoryOzone() {
+ return &event_factory_ozone_;
+}
+
+OzonePlatform* CreateDefaultOzonePlatform() { return new OzonePlatformDri; }
+
+} // namespace ui
diff --git a/ui/ozone/platform/dri/ozone_platform_dri.h b/ui/ozone/platform/dri/ozone_platform_dri.h
new file mode 100644
index 0000000..9c040e9
--- /dev/null
+++ b/ui/ozone/platform/dri/ozone_platform_dri.h
@@ -0,0 +1,35 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_OZONE_PLATFORM_DRI_OZONE_PLATFORM_DRI_H_
+#define UI_OZONE_PLATFORM_DRI_OZONE_PLATFORM_DRI_H_
+
+#include "ui/events/ozone/evdev/event_factory.h"
+#include "ui/gfx/ozone/impl/software_surface_factory_ozone.h"
+#include "ui/ozone/ozone_platform.h"
+
+namespace ui {
+
+// OzonePlatform for Linux DRI (Direct Rendering Infrastructure)
+//
+// This platform is Linux without any display server (no X, wayland, or
+// anything). This means chrome alone owns the display and input devices.
+class OzonePlatformDri : public OzonePlatform {
+ public:
+ OzonePlatformDri();
+ virtual ~OzonePlatformDri();
+
+ virtual gfx::SurfaceFactoryOzone* GetSurfaceFactoryOzone() OVERRIDE;
+ virtual ui::EventFactoryOzone* GetEventFactoryOzone() OVERRIDE;
+
+ private:
+ gfx::SoftwareSurfaceFactoryOzone surface_factory_ozone_;
+ ui::EventFactoryEvdev event_factory_ozone_;
+
+ DISALLOW_COPY_AND_ASSIGN(OzonePlatformDri);
+};
+
+} // namespace ui
+
+#endif // UI_OZONE_PLATFORM_DRI_OZONE_PLATFORM_DRI_H_
diff --git a/ui/ozone/platform/test/ozone_platform_test.cc b/ui/ozone/platform/test/ozone_platform_test.cc
new file mode 100644
index 0000000..6fc9beb
--- /dev/null
+++ b/ui/ozone/platform/test/ozone_platform_test.cc
@@ -0,0 +1,35 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/ozone/platform/test/ozone_platform_test.h"
+
+#include "base/command_line.h"
+#include "base/files/file_path.h"
+#include "ui/ozone/ozone_platform.h"
+#include "ui/ozone/ozone_switches.h"
+
+namespace ui {
+
+OzonePlatformTest::OzonePlatformTest(const base::FilePath& dump_file)
+ : surface_factory_ozone_(dump_file) {}
+
+OzonePlatformTest::~OzonePlatformTest() {}
+
+gfx::SurfaceFactoryOzone* OzonePlatformTest::GetSurfaceFactoryOzone() {
+ return &surface_factory_ozone_;
+}
+
+ui::EventFactoryOzone* OzonePlatformTest::GetEventFactoryOzone() {
+ return &event_factory_ozone_;
+}
+
+OzonePlatform* CreateDefaultOzonePlatform() {
+ CommandLine* cmd = CommandLine::ForCurrentProcess();
+ base::FilePath location = base::FilePath("/dev/null");
+ if (cmd->HasSwitch(switches::kOzoneDumpFile))
+ location = cmd->GetSwitchValuePath(switches::kOzoneDumpFile);
+ return new OzonePlatformTest(location);
+}
+
+} // namespace ui
diff --git a/ui/ozone/platform/test/ozone_platform_test.h b/ui/ozone/platform/test/ozone_platform_test.h
new file mode 100644
index 0000000..9218312
--- /dev/null
+++ b/ui/ozone/platform/test/ozone_platform_test.h
@@ -0,0 +1,35 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_OZONE_PLATFORM_TEST_OZONE_PLATFORM_TEST_H_
+#define UI_OZONE_PLATFORM_TEST_OZONE_PLATFORM_TEST_H_
+
+#include "base/files/file_path.h"
+#include "ui/events/ozone/evdev/event_factory.h"
+#include "ui/gfx/ozone/impl/file_surface_factory_ozone.h"
+#include "ui/ozone/ozone_platform.h"
+
+namespace ui {
+
+// OzonePlatform for testing
+//
+// This platform dumps images to a file for testing purposes.
+class OzonePlatformTest : public OzonePlatform {
+ public:
+ OzonePlatformTest(const base::FilePath& dump_file);
+ virtual ~OzonePlatformTest();
+
+ virtual gfx::SurfaceFactoryOzone* GetSurfaceFactoryOzone() OVERRIDE;
+ virtual ui::EventFactoryOzone* GetEventFactoryOzone() OVERRIDE;
+
+ private:
+ gfx::FileSurfaceFactoryOzone surface_factory_ozone_;
+ ui::EventFactoryEvdev event_factory_ozone_;
+
+ DISALLOW_COPY_AND_ASSIGN(OzonePlatformTest);
+};
+
+} // namespace ui
+
+#endif // UI_OZONE_PLATFORM_TEST_OZONE_PLATFORM_TEST_H_