summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshrike <shrike@chromium.org>2016-02-24 16:12:38 -0800
committerCommit bot <commit-bot@chromium.org>2016-02-25 00:13:54 +0000
commitd45509a44318afe5643302e0c1edcb3760d8b2fe (patch)
tree7e3298b3b0ad88f355de146e5728a310ff67e489
parent4e143f588ee88f7e345abd261476f7721e48a428 (diff)
downloadchromium_src-d45509a44318afe5643302e0c1edcb3760d8b2fe.zip
chromium_src-d45509a44318afe5643302e0c1edcb3760d8b2fe.tar.gz
chromium_src-d45509a44318afe5643302e0c1edcb3760d8b2fe.tar.bz2
Revert of Decouple browser-specific GPU IPC messages from GPU service IPCs (patchset #19 id:360001 of https://codereview.chromium.org/1711533002/ )
Reason for revert: Regression: Win7 Tests (dbg)(1) browser_test failures https://build.chromium.org/p/chromium.win/builders/Win7%20Tests%20%28dbg%29%281%29 Sheriff-o-matic suspecting Change #198012 in Build 46233 for cause of Win7 Tests (dbg)(1) browser_test failures: https://build.chromium.org/p/chromium.win/builders/Win7%20Tests%20%28dbg%29%281%29/builds/46233 In step 91. browser_tests failures: DevToolsPixelOutputTests.TestLatencyInfoInstrumentation DevToolsPixelOutputTests.TestScreenshotRecording Logs: https://build.chromium.org/p/chromium.win/builders/Win7%20Tests%20%28dbg%29%281%29/builds/46233/steps/browser_tests%20on%20Windows-7-SP1/logs/DevToolsPixelOutputTests.TestLatencyInfoInstrumentation https://build.chromium.org/p/chromium.win/builders/Win7%20Tests%20%28dbg%29%281%29/builds/46233/steps/browser_tests%20on%20Windows-7-SP1/logs/DevToolsPixelOutputTests.TestScreenshotRecording [ RUN ] DevToolsPixelOutputTests.TestLatencyInfoInstrumentation [2840:5856:0224/124138:ERROR:angle_platform_impl.cc(33)] ANGLE Display::initialize error 4: Could not create D3D11 device. [2840:5856:0224/124138:ERROR:gl_surface_egl.cc(586)] eglInitialize D3D11 failed with error EGL_NOT_INITIALIZED, trying next display type [2840:5856:0224/124139:ERROR:angle_platform_impl.cc(33)] ANGLE Display::initialize error 4: Renderer does not support PS 3.0.aborting! [2840:5856:0224/124139:ERROR:gl_surface_egl.cc(586)] eglInitialize D3D9 failed with error EGL_NOT_INITIALIZED [2840:5856:0224/124139:ERROR:angle_platform_impl.cc(33)] ANGLE Display::initialize error 4: Could not create D3D11 device. [2840:5856:0224/124139:ERROR:gl_surface_egl.cc(586)] eglInitialize D3D11 failed with error EGL_NOT_INITIALIZED, trying next display type HTTP server started on http://127.0.0.1:58543... sending server_data: {"host": "127.0.0.1", "port": 58543} (36 bytes) [2840:5856:0224/124140:ERROR:angle_platform_impl.cc(33)] ANGLE Display::initialize error 4: Renderer does not support PS 3.0.aborting! [2840:5856:0224/124140:ERROR:gl_surface_egl.cc(586)] eglInitialize D3D9 failed with error EGL_NOT_INITIALIZED [2840:5856:0224/124140:ERROR:gl_surface_win.cc(69)] GLSurfaceEGL::InitializeOneOff failed. [2840:5856:0224/124140:ERROR:gpu_child_thread.cc(347)] Exiting GPU process due to errors during initialization [2840:5856:0224/124140:FATAL:gpu_child_thread.cc(484)] Check failed: gpu_channel_manager_. Backtrace: base::SysInfo::AmountOfVirtualMemory [0x100A8DB1+570092] base::SysInfo::AmountOfVirtualMemory [0x10100BCB+930054] content::ImageTransportFactory::ImageTransportFactory [0x176BA2F8+29889885] content::ImageTransportFactory::ImageTransportFactory [0x176B25D9+29857854] content::ImageTransportFactory::ImageTransportFactory [0x176B2118+29856637] content::ImageTransportFactory::ImageTransportFactory [0x176B23C6+29857323] content::ImageTransportFactory::ImageTransportFactory [0x176B141C+29853313] content::ImageTransportFactory::ImageTransportFactory [0x176BB492+29894391] IPC::Message::type [0x0FA2EA2B+166218] IPC::Message::type [0x0FA26F90+134831] IPC::Message::type [0x0FA26CE7+134150] IPC::Message::type [0x0FA2F6C2+169441] base::SysInfo::AmountOfVirtualMemory [0x1007C9BF+388858] base::SysInfo::AmountOfVirtualMemory [0x100AF147+595586] base::SysInfo::AmountOfVirtualMemory [0x1012E576+1116849] base::SysInfo::AmountOfVirtualMemory [0x1012BC74+1106351] base::SysInfo::AmountOfVirtualMemory [0x1012C43D+1108344] base::SysInfo::AmountOfVirtualMemory [0x10137E44+1155967] base::SysInfo::AmountOfVirtualMemory [0x10139E62+1164189] base::SysInfo::AmountOfVirtualMemory [0x10139DBC+1164023] base::SysInfo::AmountOfVirtualMemory [0x1012E1FF+1115962] base::SysInfo::AmountOfVirtualMemory [0x101C11C6+1718017] base::SysInfo::AmountOfVirtualMemory [0x1012E02D+1115496] content::ImageTransportFactory::ImageTransportFactory [0x176C0E20+29917317] content::ImageTransportFactory::ImageTransportFactory [0x15BEB179+1778654] content::ImageTransportFactory::ImageTransportFactory [0x15BEAF90+1778165] content::ImageTransportFactory::ImageTransportFactory [0x15BD4B70+1686997] content::LaunchTests [0x0849E65E+734] LaunchChromeTests [0x037F990D+125] main [0x01D5643E+110] __tmainCRTStartup [0x09B5DBE9+409] (f:\dd ctools\crt\crtw32\dllstuff\crtexe.c:626) mainCRTStartup [0x09B5DD2D+13] (f:\dd ctools\crt\crtw32\dllstuff\crtexe.c:466) BaseThreadInitThunk [0x767C337A+18] RtlInitializeExceptionChain [0x77D29882+99] RtlInitializeExceptionChain [0x77D29855+54] ================= [ RUN ] DevToolsPixelOutputTests.TestScreenshotRecording [2512:3528:0224/124026:ERROR:angle_platform_impl.cc(33)] ANGLE Display::initialize error 4: Could not create D3D11 device. [2512:3528:0224/124026:ERROR:gl_surface_egl.cc(586)] eglInitialize D3D11 failed with error EGL_NOT_INITIALIZED, trying next display type [2512:3528:0224/124026:ERROR:angle_platform_impl.cc(33)] ANGLE Display::initialize error 4: Renderer does not support PS 3.0.aborting! [2512:3528:0224/124026:ERROR:gl_surface_egl.cc(586)] eglInitialize D3D9 failed with error EGL_NOT_INITIALIZED [2512:3528:0224/124026:ERROR:angle_platform_impl.cc(33)] ANGLE Display::initialize error 4: Could not create D3D11 device. [2512:3528:0224/124026:ERROR:gl_surface_egl.cc(586)] eglInitialize D3D11 failed with error EGL_NOT_INITIALIZED, trying next display type [2512:3528:0224/124026:ERROR:angle_platform_impl.cc(33)] ANGLE Display::initialize error 4: Renderer does not support PS 3.0.aborting! [2512:3528:0224/124026:ERROR:gl_surface_egl.cc(586)] eglInitialize D3D9 failed with error EGL_NOT_INITIALIZED [2512:3528:0224/124026:ERROR:gl_surface_win.cc(69)] GLSurfaceEGL::InitializeOneOff failed. [2512:3528:0224/124026:ERROR:gpu_child_thread.cc(347)] Exiting GPU process due to errors during initialization HTTP server started on http://127.0.0.1:51161... sending server_data: {"host": "127.0.0.1", "port": 51161} (36 bytes) [4708:1384:0224/124028:WARNING:message_queue.cc(38)] Leaking 2 ports in unreceived messages [2512:3528:0224/124026:FATAL:gpu_child_thread.cc(484)] Check failed: gpu_channel_manager_. Backtrace: base::SysInfo::AmountOfVirtualMemory [0x100A8DB1+570092] base::SysInfo::AmountOfVirtualMemory [0x10100BCB+930054] content::ImageTransportFactory::ImageTransportFactory [0x1778A2F8+29889885] content::ImageTransportFactory::ImageTransportFactory [0x177825D9+29857854] content::ImageTransportFactory::ImageTransportFactory [0x17782118+29856637] content::ImageTransportFactory::ImageTransportFactory [0x177823C6+29857323] content::ImageTransportFactory::ImageTransportFactory [0x1778141C+29853313] content::ImageTransportFactory::ImageTransportFactory [0x1778B492+29894391] IPC::Message::type [0x0FAFEA2B+166218] IPC::Message::type [0x0FAF6F90+134831] IPC::Message::type [0x0FAF6CE7+134150] IPC::Message::type [0x0FAFF6C2+169441] base::SysInfo::AmountOfVirtualMemory [0x1007C9BF+388858] base::SysInfo::AmountOfVirtualMemory [0x100AF147+595586] base::SysInfo::AmountOfVirtualMemory [0x1012E576+1116849] base::SysInfo::AmountOfVirtualMemory [0x1012BC74+1106351] base::SysInfo::AmountOfVirtualMemory [0x1012C43D+1108344] base::SysInfo::AmountOfVirtualMemory [0x10137E44+1155967] base::SysInfo::AmountOfVirtualMemory [0x10139E62+1164189] base::SysInfo::AmountOfVirtualMemory [0x10139DBC+1164023] base::SysInfo::AmountOfVirtualMemory [0x1012E1FF+1115962] base::SysInfo::AmountOfVirtualMemory [0x101C11C6+1718017] base::SysInfo::AmountOfVirtualMemory [0x1012E02D+1115496] content::ImageTransportFactory::ImageTransportFactory [0x17790E20+29917317] content::ImageTransportFactory::ImageTransportFactory [0x15CBB179+1778654] content::ImageTransportFactory::ImageTransportFactory [0x15CBAF90+1778165] content::ImageTransportFactory::ImageTransportFactory [0x15CA4B70+1686997] content::LaunchTests [0x0849E65E+734] LaunchChromeTests [0x037F990D+125] main [0x01D5643E+110] __tmainCRTStartup [0x09B5DBE9+409] (f:\dd ctools\crt\crtw32\dllstuff\crtexe.c:626) mainCRTStartup [0x09B5DD2D+13] (f:\dd ctools\crt\crtw32\dllstuff\crtexe.c:466) BaseThreadInitThunk [0x76C2337A+18] RtlInitializeExceptionChain [0x778692B2+99] RtlInitializeExceptionChain [0x77869285+54] [3768:3420:0224/124033:ERROR:singleton_hwnd.cc(34)] Cannot create windows on non-UI thread! [4708:1384:0224/124034:ERROR:CONSOLE(72)] "Uncaught TypeError: Cannot read property 'addExtensions' of undefined", source: (72) [4708:1384:0224/124035:INFO:CONSOLE(1)] "DONE:performActionsInPage.1", source: (1) c:uild\slave\win_builder__dbg_uild\src\chromerowser\devtools\devtools_sanity_browsertest.cc(124): error: Value of: result Actual: "[FAILED] Expected: 'true', but was 'false'" Expected: "[OK]" [4708:1384:0224/124038:WARNING:url_request_context_getter.cc(42)] URLRequestContextGetter leaking due to no owning thread. [ FAILED ] DevToolsPixelOutputTests.TestScreenshotRecording, where TypeParam = and GetParam() = (12746 ms) Original issue's description: > Decouple browser-specific GPU IPC messages from GPU service IPCs > > We would like Mus to reuse GPU service IPC messages. However, > browser-specific<=>gpu messages don't necessarily > make sense in Mus+Ash. This CL decouples browser messages > from Gpu channel messages in the following ways: > > 1. Browser channel messages are moved to a gpu_host_messages.h file. > > 2. Browser channel message handling is moved entirely to GpuChildThread. > > 3. GpuChannelManager is decoupled from GpuChildThread by making > GpuChildThread a GpuChannelManagerDelegate. > > The intent here is for Mus to implement an alternative > GpuChannelManagerDelegate. > > BUG=586374 > > Committed: https://crrev.com/6904b50eb105956b954279f9632f680251e41aa7 > Cr-Commit-Position: refs/heads/master@{#377341} TBR=sievers@chromium.org,piman@chromium.org,markdittmer@chromium.org,tsepez@chromium.org,fsamuel@chromium.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=586374 Review URL: https://codereview.chromium.org/1730023004 Cr-Commit-Position: refs/heads/master@{#377431}
-rw-r--r--content/browser/gpu/gpu_data_manager_impl_private.cc24
-rw-r--r--content/browser/gpu/gpu_process_host.cc20
-rw-r--r--content/browser/gpu/gpu_process_host_ui_shim.cc15
-rw-r--r--content/browser/gpu/gpu_process_host_ui_shim.h9
-rw-r--r--content/browser/renderer_host/gpu_message_filter.cc2
-rw-r--r--content/browser/renderer_host/render_process_host_impl.cc2
-rw-r--r--content/browser/renderer_host/render_widget_host_view_android.cc2
-rw-r--r--content/common/content_message_generator.h1
-rw-r--r--content/common/gpu/accelerated_surface_buffers_swapped_params_mac.cc14
-rw-r--r--content/common/gpu/accelerated_surface_buffers_swapped_params_mac.h28
-rw-r--r--content/common/gpu/buffer_presented_params_mac.cc13
-rw-r--r--content/common/gpu/buffer_presented_params_mac.h23
-rw-r--r--content/common/gpu/child_window_surface_win.cc5
-rw-r--r--content/common/gpu/establish_channel_params.cc18
-rw-r--r--content/common/gpu/establish_channel_params.h27
-rw-r--r--content/common/gpu/gpu_channel.cc10
-rw-r--r--content/common/gpu/gpu_channel_manager.cc96
-rw-r--r--content/common/gpu/gpu_channel_manager.h83
-rw-r--r--content/common/gpu/gpu_channel_manager_delegate.h79
-rw-r--r--content/common/gpu/gpu_channel_manager_unittest.cc37
-rw-r--r--content/common/gpu/gpu_channel_test_common.cc86
-rw-r--r--content/common/gpu/gpu_channel_test_common.h61
-rw-r--r--content/common/gpu/gpu_channel_unittest.cc14
-rw-r--r--content/common/gpu/gpu_command_buffer_stub.cc17
-rw-r--r--content/common/gpu/gpu_host_messages.h276
-rw-r--r--content/common/gpu/gpu_memory_manager.cc8
-rw-r--r--content/common/gpu/gpu_memory_manager.h2
-rw-r--r--content/common/gpu/gpu_messages.h243
-rw-r--r--content/common/gpu/image_transport_surface.cc47
-rw-r--r--content/common/gpu/image_transport_surface.h31
-rw-r--r--content/common/gpu/image_transport_surface_overlay_mac.h3
-rw-r--r--content/common/gpu/image_transport_surface_overlay_mac.mm9
-rw-r--r--content/content_common.gypi8
-rw-r--r--content/gpu/gpu_child_thread.cc169
-rw-r--r--content/gpu/gpu_child_thread.h45
-rw-r--r--content/gpu/gpu_main.cc6
-rw-r--r--content/renderer/gpu/gpu_benchmarking_extension.cc2
-rw-r--r--content/renderer/render_thread_impl.cc8
-rw-r--r--ipc/ipc_message_start.h1
39 files changed, 553 insertions, 991 deletions
diff --git a/content/browser/gpu/gpu_data_manager_impl_private.cc b/content/browser/gpu/gpu_data_manager_impl_private.cc
index 161f07b..6b57bcf 100644
--- a/content/browser/gpu/gpu_data_manager_impl_private.cc
+++ b/content/browser/gpu/gpu_data_manager_impl_private.cc
@@ -11,7 +11,6 @@
#include "base/metrics/histogram.h"
#include "base/metrics/sparse_histogram.h"
#include "base/strings/string_number_conversions.h"
-#include "base/strings/string_split.h"
#include "base/strings/stringprintf.h"
#include "base/sys_info.h"
#include "base/trace_event/trace_event.h"
@@ -19,7 +18,7 @@
#include "build/build_config.h"
#include "cc/base/switches.h"
#include "content/browser/gpu/gpu_process_host.h"
-#include "content/common/gpu/gpu_host_messages.h"
+#include "content/common/gpu/gpu_messages.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/gpu_data_manager_observer.h"
#include "content/public/common/content_client.h"
@@ -409,9 +408,10 @@ bool GpuDataManagerImplPrivate::IsCompleteGpuInfoAvailable() const {
}
void GpuDataManagerImplPrivate::RequestVideoMemoryUsageStatsUpdate() const {
- GpuProcessHost::SendOnIO(GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED,
- CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH,
- new GpuMsg_GetVideoMemoryUsageStats());
+ GpuProcessHost::SendOnIO(
+ GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED,
+ CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH,
+ new GpuMsg_GetVideoMemoryUsageStats());
}
bool GpuDataManagerImplPrivate::ShouldUseSwiftShader() const {
@@ -455,9 +455,10 @@ void GpuDataManagerImplPrivate::UnblockDomainFrom3DAPIs(const GURL& url) {
}
void GpuDataManagerImplPrivate::DisableGpuWatchdog() {
- GpuProcessHost::SendOnIO(GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED,
- CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH,
- new GpuMsg_DisableWatchdog);
+ GpuProcessHost::SendOnIO(
+ GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED,
+ CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH,
+ new GpuMsg_DisableWatchdog);
}
void GpuDataManagerImplPrivate::SetGLStrings(const std::string& gl_vendor,
@@ -892,9 +893,10 @@ void GpuDataManagerImplPrivate::HandleGpuSwitch() {
// Notify observers in the browser process.
ui::GpuSwitchingManager::GetInstance()->NotifyGpuSwitched();
// Pass the notification to the GPU process to notify observers there.
- GpuProcessHost::SendOnIO(GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED,
- CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH,
- new GpuMsg_GpuSwitched);
+ GpuProcessHost::SendOnIO(
+ GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED,
+ CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH,
+ new GpuMsg_GpuSwitched);
}
bool GpuDataManagerImplPrivate::UpdateActiveGpu(uint32_t vendor_id,
diff --git a/content/browser/gpu/gpu_process_host.cc b/content/browser/gpu/gpu_process_host.cc
index ef4fea3..a696ecc 100644
--- a/content/browser/gpu/gpu_process_host.cc
+++ b/content/browser/gpu/gpu_process_host.cc
@@ -31,7 +31,7 @@
#include "content/browser/mojo/mojo_application_host.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/common/child_process_host_impl.h"
-#include "content/common/gpu/gpu_host_messages.h"
+#include "content/common/gpu/gpu_messages.h"
#include "content/common/in_process_child_thread_params.h"
#include "content/common/view_messages.h"
#include "content/public/browser/browser_thread.h"
@@ -615,8 +615,10 @@ bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER_GENERIC(GpuHostMsg_AcceleratedSurfaceBuffersSwapped,
OnAcceleratedSurfaceBuffersSwapped(message))
#endif
- IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyChannel, OnDestroyChannel)
- IPC_MESSAGE_HANDLER(GpuHostMsg_CacheShader, OnCacheShader)
+ IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyChannel,
+ OnDestroyChannel)
+ IPC_MESSAGE_HANDLER(GpuHostMsg_CacheShader,
+ OnCacheShader)
#if defined(OS_WIN)
IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceCreatedChildWindow,
OnAcceleratedSurfaceCreatedChildWindow)
@@ -687,7 +689,7 @@ void GpuProcessHost::EstablishGpuChannel(
return;
}
- EstablishChannelParams params;
+ GpuMsg_EstablishChannel_Params params;
params.client_id = client_id;
params.client_tracing_id = client_tracing_id;
params.preempts = preempts;
@@ -785,7 +787,8 @@ void GpuProcessHost::OnChannelEstablished(
if (channel_requests_.empty()) {
// This happens when GPU process is compromised.
RouteOnUIThread(GpuHostMsg_OnLogMessage(
- logging::LOG_WARNING, "WARNING",
+ logging::LOG_WARNING,
+ "WARNING",
"Received a ChannelEstablished message but no requests in queue."));
return;
}
@@ -798,9 +801,10 @@ void GpuProcessHost::OnChannelEstablished(
!GpuDataManagerImpl::GetInstance()->GpuAccessAllowed(NULL)) {
Send(new GpuMsg_CloseChannel(channel_handle));
callback.Run(IPC::ChannelHandle(), gpu::GPUInfo());
- RouteOnUIThread(
- GpuHostMsg_OnLogMessage(logging::LOG_WARNING, "WARNING",
- "Hardware acceleration is unavailable."));
+ RouteOnUIThread(GpuHostMsg_OnLogMessage(
+ logging::LOG_WARNING,
+ "WARNING",
+ "Hardware acceleration is unavailable."));
return;
}
diff --git a/content/browser/gpu/gpu_process_host_ui_shim.cc b/content/browser/gpu/gpu_process_host_ui_shim.cc
index 1377dce..f50db21 100644
--- a/content/browser/gpu/gpu_process_host_ui_shim.cc
+++ b/content/browser/gpu/gpu_process_host_ui_shim.cc
@@ -22,12 +22,10 @@
#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/browser/renderer_host/render_widget_helper.h"
#include "content/browser/renderer_host/render_widget_host_view_base.h"
-#include "content/common/gpu/gpu_host_messages.h"
+#include "content/common/gpu/gpu_messages.h"
#include "content/public/browser/browser_thread.h"
-#include "ui/gfx/swap_result.h"
#if defined(OS_MACOSX)
-#include "content/common/gpu/accelerated_surface_buffers_swapped_params_mac.h"
#include "ui/accelerated_widget_mac/accelerated_widget_mac.h"
#endif
@@ -186,7 +184,8 @@ bool GpuProcessHostUIShim::OnControlMessageReceived(
DCHECK(CalledOnValidThread());
IPC_BEGIN_MESSAGE_MAP(GpuProcessHostUIShim, message)
- IPC_MESSAGE_HANDLER(GpuHostMsg_OnLogMessage, OnLogMessage)
+ IPC_MESSAGE_HANDLER(GpuHostMsg_OnLogMessage,
+ OnLogMessage)
#if defined(OS_MACOSX)
IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped,
OnAcceleratedSurfaceBuffersSwapped)
@@ -223,19 +222,19 @@ void GpuProcessHostUIShim::OnGraphicsInfoCollected(
#if defined(OS_MACOSX)
void GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped(
- const AcceleratedSurfaceBuffersSwappedParams& params) {
+ const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) {
TRACE_EVENT0("browser",
"GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped");
if (!ui::LatencyInfo::Verify(params.latency_info,
"GpuHostMsg_AcceleratedSurfaceBuffersSwapped")) {
+
TRACE_EVENT0("browser", "ui::LatencyInfo::Verify failed");
return;
}
// On Mac with delegated rendering, accelerated surfaces are not necessarily
// associated with a RenderWidgetHostViewBase.
- BufferPresentedParams ack_params;
- ack_params.surface_id = params.surface_id;
+ AcceleratedSurfaceMsg_BufferPresented_Params ack_params;
// If the frame was intended for an NSView that the gfx::AcceleratedWidget is
// no longer attached to, do not pass the frame along to the widget. Just ack
@@ -267,7 +266,7 @@ void GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped(
content::ImageTransportFactory::GetInstance()->OnGpuSwapBuffersCompleted(
params.surface_id, params.latency_info, gfx::SwapResult::SWAP_ACK);
- Send(new AcceleratedSurfaceMsg_BufferPresented(ack_params));
+ Send(new AcceleratedSurfaceMsg_BufferPresented(params.route_id, ack_params));
}
#endif
diff --git a/content/browser/gpu/gpu_process_host_ui_shim.h b/content/browser/gpu/gpu_process_host_ui_shim.h
index 4358b1c..e37eda0 100644
--- a/content/browser/gpu/gpu_process_host_ui_shim.h
+++ b/content/browser/gpu/gpu_process_host_ui_shim.h
@@ -27,6 +27,10 @@
#include "ipc/ipc_sender.h"
#include "ipc/message_router.h"
+#if defined(OS_MACOSX)
+struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params;
+#endif
+
namespace ui {
class LatencyInfo;
}
@@ -40,9 +44,6 @@ class Message;
}
namespace content {
-#if defined(OS_MACOSX)
-struct AcceleratedSurfaceBuffersSwappedParams;
-#endif
void RouteToGpuProcessHostUIShimTask(int host_id, const IPC::Message& msg);
class GpuProcessHostUIShim : public IPC::Listener,
@@ -97,7 +98,7 @@ class GpuProcessHostUIShim : public IPC::Listener,
#if defined(OS_MACOSX)
void OnAcceleratedSurfaceBuffersSwapped(
- const AcceleratedSurfaceBuffersSwappedParams& params);
+ const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params);
#endif
void OnVideoMemoryUsageStatsReceived(
const GPUVideoMemoryUsageStats& video_memory_usage_stats);
diff --git a/content/browser/renderer_host/gpu_message_filter.cc b/content/browser/renderer_host/gpu_message_filter.cc
index 14813eb..bf1fa07 100644
--- a/content/browser/renderer_host/gpu_message_filter.cc
+++ b/content/browser/renderer_host/gpu_message_filter.cc
@@ -13,7 +13,7 @@
#include "content/browser/gpu/gpu_data_manager_impl.h"
#include "content/browser/gpu/gpu_process_host.h"
#include "content/common/child_process_host_impl.h"
-#include "content/common/gpu/gpu_host_messages.h"
+#include "content/common/gpu/gpu_messages.h"
namespace content {
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
index baf6a0f..8772b0c 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -120,7 +120,7 @@
#include "content/common/child_process_messages.h"
#include "content/common/content_switches_internal.h"
#include "content/common/frame_messages.h"
-#include "content/common/gpu/gpu_host_messages.h"
+#include "content/common/gpu/gpu_messages.h"
#include "content/common/in_process_child_thread_params.h"
#include "content/common/mojo/channel_init.h"
#include "content/common/mojo/mojo_messages.h"
diff --git a/content/browser/renderer_host/render_widget_host_view_android.cc b/content/browser/renderer_host/render_widget_host_view_android.cc
index b6c97d5..ddb0f0c 100644
--- a/content/browser/renderer_host/render_widget_host_view_android.cc
+++ b/content/browser/renderer_host/render_widget_host_view_android.cc
@@ -56,7 +56,7 @@
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/common/gpu/client/gl_helper.h"
#include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
-#include "content/common/gpu/gpu_host_messages.h"
+#include "content/common/gpu/gpu_messages.h"
#include "content/common/gpu/gpu_process_launch_causes.h"
#include "content/common/input/did_overscroll_params.h"
#include "content/common/input_messages.h"
diff --git a/content/common/content_message_generator.h b/content/common/content_message_generator.h
index 312e56f..3982542 100644
--- a/content/common/content_message_generator.h
+++ b/content/common/content_message_generator.h
@@ -28,7 +28,6 @@
#include "content/common/frame_messages.h"
#include "content/common/gamepad_messages.h"
#include "content/common/geofencing_messages.h"
-#include "content/common/gpu/gpu_host_messages.h"
#include "content/common/gpu/gpu_messages.h"
#include "content/common/indexed_db/indexed_db_messages.h"
#include "content/common/input_messages.h"
diff --git a/content/common/gpu/accelerated_surface_buffers_swapped_params_mac.cc b/content/common/gpu/accelerated_surface_buffers_swapped_params_mac.cc
deleted file mode 100644
index 2364b84..0000000
--- a/content/common/gpu/accelerated_surface_buffers_swapped_params_mac.cc
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright 2016 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 "content/common/gpu/accelerated_surface_buffers_swapped_params_mac.h"
-
-namespace content {
-AcceleratedSurfaceBuffersSwappedParams::AcceleratedSurfaceBuffersSwappedParams()
- : surface_id(0), ca_context_id(0), scale_factor(1.f) {}
-
-AcceleratedSurfaceBuffersSwappedParams::
- ~AcceleratedSurfaceBuffersSwappedParams() {}
-
-} // namespace content
diff --git a/content/common/gpu/accelerated_surface_buffers_swapped_params_mac.h b/content/common/gpu/accelerated_surface_buffers_swapped_params_mac.h
deleted file mode 100644
index d0f66b0..0000000
--- a/content/common/gpu/accelerated_surface_buffers_swapped_params_mac.h
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright 2016 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 CONTENT_COMMON_GPU_ACCELERATED_SURFACE_BUFFERS_SWAPPED_PARAMS_MAC_H_
-#define CONTENT_COMMON_GPU_ACCELERATED_SURFACE_BUFFERS_SWAPPED_PARAMS_MAC_H_
-
-#include "ui/base/cocoa/remote_layer_api.h"
-#include "ui/events/latency_info.h"
-#include "ui/gfx/mac/io_surface.h"
-
-namespace content {
-
-struct AcceleratedSurfaceBuffersSwappedParams {
- AcceleratedSurfaceBuffersSwappedParams();
- ~AcceleratedSurfaceBuffersSwappedParams();
-
- int32_t surface_id;
- CAContextID ca_context_id;
- gfx::ScopedRefCountedIOSurfaceMachPort io_surface;
- gfx::Size size;
- float scale_factor;
- std::vector<ui::LatencyInfo> latency_info;
-};
-
-} // namespace content
-
-#endif // CONTENT_COMMON_GPU_ACCELERATED_SURFACE_BUFFERS_SWAPPED_PARAMS_MAC_H_
diff --git a/content/common/gpu/buffer_presented_params_mac.cc b/content/common/gpu/buffer_presented_params_mac.cc
deleted file mode 100644
index acbb973..0000000
--- a/content/common/gpu/buffer_presented_params_mac.cc
+++ /dev/null
@@ -1,13 +0,0 @@
-// Copyright 2016 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 "content/common/gpu/buffer_presented_params_mac.h"
-
-namespace content {
-
-BufferPresentedParams::BufferPresentedParams() : surface_id(0) {}
-
-BufferPresentedParams::~BufferPresentedParams() {}
-
-} // namespace content
diff --git a/content/common/gpu/buffer_presented_params_mac.h b/content/common/gpu/buffer_presented_params_mac.h
deleted file mode 100644
index b94ffa4..0000000
--- a/content/common/gpu/buffer_presented_params_mac.h
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright 2016 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 CONTENT_COMMON_GPU_BUFFER_PRESENTED_PARAMS_MAC_H_
-#define CONTENT_COMMON_GPU_BUFFER_PRESENTED_PARAMS_MAC_H_
-
-#include "base/time/time.h"
-
-namespace content {
-
-struct BufferPresentedParams {
- BufferPresentedParams();
- ~BufferPresentedParams();
-
- int32_t surface_id;
- base::TimeTicks vsync_timebase;
- base::TimeDelta vsync_interval;
-};
-
-} // namespace content
-
-#endif // CONTENT_COMMON_GPU_BUFFER_PRESENTED_PARAMS_MAC_H_
diff --git a/content/common/gpu/child_window_surface_win.cc b/content/common/gpu/child_window_surface_win.cc
index 4564972..f51115c 100644
--- a/content/common/gpu/child_window_surface_win.cc
+++ b/content/common/gpu/child_window_surface_win.cc
@@ -8,7 +8,6 @@
#include "base/win/scoped_hdc.h"
#include "base/win/wrapped_window_proc.h"
#include "content/common/gpu/gpu_channel_manager.h"
-#include "content/common/gpu/gpu_channel_manager_delegate.h"
#include "content/common/gpu/gpu_messages.h"
#include "ui/base/win/hidden_window.h"
#include "ui/gfx/native_widget_types.h"
@@ -126,8 +125,8 @@ bool ChildWindowSurfaceWin::InitializeNativeWindow() {
windowRect.right - windowRect.left, windowRect.bottom - windowRect.top,
ui::GetHiddenWindow(), NULL, NULL, NULL);
gfx::SetWindowUserData(window_, this);
- manager_->delegate()->SendAcceleratedSurfaceCreatedChildWindow(parent_window_,
- window_);
+ manager_->Send(new GpuHostMsg_AcceleratedSurfaceCreatedChildWindow(
+ parent_window_, window_));
return true;
}
diff --git a/content/common/gpu/establish_channel_params.cc b/content/common/gpu/establish_channel_params.cc
deleted file mode 100644
index 21c8027..0000000
--- a/content/common/gpu/establish_channel_params.cc
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 2016 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 "content/common/gpu/establish_channel_params.h"
-
-namespace content {
-
-EstablishChannelParams::EstablishChannelParams()
- : client_id(0),
- client_tracing_id(0),
- preempts(false),
- allow_view_command_buffers(false),
- allow_real_time_streams(false) {}
-
-EstablishChannelParams::~EstablishChannelParams() {}
-
-} // namespace content
diff --git a/content/common/gpu/establish_channel_params.h b/content/common/gpu/establish_channel_params.h
deleted file mode 100644
index 3a06f86..0000000
--- a/content/common/gpu/establish_channel_params.h
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2016 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 CONTENT_COMMON_GPU_ESTABLISH_CHANNEL_PARAMS_H_
-#define CONTENT_COMMON_GPU_ESTABLISH_CHANNEL_PARAMS_H_
-
-#include <stdint.h>
-
-#include "content/common/content_export.h"
-
-namespace content {
-
-struct CONTENT_EXPORT EstablishChannelParams {
- EstablishChannelParams();
- ~EstablishChannelParams();
-
- int client_id;
- uint64_t client_tracing_id;
- bool preempts;
- bool allow_view_command_buffers;
- bool allow_real_time_streams;
-};
-
-} // namespace content
-
-#endif // CONTENT_COMMON_GPU_ESTABLISH_CHANNEL_PARAMS_H_
diff --git a/content/common/gpu/gpu_channel.cc b/content/common/gpu/gpu_channel.cc
index b6731de..885f6d9 100644
--- a/content/common/gpu/gpu_channel.cc
+++ b/content/common/gpu/gpu_channel.cc
@@ -31,7 +31,6 @@
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "content/common/gpu/gpu_channel_manager.h"
-#include "content/common/gpu/gpu_channel_manager_delegate.h"
#include "content/common/gpu/gpu_memory_buffer_factory.h"
#include "content/common/gpu/gpu_messages.h"
#include "content/common/gpu/media/gpu_jpeg_decode_accelerator.h"
@@ -701,11 +700,13 @@ bool GpuChannel::Send(IPC::Message* message) {
}
void GpuChannel::OnAddSubscription(unsigned int target) {
- gpu_channel_manager()->delegate()->AddSubscription(client_id_, target);
+ gpu_channel_manager()->Send(
+ new GpuHostMsg_AddSubscription(client_id_, target));
}
void GpuChannel::OnRemoveSubscription(unsigned int target) {
- gpu_channel_manager()->delegate()->RemoveSubscription(client_id_, target);
+ gpu_channel_manager()->Send(
+ new GpuHostMsg_RemoveSubscription(client_id_, target));
}
void GpuChannel::OnStreamRescheduled(int32_t stream_id, bool scheduled) {
@@ -999,7 +1000,8 @@ void GpuChannel::OnCreateJpegDecoder(int32_t route_id,
void GpuChannel::CacheShader(const std::string& key,
const std::string& shader) {
- gpu_channel_manager_->delegate()->StoreShaderToDisk(client_id_, key, shader);
+ gpu_channel_manager_->Send(
+ new GpuHostMsg_CacheShader(client_id_, key, shader));
}
void GpuChannel::AddFilter(IPC::MessageFilter* filter) {
diff --git a/content/common/gpu/gpu_channel_manager.cc b/content/common/gpu/gpu_channel_manager.cc
index d5ffd60..381292b 100644
--- a/content/common/gpu/gpu_channel_manager.cc
+++ b/content/common/gpu/gpu_channel_manager.cc
@@ -13,15 +13,11 @@
#include "base/single_thread_task_runner.h"
#include "base/thread_task_runner_handle.h"
#include "build/build_config.h"
-#include "content/common/gpu/establish_channel_params.h"
#include "content/common/gpu/gpu_channel.h"
-#include "content/common/gpu/gpu_channel_manager_delegate.h"
#include "content/common/gpu/gpu_memory_buffer_factory.h"
#include "content/common/gpu/gpu_memory_manager.h"
#include "content/common/gpu/gpu_messages.h"
-#include "content/common/gpu/image_transport_surface.h"
#include "content/public/common/content_switches.h"
-#include "gpu/command_buffer/common/sync_token.h"
#include "gpu/command_buffer/common/value_state.h"
#include "gpu/command_buffer/service/feature_info.h"
#include "gpu/command_buffer/service/gpu_switches.h"
@@ -34,10 +30,6 @@
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_share_group.h"
-#if defined(OS_MACOSX)
-#include "content/common/gpu/buffer_presented_params_mac.h"
-#endif
-
namespace content {
namespace {
@@ -52,7 +44,7 @@ const int kMaxKeepAliveTimeMs = 200;
}
GpuChannelManager::GpuChannelManager(
- GpuChannelManagerDelegate* delegate,
+ IPC::SyncChannel* channel,
GpuWatchdog* watchdog,
base::SingleThreadTaskRunner* task_runner,
base::SingleThreadTaskRunner* io_task_runner,
@@ -61,7 +53,7 @@ GpuChannelManager::GpuChannelManager(
GpuMemoryBufferFactory* gpu_memory_buffer_factory)
: task_runner_(task_runner),
io_task_runner_(io_task_runner),
- delegate_(delegate),
+ channel_(channel),
watchdog_(watchdog),
shutdown_event_(shutdown_event),
share_group_(new gfx::GLShareGroup),
@@ -116,33 +108,55 @@ GpuChannelManager::framebuffer_completeness_cache() {
}
void GpuChannelManager::RemoveChannel(int client_id) {
- delegate_->DidDestroyChannel(client_id);
+ Send(new GpuHostMsg_DestroyChannel(client_id));
gpu_channels_.erase(client_id);
}
-#if defined(OS_MACOSX)
-void GpuChannelManager::AddImageTransportSurface(
- int32_t surface_id,
- ImageTransportHelper* image_transport_helper) {
- image_transport_map_.AddWithID(image_transport_helper, surface_id);
+int GpuChannelManager::GenerateRouteID() {
+ static int last_id = 0;
+ return ++last_id;
}
-void GpuChannelManager::RemoveImageTransportSurface(int32_t surface_id) {
- image_transport_map_.Remove(surface_id);
+void GpuChannelManager::AddRoute(int32_t routing_id, IPC::Listener* listener) {
+ router_.AddRoute(routing_id, listener);
}
-void GpuChannelManager::BufferPresented(const BufferPresentedParams& params) {
- ImageTransportHelper* helper = image_transport_map_.Lookup(params.surface_id);
- if (helper)
- helper->BufferPresented(params);
+void GpuChannelManager::RemoveRoute(int32_t routing_id) {
+ router_.RemoveRoute(routing_id);
}
-#endif
GpuChannel* GpuChannelManager::LookupChannel(int32_t client_id) const {
const auto& it = gpu_channels_.find(client_id);
return it != gpu_channels_.end() ? it->second : nullptr;
}
+bool GpuChannelManager::OnControlMessageReceived(const IPC::Message& msg) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(GpuChannelManager, msg)
+ IPC_MESSAGE_HANDLER(GpuMsg_EstablishChannel, OnEstablishChannel)
+ IPC_MESSAGE_HANDLER(GpuMsg_CloseChannel, OnCloseChannel)
+ IPC_MESSAGE_HANDLER(GpuMsg_DestroyGpuMemoryBuffer, OnDestroyGpuMemoryBuffer)
+ IPC_MESSAGE_HANDLER(GpuMsg_LoadedShader, OnLoadedShader)
+ IPC_MESSAGE_HANDLER(GpuMsg_UpdateValueState, OnUpdateValueState)
+#if defined(OS_ANDROID)
+ IPC_MESSAGE_HANDLER(GpuMsg_WakeUpGpu, OnWakeUpGpu);
+#endif
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+}
+
+bool GpuChannelManager::OnMessageReceived(const IPC::Message& msg) {
+ if (msg.routing_id() == MSG_ROUTING_CONTROL)
+ return OnControlMessageReceived(msg);
+
+ return router_.RouteMessage(msg);
+}
+
+bool GpuChannelManager::Send(IPC::Message* msg) {
+ return channel_->Send(msg);
+}
+
scoped_ptr<GpuChannel> GpuChannelManager::CreateGpuChannel(
int client_id,
uint64_t client_tracing_id,
@@ -157,7 +171,8 @@ scoped_ptr<GpuChannel> GpuChannelManager::CreateGpuChannel(
allow_view_command_buffers, allow_real_time_streams));
}
-void GpuChannelManager::EstablishChannel(const EstablishChannelParams& params) {
+void GpuChannelManager::OnEstablishChannel(
+ const GpuMsg_EstablishChannel_Params& params) {
scoped_ptr<GpuChannel> channel(CreateGpuChannel(
params.client_id, params.client_tracing_id, params.preempts,
params.allow_view_command_buffers, params.allow_real_time_streams));
@@ -165,10 +180,11 @@ void GpuChannelManager::EstablishChannel(const EstablishChannelParams& params) {
gpu_channels_.set(params.client_id, std::move(channel));
- delegate_->ChannelEstablished(channel_handle);
+ Send(new GpuHostMsg_ChannelEstablished(channel_handle));
}
-void GpuChannelManager::CloseChannel(const IPC::ChannelHandle& channel_handle) {
+void GpuChannelManager::OnCloseChannel(
+ const IPC::ChannelHandle& channel_handle) {
for (auto it = gpu_channels_.begin(); it != gpu_channels_.end(); ++it) {
if (it->second->channel_id() == channel_handle.name) {
gpu_channels_.erase(it);
@@ -177,22 +193,21 @@ void GpuChannelManager::CloseChannel(const IPC::ChannelHandle& channel_handle) {
}
}
-void GpuChannelManager::InternalDestroyGpuMemoryBuffer(
+void GpuChannelManager::DestroyGpuMemoryBuffer(
gfx::GpuMemoryBufferId id,
int client_id) {
io_task_runner_->PostTask(
- FROM_HERE,
- base::Bind(&GpuChannelManager::InternalDestroyGpuMemoryBufferOnIO,
- base::Unretained(this), id, client_id));
+ FROM_HERE, base::Bind(&GpuChannelManager::DestroyGpuMemoryBufferOnIO,
+ base::Unretained(this), id, client_id));
}
-void GpuChannelManager::InternalDestroyGpuMemoryBufferOnIO(
+void GpuChannelManager::DestroyGpuMemoryBufferOnIO(
gfx::GpuMemoryBufferId id,
int client_id) {
gpu_memory_buffer_factory_->DestroyGpuMemoryBuffer(id, client_id);
}
-void GpuChannelManager::DestroyGpuMemoryBuffer(
+void GpuChannelManager::OnDestroyGpuMemoryBuffer(
gfx::GpuMemoryBufferId id,
int client_id,
const gpu::SyncToken& sync_token) {
@@ -203,19 +218,18 @@ void GpuChannelManager::DestroyGpuMemoryBuffer(
if (release_state) {
sync_point_client_waiter_->WaitOutOfOrder(
release_state.get(), sync_token.release_count(),
- base::Bind(&GpuChannelManager::InternalDestroyGpuMemoryBuffer,
+ base::Bind(&GpuChannelManager::DestroyGpuMemoryBuffer,
base::Unretained(this), id, client_id));
return;
}
}
// No sync token or invalid sync token, destroy immediately.
- InternalDestroyGpuMemoryBuffer(id, client_id);
+ DestroyGpuMemoryBuffer(id, client_id);
}
-void GpuChannelManager::UpdateValueState(int client_id,
- unsigned int target,
- const gpu::ValueState& state) {
+void GpuChannelManager::OnUpdateValueState(
+ int client_id, unsigned int target, const gpu::ValueState& state) {
// Only pass updated state to the channel corresponding to the
// render_widget_host where the event originated.
auto it = gpu_channels_.find(client_id);
@@ -223,7 +237,7 @@ void GpuChannelManager::UpdateValueState(int client_id,
it->second->HandleUpdateValueState(target, state);
}
-void GpuChannelManager::PopulateShaderCache(const std::string& program_proto) {
+void GpuChannelManager::OnLoadedShader(const std::string& program_proto) {
if (program_cache())
program_cache()->LoadProgram(program_proto);
}
@@ -251,11 +265,11 @@ void GpuChannelManager::LoseAllContexts() {
kv.second->MarkAllContextsLost();
}
task_runner_->PostTask(FROM_HERE,
- base::Bind(&GpuChannelManager::DestroyAllChannels,
+ base::Bind(&GpuChannelManager::OnLoseAllContexts,
weak_factory_.GetWeakPtr()));
}
-void GpuChannelManager::DestroyAllChannels() {
+void GpuChannelManager::OnLoseAllContexts() {
gpu_channels_.clear();
}
@@ -272,7 +286,7 @@ void GpuChannelManager::DidAccessGpu() {
last_gpu_access_time_ = base::TimeTicks::Now();
}
-void GpuChannelManager::WakeUpGpu() {
+void GpuChannelManager::OnWakeUpGpu() {
begin_wake_up_time_ = base::TimeTicks::Now();
ScheduleWakeUpGpu();
}
diff --git a/content/common/gpu/gpu_channel_manager.h b/content/common/gpu/gpu_channel_manager.h
index e76b373..befc599 100644
--- a/content/common/gpu/gpu_channel_manager.h
+++ b/content/common/gpu/gpu_channel_manager.h
@@ -12,7 +12,6 @@
#include <vector>
#include "base/containers/scoped_ptr_hash_map.h"
-#include "base/id_map.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
@@ -21,11 +20,12 @@
#include "content/common/content_export.h"
#include "content/common/content_param_traits.h"
#include "content/common/gpu/gpu_memory_manager.h"
-#include "gpu/command_buffer/common/constants.h"
+#include "ipc/ipc_listener.h"
+#include "ipc/ipc_sender.h"
+#include "ipc/message_router.h"
#include "ui/gfx/gpu_memory_buffer.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gl/gl_surface.h"
-#include "url/gurl.h"
namespace base {
class WaitableEvent;
@@ -51,60 +51,46 @@ class ShaderTranslatorCache;
namespace IPC {
struct ChannelHandle;
+class SyncChannel;
}
+struct GPUCreateCommandBufferConfig;
+struct GpuMsg_EstablishChannel_Params;
+
namespace content {
class GpuChannel;
-class GpuChannelManagerDelegate;
class GpuMemoryBufferFactory;
class GpuWatchdog;
-class ImageTransportHelper;
-struct EstablishChannelParams;
-#if defined(OS_MACOSX)
-struct BufferPresentedParams;
-#endif
// A GpuChannelManager is a thread responsible for issuing rendering commands
// managing the lifetimes of GPU channels and forwarding IPC requests from the
// browser process to them based on the corresponding renderer ID.
-class CONTENT_EXPORT GpuChannelManager {
+class CONTENT_EXPORT GpuChannelManager : public IPC::Listener,
+ public IPC::Sender {
public:
- GpuChannelManager(GpuChannelManagerDelegate* delegate,
+ GpuChannelManager(IPC::SyncChannel* channel,
GpuWatchdog* watchdog,
base::SingleThreadTaskRunner* task_runner,
base::SingleThreadTaskRunner* io_task_runner,
base::WaitableEvent* shutdown_event,
gpu::SyncPointManager* sync_point_manager,
GpuMemoryBufferFactory* gpu_memory_buffer_factory);
- virtual ~GpuChannelManager();
-
- GpuChannelManagerDelegate* delegate() const { return delegate_; }
-
- void EstablishChannel(const EstablishChannelParams& params);
- void CloseChannel(const IPC::ChannelHandle& channel_handle);
- void PopulateShaderCache(const std::string& shader);
- void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id,
- int client_id,
- const gpu::SyncToken& sync_token);
- void UpdateValueState(int client_id,
- unsigned int target,
- const gpu::ValueState& state);
-#if defined(OS_ANDROID)
- void WakeUpGpu();
-#endif
- void DestroyAllChannels();
+ ~GpuChannelManager() override;
// Remove the channel for a particular renderer.
void RemoveChannel(int client_id);
+ // Listener overrides.
+ bool OnMessageReceived(const IPC::Message& msg) override;
+
+ // Sender overrides.
+ bool Send(IPC::Message* msg) override;
+
void LoseAllContexts();
-#if defined(OS_MACOSX)
- void AddImageTransportSurface(int32_t routing_id,
- ImageTransportHelper* image_transport_helper);
- void RemoveImageTransportSurface(int32_t routing_id);
- void BufferPresented(const BufferPresentedParams& params);
-#endif
+ int GenerateRouteID();
+ void AddRoute(int32_t routing_id, IPC::Listener* listener);
+ void RemoveRoute(int32_t routing_id);
gpu::gles2::ProgramCache* program_cache();
gpu::gles2::ShaderTranslatorCache* shader_translator_cache();
@@ -161,18 +147,33 @@ class CONTENT_EXPORT GpuChannelManager {
base::ScopedPtrHashMap<int32_t, scoped_ptr<GpuChannel>> gpu_channels_;
private:
- void InternalDestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, int client_id);
- void InternalDestroyGpuMemoryBufferOnIO(gfx::GpuMemoryBufferId id,
- int client_id);
+ // Message handlers.
+ bool OnControlMessageReceived(const IPC::Message& msg);
+ void OnEstablishChannel(const GpuMsg_EstablishChannel_Params& params);
+ void OnCloseChannel(const IPC::ChannelHandle& channel_handle);
+ void OnVisibilityChanged(int32_t render_view_id,
+ int32_t client_id,
+ bool visible);
+ void OnLoadedShader(const std::string& shader);
+ void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, int client_id);
+ void DestroyGpuMemoryBufferOnIO(gfx::GpuMemoryBufferId id, int client_id);
+ void OnDestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id,
+ int client_id,
+ const gpu::SyncToken& sync_token);
+
+ void OnUpdateValueState(int client_id,
+ unsigned int target,
+ const gpu::ValueState& state);
#if defined(OS_ANDROID)
+ void OnWakeUpGpu();
void ScheduleWakeUpGpu();
void DoWakeUpGpu();
#endif
+ void OnLoseAllContexts();
- GpuChannelManagerDelegate* const delegate_;
-#if defined(OS_MACOSX)
- IDMap<ImageTransportHelper> image_transport_map_;
-#endif
+ // Used to send and receive IPC messages from the browser process.
+ IPC::SyncChannel* const channel_;
+ IPC::MessageRouter router_;
GpuWatchdog* watchdog_;
diff --git a/content/common/gpu/gpu_channel_manager_delegate.h b/content/common/gpu/gpu_channel_manager_delegate.h
deleted file mode 100644
index c05556a..0000000
--- a/content/common/gpu/gpu_channel_manager_delegate.h
+++ /dev/null
@@ -1,79 +0,0 @@
-// Copyright 2016 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 CONTENT_COMMON_GPU_GPU_CHANNEL_MANAGER_DELEGATE_H_
-#define CONTENT_COMMON_GPU_GPU_CHANNEL_MANAGER_DELEGATE_H_
-
-#include "gpu/command_buffer/common/constants.h"
-#include "ui/gfx/native_widget_types.h"
-
-class GURL;
-
-namespace IPC {
-struct ChannelHandle;
-}
-
-namespace content {
-
-struct AcceleratedSurfaceBuffersSwappedParams;
-struct GPUMemoryUmaStats;
-
-class GpuChannelManagerDelegate {
- public:
- // Tells the delegate that a context has subscribed to a new target and
- // the browser should start sending the corresponding information
- virtual void AddSubscription(int32_t client_id, unsigned int target) = 0;
-
- // Response from GPU to an EstablishChannel request.
- virtual void ChannelEstablished(const IPC::ChannelHandle& channel_handle) = 0;
-
- // Tells the delegate that an offscreen context was created for the provided
- // |active_url|.
- virtual void DidCreateOffscreenContext(const GURL& active_url) = 0;
-
- // Notification from GPU that the channel is destroyed.
- virtual void DidDestroyChannel(int client_id) = 0;
-
- // Tells the delegate that an offscreen context was destroyed for the provided
- // |active_url|.
- virtual void DidDestroyOffscreenContext(const GURL& active_url) = 0;
-
- // Tells the delegate that a context was lost.
- virtual void DidLoseContext(bool offscreen,
- gpu::error::ContextLostReason reason,
- const GURL& active_url) = 0;
-
- // Tells the delegate about GPU memory usage statistics for UMA logging.
- virtual void GpuMemoryUmaStats(const GPUMemoryUmaStats& params) = 0;
-
- // Tells the delegate that no contexts are subscribed to the target anymore
- // so the delegate should stop sending the corresponding information.
- virtual void RemoveSubscription(int32_t client_id, unsigned int target) = 0;
-
- // Tells the delegate to cache the given shader information in persistent
- // storage. The embedder is expected to repopulate the in-memory cache through
- // the respective GpuChannelManager API.
- virtual void StoreShaderToDisk(int32_t client_id,
- const std::string& key,
- const std::string& shader) = 0;
-
-#if defined(OS_MACOSX)
- // Tells the delegate that an accelerated surface has swapped.
- virtual void SendAcceleratedSurfaceBuffersSwapped(
- const AcceleratedSurfaceBuffersSwappedParams& params) = 0;
-#endif
-
-#if defined(OS_WIN)
- virtual void SendAcceleratedSurfaceCreatedChildWindow(
- const gfx::PluginWindowHandle& parent_window,
- const gfx::PluginWindowHandle& child_window) = 0;
-#endif
-
- protected:
- virtual ~GpuChannelManagerDelegate() {}
-};
-
-} // namespace content
-
-#endif // CONTENT_COMMON_GPU_GPU_CHANNEL_MANAGER_DELEGATE_H_
diff --git a/content/common/gpu/gpu_channel_manager_unittest.cc b/content/common/gpu/gpu_channel_manager_unittest.cc
index f279d00..984de95 100644
--- a/content/common/gpu/gpu_channel_manager_unittest.cc
+++ b/content/common/gpu/gpu_channel_manager_unittest.cc
@@ -5,13 +5,14 @@
#include <stddef.h>
#include <stdint.h>
-#include "content/common/gpu/establish_channel_params.h"
#include "content/common/gpu/gpu_channel.h"
#include "content/common/gpu/gpu_channel_manager.h"
#include "content/common/gpu/gpu_channel_test_common.h"
+#include "content/common/gpu/gpu_messages.h"
#include "gpu/command_buffer/common/value_state.h"
#include "gpu/command_buffer/service/gl_utils.h"
#include "gpu/command_buffer/service/valuebuffer_manager.h"
+#include "ipc/ipc_test_sink.h"
using gpu::gles2::ValuebufferManager;
using gpu::ValueState;
@@ -30,20 +31,26 @@ TEST_F(GpuChannelManagerTest, EstablishChannel) {
ASSERT_TRUE(channel_manager());
- EstablishChannelParams params;
+ GpuMsg_EstablishChannel_Params params;
params.client_id = kClientId;
params.client_tracing_id = kClientTracingId;
params.preempts = false;
params.allow_view_command_buffers = false;
params.allow_real_time_streams = false;
- channel_manager()->EstablishChannel(params);
- IPC::ChannelHandle handle =
- channel_manager_delegate()->last_established_channel_handle();
- EXPECT_NE("", handle.name);
+ EXPECT_TRUE(
+ channel_manager()->OnMessageReceived(GpuMsg_EstablishChannel(params)));
+ EXPECT_EQ((size_t)1, sink()->message_count());
+ const IPC::Message* msg =
+ sink()->GetUniqueMessageMatching(GpuHostMsg_ChannelEstablished::ID);
+ ASSERT_TRUE(msg);
+ base::Tuple<IPC::ChannelHandle> handle;
+ ASSERT_TRUE(GpuHostMsg_ChannelEstablished::Read(msg, &handle));
+ EXPECT_NE("", base::get<0>(handle).name);
+ sink()->ClearMessages();
GpuChannel* channel = channel_manager()->LookupChannel(kClientId);
ASSERT_TRUE(channel);
- EXPECT_EQ(handle.name, channel->channel_id());
+ EXPECT_EQ(base::get<0>(handle).name, channel->channel_id());
}
TEST_F(GpuChannelManagerTest, SecureValueStateForwarding) {
@@ -65,29 +72,31 @@ TEST_F(GpuChannelManagerTest, SecureValueStateForwarding) {
ASSERT_TRUE(channel_manager());
// Initialize gpu channels
- EstablishChannelParams params;
+ GpuMsg_EstablishChannel_Params params;
params.client_id = kClientId1;
params.client_tracing_id = kClientTracingId1;
params.preempts = false;
params.allow_view_command_buffers = false;
params.allow_real_time_streams = false;
- channel_manager()->EstablishChannel(params);
+ EXPECT_TRUE(
+ channel_manager()->OnMessageReceived(GpuMsg_EstablishChannel(params)));
GpuChannel* channel1 = channel_manager()->LookupChannel(kClientId1);
ASSERT_TRUE(channel1);
params.client_id = kClientId2;
params.client_tracing_id = kClientTracingId2;
- channel_manager()->EstablishChannel(params);
+ EXPECT_TRUE(
+ channel_manager()->OnMessageReceived(GpuMsg_EstablishChannel(params)));
GpuChannel* channel2 = channel_manager()->LookupChannel(kClientId2);
ASSERT_TRUE(channel2);
EXPECT_NE(channel1, channel2);
// Make sure value states are only accessible by proper channels
- channel_manager()->UpdateValueState(kClientId1, GL_MOUSE_POSITION_CHROMIUM,
- value_state1);
- channel_manager()->UpdateValueState(kClientId2, GL_MOUSE_POSITION_CHROMIUM,
- value_state2);
+ channel_manager()->OnMessageReceived(GpuMsg_UpdateValueState(
+ kClientId1, GL_MOUSE_POSITION_CHROMIUM, value_state1));
+ channel_manager()->OnMessageReceived(GpuMsg_UpdateValueState(
+ kClientId2, GL_MOUSE_POSITION_CHROMIUM, value_state2));
const gpu::ValueStateMap* pending_value_buffer_state1 =
channel1->pending_valuebuffer_state();
diff --git a/content/common/gpu/gpu_channel_test_common.cc b/content/common/gpu/gpu_channel_test_common.cc
index ad83c2d..2e8be03 100644
--- a/content/common/gpu/gpu_channel_test_common.cc
+++ b/content/common/gpu/gpu_channel_test_common.cc
@@ -6,72 +6,25 @@
#include "base/test/test_simple_task_runner.h"
#include "base/thread_task_runner_handle.h"
-#include "content/common/gpu/gpu_channel_manager_delegate.h"
#include "gpu/command_buffer/service/sync_point_manager.h"
#include "ipc/ipc_test_sink.h"
namespace content {
-TestGpuChannelManagerDelegate::TestGpuChannelManagerDelegate() {}
-
-TestGpuChannelManagerDelegate::~TestGpuChannelManagerDelegate() {}
-
-void TestGpuChannelManagerDelegate::AddSubscription(int32_t client_id,
- unsigned int target) {}
-
-void TestGpuChannelManagerDelegate::ChannelEstablished(
- const IPC::ChannelHandle& channel_handle) {
- last_established_channel_handle_ = channel_handle;
-}
-
-void TestGpuChannelManagerDelegate::DidCreateOffscreenContext(
- const GURL& active_url) {}
-
-void TestGpuChannelManagerDelegate::DidDestroyChannel(int client_id) {}
-
-void TestGpuChannelManagerDelegate::DidDestroyOffscreenContext(
- const GURL& active_url) {}
-
-void TestGpuChannelManagerDelegate::DidLoseContext(
- bool offscreen,
- gpu::error::ContextLostReason reason,
- const GURL& active_url) {}
-
-void TestGpuChannelManagerDelegate::GpuMemoryUmaStats(
- const GPUMemoryUmaStats& params) {}
-
-void TestGpuChannelManagerDelegate::RemoveSubscription(int32_t client_id,
- unsigned int target) {}
-
-void TestGpuChannelManagerDelegate::StoreShaderToDisk(
- int32_t client_id,
- const std::string& key,
- const std::string& shader) {}
-
-#if defined(OS_MACOSX)
-void TestGpuChannelManagerDelegate::SendAcceleratedSurfaceBuffersSwapped(
- const AcceleratedSurfaceBuffersSwappedParams& params) {}
-#endif
-
-#if defined(OS_WIN)
-void TestGpuChannelManagerDelegate::SendAcceleratedSurfaceCreatedChildWindow(
- const gfx::PluginWindowHandle& parent_window,
- const gfx::PluginWindowHandle& child_window) {}
-#endif
-
TestGpuChannelManager::TestGpuChannelManager(
- GpuChannelManagerDelegate* delegate,
+ IPC::TestSink* sink,
base::SingleThreadTaskRunner* task_runner,
base::SingleThreadTaskRunner* io_task_runner,
gpu::SyncPointManager* sync_point_manager,
GpuMemoryBufferFactory* gpu_memory_buffer_factory)
- : GpuChannelManager(delegate,
+ : GpuChannelManager(nullptr,
nullptr,
task_runner,
io_task_runner,
nullptr,
sync_point_manager,
- gpu_memory_buffer_factory) {}
+ gpu_memory_buffer_factory),
+ sink_(sink) {}
TestGpuChannelManager::~TestGpuChannelManager() {
// Clear gpu channels here so that any IPC messages sent are handled using the
@@ -79,6 +32,10 @@ TestGpuChannelManager::~TestGpuChannelManager() {
gpu_channels_.clear();
}
+bool TestGpuChannelManager::Send(IPC::Message* msg) {
+ return sink_->Send(msg);
+}
+
scoped_ptr<GpuChannel> TestGpuChannelManager::CreateGpuChannel(
int client_id,
uint64_t client_tracing_id,
@@ -86,14 +43,15 @@ scoped_ptr<GpuChannel> TestGpuChannelManager::CreateGpuChannel(
bool allow_view_command_buffers,
bool allow_real_time_streams) {
return make_scoped_ptr(new TestGpuChannel(
- this, sync_point_manager(), share_group(), mailbox_manager(),
+ sink_, this, sync_point_manager(), share_group(), mailbox_manager(),
preempts ? preemption_flag() : nullptr,
preempts ? nullptr : preemption_flag(), task_runner_.get(),
io_task_runner_.get(), client_id, client_tracing_id,
allow_view_command_buffers, allow_real_time_streams));
}
-TestGpuChannel::TestGpuChannel(GpuChannelManager* gpu_channel_manager,
+TestGpuChannel::TestGpuChannel(IPC::TestSink* sink,
+ GpuChannelManager* gpu_channel_manager,
gpu::SyncPointManager* sync_point_manager,
gfx::GLShareGroup* share_group,
gpu::gles2::MailboxManager* mailbox_manager,
@@ -117,7 +75,8 @@ TestGpuChannel::TestGpuChannel(GpuChannelManager* gpu_channel_manager,
client_id,
client_tracing_id,
allow_view_command_buffers,
- allow_real_time_streams) {}
+ allow_real_time_streams),
+ sink_(sink) {}
TestGpuChannel::~TestGpuChannel() {
// Call stubs here so that any IPC messages sent are handled using the
@@ -130,27 +89,26 @@ base::ProcessId TestGpuChannel::GetClientPID() const {
}
IPC::ChannelHandle TestGpuChannel::Init(base::WaitableEvent* shutdown_event) {
- filter_->OnFilterAdded(&sink_);
+ filter_->OnFilterAdded(sink_);
return IPC::ChannelHandle(channel_id());
}
bool TestGpuChannel::Send(IPC::Message* msg) {
DCHECK(!msg->is_sync());
- return sink_.Send(msg);
+ return sink_->Send(msg);
}
// TODO(sunnyps): Use a mock memory buffer factory when necessary.
GpuChannelTestCommon::GpuChannelTestCommon()
- : task_runner_(new base::TestSimpleTaskRunner),
+ : sink_(new IPC::TestSink),
+ task_runner_(new base::TestSimpleTaskRunner),
io_task_runner_(new base::TestSimpleTaskRunner),
sync_point_manager_(new gpu::SyncPointManager(false)),
- channel_manager_delegate_(new TestGpuChannelManagerDelegate()),
- channel_manager_(
- new TestGpuChannelManager(channel_manager_delegate_.get(),
- task_runner_.get(),
- io_task_runner_.get(),
- sync_point_manager_.get(),
- nullptr)) {}
+ channel_manager_(new TestGpuChannelManager(sink_.get(),
+ task_runner_.get(),
+ io_task_runner_.get(),
+ sync_point_manager_.get(),
+ nullptr)) {}
GpuChannelTestCommon::~GpuChannelTestCommon() {
// Destroying channels causes tasks to run on the IO task runner.
diff --git a/content/common/gpu/gpu_channel_test_common.h b/content/common/gpu/gpu_channel_test_common.h
index fc56738..d3243b5 100644
--- a/content/common/gpu/gpu_channel_test_common.h
+++ b/content/common/gpu/gpu_channel_test_common.h
@@ -7,8 +7,6 @@
#include "base/memory/scoped_ptr.h"
#include "content/common/gpu/gpu_channel.h"
#include "content/common/gpu/gpu_channel_manager.h"
-#include "content/common/gpu/gpu_channel_manager_delegate.h"
-#include "ipc/ipc_test_sink.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace base {
@@ -23,54 +21,18 @@ namespace content {
class SyncPointManager;
-class TestGpuChannelManagerDelegate : public GpuChannelManagerDelegate {
- public:
- TestGpuChannelManagerDelegate();
- ~TestGpuChannelManagerDelegate() override;
-
- const IPC::ChannelHandle& last_established_channel_handle() const {
- return last_established_channel_handle_;
- }
-
- private:
- // GpuChannelManagerDelegate implementation:
- void AddSubscription(int32_t client_id, unsigned int target) override;
- void ChannelEstablished(const IPC::ChannelHandle& channel_handle) override;
- void DidCreateOffscreenContext(const GURL& active_url) override;
- void DidDestroyChannel(int client_id) override;
- void DidDestroyOffscreenContext(const GURL& active_url) override;
- void DidLoseContext(bool offscreen,
- gpu::error::ContextLostReason reason,
- const GURL& active_url) override;
- void GpuMemoryUmaStats(const GPUMemoryUmaStats& params) override;
- void RemoveSubscription(int32_t client_id, unsigned int target) override;
- void StoreShaderToDisk(int32_t client_id,
- const std::string& key,
- const std::string& shader) override;
-#if defined(OS_MACOSX)
- void SendAcceleratedSurfaceBuffersSwapped(
- const AcceleratedSurfaceBuffersSwappedParams& params) override;
-#endif
-#if defined(OS_WIN)
- void SendAcceleratedSurfaceCreatedChildWindow(
- const gfx::PluginWindowHandle& parent_window,
- const gfx::PluginWindowHandle& child_window) override;
-#endif
-
- IPC::ChannelHandle last_established_channel_handle_;
-
- DISALLOW_COPY_AND_ASSIGN(TestGpuChannelManagerDelegate);
-};
-
class TestGpuChannelManager : public GpuChannelManager {
public:
- TestGpuChannelManager(GpuChannelManagerDelegate* delegate,
+ TestGpuChannelManager(IPC::TestSink* sink,
base::SingleThreadTaskRunner* task_runner,
base::SingleThreadTaskRunner* io_task_runner,
gpu::SyncPointManager* sync_point_manager,
GpuMemoryBufferFactory* gpu_memory_buffer_factory);
~TestGpuChannelManager() override;
+ // IPC::Sender implementation.
+ bool Send(IPC::Message* msg) override;
+
protected:
scoped_ptr<GpuChannel> CreateGpuChannel(
int client_id,
@@ -78,11 +40,15 @@ class TestGpuChannelManager : public GpuChannelManager {
bool preempts,
bool allow_view_command_buffers,
bool allow_real_time_streams) override;
+
+ private:
+ IPC::TestSink* const sink_;
};
class TestGpuChannel : public GpuChannel {
public:
- TestGpuChannel(GpuChannelManager* gpu_channel_manager,
+ TestGpuChannel(IPC::TestSink* sink,
+ GpuChannelManager* gpu_channel_manager,
gpu::SyncPointManager* sync_point_manager,
gfx::GLShareGroup* share_group,
gpu::gles2::MailboxManager* mailbox_manager,
@@ -96,7 +62,6 @@ class TestGpuChannel : public GpuChannel {
bool allow_real_time_streams);
~TestGpuChannel() override;
- IPC::TestSink* sink() { return &sink_; }
base::ProcessId GetClientPID() const override;
IPC::ChannelHandle Init(base::WaitableEvent* shutdown_event) override;
@@ -105,7 +70,7 @@ class TestGpuChannel : public GpuChannel {
bool Send(IPC::Message* msg) override;
private:
- IPC::TestSink sink_;
+ IPC::TestSink* const sink_;
};
class GpuChannelTestCommon : public testing::Test {
@@ -114,17 +79,15 @@ class GpuChannelTestCommon : public testing::Test {
~GpuChannelTestCommon() override;
protected:
+ IPC::TestSink* sink() { return sink_.get(); }
GpuChannelManager* channel_manager() { return channel_manager_.get(); }
- TestGpuChannelManagerDelegate* channel_manager_delegate() {
- return channel_manager_delegate_.get();
- }
base::TestSimpleTaskRunner* task_runner() { return task_runner_.get(); }
private:
+ scoped_ptr<IPC::TestSink> sink_;
scoped_refptr<base::TestSimpleTaskRunner> task_runner_;
scoped_refptr<base::TestSimpleTaskRunner> io_task_runner_;
scoped_ptr<gpu::SyncPointManager> sync_point_manager_;
- scoped_ptr<TestGpuChannelManagerDelegate> channel_manager_delegate_;
scoped_ptr<GpuChannelManager> channel_manager_;
};
diff --git a/content/common/gpu/gpu_channel_unittest.cc b/content/common/gpu/gpu_channel_unittest.cc
index 2b0ba2c..cecd765 100644
--- a/content/common/gpu/gpu_channel_unittest.cc
+++ b/content/common/gpu/gpu_channel_unittest.cc
@@ -5,7 +5,6 @@
#include <stdint.h>
#include "base/test/test_simple_task_runner.h"
-#include "content/common/gpu/establish_channel_params.h"
#include "content/common/gpu/gpu_channel.h"
#include "content/common/gpu/gpu_channel_manager.h"
#include "content/common/gpu/gpu_channel_test_common.h"
@@ -24,22 +23,23 @@ class GpuChannelTest : public GpuChannelTestCommon {
bool allow_real_time_streams) {
DCHECK(channel_manager());
uint64_t kClientTracingId = 1;
- EstablishChannelParams params;
+ GpuMsg_EstablishChannel_Params params;
params.client_id = client_id;
params.client_tracing_id = kClientTracingId;
params.preempts = false;
params.allow_view_command_buffers = allow_view_command_buffers;
params.allow_real_time_streams = allow_real_time_streams;
- channel_manager()->EstablishChannel(params);
+ EXPECT_TRUE(
+ channel_manager()->OnMessageReceived(GpuMsg_EstablishChannel(params)));
+ sink()->ClearMessages();
return channel_manager()->LookupChannel(client_id);
}
void HandleMessage(GpuChannel* channel, IPC::Message* msg) {
- TestGpuChannel* test_channel = static_cast<TestGpuChannel*>(channel);
- test_channel->HandleMessageForTesting(*msg);
+ channel->HandleMessageForTesting(*msg);
if (msg->is_sync()) {
- const IPC::Message* reply_msg = test_channel->sink()->GetMessageAt(0);
+ const IPC::Message* reply_msg = sink()->GetMessageAt(0);
ASSERT_TRUE(reply_msg);
EXPECT_TRUE(IPC::SyncMessage::IsMessageReplyTo(
@@ -52,7 +52,7 @@ class GpuChannelTest : public GpuChannelTestCommon {
delete deserializer;
- test_channel->sink()->ClearMessages();
+ sink()->ClearMessages();
}
delete msg;
diff --git a/content/common/gpu/gpu_command_buffer_stub.cc b/content/common/gpu/gpu_command_buffer_stub.cc
index eae3cd4..5fd4726 100644
--- a/content/common/gpu/gpu_command_buffer_stub.cc
+++ b/content/common/gpu/gpu_command_buffer_stub.cc
@@ -18,7 +18,6 @@
#include "build/build_config.h"
#include "content/common/gpu/gpu_channel.h"
#include "content/common/gpu/gpu_channel_manager.h"
-#include "content/common/gpu/gpu_channel_manager_delegate.h"
#include "content/common/gpu/gpu_memory_manager.h"
#include "content/common/gpu/gpu_memory_tracking.h"
#include "content/common/gpu/gpu_messages.h"
@@ -468,8 +467,10 @@ void GpuCommandBufferStub::Destroy() {
if (initialized_) {
GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager();
- if (handle_.is_null() && !active_url_.is_empty())
- gpu_channel_manager->delegate()->DidDestroyOffscreenContext(active_url_);
+ if (handle_.is_null() && !active_url_.is_empty()) {
+ gpu_channel_manager->Send(
+ new GpuHostMsg_DidDestroyOffscreenContext(active_url_));
+ }
}
if (decoder_)
@@ -668,8 +669,10 @@ void GpuCommandBufferStub::OnInitialize(
reply_message, true, capabilities);
Send(reply_message);
- if (handle_.is_null() && !active_url_.is_empty())
- manager->delegate()->DidCreateOffscreenContext(active_url_);
+ if (handle_.is_null() && !active_url_.is_empty()) {
+ manager->Send(new GpuHostMsg_DidCreateOffscreenContext(
+ active_url_));
+ }
initialized_ = true;
}
@@ -732,8 +735,8 @@ void GpuCommandBufferStub::OnParseError() {
// determine whether client APIs like WebGL need to be immediately
// blocked from automatically running.
GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager();
- gpu_channel_manager->delegate()->DidLoseContext(
- handle_.is_null(), state.context_lost_reason, active_url_);
+ gpu_channel_manager->Send(new GpuHostMsg_DidLoseContext(
+ handle_.is_null(), state.context_lost_reason, active_url_));
CheckContextLost();
}
diff --git a/content/common/gpu/gpu_host_messages.h b/content/common/gpu/gpu_host_messages.h
deleted file mode 100644
index 743024f..0000000
--- a/content/common/gpu/gpu_host_messages.h
+++ /dev/null
@@ -1,276 +0,0 @@
-// Copyright 2016 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.
-
-// Multiply-included message file, hence no include guard here, but see below
-// for a much smaller-than-usual include guard section.
-
-#include "build/build_config.h"
-#include "content/common/content_export.h"
-#include "content/common/content_param_traits.h"
-#include "content/common/gpu/establish_channel_params.h"
-#include "content/common/gpu/gpu_memory_uma_stats.h"
-#include "content/common/gpu/gpu_process_launch_causes.h"
-#include "content/public/common/common_param_traits.h"
-#include "content/public/common/gpu_memory_stats.h"
-#include "gpu/command_buffer/common/sync_token.h"
-#include "gpu/command_buffer/common/value_state.h"
-#include "gpu/config/gpu_info.h"
-#include "ipc/ipc_channel_handle.h"
-#include "ipc/ipc_message_macros.h"
-#include "ipc/ipc_message_start.h"
-#include "ui/gfx/gpu_memory_buffer.h"
-#include "ui/gfx/ipc/gfx_param_traits.h"
-#include "ui/gfx/native_widget_types.h"
-#include "url/gurl.h"
-
-#if defined(OS_MACOSX)
-#include "content/common/gpu/accelerated_surface_buffers_swapped_params_mac.h"
-#include "content/common/gpu/buffer_presented_params_mac.h"
-#include "ui/base/cocoa/remote_layer_api.h"
-#include "ui/gfx/mac/io_surface.h"
-#endif
-
-#undef IPC_MESSAGE_EXPORT
-#define IPC_MESSAGE_EXPORT CONTENT_EXPORT
-
-#define IPC_MESSAGE_START GpuMsgStart
-
-IPC_ENUM_TRAITS_MAX_VALUE(content::CauseForGpuLaunch,
- content::CAUSE_FOR_GPU_LAUNCH_MAX_ENUM - 1)
-
-IPC_STRUCT_TRAITS_BEGIN(content::GPUMemoryUmaStats)
- IPC_STRUCT_TRAITS_MEMBER(bytes_allocated_current)
- IPC_STRUCT_TRAITS_MEMBER(bytes_allocated_max)
-IPC_STRUCT_TRAITS_END()
-
-IPC_STRUCT_TRAITS_BEGIN(content::GPUVideoMemoryUsageStats)
- IPC_STRUCT_TRAITS_MEMBER(process_map)
- IPC_STRUCT_TRAITS_MEMBER(bytes_allocated)
- IPC_STRUCT_TRAITS_MEMBER(bytes_allocated_historical_max)
-IPC_STRUCT_TRAITS_END()
-
-IPC_STRUCT_TRAITS_BEGIN(content::GPUVideoMemoryUsageStats::ProcessStats)
- IPC_STRUCT_TRAITS_MEMBER(video_memory)
- IPC_STRUCT_TRAITS_MEMBER(has_duplicates)
-IPC_STRUCT_TRAITS_END()
-
-IPC_STRUCT_BEGIN(GpuMsg_CreateGpuMemoryBuffer_Params)
- IPC_STRUCT_MEMBER(gfx::GpuMemoryBufferId, id)
- IPC_STRUCT_MEMBER(gfx::Size, size)
- IPC_STRUCT_MEMBER(gfx::BufferFormat, format)
- IPC_STRUCT_MEMBER(gfx::BufferUsage, usage)
- IPC_STRUCT_MEMBER(int32_t, client_id)
- IPC_STRUCT_MEMBER(gfx::PluginWindowHandle, surface_handle)
-IPC_STRUCT_END()
-
-IPC_STRUCT_BEGIN(GpuMsg_CreateGpuMemoryBufferFromHandle_Params)
- IPC_STRUCT_MEMBER(gfx::GpuMemoryBufferHandle, handle)
- IPC_STRUCT_MEMBER(gfx::GpuMemoryBufferId, id)
- IPC_STRUCT_MEMBER(gfx::Size, size)
- IPC_STRUCT_MEMBER(gfx::BufferFormat, format)
- IPC_STRUCT_MEMBER(int32_t, client_id)
-IPC_STRUCT_END()
-
-IPC_STRUCT_TRAITS_BEGIN(content::EstablishChannelParams)
- IPC_STRUCT_TRAITS_MEMBER(client_id)
- IPC_STRUCT_TRAITS_MEMBER(client_tracing_id)
- IPC_STRUCT_TRAITS_MEMBER(preempts)
- IPC_STRUCT_TRAITS_MEMBER(allow_view_command_buffers)
- IPC_STRUCT_TRAITS_MEMBER(allow_real_time_streams)
-IPC_STRUCT_TRAITS_END()
-
-#if defined(OS_MACOSX)
-IPC_STRUCT_TRAITS_BEGIN(content::AcceleratedSurfaceBuffersSwappedParams)
- IPC_STRUCT_TRAITS_MEMBER(surface_id)
- // Only one of ca_context_id or io_surface may be non-0.
- IPC_STRUCT_TRAITS_MEMBER(ca_context_id)
- IPC_STRUCT_TRAITS_MEMBER(io_surface)
- IPC_STRUCT_TRAITS_MEMBER(size)
- IPC_STRUCT_TRAITS_MEMBER(scale_factor)
- IPC_STRUCT_TRAITS_MEMBER(latency_info)
-IPC_STRUCT_TRAITS_END()
-
-IPC_STRUCT_TRAITS_BEGIN(content::BufferPresentedParams)
- // The vsync parameters, to synchronize presentation with the display.
- IPC_STRUCT_TRAITS_MEMBER(surface_id)
- IPC_STRUCT_TRAITS_MEMBER(vsync_timebase)
- IPC_STRUCT_TRAITS_MEMBER(vsync_interval)
-IPC_STRUCT_TRAITS_END()
-#endif
-
-//------------------------------------------------------------------------------
-// GPU Messages
-// These are messages from the browser to the GPU process.
-
-// Tells the GPU process to initialize itself. The browser explicitly
-// requests this be done so that we are guaranteed that the channel is set
-// up between the browser and GPU process before doing any work that might
-// potentially crash the GPU process. Detection of the child process
-// exiting abruptly is predicated on having the IPC channel set up.
-IPC_MESSAGE_CONTROL0(GpuMsg_Initialize)
-
-// Tells the GPU process to shutdown itself.
-IPC_MESSAGE_CONTROL0(GpuMsg_Finalize)
-
-// Tells the GPU process to create a new channel for communication with a
-// given client. The channel name is returned in a
-// GpuHostMsg_ChannelEstablished message. The client ID is passed so
-// that
-// the GPU process reuses an existing channel to that process if it exists.
-// This ID is a unique opaque identifier generated by the browser process.
-// The client_tracing_id is a unique ID used for the purposes of tracing.
-IPC_MESSAGE_CONTROL1(GpuMsg_EstablishChannel,
- content::EstablishChannelParams /* params */)
-
-// Tells the GPU process to close the channel identified by IPC channel
-// handle. If no channel can be identified, do nothing.
-IPC_MESSAGE_CONTROL1(GpuMsg_CloseChannel,
- IPC::ChannelHandle /* channel_handle */)
-
-// Tells the GPU process to create a new gpu memory buffer.
-IPC_MESSAGE_CONTROL1(GpuMsg_CreateGpuMemoryBuffer,
- GpuMsg_CreateGpuMemoryBuffer_Params)
-
-// Tells the GPU process to create a new gpu memory buffer from an existing
-// handle.
-IPC_MESSAGE_CONTROL1(GpuMsg_CreateGpuMemoryBufferFromHandle,
- GpuMsg_CreateGpuMemoryBufferFromHandle_Params)
-
-// Tells the GPU process to destroy buffer.
-IPC_MESSAGE_CONTROL3(GpuMsg_DestroyGpuMemoryBuffer,
- gfx::GpuMemoryBufferId, /* id */
- int32_t, /* client_id */
- gpu::SyncToken /* sync_token */)
-
-// Tells the GPU process to create a context for collecting graphics card
-// information.
-IPC_MESSAGE_CONTROL0(GpuMsg_CollectGraphicsInfo)
-
-// Tells the GPU process to report video_memory information for the task manager
-IPC_MESSAGE_CONTROL0(GpuMsg_GetVideoMemoryUsageStats)
-
-#if defined(OS_MACOSX)
-// Tells the GPU process that the browser process has handled the swap
-// buffers or post sub-buffer request.
-IPC_MESSAGE_CONTROL1(AcceleratedSurfaceMsg_BufferPresented,
- content::BufferPresentedParams)
-#endif
-
-#if defined(OS_ANDROID)
-// Tells the GPU process to wake up the GPU because we're about to draw.
-IPC_MESSAGE_CONTROL0(GpuMsg_WakeUpGpu)
-#endif
-
-// Tells the GPU process to remove all contexts.
-IPC_MESSAGE_CONTROL0(GpuMsg_Clean)
-
-// Tells the GPU process to crash.
-IPC_MESSAGE_CONTROL0(GpuMsg_Crash)
-
-// Tells the GPU process to hang.
-IPC_MESSAGE_CONTROL0(GpuMsg_Hang)
-
-// Tells the GPU process to disable the watchdog thread.
-IPC_MESSAGE_CONTROL0(GpuMsg_DisableWatchdog)
-
-// Tells the GPU process that the browser has seen a GPU switch.
-IPC_MESSAGE_CONTROL0(GpuMsg_GpuSwitched)
-
-// Sends an input event to the gpu service.
-IPC_MESSAGE_CONTROL3(GpuMsg_UpdateValueState,
- int, /* client_id */
- unsigned int, /* target */
- gpu::ValueState /* valuestate */)
-
-//------------------------------------------------------------------------------
-// GPU Host Messages
-// These are messages to the browser.
-
-// A renderer sends this when it wants to create a connection to the GPU
-// process. The browser will create the GPU process if necessary, and will
-// return a handle to the channel via a GpuChannelEstablished message.
-IPC_SYNC_MESSAGE_CONTROL1_3(GpuHostMsg_EstablishGpuChannel,
- content::CauseForGpuLaunch,
- int /* client id */,
- IPC::ChannelHandle /* handle to channel */,
- gpu::GPUInfo /* stats about GPU process*/)
-
-// A renderer sends this when it wants to know whether a gpu process exists.
-IPC_SYNC_MESSAGE_CONTROL0_1(GpuHostMsg_HasGpuProcess, bool /* result */)
-
-// Response from GPU to a GputMsg_Initialize message.
-IPC_MESSAGE_CONTROL2(GpuHostMsg_Initialized,
- bool /* result */,
- ::gpu::GPUInfo /* gpu_info */)
-
-// Response from GPU to a GpuHostMsg_EstablishChannel message.
-IPC_MESSAGE_CONTROL1(GpuHostMsg_ChannelEstablished,
- IPC::ChannelHandle /* channel_handle */)
-
-// Message from GPU to notify to destroy the channel.
-IPC_MESSAGE_CONTROL1(GpuHostMsg_DestroyChannel, int32_t /* client_id */)
-
-// Message to cache the given shader information.
-IPC_MESSAGE_CONTROL3(GpuHostMsg_CacheShader,
- int32_t /* client_id */,
- std::string /* key */,
- std::string /* shader */)
-
-// Message to the GPU that a shader was loaded from disk.
-IPC_MESSAGE_CONTROL1(GpuMsg_LoadedShader, std::string /* encoded shader */)
-
-// Response from GPU to a GpuMsg_CreateGpuMemoryBuffer message.
-IPC_MESSAGE_CONTROL1(GpuHostMsg_GpuMemoryBufferCreated,
- gfx::GpuMemoryBufferHandle /* handle */)
-
-// Response from GPU to a GpuMsg_CollectGraphicsInfo.
-IPC_MESSAGE_CONTROL1(GpuHostMsg_GraphicsInfoCollected,
- gpu::GPUInfo /* GPU logging stats */)
-
-// Response from GPU to a GpuMsg_GetVideoMemory.
-IPC_MESSAGE_CONTROL1(GpuHostMsg_VideoMemoryUsageStats,
- content::GPUVideoMemoryUsageStats /* GPU memory stats */)
-
-#if defined(OS_MACOSX)
-// Tells the browser that an accelerated surface has swapped.
-IPC_MESSAGE_CONTROL1(GpuHostMsg_AcceleratedSurfaceBuffersSwapped,
- content::AcceleratedSurfaceBuffersSwappedParams)
-#endif
-
-#if defined(OS_WIN)
-IPC_MESSAGE_CONTROL2(GpuHostMsg_AcceleratedSurfaceCreatedChildWindow,
- gfx::PluginWindowHandle /* parent_window */,
- gfx::PluginWindowHandle /* child_window */)
-#endif
-
-IPC_MESSAGE_CONTROL1(GpuHostMsg_DidCreateOffscreenContext, GURL /* url */)
-
-IPC_MESSAGE_CONTROL3(GpuHostMsg_DidLoseContext,
- bool /* offscreen */,
- gpu::error::ContextLostReason /* reason */,
- GURL /* url */)
-
-IPC_MESSAGE_CONTROL1(GpuHostMsg_DidDestroyOffscreenContext, GURL /* url */)
-
-// Tells the browser about GPU memory usage statistics for UMA logging.
-IPC_MESSAGE_CONTROL1(GpuHostMsg_GpuMemoryUmaStats,
- content::GPUMemoryUmaStats /* GPU memory UMA stats */)
-
-// Tells the browser that a context has subscribed to a new target and
-// the browser should start sending the corresponding information
-IPC_MESSAGE_CONTROL2(GpuHostMsg_AddSubscription,
- int32_t /* client_id */,
- unsigned int /* target */)
-
-// Tells the browser that no contexts are subscribed to the target anymore
-// so the browser should stop sending the corresponding information
-IPC_MESSAGE_CONTROL2(GpuHostMsg_RemoveSubscription,
- int32_t /* client_id */,
- unsigned int /* target */)
-
-// Message from GPU to add a GPU log message to the about:gpu page.
-IPC_MESSAGE_CONTROL3(GpuHostMsg_OnLogMessage,
- int /*severity*/,
- std::string /* header */,
- std::string /* message */)
diff --git a/content/common/gpu/gpu_memory_manager.cc b/content/common/gpu/gpu_memory_manager.cc
index 920ec3c..10f769c 100644
--- a/content/common/gpu/gpu_memory_manager.cc
+++ b/content/common/gpu/gpu_memory_manager.cc
@@ -13,9 +13,9 @@
#include "base/strings/string_number_conversions.h"
#include "base/trace_event/trace_event.h"
#include "content/common/gpu/gpu_channel_manager.h"
-#include "content/common/gpu/gpu_channel_manager_delegate.h"
#include "content/common/gpu/gpu_memory_tracking.h"
#include "content/common/gpu/gpu_memory_uma_stats.h"
+#include "content/common/gpu/gpu_messages.h"
#include "gpu/command_buffer/common/gpu_memory_allocation.h"
#include "gpu/command_buffer/service/gpu_switches.h"
@@ -57,7 +57,7 @@ void GpuMemoryManager::TrackMemoryAllocatedChange(
bytes_allocated_historical_max_ = GetCurrentUsage();
// If we're blowing into new memory usage territory, spam the browser
// process with the most up-to-date information about our memory usage.
- SendUmaStatsToHost();
+ SendUmaStatsToBrowser();
}
}
@@ -112,13 +112,13 @@ void GpuMemoryManager::GetVideoMemoryUsageStats(
bytes_allocated_historical_max_;
}
-void GpuMemoryManager::SendUmaStatsToHost() {
+void GpuMemoryManager::SendUmaStatsToBrowser() {
if (!channel_manager_)
return;
GPUMemoryUmaStats params;
params.bytes_allocated_current = GetCurrentUsage();
params.bytes_allocated_max = bytes_allocated_historical_max_;
params.context_group_count = static_cast<uint32_t>(tracking_groups_.size());
- channel_manager_->delegate()->GpuMemoryUmaStats(params);
+ channel_manager_->Send(new GpuHostMsg_GpuMemoryUmaStats(params));
}
} // namespace content
diff --git a/content/common/gpu/gpu_memory_manager.h b/content/common/gpu/gpu_memory_manager.h
index 20d5d20..7de22e5 100644
--- a/content/common/gpu/gpu_memory_manager.h
+++ b/content/common/gpu/gpu_memory_manager.h
@@ -49,7 +49,7 @@ class CONTENT_EXPORT GpuMemoryManager :
TrackingGroupMap;
// Send memory usage stats to the browser process.
- void SendUmaStatsToHost();
+ void SendUmaStatsToBrowser();
// Get the current number of bytes allocated.
uint64_t GetCurrentUsage() const { return bytes_allocated_current_; }
diff --git a/content/common/gpu/gpu_messages.h b/content/common/gpu/gpu_messages.h
index 8ad2fce..e4db8b3 100644
--- a/content/common/gpu/gpu_messages.h
+++ b/content/common/gpu/gpu_messages.h
@@ -53,8 +53,10 @@
#undef IPC_MESSAGE_EXPORT
#define IPC_MESSAGE_EXPORT CONTENT_EXPORT
-#define IPC_MESSAGE_START GpuChannelMsgStart
+#define IPC_MESSAGE_START GpuMsgStart
+IPC_ENUM_TRAITS_MAX_VALUE(content::CauseForGpuLaunch,
+ content::CAUSE_FOR_GPU_LAUNCH_MAX_ENUM - 1)
IPC_ENUM_TRAITS_MAX_VALUE(gfx::GpuPreference,
gfx::GpuPreferenceLast)
IPC_ENUM_TRAITS_MAX_VALUE(content::GpuStreamPriority,
@@ -89,6 +91,50 @@ IPC_STRUCT_BEGIN(GPUCreateCommandBufferConfig)
IPC_STRUCT_MEMBER(gfx::GpuPreference, gpu_preference)
IPC_STRUCT_END()
+IPC_STRUCT_BEGIN(GpuMsg_EstablishChannel_Params)
+ IPC_STRUCT_MEMBER(int, client_id)
+ IPC_STRUCT_MEMBER(uint64_t, client_tracing_id)
+ IPC_STRUCT_MEMBER(bool, preempts)
+ IPC_STRUCT_MEMBER(bool, allow_view_command_buffers)
+ IPC_STRUCT_MEMBER(bool, allow_real_time_streams)
+IPC_STRUCT_END()
+
+IPC_STRUCT_BEGIN(GpuMsg_CreateGpuMemoryBuffer_Params)
+ IPC_STRUCT_MEMBER(gfx::GpuMemoryBufferId, id)
+ IPC_STRUCT_MEMBER(gfx::Size, size)
+ IPC_STRUCT_MEMBER(gfx::BufferFormat, format)
+ IPC_STRUCT_MEMBER(gfx::BufferUsage, usage)
+ IPC_STRUCT_MEMBER(int32_t, client_id)
+ IPC_STRUCT_MEMBER(gfx::PluginWindowHandle, surface_handle)
+IPC_STRUCT_END()
+
+IPC_STRUCT_BEGIN(GpuMsg_CreateGpuMemoryBufferFromHandle_Params)
+ IPC_STRUCT_MEMBER(gfx::GpuMemoryBufferHandle, handle)
+ IPC_STRUCT_MEMBER(gfx::GpuMemoryBufferId, id)
+ IPC_STRUCT_MEMBER(gfx::Size, size)
+ IPC_STRUCT_MEMBER(gfx::BufferFormat, format)
+ IPC_STRUCT_MEMBER(int32_t, client_id)
+IPC_STRUCT_END()
+
+#if defined(OS_MACOSX)
+IPC_STRUCT_BEGIN(GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params)
+ IPC_STRUCT_MEMBER(int32_t, surface_id)
+ // Only one of ca_context_id or io_surface may be non-0.
+ IPC_STRUCT_MEMBER(CAContextID, ca_context_id)
+ IPC_STRUCT_MEMBER(gfx::ScopedRefCountedIOSurfaceMachPort, io_surface)
+ IPC_STRUCT_MEMBER(int32_t, route_id)
+ IPC_STRUCT_MEMBER(gfx::Size, size)
+ IPC_STRUCT_MEMBER(float, scale_factor)
+ IPC_STRUCT_MEMBER(std::vector<ui::LatencyInfo>, latency_info)
+IPC_STRUCT_END()
+
+IPC_STRUCT_BEGIN(AcceleratedSurfaceMsg_BufferPresented_Params)
+ // The vsync parameters, to synchronize presentation with the display.
+ IPC_STRUCT_MEMBER(base::TimeTicks, vsync_timebase)
+ IPC_STRUCT_MEMBER(base::TimeDelta, vsync_interval)
+IPC_STRUCT_END()
+#endif
+
IPC_STRUCT_BEGIN(AcceleratedJpegDecoderMsg_Decode_Params)
IPC_STRUCT_MEMBER(int32_t, input_buffer_id)
IPC_STRUCT_MEMBER(gfx::Size, coded_size)
@@ -239,6 +285,22 @@ IPC_STRUCT_TRAITS_BEGIN(gpu::GPUInfo)
IPC_STRUCT_TRAITS_MEMBER(jpeg_decode_accelerator_supported)
IPC_STRUCT_TRAITS_END()
+IPC_STRUCT_TRAITS_BEGIN(content::GPUVideoMemoryUsageStats::ProcessStats)
+ IPC_STRUCT_TRAITS_MEMBER(video_memory)
+ IPC_STRUCT_TRAITS_MEMBER(has_duplicates)
+IPC_STRUCT_TRAITS_END()
+
+IPC_STRUCT_TRAITS_BEGIN(content::GPUVideoMemoryUsageStats)
+ IPC_STRUCT_TRAITS_MEMBER(process_map)
+ IPC_STRUCT_TRAITS_MEMBER(bytes_allocated)
+ IPC_STRUCT_TRAITS_MEMBER(bytes_allocated_historical_max)
+IPC_STRUCT_TRAITS_END()
+
+IPC_STRUCT_TRAITS_BEGIN(content::GPUMemoryUmaStats)
+ IPC_STRUCT_TRAITS_MEMBER(bytes_allocated_current)
+ IPC_STRUCT_TRAITS_MEMBER(bytes_allocated_max)
+IPC_STRUCT_TRAITS_END()
+
IPC_STRUCT_TRAITS_BEGIN(gpu::MemoryAllocation)
IPC_STRUCT_TRAITS_MEMBER(bytes_limit_when_visible)
IPC_STRUCT_TRAITS_MEMBER(priority_cutoff_when_visible)
@@ -255,6 +317,185 @@ IPC_STRUCT_TRAITS_BEGIN(media::SubsampleEntry)
IPC_STRUCT_TRAITS_END()
//------------------------------------------------------------------------------
+// GPU Messages
+// These are messages from the browser to the GPU process.
+
+// Tells the GPU process to initialize itself. The browser explicitly
+// requests this be done so that we are guaranteed that the channel is set
+// up between the browser and GPU process before doing any work that might
+// potentially crash the GPU process. Detection of the child process
+// exiting abruptly is predicated on having the IPC channel set up.
+IPC_MESSAGE_CONTROL0(GpuMsg_Initialize)
+
+// Tells the GPU process to shutdown itself.
+IPC_MESSAGE_CONTROL0(GpuMsg_Finalize)
+
+// Tells the GPU process to create a new channel for communication with a
+// given client. The channel name is returned in a
+// GpuHostMsg_ChannelEstablished message. The client ID is passed so that
+// the GPU process reuses an existing channel to that process if it exists.
+// This ID is a unique opaque identifier generated by the browser process.
+// The client_tracing_id is a unique ID used for the purposes of tracing.
+IPC_MESSAGE_CONTROL1(GpuMsg_EstablishChannel,
+ GpuMsg_EstablishChannel_Params /* params */)
+
+// Tells the GPU process to close the channel identified by IPC channel
+// handle. If no channel can be identified, do nothing.
+IPC_MESSAGE_CONTROL1(GpuMsg_CloseChannel,
+ IPC::ChannelHandle /* channel_handle */)
+
+// Tells the GPU process to create a new gpu memory buffer.
+IPC_MESSAGE_CONTROL1(GpuMsg_CreateGpuMemoryBuffer,
+ GpuMsg_CreateGpuMemoryBuffer_Params)
+
+// Tells the GPU process to create a new gpu memory buffer from an existing
+// handle.
+IPC_MESSAGE_CONTROL1(GpuMsg_CreateGpuMemoryBufferFromHandle,
+ GpuMsg_CreateGpuMemoryBufferFromHandle_Params)
+
+// Tells the GPU process to destroy buffer.
+IPC_MESSAGE_CONTROL3(GpuMsg_DestroyGpuMemoryBuffer,
+ gfx::GpuMemoryBufferId, /* id */
+ int32_t, /* client_id */
+ gpu::SyncToken /* sync_token */)
+
+// Tells the GPU process to create a context for collecting graphics card
+// information.
+IPC_MESSAGE_CONTROL0(GpuMsg_CollectGraphicsInfo)
+
+// Tells the GPU process to report video_memory information for the task manager
+IPC_MESSAGE_CONTROL0(GpuMsg_GetVideoMemoryUsageStats)
+
+#if defined(OS_MACOSX)
+// Tells the GPU process that the browser process has handled the swap
+// buffers or post sub-buffer request.
+IPC_MESSAGE_ROUTED1(AcceleratedSurfaceMsg_BufferPresented,
+ AcceleratedSurfaceMsg_BufferPresented_Params)
+#endif
+
+#if defined(OS_ANDROID)
+// Tells the GPU process to wake up the GPU because we're about to draw.
+IPC_MESSAGE_CONTROL0(GpuMsg_WakeUpGpu)
+#endif
+
+// Tells the GPU process to remove all contexts.
+IPC_MESSAGE_CONTROL0(GpuMsg_Clean)
+
+// Tells the GPU process to crash.
+IPC_MESSAGE_CONTROL0(GpuMsg_Crash)
+
+// Tells the GPU process to hang.
+IPC_MESSAGE_CONTROL0(GpuMsg_Hang)
+
+// Tells the GPU process to disable the watchdog thread.
+IPC_MESSAGE_CONTROL0(GpuMsg_DisableWatchdog)
+
+// Tells the GPU process that the browser has seen a GPU switch.
+IPC_MESSAGE_CONTROL0(GpuMsg_GpuSwitched)
+
+// Sends an input event to the gpu service.
+IPC_MESSAGE_CONTROL3(GpuMsg_UpdateValueState,
+ int, /* client_id */
+ unsigned int, /* target */
+ gpu::ValueState /* valuestate */)
+
+//------------------------------------------------------------------------------
+// GPU Host Messages
+// These are messages to the browser.
+
+// A renderer sends this when it wants to create a connection to the GPU
+// process. The browser will create the GPU process if necessary, and will
+// return a handle to the channel via a GpuChannelEstablished message.
+IPC_SYNC_MESSAGE_CONTROL1_3(GpuHostMsg_EstablishGpuChannel,
+ content::CauseForGpuLaunch,
+ int /* client id */,
+ IPC::ChannelHandle /* handle to channel */,
+ gpu::GPUInfo /* stats about GPU process*/)
+
+// A renderer sends this when it wants to know whether a gpu process exists.
+IPC_SYNC_MESSAGE_CONTROL0_1(GpuHostMsg_HasGpuProcess, bool /* result */)
+
+// Response from GPU to a GputMsg_Initialize message.
+IPC_MESSAGE_CONTROL2(GpuHostMsg_Initialized,
+ bool /* result */,
+ ::gpu::GPUInfo /* gpu_info */)
+
+// Response from GPU to a GpuHostMsg_EstablishChannel message.
+IPC_MESSAGE_CONTROL1(GpuHostMsg_ChannelEstablished,
+ IPC::ChannelHandle /* channel_handle */)
+
+// Message from GPU to notify to destroy the channel.
+IPC_MESSAGE_CONTROL1(GpuHostMsg_DestroyChannel, int32_t /* client_id */)
+
+// Message to cache the given shader information.
+IPC_MESSAGE_CONTROL3(GpuHostMsg_CacheShader,
+ int32_t /* client_id */,
+ std::string /* key */,
+ std::string /* shader */)
+
+// Message to the GPU that a shader was loaded from disk.
+IPC_MESSAGE_CONTROL1(GpuMsg_LoadedShader,
+ std::string /* encoded shader */)
+
+// Response from GPU to a GpuMsg_CreateGpuMemoryBuffer message.
+IPC_MESSAGE_CONTROL1(GpuHostMsg_GpuMemoryBufferCreated,
+ gfx::GpuMemoryBufferHandle /* handle */)
+
+// Response from GPU to a GpuMsg_CollectGraphicsInfo.
+IPC_MESSAGE_CONTROL1(GpuHostMsg_GraphicsInfoCollected,
+ gpu::GPUInfo /* GPU logging stats */)
+
+// Response from GPU to a GpuMsg_GetVideoMemory.
+IPC_MESSAGE_CONTROL1(GpuHostMsg_VideoMemoryUsageStats,
+ content::GPUVideoMemoryUsageStats /* GPU memory stats */)
+
+// Message from GPU to add a GPU log message to the about:gpu page.
+IPC_MESSAGE_CONTROL3(GpuHostMsg_OnLogMessage,
+ int /*severity*/,
+ std::string /* header */,
+ std::string /* message */)
+
+
+#if defined(OS_MACOSX)
+// Tells the browser that an accelerated surface has swapped.
+IPC_MESSAGE_CONTROL1(GpuHostMsg_AcceleratedSurfaceBuffersSwapped,
+ GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params)
+#endif
+
+#if defined(OS_WIN)
+IPC_MESSAGE_CONTROL2(GpuHostMsg_AcceleratedSurfaceCreatedChildWindow,
+ gfx::PluginWindowHandle /* parent_window */,
+ gfx::PluginWindowHandle /* child_window */)
+#endif
+
+IPC_MESSAGE_CONTROL1(GpuHostMsg_DidCreateOffscreenContext,
+ GURL /* url */)
+
+IPC_MESSAGE_CONTROL3(GpuHostMsg_DidLoseContext,
+ bool /* offscreen */,
+ gpu::error::ContextLostReason /* reason */,
+ GURL /* url */)
+
+IPC_MESSAGE_CONTROL1(GpuHostMsg_DidDestroyOffscreenContext,
+ GURL /* url */)
+
+// Tells the browser about GPU memory usage statistics for UMA logging.
+IPC_MESSAGE_CONTROL1(GpuHostMsg_GpuMemoryUmaStats,
+ content::GPUMemoryUmaStats /* GPU memory UMA stats */)
+
+// Tells the browser that a context has subscribed to a new target and
+// the browser should start sending the corresponding information
+IPC_MESSAGE_CONTROL2(GpuHostMsg_AddSubscription,
+ int32_t /* client_id */,
+ unsigned int /* target */)
+
+// Tells the browser that no contexts are subscribed to the target anymore
+// so the browser should stop sending the corresponding information
+IPC_MESSAGE_CONTROL2(GpuHostMsg_RemoveSubscription,
+ int32_t /* client_id */,
+ unsigned int /* target */)
+
+//------------------------------------------------------------------------------
// GPU Channel Messages
// These are messages from a renderer process to the GPU process.
diff --git a/content/common/gpu/image_transport_surface.cc b/content/common/gpu/image_transport_surface.cc
index eae07e9..8f5c1ab 100644
--- a/content/common/gpu/image_transport_surface.cc
+++ b/content/common/gpu/image_transport_surface.cc
@@ -14,7 +14,6 @@
#include "build/build_config.h"
#include "content/common/gpu/gpu_channel.h"
#include "content/common/gpu/gpu_channel_manager.h"
-#include "content/common/gpu/gpu_channel_manager_delegate.h"
#include "content/common/gpu/gpu_command_buffer_stub.h"
#include "content/common/gpu/gpu_messages.h"
#include "gpu/command_buffer/service/sync_point_manager.h"
@@ -23,11 +22,6 @@
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_switches.h"
-#if defined(OS_MACOSX)
-#include "content/common/gpu/accelerated_surface_buffers_swapped_params_mac.h"
-#include "ui/accelerated_widget_mac/accelerated_widget_mac.h"
-#endif
-
namespace content {
ImageTransportSurface::ImageTransportSurface() {}
@@ -59,9 +53,8 @@ ImageTransportHelper::ImageTransportHelper(ImageTransportSurface* surface,
manager_(manager),
stub_(stub->AsWeakPtr()),
handle_(handle) {
-#if defined(OS_MACOSX)
- manager_->AddImageTransportSurface(handle_, this);
-#endif
+ route_id_ = manager_->GenerateRouteID();
+ manager_->AddRoute(route_id_, this);
}
ImageTransportHelper::~ImageTransportHelper() {
@@ -69,9 +62,7 @@ ImageTransportHelper::~ImageTransportHelper() {
stub_->SetLatencyInfoCallback(
base::Callback<void(const std::vector<ui::LatencyInfo>&)>());
}
-#if defined(OS_MACOSX)
- manager_->RemoveImageTransportSurface(handle_);
-#endif
+ manager_->RemoveRoute(route_id_);
}
bool ImageTransportHelper::Initialize(gfx::GLSurface::Format format) {
@@ -87,14 +78,24 @@ bool ImageTransportHelper::Initialize(gfx::GLSurface::Format format) {
return true;
}
+bool ImageTransportHelper::OnMessageReceived(const IPC::Message& message) {
#if defined(OS_MACOSX)
-void ImageTransportHelper::BufferPresented(
- const BufferPresentedParams& params) {
- surface_->BufferPresented(params);
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(ImageTransportHelper, message)
+ IPC_MESSAGE_HANDLER(AcceleratedSurfaceMsg_BufferPresented,
+ OnBufferPresented)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+#else
+ NOTREACHED();
+ return false;
+#endif
}
+#if defined(OS_MACOSX)
void ImageTransportHelper::SendAcceleratedSurfaceBuffersSwapped(
- AcceleratedSurfaceBuffersSwappedParams params) {
+ GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params) {
// TRACE_EVENT for gpu tests:
TRACE_EVENT_INSTANT2("test_gpu", "SwapBuffers",
TRACE_EVENT_SCOPE_THREAD,
@@ -103,7 +104,8 @@ void ImageTransportHelper::SendAcceleratedSurfaceBuffersSwapped(
// On mac, handle_ is a surface id. See
// GpuProcessTransportFactory::CreatePerCompositorData
params.surface_id = handle_;
- manager_->delegate()->SendAcceleratedSurfaceBuffersSwapped(params);
+ params.route_id = route_id_;
+ manager_->Send(new GpuHostMsg_AcceleratedSurfaceBuffersSwapped(params));
}
#endif
@@ -128,6 +130,13 @@ gpu::gles2::GLES2Decoder* ImageTransportHelper::Decoder() {
return stub_->decoder();
}
+#if defined(OS_MACOSX)
+void ImageTransportHelper::OnBufferPresented(
+ const AcceleratedSurfaceMsg_BufferPresented_Params& params) {
+ surface_->OnBufferPresented(params);
+}
+#endif
+
void ImageTransportHelper::SetLatencyInfo(
const std::vector<ui::LatencyInfo>& latency_info) {
surface_->SetLatencyInfo(latency_info);
@@ -231,8 +240,8 @@ bool PassThroughImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) {
}
#if defined(OS_MACOSX)
-void PassThroughImageTransportSurface::BufferPresented(
- const BufferPresentedParams& /* params */) {
+void PassThroughImageTransportSurface::OnBufferPresented(
+ const AcceleratedSurfaceMsg_BufferPresented_Params& /* params */) {
NOTREACHED();
}
#endif
diff --git a/content/common/gpu/image_transport_surface.h b/content/common/gpu/image_transport_surface.h
index 130d5cb..d432708 100644
--- a/content/common/gpu/image_transport_surface.h
+++ b/content/common/gpu/image_transport_surface.h
@@ -26,6 +26,10 @@
#include "ui/gfx/swap_result.h"
#include "ui/gl/gl_surface.h"
+#if defined(OS_MACOSX)
+struct AcceleratedSurfaceMsg_BufferPresented_Params;
+struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params;
+#endif
namespace gfx {
class GLSurface;
@@ -41,10 +45,6 @@ class GLES2Decoder;
namespace content {
class GpuChannelManager;
class GpuCommandBufferStub;
-#if defined(OS_MACOSX)
-struct BufferPresentedParams;
-struct AcceleratedSurfaceBuffersSwappedParams;
-#endif
// The GPU process is agnostic as to how it displays results. On some platforms
// it renders directly to window. On others it renders offscreen and transports
@@ -64,7 +64,8 @@ class ImageTransportSurface {
ImageTransportSurface();
#if defined(OS_MACOSX)
- virtual void BufferPresented(const BufferPresentedParams& params) = 0;
+ virtual void OnBufferPresented(
+ const AcceleratedSurfaceMsg_BufferPresented_Params& params) = 0;
#endif
virtual void SetLatencyInfo(
const std::vector<ui::LatencyInfo>& latency_info) = 0;
@@ -103,23 +104,26 @@ class ImageTransportSurface {
};
class ImageTransportHelper
- : public base::SupportsWeakPtr<ImageTransportHelper> {
+ : public IPC::Listener,
+ public base::SupportsWeakPtr<ImageTransportHelper> {
public:
// Takes weak pointers to objects that outlive the helper.
ImageTransportHelper(ImageTransportSurface* surface,
GpuChannelManager* manager,
GpuCommandBufferStub* stub,
gfx::PluginWindowHandle handle);
- ~ImageTransportHelper();
+ ~ImageTransportHelper() override;
bool Initialize(gfx::GLSurface::Format format);
+ // IPC::Listener implementation:
+ bool OnMessageReceived(const IPC::Message& message) override;
+
// Helper send functions. Caller fills in the surface specific params
// like size and surface id. The helper fills in the rest.
#if defined(OS_MACOSX)
- void BufferPresented(const BufferPresentedParams& params);
void SendAcceleratedSurfaceBuffersSwapped(
- AcceleratedSurfaceBuffersSwappedParams params);
+ GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params);
#endif
// Make the surface's context current.
@@ -134,6 +138,12 @@ class ImageTransportHelper
private:
gpu::gles2::GLES2Decoder* Decoder();
+ // IPC::Message handlers.
+#if defined(OS_MACOSX)
+ void OnBufferPresented(
+ const AcceleratedSurfaceMsg_BufferPresented_Params& params);
+#endif
+
// Backbuffer resize callback.
void Resize(gfx::Size size, float scale_factor);
@@ -178,7 +188,8 @@ class PassThroughImageTransportSurface
// ImageTransportSurface implementation.
#if defined(OS_MACOSX)
- void BufferPresented(const BufferPresentedParams& params) override;
+ void OnBufferPresented(
+ const AcceleratedSurfaceMsg_BufferPresented_Params& params) override;
#endif
gfx::Size GetSize() override;
void SetLatencyInfo(
diff --git a/content/common/gpu/image_transport_surface_overlay_mac.h b/content/common/gpu/image_transport_surface_overlay_mac.h
index 76d4eea..97b3e24 100644
--- a/content/common/gpu/image_transport_surface_overlay_mac.h
+++ b/content/common/gpu/image_transport_surface_overlay_mac.h
@@ -63,7 +63,8 @@ class ImageTransportSurfaceOverlayMac : public gfx::GLSurface,
bool IsSurfaceless() const override;
// ImageTransportSurface implementation
- void BufferPresented(const BufferPresentedParams& params) override;
+ void OnBufferPresented(
+ const AcceleratedSurfaceMsg_BufferPresented_Params& params) override;
void SetLatencyInfo(const std::vector<ui::LatencyInfo>&) override;
// ui::GpuSwitchingObserver implementation.
diff --git a/content/common/gpu/image_transport_surface_overlay_mac.mm b/content/common/gpu/image_transport_surface_overlay_mac.mm
index 05f6512..ea8a8fd 100644
--- a/content/common/gpu/image_transport_surface_overlay_mac.mm
+++ b/content/common/gpu/image_transport_surface_overlay_mac.mm
@@ -22,10 +22,9 @@ typedef void* GLeglImageOES;
#include "base/mac/scoped_cftyperef.h"
#include "base/trace_event/trace_event.h"
-#include "content/common/gpu/accelerated_surface_buffers_swapped_params_mac.h"
-#include "content/common/gpu/buffer_presented_params_mac.h"
#include "content/common/gpu/ca_layer_partial_damage_tree_mac.h"
#include "content/common/gpu/ca_layer_tree_mac.h"
+#include "content/common/gpu/gpu_messages.h"
#include "ui/accelerated_widget_mac/io_surface_context.h"
#include "ui/base/cocoa/animation_utils.h"
#include "ui/base/cocoa/remote_layer_api.h"
@@ -310,7 +309,7 @@ void ImageTransportSurfaceOverlayMac::DisplayFirstPendingSwapImmediately() {
}
// Send acknowledgement to the browser.
- AcceleratedSurfaceBuffersSwappedParams params;
+ GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params;
if (use_remote_layer_api_) {
params.ca_context_id = [ca_context_ contextId];
} else if (current_partial_damage_tree_) {
@@ -455,8 +454,8 @@ bool ImageTransportSurfaceOverlayMac::IsSurfaceless() const {
return true;
}
-void ImageTransportSurfaceOverlayMac::BufferPresented(
- const BufferPresentedParams& params) {
+void ImageTransportSurfaceOverlayMac::OnBufferPresented(
+ const AcceleratedSurfaceMsg_BufferPresented_Params& params) {
vsync_timebase_ = params.vsync_timebase;
vsync_interval_ = params.vsync_interval;
vsync_parameters_valid_ = (vsync_interval_ != base::TimeDelta());
diff --git a/content/content_common.gypi b/content/content_common.gypi
index 4b9ec41..4de364b 100644
--- a/content/content_common.gypi
+++ b/content/content_common.gypi
@@ -339,10 +339,6 @@
'common/geofencing_types.cc',
'common/geofencing_types.h',
'common/gin_java_bridge_messages.h',
- 'common/gpu/accelerated_surface_buffers_swapped_params_mac.cc',
- 'common/gpu/accelerated_surface_buffers_swapped_params_mac.h',
- 'common/gpu/buffer_presented_params_mac.cc',
- 'common/gpu/buffer_presented_params_mac.h',
'common/gpu/client/command_buffer_metrics.cc',
'common/gpu/client/command_buffer_metrics.h',
'common/gpu/client/command_buffer_proxy_impl.cc',
@@ -379,14 +375,10 @@
'common/gpu/ca_layer_tree_mac.mm',
'common/gpu/child_window_surface_win.cc',
'common/gpu/child_window_surface_win.h',
- 'common/gpu/establish_channel_params.cc',
- 'common/gpu/establish_channel_params.h',
- 'common/gpu/gpu_host_messages.h',
'common/gpu/gpu_channel.cc',
'common/gpu/gpu_channel.h',
'common/gpu/gpu_channel_manager.cc',
'common/gpu/gpu_channel_manager.h',
- 'common/gpu/gpu_channel_manager_delegate.h',
'common/gpu/gpu_command_buffer_stub.cc',
'common/gpu/gpu_command_buffer_stub.h',
'common/gpu/gpu_config.h',
diff --git a/content/gpu/gpu_child_thread.cc b/content/gpu/gpu_child_thread.cc
index 914810e..6ea7e2e 100644
--- a/content/gpu/gpu_child_thread.cc
+++ b/content/gpu/gpu_child_thread.cc
@@ -13,9 +13,8 @@
#include "build/build_config.h"
#include "content/child/child_process.h"
#include "content/child/thread_safe_sender.h"
-#include "content/common/gpu/establish_channel_params.h"
-#include "content/common/gpu/gpu_host_messages.h"
#include "content/common/gpu/gpu_memory_buffer_factory.h"
+#include "content/common/gpu/gpu_messages.h"
#include "content/common/gpu/media/gpu_video_decode_accelerator.h"
#include "content/gpu/gpu_process_control_impl.h"
#include "content/gpu/gpu_watchdog_thread.h"
@@ -46,14 +45,14 @@ bool GpuProcessLogMessageHandler(int severity,
std::string header = str.substr(0, message_start);
std::string message = str.substr(message_start);
- g_thread_safe_sender.Get()->Send(
- new GpuHostMsg_OnLogMessage(severity, header, message));
+ g_thread_safe_sender.Get()->Send(new GpuHostMsg_OnLogMessage(
+ severity, header, message));
return false;
}
-// Message filter used to to handle GpuMsg_CreateGpuMemoryBuffer messages
-// on the IO thread. This allows the UI thread in the browser process to remain
+// Message filter used to to handle GpuMsg_CreateGpuMemoryBuffer messages on
+// the IO thread. This allows the UI thread in the browser process to remain
// fast at all times.
class GpuMemoryBufferMessageFilter : public IPC::MessageFilter {
public:
@@ -75,10 +74,10 @@ class GpuMemoryBufferMessageFilter : public IPC::MessageFilter {
DCHECK(sender_);
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(GpuMemoryBufferMessageFilter, message)
- IPC_MESSAGE_HANDLER(GpuMsg_CreateGpuMemoryBuffer, OnCreateGpuMemoryBuffer)
- IPC_MESSAGE_HANDLER(GpuMsg_CreateGpuMemoryBufferFromHandle,
- OnCreateGpuMemoryBufferFromHandle)
- IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_MESSAGE_HANDLER(GpuMsg_CreateGpuMemoryBuffer, OnCreateGpuMemoryBuffer)
+ IPC_MESSAGE_HANDLER(GpuMsg_CreateGpuMemoryBufferFromHandle,
+ OnCreateGpuMemoryBufferFromHandle)
+ IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
@@ -253,84 +252,8 @@ bool GpuChildThread::OnMessageReceived(const IPC::Message& msg) {
if (ChildThreadImpl::OnMessageReceived(msg))
return true;
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(GpuChildThread, msg)
-#if defined(OS_MACOSX)
- IPC_MESSAGE_HANDLER(AcceleratedSurfaceMsg_BufferPresented,
- OnBufferPresented)
-#endif
- IPC_MESSAGE_HANDLER(GpuMsg_EstablishChannel, OnEstablishChannel)
- IPC_MESSAGE_HANDLER(GpuMsg_CloseChannel, OnCloseChannel)
- IPC_MESSAGE_HANDLER(GpuMsg_DestroyGpuMemoryBuffer, OnDestroyGpuMemoryBuffer)
- IPC_MESSAGE_HANDLER(GpuMsg_LoadedShader, OnLoadedShader)
- IPC_MESSAGE_HANDLER(GpuMsg_UpdateValueState, OnUpdateValueState)
-#if defined(OS_ANDROID)
- IPC_MESSAGE_HANDLER(GpuMsg_WakeUpGpu, OnWakeUpGpu);
-#endif
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP()
- if (handled)
- return true;
-
- return false;
-}
-
-void GpuChildThread::AddSubscription(int32_t client_id, unsigned int target) {
- Send(new GpuHostMsg_AddSubscription(client_id, target));
-}
-
-void GpuChildThread::ChannelEstablished(
- const IPC::ChannelHandle& channel_handle) {
- Send(new GpuHostMsg_ChannelEstablished(channel_handle));
-}
-
-void GpuChildThread::DidCreateOffscreenContext(const GURL& active_url) {
- Send(new GpuHostMsg_DidCreateOffscreenContext(active_url));
-}
-
-void GpuChildThread::DidDestroyChannel(int client_id) {
- Send(new GpuHostMsg_DestroyChannel(client_id));
-}
-
-void GpuChildThread::DidDestroyOffscreenContext(const GURL& active_url) {
- Send(new GpuHostMsg_DidDestroyOffscreenContext(active_url));
-}
-
-void GpuChildThread::DidLoseContext(bool offscreen,
- gpu::error::ContextLostReason reason,
- const GURL& active_url) {
- Send(new GpuHostMsg_DidLoseContext(offscreen, reason, active_url));
-}
-
-void GpuChildThread::GpuMemoryUmaStats(const GPUMemoryUmaStats& params) {
- Send(new GpuHostMsg_GpuMemoryUmaStats(params));
-}
-
-void GpuChildThread::RemoveSubscription(int32_t client_id,
- unsigned int target) {
- Send(new GpuHostMsg_RemoveSubscription(client_id, target));
-}
-
-#if defined(OS_MACOSX)
-void GpuChildThread::SendAcceleratedSurfaceBuffersSwapped(
- const AcceleratedSurfaceBuffersSwappedParams& params) {
- Send(new GpuHostMsg_AcceleratedSurfaceBuffersSwapped(params));
-}
-#endif
-
-#if defined(OS_WIN)
-void GpuChildThread::SendAcceleratedSurfaceCreatedChildWindow(
- const gfx::PluginWindowHandle& parent_window,
- const gfx::PluginWindowHandle& child_window) {
- Send(new GpuHostMsg_AcceleratedSurfaceCreatedChildWindow(parent_window,
- child_window));
-}
-#endif
-
-void GpuChildThread::StoreShaderToDisk(int32_t client_id,
- const std::string& key,
- const std::string& shader) {
- Send(new GpuHostMsg_CacheShader(client_id, key, shader));
+ return gpu_channel_manager_.get() &&
+ gpu_channel_manager_->OnMessageReceived(msg);
}
void GpuChildThread::OnInitialize() {
@@ -357,11 +280,12 @@ void GpuChildThread::OnInitialize() {
// Defer creation of the render thread. This is to prevent it from handling
// IPC messages before the sandbox has been enabled and all other necessary
// initialization has succeeded.
- gpu_channel_manager_.reset(new GpuChannelManager(
- this, watchdog_thread_.get(), base::ThreadTaskRunnerHandle::Get().get(),
- ChildProcess::current()->io_task_runner(),
- ChildProcess::current()->GetShutDownEvent(), sync_point_manager_,
- gpu_memory_buffer_factory_));
+ gpu_channel_manager_.reset(
+ new GpuChannelManager(channel(), watchdog_thread_.get(),
+ base::ThreadTaskRunnerHandle::Get().get(),
+ ChildProcess::current()->io_task_runner(),
+ ChildProcess::current()->GetShutDownEvent(),
+ sync_point_manager_, gpu_memory_buffer_factory_));
#if defined(USE_OZONE)
ui::OzonePlatform::GetInstance()
@@ -428,16 +352,16 @@ void GpuChildThread::OnCollectGraphicsInfo() {
void GpuChildThread::OnGetVideoMemoryUsageStats() {
GPUVideoMemoryUsageStats video_memory_usage_stats;
- DCHECK(gpu_channel_manager_);
- gpu_channel_manager_->gpu_memory_manager()->GetVideoMemoryUsageStats(
- &video_memory_usage_stats);
+ if (gpu_channel_manager_)
+ gpu_channel_manager_->gpu_memory_manager()->GetVideoMemoryUsageStats(
+ &video_memory_usage_stats);
Send(new GpuHostMsg_VideoMemoryUsageStats(video_memory_usage_stats));
}
void GpuChildThread::OnClean() {
DVLOG(1) << "GPU: Removing all contexts";
- DCHECK(gpu_channel_manager_);
- gpu_channel_manager_->DestroyAllChannels();
+ if (gpu_channel_manager_)
+ gpu_channel_manager_->LoseAllContexts();
}
void GpuChildThread::OnCrash() {
@@ -473,55 +397,6 @@ void GpuChildThread::OnGpuSwitched() {
ui::GpuSwitchingManager::GetInstance()->NotifyGpuSwitched();
}
-#if defined(OS_MACOSX)
-void GpuChildThread::OnBufferPresented(const BufferPresentedParams& params) {
- DCHECK(gpu_channel_manager_);
- gpu_channel_manager_->BufferPresented(params);
-}
-#endif
-
-void GpuChildThread::OnEstablishChannel(const EstablishChannelParams& params) {
- DCHECK(gpu_channel_manager_);
- gpu_channel_manager_->EstablishChannel(params);
-}
-
-void GpuChildThread::OnCloseChannel(const IPC::ChannelHandle& channel_handle) {
- DCHECK(gpu_channel_manager_);
- gpu_channel_manager_->CloseChannel(channel_handle);
-}
-
-void GpuChildThread::OnLoadedShader(const std::string& shader) {
- DCHECK(gpu_channel_manager_);
- gpu_channel_manager_->PopulateShaderCache(shader);
-}
-
-void GpuChildThread::OnDestroyGpuMemoryBuffer(
- gfx::GpuMemoryBufferId id,
- int client_id,
- const gpu::SyncToken& sync_token) {
- DCHECK(gpu_channel_manager_);
- gpu_channel_manager_->DestroyGpuMemoryBuffer(id, client_id, sync_token);
-}
-
-void GpuChildThread::OnUpdateValueState(int client_id,
- unsigned int target,
- const gpu::ValueState& state) {
- DCHECK(gpu_channel_manager_);
- gpu_channel_manager_->UpdateValueState(client_id, target, state);
-}
-
-#if defined(OS_ANDROID)
-void GpuChildThread::OnWakeUpGpu() {
- DCHECK(gpu_channel_manager_);
- gpu_channel_manager_->WakeUpGpu();
-}
-#endif
-
-void GpuChildThread::OnLoseAllContexts() {
- DCHECK(gpu_channel_manager_);
- gpu_channel_manager_->DestroyAllChannels();
-}
-
void GpuChildThread::BindProcessControlRequest(
mojo::InterfaceRequest<ProcessControl> request) {
DVLOG(1) << "GPU: Binding ProcessControl request";
diff --git a/content/gpu/gpu_child_thread.h b/content/gpu/gpu_child_thread.h
index c279c5f..b83ff79 100644
--- a/content/gpu/gpu_child_thread.h
+++ b/content/gpu/gpu_child_thread.h
@@ -19,7 +19,6 @@
#include "content/child/child_thread_impl.h"
#include "content/common/gpu/gpu_channel.h"
#include "content/common/gpu/gpu_channel_manager.h"
-#include "content/common/gpu/gpu_channel_manager_delegate.h"
#include "content/common/gpu/gpu_config.h"
#include "content/common/gpu/x_util.h"
#include "content/common/process_control.mojom.h"
@@ -45,8 +44,7 @@ class GpuWatchdogThread;
// these per process. It does process initialization and shutdown. It forwards
// IPC messages to GpuChannelManager, which is responsible for issuing rendering
// commands to the GPU.
-class GpuChildThread : public ChildThreadImpl,
- public GpuChannelManagerDelegate {
+class GpuChildThread : public ChildThreadImpl {
public:
typedef std::queue<IPC::Message*> DeferredMessages;
@@ -74,30 +72,6 @@ class GpuChildThread : public ChildThreadImpl,
bool OnMessageReceived(const IPC::Message& msg) override;
private:
- // GpuChannelManagerDelegate implementation.
- void AddSubscription(int32_t client_id, unsigned int target) override;
- void ChannelEstablished(const IPC::ChannelHandle& channel_handle) override;
- void DidCreateOffscreenContext(const GURL& active_url) override;
- void DidDestroyChannel(int client_id) override;
- void DidDestroyOffscreenContext(const GURL& active_url) override;
- void DidLoseContext(bool offscreen,
- gpu::error::ContextLostReason reason,
- const GURL& active_url) override;
- void GpuMemoryUmaStats(const GPUMemoryUmaStats& params) override;
- void RemoveSubscription(int32_t client_id, unsigned int target) override;
-#if defined(OS_MACOSX)
- void SendAcceleratedSurfaceBuffersSwapped(
- const AcceleratedSurfaceBuffersSwappedParams& params) override;
-#endif
-#if defined(OS_WIN)
- void SendAcceleratedSurfaceCreatedChildWindow(
- const gfx::PluginWindowHandle& parent_window,
- const gfx::PluginWindowHandle& child_window) override;
-#endif
- void StoreShaderToDisk(int32_t client_id,
- const std::string& key,
- const std::string& shader) override;
-
// Message handlers.
void OnInitialize();
void OnFinalize();
@@ -111,23 +85,6 @@ class GpuChildThread : public ChildThreadImpl,
void OnDisableWatchdog();
void OnGpuSwitched();
-#if defined(OS_MACOSX)
- void OnBufferPresented(const BufferPresentedParams& params);
-#endif
- void OnEstablishChannel(const EstablishChannelParams& params);
- void OnCloseChannel(const IPC::ChannelHandle& channel_handle);
- void OnLoadedShader(const std::string& shader);
- void OnDestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id,
- int client_id,
- const gpu::SyncToken& sync_token);
- void OnUpdateValueState(int client_id,
- unsigned int target,
- const gpu::ValueState& state);
-#if defined(OS_ANDROID)
- void OnWakeUpGpu();
-#endif
- void OnLoseAllContexts();
-
void BindProcessControlRequest(
mojo::InterfaceRequest<ProcessControl> request);
diff --git a/content/gpu/gpu_main.cc b/content/gpu/gpu_main.cc
index 958e40d..7ce05a0 100644
--- a/content/gpu/gpu_main.cc
+++ b/content/gpu/gpu_main.cc
@@ -21,8 +21,8 @@
#include "content/child/child_process.h"
#include "content/common/content_constants_internal.h"
#include "content/common/gpu/gpu_config.h"
-#include "content/common/gpu/gpu_host_messages.h"
#include "content/common/gpu/gpu_memory_buffer_factory.h"
+#include "content/common/gpu/gpu_messages.h"
#include "content/common/gpu/media/gpu_jpeg_decode_accelerator.h"
#include "content/common/gpu/media/gpu_video_decode_accelerator.h"
#include "content/common/gpu/media/gpu_video_encode_accelerator.h"
@@ -121,8 +121,8 @@ bool GpuProcessLogMessageHandler(int severity,
const std::string& str) {
std::string header = str.substr(0, message_start);
std::string message = str.substr(message_start);
- deferred_messages.Get().push(
- new GpuHostMsg_OnLogMessage(severity, header, message));
+ deferred_messages.Get().push(new GpuHostMsg_OnLogMessage(
+ severity, header, message));
return false;
}
diff --git a/content/renderer/gpu/gpu_benchmarking_extension.cc b/content/renderer/gpu/gpu_benchmarking_extension.cc
index 9a3c79a..f471360 100644
--- a/content/renderer/gpu/gpu_benchmarking_extension.cc
+++ b/content/renderer/gpu/gpu_benchmarking_extension.cc
@@ -15,7 +15,7 @@
#include "base/macros.h"
#include "base/strings/string_number_conversions.h"
#include "cc/layers/layer.h"
-#include "content/common/gpu/gpu_host_messages.h"
+#include "content/common/gpu/gpu_messages.h"
#include "content/common/input/synthetic_gesture_params.h"
#include "content/common/input/synthetic_pinch_gesture_params.h"
#include "content/common/input/synthetic_smooth_drag_gesture_params.h"
diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc
index 27892b3..5b5f16c 100644
--- a/content/renderer/render_thread_impl.cc
+++ b/content/renderer/render_thread_impl.cc
@@ -75,7 +75,7 @@
#include "content/common/frame_messages.h"
#include "content/common/gpu/client/context_provider_command_buffer.h"
#include "content/common/gpu/client/gpu_channel_host.h"
-#include "content/common/gpu/gpu_host_messages.h"
+#include "content/common/gpu/gpu_messages.h"
#include "content/common/gpu/gpu_process_launch_causes.h"
#include "content/common/render_frame_setup.mojom.h"
#include "content/common/render_process_messages.h"
@@ -1873,8 +1873,10 @@ GpuChannelHost* RenderThreadImpl::EstablishGpuChannelSync(
int client_id = 0;
IPC::ChannelHandle channel_handle;
gpu::GPUInfo gpu_info;
- if (!Send(new GpuHostMsg_EstablishGpuChannel(cause_for_gpu_launch, &client_id,
- &channel_handle, &gpu_info)) ||
+ if (!Send(new GpuHostMsg_EstablishGpuChannel(cause_for_gpu_launch,
+ &client_id,
+ &channel_handle,
+ &gpu_info)) ||
#if defined(OS_POSIX)
channel_handle.socket.fd == -1 ||
#endif
diff --git a/ipc/ipc_message_start.h b/ipc/ipc_message_start.h
index 88b0204..e63e1f06c 100644
--- a/ipc/ipc_message_start.h
+++ b/ipc/ipc_message_start.h
@@ -21,7 +21,6 @@ enum IPCMessageStart {
WorkerMsgStart,
NaClMsgStart,
UtilityMsgStart,
- GpuChannelMsgStart,
GpuMsgStart,
ServiceMsgStart,
PpapiMsgStart,