Index: components/viz/client/client_compositor_frame_sink.cc |
diff --git a/components/viz/client/client_compositor_frame_sink.cc b/components/viz/client/client_compositor_frame_sink.cc |
index df0ad3f928eb32b6699386d8c3f8eb223a4fb50b..b39624a5d655479e69f6b171abda0ab82da141f4 100644 |
--- a/components/viz/client/client_compositor_frame_sink.cc |
+++ b/components/viz/client/client_compositor_frame_sink.cc |
@@ -17,19 +17,24 @@ ClientCompositorFrameSink::ClientCompositorFrameSink( |
gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
cc::mojom::MojoCompositorFrameSinkPtrInfo compositor_frame_sink_info, |
cc::mojom::MojoCompositorFrameSinkClientRequest client_request, |
- bool enable_surface_synchronization) |
+ bool generate_local_surface_id) |
: cc::CompositorFrameSink(std::move(context_provider), |
nullptr, |
gpu_memory_buffer_manager, |
nullptr), |
compositor_frame_sink_info_(std::move(compositor_frame_sink_info)), |
client_request_(std::move(client_request)), |
- enable_surface_synchronization_(enable_surface_synchronization) { |
+ generate_local_surface_id_(generate_local_surface_id) { |
DETACH_FROM_THREAD(thread_checker_); |
} |
ClientCompositorFrameSink::~ClientCompositorFrameSink() {} |
+void ClientCompositorFrameSink::SetSurfaceChangedCallback( |
+ const SurfaceChangedCallback& callback) { |
+ surface_changed_callback_ = callback; |
+} |
+ |
bool ClientCompositorFrameSink::BindToClient( |
cc::CompositorFrameSinkClient* client) { |
if (!cc::CompositorFrameSink::BindToClient(client)) |
@@ -58,7 +63,7 @@ void ClientCompositorFrameSink::DetachFromClient() { |
void ClientCompositorFrameSink::SetLocalSurfaceId( |
const cc::LocalSurfaceId& local_surface_id) { |
DCHECK(local_surface_id.is_valid()); |
- DCHECK(enable_surface_synchronization_); |
+ DCHECK(!generate_local_surface_id_); |
local_surface_id_ = local_surface_id; |
} |
@@ -72,15 +77,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 (generate_local_surface_id_) { |
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); |
} |
void ClientCompositorFrameSink::DidNotProduceFrame( |