| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 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 "services/ui/ws/compositor_frame_sink_client_binding.h" |
| 6 |
| 7 namespace ui { |
| 8 namespace ws { |
| 9 |
| 10 DefaultCompositorFrameSinkClientBinding:: |
| 11 DefaultCompositorFrameSinkClientBinding( |
| 12 cc::mojom::MojoCompositorFrameSinkClient* sink_client, |
| 13 cc::mojom::MojoCompositorFrameSinkClientRequest sink_client_request, |
| 14 cc::mojom::MojoCompositorFrameSinkAssociatedPtr compositor_frame_sink, |
| 15 cc::mojom::DisplayPrivateAssociatedPtr display_private) |
| 16 : binding_(sink_client, std::move(sink_client_request)), |
| 17 display_private_(std::move(display_private)), |
| 18 compositor_frame_sink_(std::move(compositor_frame_sink)) {} |
| 19 |
| 20 DefaultCompositorFrameSinkClientBinding:: |
| 21 ~DefaultCompositorFrameSinkClientBinding() = default; |
| 22 |
| 23 void DefaultCompositorFrameSinkClientBinding::SubmitCompositorFrame( |
| 24 cc::CompositorFrame frame) { |
| 25 gfx::Size frame_size = last_submitted_frame_size_; |
| 26 if (!frame.render_pass_list.empty()) |
| 27 frame_size = frame.render_pass_list.back()->output_rect.size(); |
| 28 |
| 29 if (!local_surface_id_.is_valid() || |
| 30 frame_size != last_submitted_frame_size_) { |
| 31 local_surface_id_ = id_allocator_.GenerateId(); |
| 32 display_private_->ResizeDisplay(frame_size); |
| 33 display_private_->SetLocalSurfaceId(local_surface_id_, |
| 34 frame.metadata.device_scale_factor); |
| 35 } |
| 36 |
| 37 compositor_frame_sink_->SubmitCompositorFrame(local_surface_id_, |
| 38 std::move(frame)); |
| 39 compositor_frame_sink_->SetNeedsBeginFrame(false); |
| 40 last_submitted_frame_size_ = frame_size; |
| 41 } |
| 42 |
| 43 void DefaultCompositorFrameSinkClientBinding::SetNeedsBeginFrame( |
| 44 bool needs_begin_frame) { |
| 45 compositor_frame_sink_->SetNeedsBeginFrame(needs_begin_frame); |
| 46 } |
| 47 |
| 48 } // namespace ws |
| 49 } // namespace ui |
| OLD | NEW |