summaryrefslogtreecommitdiffstats
path: root/content/gpu
diff options
context:
space:
mode:
authoramarinichev@chromium.org <amarinichev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-19 00:06:53 +0000
committeramarinichev@chromium.org <amarinichev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-19 00:06:53 +0000
commit83d8632524a4540f96abfe2fd86a3eaae35e2191 (patch)
tree49752f12e06bb8f189b3500185a4375193f36758 /content/gpu
parent915679f57bee15233874af080d8bf30394988dbe (diff)
downloadchromium_src-83d8632524a4540f96abfe2fd86a3eaae35e2191.zip
chromium_src-83d8632524a4540f96abfe2fd86a3eaae35e2191.tar.gz
chromium_src-83d8632524a4540f96abfe2fd86a3eaae35e2191.tar.bz2
Do not put off destroying of the IOSurface in the GPU process.
Evicting old graphics contexts will be done in the GPU process by removing routes from GpuChannel::router_. Doing so on a mac results in an assert when handling GpuCommandBufferMsg_SetWindowSize. The assert was a consequence of how we deal with closed windows. When a window is closed, the browser process sends a message to the GPU process to request that the surface is removed. Rather than doing that immediately, GpuThread object stores the view id of the renderer in destroyed_renderer_routes_. GpuCommandBufferStub::OnFlush always checks if its view id is in that set, and if is, it asks the GPUProcessor to destroy its surface. This change gets rid of the destroyed_renderer_routes_. Rather than deferring the request to destroy the surface, we ask the GPU process to remove the route which, in turn, will remove the GpuCommandBufferStub, GPUProcessor and its surface. See also bug 67170. BUG=none TEST=set the breakpoint in GpuChannel::OnMessageReceived, manually remove the route from router_ and stubs_. No assert should be triggered and context should be silently recovered. Review URL: http://codereview.chromium.org/6688026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78777 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/gpu')
-rw-r--r--content/gpu/gpu_channel.cc22
-rw-r--r--content/gpu/gpu_channel.h8
-rw-r--r--content/gpu/gpu_command_buffer_stub.cc5
-rw-r--r--content/gpu/gpu_command_buffer_stub.h9
-rw-r--r--content/gpu/gpu_thread.cc11
-rw-r--r--content/gpu/gpu_thread.h2
6 files changed, 25 insertions, 32 deletions
diff --git a/content/gpu/gpu_channel.cc b/content/gpu/gpu_channel.cc
index 017fab1..622c213 100644
--- a/content/gpu/gpu_channel.cc
+++ b/content/gpu/gpu_channel.cc
@@ -113,17 +113,17 @@ void GpuChannel::AcceleratedSurfaceBuffersSwapped(
stub->AcceleratedSurfaceBuffersSwapped(swap_buffers_count);
}
-void GpuChannel::DidDestroySurface(int32 renderer_route_id) {
- // Since acclerated views are created in the renderer process and then sent
- // to the browser process during GPU channel construction, it is possible that
- // this is called before a GpuCommandBufferStub for |renderer_route_id| was
- // put into |stubs_|. Hence, do not walk |stubs_| here but instead remember
- // all |renderer_route_id|s this was called for and use them later.
- destroyed_renderer_routes_.insert(renderer_route_id);
-}
-
-bool GpuChannel::IsRenderViewGone(int32 renderer_route_id) {
- return destroyed_renderer_routes_.count(renderer_route_id) > 0;
+void GpuChannel::DestroyCommandBufferByViewId(int32 render_view_id) {
+ // This responds to a message from the browser process to destroy the command
+ // buffer when the window with a GPUProcessor is closed (see
+ // RenderWidgetHostViewMac::DeallocFakePluginWindowHandle). Find the route id
+ // that matches the given render_view_id and delete the route.
+ for (StubMap::const_iterator iter(&stubs_); !iter.IsAtEnd(); iter.Advance()) {
+ if (iter.GetCurrentValue()->render_view_id() == render_view_id) {
+ OnDestroyCommandBuffer(iter.GetCurrentKey());
+ return;
+ }
+ }
}
#endif
diff --git a/content/gpu/gpu_channel.h b/content/gpu/gpu_channel.h
index 9c87c8e..5e24a4c 100644
--- a/content/gpu/gpu_channel.h
+++ b/content/gpu/gpu_channel.h
@@ -67,9 +67,7 @@ class GpuChannel : public IPC::Channel::Listener,
#if defined(OS_MACOSX)
virtual void AcceleratedSurfaceBuffersSwapped(
int32 route_id, uint64 swap_buffers_count);
- void DidDestroySurface(int32 renderer_route_id);
-
- bool IsRenderViewGone(int32 renderer_route_id);
+ void DestroyCommandBufferByViewId(int32 render_view_id);
#endif
private:
@@ -113,10 +111,6 @@ class GpuChannel : public IPC::Channel::Listener,
#if defined(ENABLE_GPU)
typedef IDMap<GpuCommandBufferStub, IDMapOwnPointer> StubMap;
StubMap stubs_;
-
-#if defined(OS_MACOSX)
- std::set<int32> destroyed_renderer_routes_;
-#endif // defined (OS_MACOSX)
#endif // defined (ENABLE_GPU)
bool log_messages_; // True if we should log sent and received messages.
diff --git a/content/gpu/gpu_command_buffer_stub.cc b/content/gpu/gpu_command_buffer_stub.cc
index d838c9f..0347a60 100644
--- a/content/gpu/gpu_command_buffer_stub.cc
+++ b/content/gpu/gpu_command_buffer_stub.cc
@@ -286,11 +286,6 @@ void GpuCommandBufferStub::OnAsyncGetState() {
void GpuCommandBufferStub::OnFlush(int32 put_offset,
gpu::CommandBuffer::State* state) {
-#if defined(OS_MACOSX)
- // See comment in |DidDestroySurface()| in gpu_processor_mac.cc.
- if (channel_->IsRenderViewGone(render_view_id_))
- processor_->DidDestroySurface();
-#endif
*state = command_buffer_->FlushSync(put_offset);
}
diff --git a/content/gpu/gpu_command_buffer_stub.h b/content/gpu/gpu_command_buffer_stub.h
index 981ee0a..5190c5c 100644
--- a/content/gpu/gpu_command_buffer_stub.h
+++ b/content/gpu/gpu_command_buffer_stub.h
@@ -51,13 +51,16 @@ class GpuCommandBufferStub
// Get the GLContext associated with this object.
gpu::GPUProcessor* processor() const { return processor_.get(); }
+ // Identifies the renderer process.
+ int32 renderer_id() const { return renderer_id_; }
+
+ // Identifies a particular renderer belonging to the same renderer process.
+ int32 render_view_id() const { return render_view_id_; }
+
// Identifies the various GpuCommandBufferStubs in the GPU process belonging
// to the same renderer process.
int32 route_id() const { return route_id_; }
- // Identifies the various render views in the renderer process.
- int32 renderer_route_id() const { return renderer_id_; }
-
#if defined(OS_WIN)
// Called only by the compositor window's window proc
void OnCompositorWindowPainted();
diff --git a/content/gpu/gpu_thread.cc b/content/gpu/gpu_thread.cc
index d620747..e8fd331 100644
--- a/content/gpu/gpu_thread.cc
+++ b/content/gpu/gpu_thread.cc
@@ -90,8 +90,8 @@ bool GpuThread::OnControlMessageReceived(const IPC::Message& msg) {
#if defined(OS_MACOSX)
IPC_MESSAGE_HANDLER(GpuMsg_AcceleratedSurfaceBuffersSwappedACK,
OnAcceleratedSurfaceBuffersSwappedACK)
- IPC_MESSAGE_HANDLER(GpuMsg_DidDestroyAcceleratedSurface,
- OnDidDestroyAcceleratedSurface)
+ IPC_MESSAGE_HANDLER(GpuMsg_DestroyCommandBuffer,
+ OnDestroyCommandBuffer)
#endif
IPC_MESSAGE_HANDLER(GpuMsg_Crash, OnCrash)
IPC_MESSAGE_HANDLER(GpuMsg_Hang, OnHang)
@@ -295,13 +295,14 @@ void GpuThread::OnAcceleratedSurfaceBuffersSwappedACK(
scoped_refptr<GpuChannel> channel = iter->second;
channel->AcceleratedSurfaceBuffersSwapped(route_id, swap_buffers_count);
}
-void GpuThread::OnDidDestroyAcceleratedSurface(
- int renderer_id, int32 renderer_route_id) {
+
+void GpuThread::OnDestroyCommandBuffer(
+ int renderer_id, int32 render_view_id) {
GpuChannelMap::const_iterator iter = gpu_channels_.find(renderer_id);
if (iter == gpu_channels_.end())
return;
scoped_refptr<GpuChannel> channel = iter->second;
- channel->DidDestroySurface(renderer_route_id);
+ channel->DestroyCommandBufferByViewId(render_view_id);
}
#endif
diff --git a/content/gpu/gpu_thread.h b/content/gpu/gpu_thread.h
index 4a0c348..0baf864 100644
--- a/content/gpu/gpu_thread.h
+++ b/content/gpu/gpu_thread.h
@@ -67,7 +67,7 @@ class GpuThread : public ChildThread {
#if defined(OS_MACOSX)
void OnAcceleratedSurfaceBuffersSwappedACK(
int renderer_id, int32 route_id, uint64 swap_buffers_count);
- void OnDidDestroyAcceleratedSurface(int renderer_id, int32 renderer_route_id);
+ void OnDestroyCommandBuffer(int renderer_id, int32 render_view_id);
#endif
void OnCrash();
void OnHang();