summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspang <spang@chromium.org>2014-09-02 22:14:58 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-03 05:18:44 +0000
commitaa2a372038d7faf53f0f98194fdac467b56580de (patch)
treeb38600a281b83e790092b6b75dc1d4e0130bbede
parent8b156314b9fa0a730c9a02ebb44ba7638d52aef7 (diff)
downloadchromium_src-aa2a372038d7faf53f0f98194fdac467b56580de.zip
chromium_src-aa2a372038d7faf53f0f98194fdac467b56580de.tar.gz
chromium_src-aa2a372038d7faf53f0f98194fdac467b56580de.tar.bz2
ozone: Add UiThreadGpu for applications that do UI thread GL
The demo does GL on the main thread, which broken since we now depend on GpuPlatformSupport(Host). Let's deliver these messages directly via a helper class for those applications. BUG=409978 TEST=ozone_demo --ozone-platform=gbm on link_freon NOTRY=true Review URL: https://codereview.chromium.org/533803003 Cr-Commit-Position: refs/heads/master@{#293075}
-rw-r--r--ui/ozone/BUILD.gn2
-rw-r--r--ui/ozone/demo/ozone_demo.cc9
-rw-r--r--ui/ozone/ozone.gyp2
-rw-r--r--ui/ozone/public/ui_thread_gpu.cc55
-rw-r--r--ui/ozone/public/ui_thread_gpu.h40
5 files changed, 107 insertions, 1 deletions
diff --git a/ui/ozone/BUILD.gn b/ui/ozone/BUILD.gn
index b23cf66..b8cb11f 100644
--- a/ui/ozone/BUILD.gn
+++ b/ui/ozone/BUILD.gn
@@ -98,6 +98,8 @@ component("ozone") {
"public/ozone_platform.h",
"public/ozone_switches.cc",
"public/ozone_switches.h",
+ "public/ui_thread_gpu.cc",
+ "public/ui_thread_gpu.h",
"platform_selection.cc",
"platform_selection.h",
]
diff --git a/ui/ozone/demo/ozone_demo.cc b/ui/ozone/demo/ozone_demo.cc
index 43c98cf..309b138 100644
--- a/ui/ozone/demo/ozone_demo.cc
+++ b/ui/ozone/demo/ozone_demo.cc
@@ -16,6 +16,7 @@
#include "ui/ozone/public/ozone_platform.h"
#include "ui/ozone/public/surface_factory_ozone.h"
#include "ui/ozone/public/surface_ozone_canvas.h"
+#include "ui/ozone/public/ui_thread_gpu.h"
#include "ui/platform_window/platform_window.h"
#include "ui/platform_window/platform_window_delegate.h"
@@ -47,7 +48,8 @@ class DemoWindow : public ui::PlatformWindowDelegate {
void Start() {
if (!CommandLine::ForCurrentProcess()->HasSwitch(kDisableGpu) &&
- gfx::GLSurface::InitializeOneOff() && InitializeGLSurface()) {
+ gfx::GLSurface::InitializeOneOff() && StartInProcessGpu() &&
+ InitializeGLSurface()) {
StartAnimationGL();
} else if (InitializeSoftwareSurface()) {
StartAnimationSoftware();
@@ -173,6 +175,8 @@ class DemoWindow : public ui::PlatformWindowDelegate {
software_surface_->PresentCanvas(gfx::Rect(window_size));
}
+ bool StartInProcessGpu() { return ui_thread_gpu_.Initialize(); }
+
// Timer for animation.
base::RepeatingTimer<DemoWindow> timer_;
@@ -187,6 +191,9 @@ class DemoWindow : public ui::PlatformWindowDelegate {
scoped_ptr<ui::PlatformWindow> platform_window_;
gfx::AcceleratedWidget widget_;
+ // Helper for applications that do GL on main thread.
+ ui::UiThreadGpu ui_thread_gpu_;
+
// Animation state.
int iteration_;
diff --git a/ui/ozone/ozone.gyp b/ui/ozone/ozone.gyp
index 123ea2a..8c92871 100644
--- a/ui/ozone/ozone.gyp
+++ b/ui/ozone/ozone.gyp
@@ -102,6 +102,8 @@
'public/ozone_platform.h',
'public/ozone_switches.cc',
'public/ozone_switches.h',
+ 'public/ui_thread_gpu.cc',
+ 'public/ui_thread_gpu.h',
'platform_selection.cc',
'platform_selection.h',
'<@(external_ozone_platform_files)',
diff --git a/ui/ozone/public/ui_thread_gpu.cc b/ui/ozone/public/ui_thread_gpu.cc
new file mode 100644
index 0000000..68b260e
--- /dev/null
+++ b/ui/ozone/public/ui_thread_gpu.cc
@@ -0,0 +1,55 @@
+// Copyright 2014 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/public/ui_thread_gpu.h"
+
+#include "ipc/ipc_listener.h"
+#include "ipc/ipc_message.h"
+#include "ipc/ipc_sender.h"
+#include "ui/ozone/public/gpu_platform_support.h"
+#include "ui/ozone/public/gpu_platform_support_host.h"
+#include "ui/ozone/public/ozone_platform.h"
+
+namespace ui {
+
+class UiThreadGpuForwardingSender : public IPC::Sender {
+ public:
+ explicit UiThreadGpuForwardingSender(IPC::Listener* listener)
+ : listener_(listener) {}
+ virtual ~UiThreadGpuForwardingSender() {}
+
+ // IPC::Sender:
+ virtual bool Send(IPC::Message* msg) OVERRIDE {
+ listener_->OnMessageReceived(*msg);
+ delete msg;
+ return true;
+ }
+
+ private:
+ IPC::Listener* listener_;
+};
+
+UiThreadGpu::UiThreadGpu() {
+}
+
+UiThreadGpu::~UiThreadGpu() {
+}
+
+bool UiThreadGpu::Initialize() {
+ OzonePlatform* platform = ui::OzonePlatform::GetInstance();
+
+ ui_sender_.reset(
+ new UiThreadGpuForwardingSender(platform->GetGpuPlatformSupportHost()));
+ gpu_sender_.reset(
+ new UiThreadGpuForwardingSender(platform->GetGpuPlatformSupport()));
+
+ const int kHostId = 1;
+ platform->GetGpuPlatformSupportHost()->OnChannelEstablished(
+ kHostId, gpu_sender_.get());
+ platform->GetGpuPlatformSupport()->OnChannelEstablished(ui_sender_.get());
+
+ return true;
+}
+
+} // namespace ui
diff --git a/ui/ozone/public/ui_thread_gpu.h b/ui/ozone/public/ui_thread_gpu.h
new file mode 100644
index 0000000..8e2358a
--- /dev/null
+++ b/ui/ozone/public/ui_thread_gpu.h
@@ -0,0 +1,40 @@
+// Copyright 2014 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_PUBLIC_UI_THREAD_GPU_H_
+#define UI_OZONE_PUBLIC_UI_THREAD_GPU_H_
+
+#include "base/memory/scoped_ptr.h"
+#include "ui/ozone/ozone_export.h"
+
+namespace IPC {
+class Sender;
+}
+
+namespace ui {
+
+class UiThreadGpuForwardingSender;
+
+// Helper class for applications that do GL on the UI thead.
+//
+// This sets up message forwarding between the "gpu" and "ui" threads,
+// for applications in which they are both the same thread.
+class OZONE_EXPORT UiThreadGpu {
+ public:
+ UiThreadGpu();
+ virtual ~UiThreadGpu();
+
+ // Start processing gpu messages.
+ bool Initialize();
+
+ private:
+ scoped_ptr<UiThreadGpuForwardingSender> ui_sender_;
+ scoped_ptr<UiThreadGpuForwardingSender> gpu_sender_;
+
+ DISALLOW_COPY_AND_ASSIGN(UiThreadGpu);
+};
+
+} // namespace ui
+
+#endif // UI_OZONE_PUBLIC_UI_THREAD_GPU_H_