Skip to content

Commit

Permalink
Revert 256955 "Add shared bitmap managers for browser and render..."
Browse files Browse the repository at this point in the history
Seems to be causing renderer crashes and possibly out-of-memory issues.

> Add shared bitmap managers for browser and renderer processes.
> 
> The shared bitmap managers will allow software tiles to be allocated in shared memory, so delegated rendering could be used with them.
> 
> BUG=327220
> R=danakj@chromium.org, jschuh@chromium.org, piman@chromium.org
> 
> Review URL: https://codereview.chromium.org/148243013

TBR=jbauman@chromium.org
BUG=352689,352616,352618

Review URL: https://codereview.chromium.org/197703004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257161 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
jbauman@chromium.org committed Mar 14, 2014
1 parent b999632 commit 7407ad6
Show file tree
Hide file tree
Showing 21 changed files with 7 additions and 669 deletions.
4 changes: 2 additions & 2 deletions cc/output/delegating_renderer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ void DelegatingRenderer::SetVisible(bool visible) {
// We loop visibility to the GPU process, since that's what manages memory.
// That will allow it to feed us with memory allocations that we can act
// upon.
if (context_provider)
context_provider->ContextSupport()->SetSurfaceVisible(visible);
DCHECK(context_provider);
context_provider->ContextSupport()->SetSurfaceVisible(visible);
}

