#include "content/common/gpu/client/gpu_memory_buffer_impl.h"
#include "content/common/gpu/gpu_messages.h"
#include "content/common/gpu/gpu_process_launch_causes.h"
+#include "content/common/mojo/mojo_service_names.h"
#include "content/common/resource_messages.h"
#include "content/common/view_messages.h"
#include "content/common/worker_messages.h"
#include "content/renderer/service_worker/embedded_worker_context_message_filter.h"
#include "content/renderer/service_worker/embedded_worker_dispatcher.h"
#include "content/renderer/shared_worker/embedded_shared_worker_stub.h"
+#include "content/renderer/web_ui_setup_impl.h"
#include "grit/content_resources.h"
#include "ipc/ipc_channel_handle.h"
#include "ipc/ipc_forwarding_message_filter.h"
#include "media/base/audio_hardware_config.h"
#include "media/base/media.h"
#include "media/filters/gpu_video_accelerator_factories.h"
+#include "mojo/common/common_type_converters.h"
#include "net/base/net_errors.h"
#include "net/base/net_util.h"
#include "skia/ext/event_tracer_impl.h"
#include "content/renderer/npapi/plugin_channel_host.h"
#endif
-#if defined(USE_MOJO)
-#include "content/renderer/mojo/mojo_render_process_observer.h"
-#endif
-
using base::ThreadRestrictions;
using blink::WebDocument;
using blink::WebFrame;
AddFilter((new EmbeddedWorkerContextMessageFilter())->GetFilter());
-#if defined(USE_MOJO)
- // MojoRenderProcessObserver deletes itself as necessary.
- new MojoRenderProcessObserver(this);
-#endif
+ gamepad_shared_memory_reader_.reset(new GamepadSharedMemoryReader());
+ AddObserver(gamepad_shared_memory_reader_.get());
GetContentClient()->renderer()->RenderThreadStarted();
RegisterExtension(GpuBenchmarkingExtension::Get());
is_impl_side_painting_enabled_ =
- command_line.HasSwitch(switches::kEnableImplSidePainting) &&
- !command_line.HasSwitch(switches::kDisableImplSidePainting);
+ command_line.HasSwitch(switches::kEnableImplSidePainting);
webkit::WebLayerImpl::SetImplSidePaintingEnabled(
is_impl_side_painting_enabled_);
- is_map_image_enabled_ =
- command_line.HasSwitch(switches::kEnableMapImage) &&
- !command_line.HasSwitch(switches::kDisableMapImage);
+ is_zero_copy_enabled_ = command_line.HasSwitch(switches::kEnableZeroCopy) &&
+ !command_line.HasSwitch(switches::kDisableZeroCopy);
+
+ is_one_copy_enabled_ = command_line.HasSwitch(switches::kEnableOneCopy);
if (command_line.HasSwitch(switches::kDisableLCDText)) {
is_lcd_text_enabled_ = false;
#endif
}
- is_gpu_rasterization_enabled_ = false;
- is_gpu_rasterization_forced_ = false;
- if (is_impl_side_painting_enabled_ &&
- !command_line.HasSwitch(switches::kDisableGpuRasterization)) {
- if (command_line.HasSwitch(switches::kForceGpuRasterization)) {
- is_gpu_rasterization_forced_ = true;
- } else if (command_line.HasSwitch(switches::kEnableGpuRasterization) ||
- command_line.HasSwitch(
- switches::kEnableBleedingEdgeRenderingFastPaths)) {
- is_gpu_rasterization_enabled_ = true;
- }
+ is_gpu_rasterization_enabled_ =
+ command_line.HasSwitch(switches::kEnableGpuRasterization);
+ is_gpu_rasterization_forced_ =
+ command_line.HasSwitch(switches::kForceGpuRasterization);
+
+ if (command_line.HasSwitch(switches::kDisableDistanceFieldText)) {
+ is_distance_field_text_enabled_ = false;
+ } else if (command_line.HasSwitch(switches::kEnableDistanceFieldText)) {
+ is_distance_field_text_enabled_ = true;
+ } else {
+ is_distance_field_text_enabled_ = false;
}
is_low_res_tiling_enabled_ = true;
// Clean up plugin channels before this thread goes away.
NPChannelBase::CleanupChannels();
#endif
-
- // Leak shared contexts on other threads, as we can not get to the correct
- // thread to destroy them.
- if (offscreen_compositor_contexts_.get())
- offscreen_compositor_contexts_->set_leak_on_destroy();
}
bool RenderThreadImpl::Send(IPC::Message* msg) {
ChildThread::GetRouter()->RemoveRoute(routing_id);
}
-void RenderThreadImpl::AddSharedWorkerRoute(int32 routing_id,
- IPC::Listener* listener) {
+void RenderThreadImpl::AddEmbeddedWorkerRoute(int32 routing_id,
+ IPC::Listener* listener) {
AddRoute(routing_id, listener);
if (devtools_agent_message_filter_.get()) {
- devtools_agent_message_filter_->AddSharedWorkerRouteOnMainThread(
+ devtools_agent_message_filter_->AddEmbeddedWorkerRouteOnMainThread(
routing_id);
}
}
-void RenderThreadImpl::RemoveSharedWorkerRoute(int32 routing_id) {
+void RenderThreadImpl::RemoveEmbeddedWorkerRoute(int32 routing_id) {
RemoveRoute(routing_id);
if (devtools_agent_message_filter_.get()) {
- devtools_agent_message_filter_->RemoveSharedWorkerRouteOnMainThread(
+ devtools_agent_message_filter_->RemoveEmbeddedWorkerRouteOnMainThread(
routing_id);
}
}
return routing_id;
}
-void RenderThreadImpl::AddFilter(IPC::ChannelProxy::MessageFilter* filter) {
+void RenderThreadImpl::AddFilter(IPC::MessageFilter* filter) {
channel()->AddFilter(filter);
}
-void RenderThreadImpl::RemoveFilter(IPC::ChannelProxy::MessageFilter* filter) {
+void RenderThreadImpl::RemoveFilter(IPC::MessageFilter* filter) {
channel()->RemoveFilter(filter);
}
NULL));
}
-scoped_refptr<cc::ContextProvider>
-RenderThreadImpl::OffscreenCompositorContextProvider() {
- DCHECK(IsMainThread());
-
-#if defined(OS_ANDROID)
- if (SynchronousCompositorFactory* factory =
- SynchronousCompositorFactory::GetInstance()) {
- if (compositor_message_loop_proxy_)
- return factory->GetOffscreenContextProviderForCompositorThread();
- return factory->GetOffscreenContextProviderForMainThread();
- }
-#endif
-
- if (!offscreen_compositor_contexts_.get() ||
- offscreen_compositor_contexts_->DestroyedOnMainThread()) {
- offscreen_compositor_contexts_ = ContextProviderCommandBuffer::Create(
- CreateOffscreenContext3d(),
- "Compositor-Offscreen");
- }
- return offscreen_compositor_contexts_;
-}
-
scoped_refptr<webkit::gpu::ContextProviderWebContext>
RenderThreadImpl::SharedMainThreadContextProvider() {
DCHECK(IsMainThread());
#if defined(OS_ANDROID)
if (SynchronousCompositorFactory* factory =
SynchronousCompositorFactory::GetInstance())
- return factory->GetOffscreenContextProviderForMainThread();
+ return factory->GetSharedOffscreenContextProviderForMainThread();
#endif
if (!shared_main_thread_contexts_ ||
shared_main_thread_contexts_->DestroyedOnMainThread()) {
- if (compositor_message_loop_proxy_) {
- // In threaded compositing mode, we have to create a new ContextProvider
- // to bind to the main thread since the compositor's is bound to the
- // compositor thread.
- shared_main_thread_contexts_ =
- ContextProviderCommandBuffer::Create(CreateOffscreenContext3d(),
- "Offscreen-MainThread");
- } else {
- // In single threaded mode, we can use the same context provider.
- shared_main_thread_contexts_ =
- static_cast<ContextProviderCommandBuffer*>(
- OffscreenCompositorContextProvider().get());
- }
+ shared_main_thread_contexts_ = ContextProviderCommandBuffer::Create(
+ CreateOffscreenContext3d(), "Offscreen-MainThread");
}
if (shared_main_thread_contexts_ &&
!shared_main_thread_contexts_->BindToCurrentThread())
HostAllocateSharedMemoryBuffer(size));
}
-int32 RenderThreadImpl::CreateViewCommandBuffer(
- int32 surface_id, const GPUCreateCommandBufferConfig& init_params) {
+bool RenderThreadImpl::CreateViewCommandBuffer(
+ int32 surface_id,
+ const GPUCreateCommandBufferConfig& init_params,
+ int32 route_id) {
TRACE_EVENT1("gpu",
"RenderThreadImpl::CreateViewCommandBuffer",
"surface_id",
surface_id);
- int32 route_id = MSG_ROUTING_NONE;
+ bool succeeded = false;
IPC::Message* message = new GpuHostMsg_CreateViewCommandBuffer(
surface_id,
init_params,
- &route_id);
+ route_id,
+ &succeeded);
// Allow calling this from the compositor thread.
thread_safe_sender()->Send(message);
- return route_id;
+ return succeeded;
}
void RenderThreadImpl::CreateImage(
scoped_ptr<gfx::GpuMemoryBuffer> RenderThreadImpl::AllocateGpuMemoryBuffer(
size_t width,
size_t height,
- unsigned internalformat) {
+ unsigned internalformat,
+ unsigned usage) {
DCHECK(allocate_gpu_memory_buffer_thread_checker_.CalledOnValidThread());
if (!GpuMemoryBufferImpl::IsFormatValid(internalformat))
gfx::GpuMemoryBufferHandle handle;
bool success;
- IPC::Message* message =
- new ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer(width,
- height,
- internalformat,
- &handle);
+ IPC::Message* message = new ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer(
+ width, height, internalformat, usage, &handle);
// Allow calling this from the compositor thread.
if (base::MessageLoop::current() == message_loop())
if (!success)
return scoped_ptr<gfx::GpuMemoryBuffer>();
- return GpuMemoryBufferImpl::Create(
- handle,
- gfx::Size(width, height),
- internalformat).PassAs<gfx::GpuMemoryBuffer>();
+ return GpuMemoryBufferImpl::CreateFromHandle(
+ handle, gfx::Size(width, height), internalformat)
+ .PassAs<gfx::GpuMemoryBuffer>();
+}
+
+void RenderThreadImpl::AcceptConnection(
+ const mojo::String& service_name,
+ mojo::ScopedMessagePipeHandle message_pipe) {
+ // TODO(darin): Invent some kind of registration system to use here.
+ if (service_name.To<base::StringPiece>() == kRendererService_WebUISetup) {
+ WebUISetupImpl::Bind(message_pipe.Pass());
+ } else {
+ NOTREACHED() << "Unknown service name";
+ }
}
void RenderThreadImpl::DoNotSuspendWebKitSharedTimer() {
EnsureWebKitInitialized();
// When bringing in render_view, also bring in webkit's glue and jsbindings.
RenderViewImpl::Create(params.opener_route_id,
+ params.window_was_created_with_opener,
params.renderer_preferences,
params.web_preferences,
params.view_id,
false,
params.swapped_out,
params.hidden,
+ params.never_visible,
params.next_page_id,
params.screen_info,
params.accessibility_mode);
params.name,
params.content_security_policy,
params.security_policy_type,
+ params.pause_on_start,
params.route_id);
}
}
void RenderThreadImpl::SampleGamepads(blink::WebGamepads* data) {
- if (!gamepad_shared_memory_reader_)
- gamepad_shared_memory_reader_.reset(new GamepadSharedMemoryReader);
gamepad_shared_memory_reader_->SampleGamepads(*data);
}
+void RenderThreadImpl::SetGamepadListener(blink::WebGamepadListener* listener) {
+ gamepad_shared_memory_reader_->SetGamepadListener(listener);
+}
+
void RenderThreadImpl::WidgetCreated() {
widget_count_++;
}