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 487ef4dba3bf40963b51e683c91dfb7deaa23bae..2bf8d89658896b658caea874c33c57641a87b0d6 100644 |
--- a/services/ui/public/cpp/client_compositor_frame_sink.cc |
+++ b/services/ui/public/cpp/client_compositor_frame_sink.cc |
@@ -37,6 +37,12 @@ std::unique_ptr<ClientCompositorFrameSink> ClientCompositorFrameSink::Create( |
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)) |
@@ -56,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(); |
@@ -80,15 +88,20 @@ 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 (!local_surface_id_.is_valid() || |
frame_size != last_submitted_frame_size_) { |
last_submitted_frame_size_ = frame_size; |
- if (!enable_surface_synchronization_) |
+ if (!enable_surface_synchronization_) { |
local_surface_id_ = id_allocator_.GenerateId(); |
+ surface_changed = true; |
+ } |
} |
compositor_frame_sink_->SubmitCompositorFrame(local_surface_id_, |
std::move(frame)); |
+ if (surface_changed && surface_changed_callback_) |
+ surface_changed_callback_.Run(local_surface_id_, frame_size); |
} |
ClientCompositorFrameSink::ClientCompositorFrameSink( |