Chromium Code Reviews| Index: content/renderer/child_frame_compositing_helper.cc |
| diff --git a/content/renderer/child_frame_compositing_helper.cc b/content/renderer/child_frame_compositing_helper.cc |
| index 237badcc3f0104a4ade09533f6e5428f916812bf..c118419e680ccecb64ffe34ca8ca68d3e854c95a 100644 |
| --- a/content/renderer/child_frame_compositing_helper.cc |
| +++ b/content/renderer/child_frame_compositing_helper.cc |
| @@ -23,7 +23,6 @@ |
| #include "content/renderer/render_frame_proxy.h" |
| #include "content/renderer/render_thread_impl.h" |
| #include "skia/ext/image_operations.h" |
| -#include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" |
| #include "third_party/WebKit/public/web/WebFrame.h" |
| #include "third_party/WebKit/public/web/WebPluginContainer.h" |
| #include "third_party/khronos/GLES2/gl2.h" |
| @@ -32,13 +31,6 @@ |
| namespace content { |
| -ChildFrameCompositingHelper::SwapBuffersInfo::SwapBuffersInfo() |
| - : route_id(0), |
| - output_surface_id(0), |
| - host_id(0), |
| - software_frame_id(0), |
| - shared_memory(NULL) {} |
| - |
| ChildFrameCompositingHelper* |
| ChildFrameCompositingHelper::CreateForBrowserPlugin( |
| const base::WeakPtr<BrowserPlugin>& browser_plugin) { |
| @@ -64,9 +56,7 @@ ChildFrameCompositingHelper::ChildFrameCompositingHelper( |
| last_route_id_(0), |
| last_output_surface_id_(0), |
| last_host_id_(0), |
| - last_mailbox_valid_(false), |
| ack_pending_(true), |
| - software_ack_pending_(false), |
| opaque_(true), |
| browser_plugin_(browser_plugin), |
| render_frame_proxy_(render_frame_proxy), |
| @@ -109,19 +99,6 @@ void ChildFrameCompositingHelper::SendCompositorFrameSwappedACKToBrowser( |
| } |
| } |
| -void ChildFrameCompositingHelper::SendBuffersSwappedACKToBrowser( |
| - FrameHostMsg_BuffersSwappedACK_Params& params) { |
| - // This function will be removed when BrowserPluginManager is removed and |
| - // BrowserPlugin is modified to use a RenderFrame. |
| - if (GetBrowserPluginManager()) { |
| - GetBrowserPluginManager()->Send(new BrowserPluginHostMsg_BuffersSwappedACK( |
| - host_routing_id_, params)); |
| - } else if (render_frame_proxy_) { |
| - render_frame_proxy_->Send( |
| - new FrameHostMsg_BuffersSwappedACK(host_routing_id_, params)); |
| - } |
| -} |
| - |
| void ChildFrameCompositingHelper::SendReclaimCompositorResourcesToBrowser( |
| FrameHostMsg_ReclaimCompositorResources_Params& params) { |
| // This function will be removed when BrowserPluginManager is removed and |
| @@ -152,20 +129,6 @@ void ChildFrameCompositingHelper::CopyFromCompositingSurface( |
| } |
| void ChildFrameCompositingHelper::DidCommitCompositorFrame() { |
| - if (software_ack_pending_) { |
| - FrameHostMsg_CompositorFrameSwappedACK_Params params; |
| - params.producing_host_id = last_host_id_; |
| - params.producing_route_id = last_route_id_; |
| - params.output_surface_id = last_output_surface_id_; |
| - if (!unacked_software_frames_.empty()) { |
| - params.ack.last_software_frame_id = unacked_software_frames_.back(); |
| - unacked_software_frames_.pop_back(); |
| - } |
| - |
| - SendCompositorFrameSwappedACKToBrowser(params); |
| - |
| - software_ack_pending_ = false; |
| - } |
| if (!resource_collection_.get() || !ack_pending_) |
| return; |
| @@ -216,62 +179,6 @@ void ChildFrameCompositingHelper::CheckSizeAndAdjustLayerProperties( |
| background_layer_->SetIsDrawable(false); |
| } |
| -void ChildFrameCompositingHelper::MailboxReleased(SwapBuffersInfo mailbox, |
| - uint32 sync_point, |
| - bool lost_resource) { |
| - if (mailbox.type == SOFTWARE_COMPOSITOR_FRAME) { |
| - delete mailbox.shared_memory; |
| - mailbox.shared_memory = NULL; |
| - } else if (lost_resource) { |
| - // Reset mailbox's name if the resource was lost. |
| - mailbox.name.SetZero(); |
| - } |
| - |
| - // This means the GPU process crashed or guest crashed. |
| - if (last_host_id_ != mailbox.host_id || |
| - last_output_surface_id_ != mailbox.output_surface_id || |
| - last_route_id_ != mailbox.route_id) |
| - return; |
| - |
| - if (mailbox.type == SOFTWARE_COMPOSITOR_FRAME) |
| - unacked_software_frames_.push_back(mailbox.software_frame_id); |
| - |
| - // We need to send an ACK to for every buffer sent to us. |
| - // However, if a buffer is freed up from |
| - // the compositor in cases like switching back to SW mode without a new |
| - // buffer arriving, no ACK is needed. |
| - if (!ack_pending_) { |
| - last_mailbox_valid_ = false; |
| - return; |
| - } |
| - ack_pending_ = false; |
| - switch (mailbox.type) { |
| - case TEXTURE_IMAGE_TRANSPORT: { |
| - FrameHostMsg_BuffersSwappedACK_Params params; |
| - params.gpu_host_id = mailbox.host_id; |
| - params.gpu_route_id = mailbox.route_id; |
| - params.mailbox = mailbox.name; |
| - params.sync_point = sync_point; |
| - SendBuffersSwappedACKToBrowser(params); |
| - break; |
| - } |
| - case GL_COMPOSITOR_FRAME: { |
| - FrameHostMsg_CompositorFrameSwappedACK_Params params; |
| - params.producing_host_id = mailbox.host_id; |
| - params.producing_route_id = mailbox.route_id; |
| - params.output_surface_id = mailbox.output_surface_id; |
| - params.ack.gl_frame_data.reset(new cc::GLFrameData()); |
| - params.ack.gl_frame_data->mailbox = mailbox.name; |
| - params.ack.gl_frame_data->size = mailbox.size; |
| - params.ack.gl_frame_data->sync_point = sync_point; |
| - SendCompositorFrameSwappedACKToBrowser(params); |
| - break; |
| - } |
| - case SOFTWARE_COMPOSITOR_FRAME: |
| - break; |
| - } |
| -} |
| - |
| void ChildFrameCompositingHelper::OnContainerDestroy() { |
| if (GetContainer()) |
| GetContainer()->setWebLayer(NULL); |
| @@ -280,7 +187,6 @@ void ChildFrameCompositingHelper::OnContainerDestroy() { |
| resource_collection_->SetClient(NULL); |
| ack_pending_ = false; |
| - software_ack_pending_ = false; |
| resource_collection_ = NULL; |
| frame_provider_ = NULL; |
| texture_layer_ = NULL; |
| @@ -296,154 +202,12 @@ void ChildFrameCompositingHelper::ChildFrameGone() { |
| background_layer_->SetContentsOpaque(true); |
| } |
| -void ChildFrameCompositingHelper::OnBuffersSwappedPrivate( |
| - const SwapBuffersInfo& mailbox, |
| - uint32 sync_point, |
| - float device_scale_factor) { |
| - DCHECK(!delegated_layer_.get()); |
| - // If these mismatch, we are either just starting up, GPU process crashed or |
| - // guest renderer crashed. |
| - // In this case, we are communicating with a new image transport |
| - // surface and must ACK with the new ID's and an empty mailbox. |
| - if (last_route_id_ != mailbox.route_id || |
| - last_output_surface_id_ != mailbox.output_surface_id || |
| - last_host_id_ != mailbox.host_id) |
| - last_mailbox_valid_ = false; |
| - |
| - last_route_id_ = mailbox.route_id; |
| - last_output_surface_id_ = mailbox.output_surface_id; |
| - last_host_id_ = mailbox.host_id; |
| - |
| - ack_pending_ = true; |
| - // Browser plugin getting destroyed, do a fast ACK. |
| - if (!background_layer_.get()) { |
| - MailboxReleased(mailbox, sync_point, false); |
| - return; |
| - } |
| - |
| - if (!texture_layer_.get()) { |
| - texture_layer_ = cc::TextureLayer::CreateForMailbox(NULL); |
| - texture_layer_->SetIsDrawable(true); |
| - SetContentsOpaque(opaque_); |
| - |
| - background_layer_->AddChild(texture_layer_); |
| - } |
| - |
| - // The size of browser plugin container is not always equal to the size |
| - // of the buffer that arrives here. This could be for a number of reasons, |
| - // including autosize and a resize in progress. |
| - // During resize, the container size changes first and then some time |
| - // later, a new buffer with updated size will arrive. During this process, |
| - // we need to make sure that things are still displayed pixel perfect. |
| - // We accomplish this by modifying bounds of the texture layer only |
| - // when a new buffer arrives. |
| - // Visually, this will either display a smaller part of the buffer |
| - // or introduce a gutter around it. |
| - CheckSizeAndAdjustLayerProperties( |
| - mailbox.size, device_scale_factor, texture_layer_.get()); |
| - |
| - bool is_software_frame = mailbox.type == SOFTWARE_COMPOSITOR_FRAME; |
| - bool current_mailbox_valid = is_software_frame ? mailbox.shared_memory != NULL |
| - : !mailbox.name.IsZero(); |
| - if (!is_software_frame && !last_mailbox_valid_) { |
| - SwapBuffersInfo empty_info = mailbox; |
| - empty_info.name.SetZero(); |
| - MailboxReleased(empty_info, 0, false); |
| - if (!current_mailbox_valid) |
| - return; |
| - } |
| - |
| - cc::TextureMailbox texture_mailbox; |
| - scoped_ptr<cc::SingleReleaseCallback> release_callback; |
| - if (current_mailbox_valid) { |
| - release_callback = |
| - cc::SingleReleaseCallback::Create( |
| - base::Bind(&ChildFrameCompositingHelper::MailboxReleased, |
| - scoped_refptr<ChildFrameCompositingHelper>(this), |
| - mailbox)).Pass(); |
| - if (is_software_frame) { |
| - texture_mailbox = cc::TextureMailbox(mailbox.shared_memory, mailbox.size); |
| - } else { |
| - texture_mailbox = |
| - cc::TextureMailbox(mailbox.name, GL_TEXTURE_2D, sync_point); |
| - } |
| - } |
| - |
| - texture_layer_->SetFlipped(!is_software_frame); |
| - texture_layer_->SetTextureMailbox(texture_mailbox, release_callback.Pass()); |
| - texture_layer_->SetNeedsDisplay(); |
| - last_mailbox_valid_ = current_mailbox_valid; |
| -} |
| - |
| -void ChildFrameCompositingHelper::OnBuffersSwapped( |
| - const gfx::Size& size, |
| - const gpu::Mailbox& mailbox, |
| - int gpu_route_id, |
| - int gpu_host_id, |
| - float device_scale_factor) { |
| - SwapBuffersInfo swap_info; |
| - swap_info.name = mailbox; |
| - swap_info.type = TEXTURE_IMAGE_TRANSPORT; |
| - swap_info.size = size; |
| - swap_info.route_id = gpu_route_id; |
| - swap_info.output_surface_id = 0; |
| - swap_info.host_id = gpu_host_id; |
| - OnBuffersSwappedPrivate(swap_info, 0, device_scale_factor); |
| -} |
| - |
| void ChildFrameCompositingHelper::OnCompositorFrameSwapped( |
| scoped_ptr<cc::CompositorFrame> frame, |
| int route_id, |
| uint32 output_surface_id, |
| int host_id, |
| base::SharedMemoryHandle handle) { |
| - |
| - if (frame->gl_frame_data) { |
| - SwapBuffersInfo swap_info; |
| - swap_info.name = frame->gl_frame_data->mailbox; |
| - swap_info.type = GL_COMPOSITOR_FRAME; |
| - swap_info.size = frame->gl_frame_data->size; |
| - swap_info.route_id = route_id; |
| - swap_info.output_surface_id = output_surface_id; |
| - swap_info.host_id = host_id; |
| - OnBuffersSwappedPrivate(swap_info, |
| - frame->gl_frame_data->sync_point, |
| - frame->metadata.device_scale_factor); |
| - return; |
| - } |
| - |
| - if (frame->software_frame_data) { |
| - cc::SoftwareFrameData* frame_data = frame->software_frame_data.get(); |
| - |
| - SwapBuffersInfo swap_info; |
| - swap_info.type = SOFTWARE_COMPOSITOR_FRAME; |
| - swap_info.size = frame_data->size; |
| - swap_info.route_id = route_id; |
| - swap_info.output_surface_id = output_surface_id; |
| - swap_info.host_id = host_id; |
| - swap_info.software_frame_id = frame_data->id; |
| - |
| - scoped_ptr<base::SharedMemory> shared_memory( |
| - new base::SharedMemory(handle, true)); |
| - const size_t size_in_bytes = 4 * frame_data->size.GetArea(); |
| - if (!shared_memory->Map(size_in_bytes)) { |
| - LOG(ERROR) << "Failed to map shared memory of size " << size_in_bytes; |
| - // Send ACK right away. |
| - software_ack_pending_ = true; |
| - MailboxReleased(swap_info, 0, false); |
| - DidCommitCompositorFrame(); |
| - return; |
| - } |
| - |
| - swap_info.shared_memory = shared_memory.release(); |
| - OnBuffersSwappedPrivate(swap_info, 0, frame->metadata.device_scale_factor); |
| - software_ack_pending_ = true; |
| - last_route_id_ = route_id; |
| - last_output_surface_id_ = output_surface_id; |
| - last_host_id_ = host_id; |
| - return; |
| - } |
| - |
| DCHECK(!texture_layer_.get()); |
|
danakj
2014/09/19 19:06:29
can you remove texture_layer_?
Fady Samuel
2014/09/19 20:04:13
Done.
|
| cc::DelegatedFrameData* frame_data = frame->delegated_frame_data.get(); |