Index: services/ui/public/cpp/client_compositor_frame_sink.cc |
diff --git a/services/ui/public/cpp/client_compositor_frame_sink.cc b/services/ui/public/cpp/client_compositor_frame_sink.cc |
index ef014e05ae77d58a8dbc11cf528072e859106aa0..65a3567068b367277fdf09d2a48a1dd5c311cb30 100644 |
--- a/services/ui/public/cpp/client_compositor_frame_sink.cc |
+++ b/services/ui/public/cpp/client_compositor_frame_sink.cc |
@@ -16,7 +16,6 @@ namespace ui { |
// static |
std::unique_ptr<ClientCompositorFrameSink> ClientCompositorFrameSink::Create( |
- const cc::FrameSinkId& frame_sink_id, |
scoped_refptr<cc::ContextProvider> context_provider, |
gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
std::unique_ptr<ClientCompositorFrameSinkBinding>* |
@@ -31,13 +30,19 @@ std::unique_ptr<ClientCompositorFrameSink> ClientCompositorFrameSink::Create( |
MakeRequest(&compositor_frame_sink), |
compositor_frame_sink_client.PassInterface())); |
return base::WrapUnique(new ClientCompositorFrameSink( |
- frame_sink_id, std::move(context_provider), gpu_memory_buffer_manager, |
+ std::move(context_provider), gpu_memory_buffer_manager, |
compositor_frame_sink.PassInterface(), |
std::move(compositor_frame_sink_client_request))); |
} |
ClientCompositorFrameSink::~ClientCompositorFrameSink() {} |
+void ClientCompositorFrameSink::SetSurfaceChangedCallback( |
+ const SurfaceChangedCallback& callback) { |
+ DCHECK(!surface_changed_callback_); |
+ surface_changed_callback_ = callback; |
+} |
+ |
bool ClientCompositorFrameSink::BindToClient( |
cc::CompositorFrameSinkClient* client) { |
if (!cc::CompositorFrameSink::BindToClient(client)) |
@@ -57,6 +62,8 @@ bool ClientCompositorFrameSink::BindToClient( |
} |
void ClientCompositorFrameSink::DetachFromClient() { |
+ if (surface_changed_callback_ && local_surface_id_.is_valid()) |
+ surface_changed_callback_.Run(cc::LocalSurfaceId(), gfx::Size()); |
client_->SetBeginFrameSource(nullptr); |
begin_frame_source_.reset(); |
client_binding_.reset(); |
@@ -81,19 +88,23 @@ void ClientCompositorFrameSink::SubmitCompositorFrame( |
DCHECK_LE(cc::BeginFrameArgs::kStartingFrameNumber, |
frame.metadata.begin_frame_ack.sequence_number); |
+ bool surface_changed = false; |
gfx::Size frame_size = frame.render_pass_list.back()->output_rect.size(); |
if (!enable_surface_synchronization_ && |
(!local_surface_id_.is_valid() || |
frame_size != last_submitted_frame_size_)) { |
local_surface_id_ = id_allocator_.GenerateId(); |
+ last_submitted_frame_size_ = frame_size; |
+ surface_changed = true; |
} |
compositor_frame_sink_->SubmitCompositorFrame(local_surface_id_, |
std::move(frame)); |
- last_submitted_frame_size_ = frame_size; |
+ if (surface_changed && surface_changed_callback_) { |
+ surface_changed_callback_.Run(local_surface_id_, frame_size); |
+ } |
} |
ClientCompositorFrameSink::ClientCompositorFrameSink( |
- const cc::FrameSinkId& frame_sink_id, |
scoped_refptr<cc::ContextProvider> context_provider, |
gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
cc::mojom::MojoCompositorFrameSinkPtrInfo compositor_frame_sink_info, |
@@ -103,8 +114,7 @@ ClientCompositorFrameSink::ClientCompositorFrameSink( |
gpu_memory_buffer_manager, |
nullptr), |
compositor_frame_sink_info_(std::move(compositor_frame_sink_info)), |
- client_request_(std::move(client_request)), |
- frame_sink_id_(frame_sink_id) { |
+ client_request_(std::move(client_request)) { |
enable_surface_synchronization_ = |
base::CommandLine::ForCurrentProcess()->HasSwitch( |
cc::switches::kEnableSurfaceSynchronization); |