Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Unified Diff: content/browser/renderer_host/render_process_host_impl.cc

Issue 542083002: content: Move all GpuMemoryBuffer allocation to IO thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address review feedback Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/render_process_host_impl.cc
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
index 58938cb80119ae5729b5845fc99775772cd6da09..f6f0853349506330c61438a07b0d9a403f69682e 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -26,7 +26,6 @@
#include "base/logging.h"
#include "base/metrics/field_trial.h"
#include "base/metrics/histogram.h"
-#include "base/numerics/safe_math.h"
#include "base/path_service.h"
#include "base/process/process_handle.h"
#include "base/rand_util.h"
@@ -109,7 +108,6 @@
#include "content/common/child_process_host_impl.h"
#include "content/common/child_process_messages.h"
#include "content/common/content_switches_internal.h"
-#include "content/common/gpu/client/gpu_memory_buffer_impl.h"
#include "content/common/gpu/gpu_messages.h"
#include "content/common/mojo/mojo_messages.h"
#include "content/common/resource_messages.h"
@@ -151,13 +149,7 @@
#if defined(OS_ANDROID)
#include "content/browser/media/android/browser_demuxer_android.h"
-#include "content/browser/renderer_host/compositor_impl_android.h"
#include "content/browser/screen_orientation/screen_orientation_message_filter_android.h"
-#include "content/common/gpu/client/gpu_memory_buffer_impl_surface_texture.h"
-#endif
-
-#if defined(OS_MACOSX)
-#include "content/common/gpu/client/gpu_memory_buffer_impl_io_surface.h"
#endif
#if defined(OS_WIN)
@@ -340,23 +332,6 @@ class RendererSandboxedProcessLauncherDelegate
#endif // OS_POSIX
};
-#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
-
const char kSessionStorageHolderKey[] = "kSessionStorageHolderKey";
class SessionStorageHolder : public base::SupportsUserData::Data {
@@ -559,10 +534,6 @@ RenderProcessHostImpl::~RenderProcessHostImpl() {
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
base::Bind(&RemoveShaderInfo, GetID()));
}
-
-#if defined(OS_ANDROID)
- CompositorImpl::DestroyAllSurfaceTextures(GetID());
-#endif
}
void RenderProcessHostImpl::EnableSendQueue() {
@@ -1388,11 +1359,6 @@ bool RenderProcessHostImpl::OnMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_HANDLER(ViewHostMsg_UserMetricsRecordAction,
OnUserMetricsRecordAction)
IPC_MESSAGE_HANDLER(ViewHostMsg_SavedPageAsMHTML, OnSavedPageAsMHTML)
- IPC_MESSAGE_HANDLER_DELAY_REPLY(
- ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer,
- OnAllocateGpuMemoryBuffer)
- IPC_MESSAGE_HANDLER(ChildProcessHostMsg_DeletedGpuMemoryBuffer,
- OnDeletedGpuMemoryBuffer)
IPC_MESSAGE_HANDLER(ViewHostMsg_Close_ACK, OnCloseACK)
#if defined(ENABLE_WEBRTC)
IPC_MESSAGE_HANDLER(AecDumpMsg_RegisterAecDumpConsumer,
@@ -2265,113 +2231,4 @@ void RenderProcessHostImpl::EnsureMojoActivated() {
MaybeActivateMojo();
}
-void RenderProcessHostImpl::OnAllocateGpuMemoryBuffer(uint32 width,
- uint32 height,
- uint32 internalformat,
- uint32 usage,
- IPC::Message* reply) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- 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(GetID());
- if (surface_texture_id != -1) {
- gfx::GpuMemoryBufferHandle handle;
- handle.type = gfx::SURFACE_TEXTURE_BUFFER;
- handle.surface_texture_id =
- gfx::SurfaceTextureId(surface_texture_id, GetID());
- GpuMemoryBufferAllocated(reply, handle);
- return;
- }
- }
-#endif
-
- GpuMemoryBufferImpl::AllocateForChildProcess(
- gfx::Size(width, height),
- internalformat,
- usage,
- GetHandle(),
- GetID(),
- base::Bind(&RenderProcessHostImpl::GpuMemoryBufferAllocated,
- weak_factory_.GetWeakPtr(),
- reply));
-}
-
-void RenderProcessHostImpl::GpuMemoryBufferAllocated(
- IPC::Message* reply,
- const gfx::GpuMemoryBufferHandle& handle) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer::WriteReplyParams(reply,
- handle);
- Send(reply);
-}
-
-void RenderProcessHostImpl::OnDeletedGpuMemoryBuffer(
- gfx::GpuMemoryBufferType type,
- const gfx::GpuMemoryBufferId& id) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- GpuMemoryBufferImpl::DeletedByChildProcess(type, id, GetHandle());
-}
-
} // namespace content
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698