| Index: content/browser/renderer_host/render_message_filter.cc
|
| diff --git a/content/browser/renderer_host/render_message_filter.cc b/content/browser/renderer_host/render_message_filter.cc
|
| index b43c67d6a45f25596b4113e08ed6c0cd3a8b2ac1..5c5091089be92e394c346b2ec0aa97c48580c289 100644
|
| --- a/content/browser/renderer_host/render_message_filter.cc
|
| +++ b/content/browser/renderer_host/render_message_filter.cc
|
| @@ -10,6 +10,7 @@
|
| #include "base/bind_helpers.h"
|
| #include "base/command_line.h"
|
| #include "base/debug/alias.h"
|
| +#include "base/numerics/safe_math.h"
|
| #include "base/strings/sys_string_conversions.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| #include "base/threading/thread.h"
|
| @@ -34,6 +35,7 @@
|
| #include "content/common/cookie_data.h"
|
| #include "content/common/desktop_notification_messages.h"
|
| #include "content/common/frame_messages.h"
|
| +#include "content/common/gpu/client/gpu_memory_buffer_impl.h"
|
| #include "content/common/host_shared_bitmap_manager.h"
|
| #include "content/common/media/media_param_traits.h"
|
| #include "content/common/view_messages.h"
|
| @@ -70,6 +72,7 @@
|
| #include "ui/gfx/color_profile.h"
|
|
|
| #if defined(OS_MACOSX)
|
| +#include "content/common/gpu/client/gpu_memory_buffer_impl_io_surface.h"
|
| #include "content/common/mac/font_descriptor.h"
|
| #else
|
| #include "gpu/GLES2/gl2extchromium.h"
|
| @@ -84,6 +87,8 @@
|
| #include "content/common/sandbox_win.h"
|
| #endif
|
| #if defined(OS_ANDROID)
|
| +#include "content/browser/renderer_host/compositor_impl_android.h"
|
| +#include "content/common/gpu/client/gpu_memory_buffer_impl_surface_texture.h"
|
| #include "media/base/android/webaudio_media_codec_bridge.h"
|
| #endif
|
|
|
| @@ -222,6 +227,23 @@ class OpenChannelToPpapiBrokerCallback
|
| };
|
| #endif // defined(ENABLE_PLUGINS)
|
|
|
| +#if defined(OS_MACOSX)
|
| +void AddBooleanValue(CFMutableDictionaryRef dictionary,
|
| + const CFStringRef key,
|
| + bool value) {
|
| + CFDictionaryAddValue(
|
| + dictionary, key, value ? kCFBooleanTrue : kCFBooleanFalse);
|
| +}
|
| +
|
| +void AddIntegerValue(CFMutableDictionaryRef dictionary,
|
| + const CFStringRef key,
|
| + int32 value) {
|
| + base::ScopedCFTypeRef<CFNumberRef> number(
|
| + CFNumberCreate(NULL, kCFNumberSInt32Type, &value));
|
| + CFDictionaryAddValue(dictionary, key, number.get());
|
| +}
|
| +#endif
|
| +
|
| } // namespace
|
|
|
| class RenderMessageFilter::OpenChannelToNpapiPluginCallback
|
| @@ -359,6 +381,9 @@ void RenderMessageFilter::OnChannelClosing() {
|
| }
|
| #endif // defined(ENABLE_PLUGINS)
|
| plugin_host_clients_.clear();
|
| +#if defined(OS_ANDROID)
|
| + CompositorImpl::DestroyAllSurfaceTextures(render_process_id_);
|
| +#endif
|
| }
|
|
|
| void RenderMessageFilter::OnChannelConnected(int32 peer_id) {
|
| @@ -424,6 +449,11 @@ bool RenderMessageFilter::OnMessageReceived(const IPC::Message& message) {
|
| OnAllocateSharedMemory)
|
| IPC_MESSAGE_HANDLER_DELAY_REPLY(
|
| ChildProcessHostMsg_SyncAllocateSharedBitmap, OnAllocateSharedBitmap)
|
| + IPC_MESSAGE_HANDLER_DELAY_REPLY(
|
| + ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer,
|
| + OnAllocateGpuMemoryBuffer)
|
| + IPC_MESSAGE_HANDLER(ChildProcessHostMsg_DeletedGpuMemoryBuffer,
|
| + OnDeletedGpuMemoryBuffer)
|
| IPC_MESSAGE_HANDLER(ChildProcessHostMsg_AllocatedSharedBitmap,
|
| OnAllocatedSharedBitmap)
|
| IPC_MESSAGE_HANDLER(ChildProcessHostMsg_DeletedSharedBitmap,
|
| @@ -1220,7 +1250,6 @@ void RenderMessageFilter::OnWebAudioMediaCodec(
|
| }
|
| #endif
|
|
|
| -
|
| void RenderMessageFilter::OnAddNavigationTransitionData(
|
| int render_frame_id,
|
| const std::string& allowed_destination_host_pattern,
|
| @@ -1231,4 +1260,108 @@ void RenderMessageFilter::OnAddNavigationTransitionData(
|
| selector, markup);
|
| }
|
|
|
| +void RenderMessageFilter::OnAllocateGpuMemoryBuffer(uint32 width,
|
| + uint32 height,
|
| + uint32 internalformat,
|
| + uint32 usage,
|
| + IPC::Message* reply) {
|
| + if (!GpuMemoryBufferImpl::IsFormatValid(internalformat) ||
|
| + !GpuMemoryBufferImpl::IsUsageValid(usage)) {
|
| + GpuMemoryBufferAllocated(reply, gfx::GpuMemoryBufferHandle());
|
| + return;
|
| + }
|
| + base::CheckedNumeric<int> size = width;
|
| + size *= height;
|
| + if (!size.IsValid()) {
|
| + GpuMemoryBufferAllocated(reply, gfx::GpuMemoryBufferHandle());
|
| + return;
|
| + }
|
| +
|
| +#if defined(OS_MACOSX)
|
| + // TODO(reveman): This should be moved to
|
| + // GpuMemoryBufferImpl::AllocateForChildProcess and
|
| + // GpuMemoryBufferImplIOSurface. crbug.com/325045, crbug.com/323304
|
| + if (GpuMemoryBufferImplIOSurface::IsConfigurationSupported(internalformat,
|
| + usage)) {
|
| + base::ScopedCFTypeRef<CFMutableDictionaryRef> properties;
|
| + properties.reset(
|
| + CFDictionaryCreateMutable(kCFAllocatorDefault,
|
| + 0,
|
| + &kCFTypeDictionaryKeyCallBacks,
|
| + &kCFTypeDictionaryValueCallBacks));
|
| + AddIntegerValue(properties, kIOSurfaceWidth, width);
|
| + AddIntegerValue(properties, kIOSurfaceHeight, height);
|
| + AddIntegerValue(properties,
|
| + kIOSurfaceBytesPerElement,
|
| + GpuMemoryBufferImpl::BytesPerPixel(internalformat));
|
| + AddIntegerValue(properties,
|
| + kIOSurfacePixelFormat,
|
| + GpuMemoryBufferImplIOSurface::PixelFormat(internalformat));
|
| + // TODO(reveman): Remove this when using a mach_port_t to transfer
|
| + // IOSurface to renderer process. crbug.com/323304
|
| + AddBooleanValue(properties, kIOSurfaceIsGlobal, true);
|
| +
|
| + base::ScopedCFTypeRef<IOSurfaceRef> io_surface(IOSurfaceCreate(properties));
|
| + if (io_surface) {
|
| + gfx::GpuMemoryBufferHandle handle;
|
| + handle.type = gfx::IO_SURFACE_BUFFER;
|
| + handle.io_surface_id = IOSurfaceGetID(io_surface);
|
| +
|
| + // TODO(reveman): This makes the assumption that the renderer will
|
| + // grab a reference to the surface before sending another message.
|
| + // crbug.com/325045
|
| + last_io_surface_ = io_surface;
|
| + GpuMemoryBufferAllocated(reply, handle);
|
| + return;
|
| + }
|
| + }
|
| +#endif
|
| +
|
| +#if defined(OS_ANDROID)
|
| + // TODO(reveman): This should be moved to
|
| + // GpuMemoryBufferImpl::AllocateForChildProcess and
|
| + // GpuMemoryBufferImplSurfaceTexture when adding support for out-of-process
|
| + // GPU service. crbug.com/368716
|
| + if (GpuMemoryBufferImplSurfaceTexture::IsConfigurationSupported(
|
| + internalformat, usage)) {
|
| + // Each surface texture is associated with a render process id. This allows
|
| + // the GPU service and Java Binder IPC to verify that a renderer is not
|
| + // trying to use a surface texture it doesn't own.
|
| + int surface_texture_id =
|
| + CompositorImpl::CreateSurfaceTexture(render_process_id_);
|
| + if (surface_texture_id != -1) {
|
| + gfx::GpuMemoryBufferHandle handle;
|
| + handle.type = gfx::SURFACE_TEXTURE_BUFFER;
|
| + handle.surface_texture_id =
|
| + gfx::SurfaceTextureId(surface_texture_id, render_process_id_);
|
| + GpuMemoryBufferAllocated(reply, handle);
|
| + return;
|
| + }
|
| + }
|
| +#endif
|
| +
|
| + GpuMemoryBufferImpl::AllocateForChildProcess(
|
| + gfx::Size(width, height),
|
| + internalformat,
|
| + usage,
|
| + PeerHandle(),
|
| + render_process_id_,
|
| + base::Bind(&RenderMessageFilter::GpuMemoryBufferAllocated, this, reply));
|
| +}
|
| +
|
| +void RenderMessageFilter::GpuMemoryBufferAllocated(
|
| + IPC::Message* reply,
|
| + const gfx::GpuMemoryBufferHandle& handle) {
|
| + DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
| + ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer::WriteReplyParams(reply,
|
| + handle);
|
| + Send(reply);
|
| +}
|
| +
|
| +void RenderMessageFilter::OnDeletedGpuMemoryBuffer(
|
| + gfx::GpuMemoryBufferType type,
|
| + const gfx::GpuMemoryBufferId& id) {
|
| + GpuMemoryBufferImpl::DeletedByChildProcess(type, id, PeerHandle());
|
| +}
|
| +
|
| } // namespace content
|
|
|