Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/renderer/gpu/renderer_compositor_frame_sink.h" | |
| 6 | |
| 7 #include <utility> | |
| 8 | |
| 9 #include "base/command_line.h" | |
| 10 #include "base/location.h" | |
| 11 #include "base/single_thread_task_runner.h" | |
| 12 #include "base/threading/thread_task_runner_handle.h" | |
| 13 #include "build/build_config.h" | |
| 14 #include "cc/output/compositor_frame.h" | |
| 15 #include "cc/output/compositor_frame_sink_client.h" | |
| 16 #include "cc/output/managed_memory_policy.h" | |
| 17 #include "content/common/view_messages.h" | |
| 18 #include "content/public/common/content_switches.h" | |
| 19 #include "content/renderer/render_thread_impl.h" | |
| 20 #include "gpu/command_buffer/client/context_support.h" | |
| 21 #include "gpu/command_buffer/client/gles2_interface.h" | |
| 22 #include "gpu/ipc/client/command_buffer_proxy_impl.h" | |
| 23 #include "ipc/ipc_sync_channel.h" | |
| 24 #include "services/ui/public/cpp/gpu/context_provider_command_buffer.h" | |
| 25 | |
| 26 namespace content { | |
| 27 | |
| 28 RendererCompositorFrameSink::RendererCompositorFrameSink( | |
| 29 int32_t routing_id, | |
| 30 std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source, | |
| 31 scoped_refptr<cc::ContextProvider> context_provider, | |
| 32 scoped_refptr<cc::ContextProvider> worker_context_provider, | |
| 33 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | |
| 34 cc::SharedBitmapManager* shared_bitmap_manager, | |
| 35 cc::mojom::MojoCompositorFrameSinkPtrInfo sink_info, | |
| 36 cc::mojom::MojoCompositorFrameSinkClientRequest sink_client_request) | |
| 37 : ClientCompositorFrameSink(std::move(context_provider), | |
| 38 std::move(worker_context_provider), | |
| 39 gpu_memory_buffer_manager, | |
| 40 shared_bitmap_manager, | |
| 41 std::move(synthetic_begin_frame_source), | |
| 42 std::move(sink_info), | |
| 43 std::move(sink_client_request), | |
| 44 false /* enable_surface_synchronization */), | |
| 45 compositor_frame_sink_filter_( | |
| 46 RenderThreadImpl::current()->compositor_message_filter()), | |
| 47 message_sender_(RenderThreadImpl::current()->sync_message_filter()), | |
| 48 routing_id_(routing_id) { | |
| 49 DCHECK(compositor_frame_sink_filter_); | |
| 50 DCHECK(message_sender_); | |
| 51 } | |
| 52 | |
| 53 RendererCompositorFrameSink::RendererCompositorFrameSink( | |
| 54 int32_t routing_id, | |
| 55 std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source, | |
| 56 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider, | |
| 57 cc::mojom::MojoCompositorFrameSinkPtrInfo sink_info, | |
| 58 cc::mojom::MojoCompositorFrameSinkClientRequest sink_client_request) | |
| 59 : ClientCompositorFrameSink(std::move(vulkan_context_provider), | |
| 60 std::move(synthetic_begin_frame_source), | |
| 61 std::move(sink_info), | |
| 62 std::move(sink_client_request), | |
| 63 false /* enable_surface_synchronization */), | |
| 64 compositor_frame_sink_filter_( | |
| 65 RenderThreadImpl::current()->compositor_message_filter()), | |
| 66 message_sender_(RenderThreadImpl::current()->sync_message_filter()), | |
| 67 routing_id_(routing_id) { | |
| 68 DCHECK(compositor_frame_sink_filter_); | |
| 69 DCHECK(message_sender_); | |
| 70 } | |
| 71 | |
| 72 RendererCompositorFrameSink::~RendererCompositorFrameSink() = default; | |
| 73 | |
| 74 bool RendererCompositorFrameSink::BindToClient( | |
| 75 cc::CompositorFrameSinkClient* client) { | |
| 76 if (!ClientCompositorFrameSink::BindToClient(client)) | |
| 77 return false; | |
| 78 | |
| 79 compositor_frame_sink_proxy_ = new RendererCompositorFrameSinkProxy(this); | |
|
piman
2017/06/05 16:56:25
nit: Can we remove RendererCompositorFrameSinkProx
| |
| 80 compositor_frame_sink_filter_handler_ = | |
| 81 base::Bind(&RendererCompositorFrameSinkProxy::OnMessageReceived, | |
| 82 compositor_frame_sink_proxy_); | |
| 83 compositor_frame_sink_filter_->AddHandlerOnCompositorThread( | |
| 84 routing_id_, compositor_frame_sink_filter_handler_); | |
| 85 | |
| 86 return true; | |
| 87 } | |
| 88 | |
| 89 void RendererCompositorFrameSink::DetachFromClient() { | |
| 90 compositor_frame_sink_proxy_->ClearCompositorFrameSink(); | |
| 91 compositor_frame_sink_filter_->RemoveHandlerOnCompositorThread( | |
| 92 routing_id_, compositor_frame_sink_filter_handler_); | |
| 93 ClientCompositorFrameSink::DetachFromClient(); | |
| 94 } | |
| 95 | |
| 96 void RendererCompositorFrameSink::SubmitCompositorFrame( | |
| 97 cc::CompositorFrame frame) { | |
| 98 auto new_surface_properties = | |
| 99 RenderWidgetSurfaceProperties::FromCompositorFrame(frame); | |
| 100 ClientCompositorFrameSink::SubmitCompositorFrame(std::move(frame)); | |
| 101 current_surface_properties_ = new_surface_properties; | |
| 102 } | |
| 103 | |
| 104 bool RendererCompositorFrameSink::ShouldAllocateNewLocalSurfaceId( | |
| 105 const cc::CompositorFrame& frame) { | |
| 106 return current_surface_properties_ != | |
| 107 RenderWidgetSurfaceProperties::FromCompositorFrame(frame); | |
| 108 } | |
| 109 | |
| 110 } // namespace content | |
| OLD | NEW |