void DelegatingRenderer::SendManagedMemoryStats(size_t bytes_visible,
Expand Down
3 changes: 1 addition & 2 deletions cc/resources/resource_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1949,8 +1949,7 @@ void ResourceProvider::BeginSetPixels(ResourceId id) {
DCHECK(resource->pixel_buffer);
DCHECK_EQ(RGBA_8888, resource->format);

memcpy(
resource->pixels, resource->pixel_buffer, 4 * resource->size.GetArea());
std::swap(resource->pixels, resource->pixel_buffer);
delete[] resource->pixel_buffer;
resource->pixel_buffer = NULL;
}
Expand Down
25 changes: 0 additions & 25 deletions cc/resources/shared_bitmap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

#include "cc/resources/shared_bitmap.h"

#include "base/numerics/safe_math.h"
#include "base/rand_util.h"

namespace cc {

SharedBitmap::SharedBitmap(
Expand All @@ -17,26 +14,4 @@ SharedBitmap::SharedBitmap(

SharedBitmap::~SharedBitmap() { free_callback_.Run(this); }

// static
bool SharedBitmap::GetSizeInBytes(const gfx::Size& size,
size_t* size_in_bytes) {
if (size.width() <= 0 || size.height() <= 0)
return false;
base::CheckedNumeric<int> s = size.width();
s *= size.height();
s *= 4;
if (!s.IsValid())
return false;
*size_in_bytes = s.ValueOrDie();
return true;
}

// static
SharedBitmapId SharedBitmap::GenerateId() {
SharedBitmapId id;
// Needs cryptographically-secure random numbers.
base::RandBytes(id.name, sizeof(id.name));
return id;
}

} // namespace cc
6 changes: 0 additions & 6 deletions cc/resources/shared_bitmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "base/memory/shared_memory.h"
#include "cc/base/cc_export.h"
#include "gpu/command_buffer/common/mailbox.h"
#include "ui/gfx/size.h"

namespace base { class SharedMemory; }

Expand Down Expand Up @@ -39,11 +38,6 @@ class CC_EXPORT SharedBitmap {

SharedBitmapId id() { return id_; }

// Returns true if the size is valid and false otherwise.
static bool GetSizeInBytes(const gfx::Size& size, size_t* size_in_bytes);

static SharedBitmapId GenerateId();

private:
base::SharedMemory* memory_;
SharedBitmapId id_;
Expand Down
2 changes: 0 additions & 2 deletions content/browser/compositor/image_transport_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "base/command_line.h"
#include "content/browser/compositor/gpu_process_transport_factory.h"
#include "content/browser/compositor/no_transport_image_transport_factory.h"
#include "content/common/host_shared_bitmap_manager.h"
#include "ui/compositor/compositor.h"
#include "ui/compositor/compositor_switches.h"
#include "ui/gl/gl_implementation.h"
Expand All @@ -27,7 +26,6 @@ void ImageTransportFactory::Initialize() {
return;
g_factory = new GpuProcessTransportFactory;
ui::ContextFactory::SetInstance(g_factory->AsContextFactory());
ui::Compositor::SetSharedBitmapManager(HostSharedBitmapManager::current());
}

void ImageTransportFactory::InitializeForUnitTests(
Expand Down
28 changes: 0 additions & 28 deletions content/browser/renderer_host/render_message_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#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"
#include "content/public/browser/browser_child_process_host.h"
Expand Down Expand Up @@ -355,7 +354,6 @@ RenderMessageFilter::~RenderMessageFilter() {
}

void RenderMessageFilter::OnChannelClosing() {
HostSharedBitmapManager::current()->ProcessRemoved(PeerHandle());
#if defined(ENABLE_PLUGINS)
for (std::set<OpenChannelToNpapiPluginCallback*>::iterator it =
plugin_host_clients_.begin(); it != plugin_host_clients_.end(); ++it) {
Expand Down Expand Up @@ -432,14 +430,8 @@ bool RenderMessageFilter::OnMessageReceived(const IPC::Message& message,
OnCheckNotificationPermission)
IPC_MESSAGE_HANDLER(ChildProcessHostMsg_SyncAllocateSharedMemory,
OnAllocateSharedMemory)
IPC_MESSAGE_HANDLER(ChildProcessHostMsg_SyncAllocateSharedBitmap,
OnAllocateSharedBitmap)
IPC_MESSAGE_HANDLER(ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer,
OnAllocateGpuMemoryBuffer)
IPC_MESSAGE_HANDLER(ChildProcessHostMsg_AllocatedSharedBitmap,
OnAllocatedSharedBitmap)
IPC_MESSAGE_HANDLER(ChildProcessHostMsg_DeletedSharedBitmap,
OnDeletedSharedBitmap)
#if defined(OS_POSIX) && !defined(TOOLKIT_GTK) && !defined(OS_ANDROID)
IPC_MESSAGE_HANDLER(ViewHostMsg_AllocTransportDIB, OnAllocTransportDIB)
IPC_MESSAGE_HANDLER(ViewHostMsg_FreeTransportDIB, OnFreeTransportDIB)
Expand Down Expand Up @@ -934,26 +926,6 @@ void RenderMessageFilter::OnAllocateSharedMemory(
buffer_size, PeerHandle(), handle);
}

void RenderMessageFilter::OnAllocateSharedBitmap(
uint32 buffer_size,
const cc::SharedBitmapId& id,
base::SharedMemoryHandle* handle) {
HostSharedBitmapManager::current()->AllocateSharedBitmapForChild(
PeerHandle(), buffer_size, id, handle);
}

void RenderMessageFilter::OnAllocatedSharedBitmap(
size_t buffer_size,
const base::SharedMemoryHandle& handle,
const cc::SharedBitmapId& id) {
HostSharedBitmapManager::current()->ChildAllocatedSharedBitmap(
buffer_size, handle, PeerHandle(), id);
}

void RenderMessageFilter::OnDeletedSharedBitmap(const cc::SharedBitmapId& id) {
HostSharedBitmapManager::current()->ChildDeletedSharedBitmap(id);
}

net::CookieStore* RenderMessageFilter::GetCookieStoreForURL(
const GURL& url) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
Expand Down
8 changes: 0 additions & 8 deletions content/browser/renderer_host/render_message_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "base/sequenced_task_runner_helpers.h"
#include "base/strings/string16.h"
#include "build/build_config.h"
#include "cc/resources/shared_bitmap_manager.h"
#include "content/common/pepper_renderer_instance_data.h"
#include "content/public/browser/browser_message_filter.h"
#include "content/public/common/three_d_api_types.h"
Expand Down Expand Up @@ -214,13 +213,6 @@ class RenderMessageFilter : public BrowserMessageFilter {
// in the renderer on POSIX due to the sandbox.
void OnAllocateSharedMemory(uint32 buffer_size,
base::SharedMemoryHandle* handle);
void OnAllocateSharedBitmap(uint32 buffer_size,
const cc::SharedBitmapId& id,
base::SharedMemoryHandle* handle);
void OnAllocatedSharedBitmap(size_t buffer_size,
const base::SharedMemoryHandle& handle,
const cc::SharedBitmapId& id);
void OnDeletedSharedBitmap(const cc::SharedBitmapId& id);
void OnResolveProxy(const GURL& url, IPC::Message* reply_msg);

// Browser side transport DIB allocation
Expand Down
92 changes: 0 additions & 92 deletions content/child/child_shared_bitmap_manager.cc

This file was deleted.

40 changes: 0 additions & 40 deletions content/child/child_shared_bitmap_manager.h

This file was deleted.

4 changes: 0 additions & 4 deletions content/child/child_thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include "content/child/child_histogram_message_filter.h"
#include "content/child/child_process.h"
#include "content/child/child_resource_message_filter.h"
#include "content/child/child_shared_bitmap_manager.h"
#include "content/child/fileapi/file_system_dispatcher.h"
#include "content/child/power_monitor_broadcast_source.h"
#include "content/child/quota_dispatcher.h"
Expand Down Expand Up @@ -312,9 +311,6 @@ void ChildThread::Init() {
::HeapProfilerStop,
::GetHeapProfile));
#endif

shared_bitmap_manager_.reset(
new ChildSharedBitmapManager(thread_safe_sender()));
}

ChildThread::~ChildThread() {
Expand Down
7 changes: 0 additions & 7 deletions content/child/child_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class WebFrame;
namespace content {
class ChildHistogramMessageFilter;
class ChildResourceMessageFilter;
class ChildSharedBitmapManager;
class FileSystemDispatcher;
class ServiceWorkerDispatcher;
class ServiceWorkerMessageFilter;
Expand Down Expand Up @@ -87,10 +86,6 @@ class CONTENT_EXPORT ChildThread : public IPC::Listener, public IPC::Sender {
static base::SharedMemory* AllocateSharedMemory(size_t buf_size,
IPC::Sender* sender);

ChildSharedBitmapManager* shared_bitmap_manager() const {
return shared_bitmap_manager_.get();
}

ResourceDispatcher* resource_dispatcher() const {
return resource_dispatcher_.get();
}
Expand Down Expand Up @@ -232,8 +227,6 @@ class CONTENT_EXPORT ChildThread : public IPC::Listener, public IPC::Sender {

scoped_refptr<QuotaMessageFilter> quota_message_filter_;

scoped_ptr<ChildSharedBitmapManager> shared_bitmap_manager_;

base::WeakPtrFactory<ChildThread> channel_connected_factory_;

// Observes the trace event system. When tracing is enabled, optionally
Expand Down
18 changes: 0 additions & 18 deletions content/common/child_process_messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "base/memory/shared_memory.h"
#include "base/tracked_objects.h"
#include "base/values.h"
#include "cc/resources/shared_bitmap_manager.h"
#include "content/common/content_export.h"
#include "ipc/ipc_message_macros.h"
#include "ui/gfx/gpu_memory_buffer.h"
Expand Down Expand Up @@ -147,23 +146,6 @@ IPC_SYNC_MESSAGE_CONTROL1_1(ChildProcessHostMsg_SyncAllocateSharedMemory,
uint32 /* buffer size */,
base::SharedMemoryHandle)

// Asks the browser to create a block of shared memory for the child process to
// fill in and pass back to the browser.
IPC_SYNC_MESSAGE_CONTROL2_1(ChildProcessHostMsg_SyncAllocateSharedBitmap,
uint32 /* buffer size */,
cc::SharedBitmapId,
base::SharedMemoryHandle)

// Informs the browser that the child allocated a shared bitmap.
IPC_MESSAGE_CONTROL3(ChildProcessHostMsg_AllocatedSharedBitmap,
uint32 /* buffer size */,
base::SharedMemoryHandle,
cc::SharedBitmapId)

// Informs the browser that the child deleted a shared bitmap.
IPC_MESSAGE_CONTROL1(ChildProcessHostMsg_DeletedSharedBitmap,
cc::SharedBitmapId)

#if defined(USE_TCMALLOC)
// Reply to ChildProcessMsg_GetTcmallocStats.
IPC_MESSAGE_CONTROL1(ChildProcessHostMsg_TcmallocStats,
Expand Down
Loading

0 comments on commit 7407ad6

Please sign in to comment.