Index: services/native_viewport/main.cc |
diff --git a/services/native_viewport/main.cc b/services/native_viewport/main.cc |
index 2e8dd7ad33bfc30382ad18eb736347e0c01efca1..fb5737a9a82aa8415492ccaa7c3a82fd63034620 100644 |
--- a/services/native_viewport/main.cc |
+++ b/services/native_viewport/main.cc |
@@ -4,6 +4,7 @@ |
#include <algorithm> |
+#include "base/bind.h" |
#include "base/command_line.h" |
#include "base/macros.h" |
#include "base/message_loop/message_loop.h" |
@@ -20,10 +21,24 @@ |
#include "ui/events/event_switches.h" |
#include "ui/gl/gl_surface.h" |
+#if defined(USE_OZONE) |
+#include "mojo/services/ozone_drm_gpu/public/interfaces/ozone_drm_gpu.mojom.h" //nogncheck |
+#include "mojo/services/ozone_drm_host/public/interfaces/ozone_drm_host.mojom.h" //nogncheck |
+#include "services/native_viewport/ozone/display_manager.h" //nogncheck |
+#include "services/native_viewport/ozone/ozone_drm_gpu_impl.h" //nogncheck |
+#include "services/native_viewport/ozone/ozone_drm_host_impl.h" //nogncheck |
+#include "ui/ozone/public/ozone_platform.h" //nogncheck |
+#endif |
+ |
using mojo::ApplicationConnection; |
using mojo::Gpu; |
using mojo::NativeViewport; |
+#if defined(USE_OZONE) |
+using mojo::OzoneDrmGpu; |
+using mojo::OzoneDrmHost; |
+#endif |
+ |
namespace native_viewport { |
class NativeViewportAppDelegate : public mojo::ApplicationDelegate, |
@@ -33,10 +48,10 @@ class NativeViewportAppDelegate : public mojo::ApplicationDelegate, |
NativeViewportAppDelegate() : is_headless_(false) {} |
~NativeViewportAppDelegate() override {} |
- private: |
// mojo::ApplicationDelegate implementation. |
void Initialize(mojo::ApplicationImpl* application) override { |
application_ = application; |
+ |
tracing_.Initialize(application); |
// Apply the switch for kTouchEvents to CommandLine (if set). This allows |
@@ -91,11 +106,64 @@ class NativeViewportAppDelegate : public mojo::ApplicationDelegate, |
DISALLOW_COPY_AND_ASSIGN(NativeViewportAppDelegate); |
}; |
-} |
+ |
+#if defined(USE_OZONE) |
jamesr
2015/08/25 00:30:28
can this stuff go somewhere other than main.cc? y
cdotstout
2015/08/27 19:10:21
Done.
|
+class NativeViewportOzoneDrmAppDelegate |
+ : public NativeViewportAppDelegate, |
+ public mojo::InterfaceFactory<OzoneDrmHost>, |
+ public mojo::InterfaceFactory<OzoneDrmGpu> { |
+ public: |
+ using NativeViewportAppDelegate::Create; |
+ |
+ void Initialize(mojo::ApplicationImpl* application) override { |
+ NativeViewportAppDelegate::Initialize(application); |
+ application->ConnectToService("mojo:native_viewport_service", |
+ &ozone_drm_gpu_); |
+ application->ConnectToService("mojo:native_viewport_service", |
+ &ozone_drm_host_); |
+ } |
+ |
+ bool ConfigureIncomingConnection(ApplicationConnection* connection) override { |
+ if (!NativeViewportAppDelegate::ConfigureIncomingConnection(connection)) |
+ return false; |
+ connection->AddService<OzoneDrmGpu>(this); |
+ connection->AddService<OzoneDrmHost>(this); |
+ return true; |
+ } |
+ |
+ // mojo::InterfaceFactory<OzoneDrmGpu> implementation. |
+ void Create(ApplicationConnection* connection, |
+ mojo::InterfaceRequest<OzoneDrmGpu> request) override { |
+ new OzoneDrmGpuImpl(request.Pass(), ozone_drm_host_); |
+ } |
+ |
+ // mojo::InterfaceFactory<OzoneDrmHost> implementation. |
+ void Create(ApplicationConnection* connection, |
+ mojo::InterfaceRequest<OzoneDrmHost> request) override { |
+ ui::OzonePlatform::InitializeForUI(); |
+ new OzoneDrmHostImpl(request.Pass(), ozone_drm_gpu_); |
+ |
+ display_manager_.reset(new DisplayManager()); |
+ } |
+ |
+ private: |
+ std::unique_ptr<DisplayManager> display_manager_; |
+ mojo::OzoneDrmHostPtr ozone_drm_host_; |
+ mojo::OzoneDrmGpuPtr ozone_drm_gpu_; |
+}; |
+ |
+#endif |
+ |
+} // namespace |
MojoResult MojoMain(MojoHandle application_request) { |
+#if defined(USE_OZONE) |
+ mojo::ApplicationRunnerChromium runner( |
+ new native_viewport::NativeViewportOzoneDrmAppDelegate); |
+#else |
mojo::ApplicationRunnerChromium runner( |
new native_viewport::NativeViewportAppDelegate); |
+#endif |
runner.set_message_loop_type(base::MessageLoop::TYPE_UI); |
return runner.Run(application_request); |
} |