| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "services/ui/ws/server_window_surface.h" | 5 #include "services/ui/ws/server_window_surface.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "cc/output/compositor_frame.h" | 9 #include "cc/output/compositor_frame.h" |
| 10 #include "cc/quads/shared_quad_state.h" | 10 #include "cc/quads/shared_quad_state.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 surface_manager->InvalidateFrameSinkId(frame_sink_id_); | 43 surface_manager->InvalidateFrameSinkId(frame_sink_id_); |
| 44 } | 44 } |
| 45 | 45 |
| 46 void ServerWindowSurface::SubmitCompositorFrame( | 46 void ServerWindowSurface::SubmitCompositorFrame( |
| 47 cc::CompositorFrame frame, | 47 cc::CompositorFrame frame, |
| 48 const SubmitCompositorFrameCallback& callback) { | 48 const SubmitCompositorFrameCallback& callback) { |
| 49 gfx::Size frame_size = | 49 gfx::Size frame_size = |
| 50 frame.delegated_frame_data->render_pass_list[0]->output_rect.size(); | 50 frame.delegated_frame_data->render_pass_list[0]->output_rect.size(); |
| 51 // If the size of the CompostiorFrame has changed then destroy the existing | 51 // If the size of the CompostiorFrame has changed then destroy the existing |
| 52 // Surface and create a new one of the appropriate size. | 52 // Surface and create a new one of the appropriate size. |
| 53 if (local_frame_id_.is_null() || frame_size != last_submitted_frame_size_) { | 53 if (!local_frame_id_.is_valid() || frame_size != last_submitted_frame_size_) { |
| 54 if (!local_frame_id_.is_null()) | 54 if (local_frame_id_.is_valid()) |
| 55 surface_factory_.Destroy(local_frame_id_); | 55 surface_factory_.Destroy(local_frame_id_); |
| 56 local_frame_id_ = surface_id_allocator_.GenerateId(); | 56 local_frame_id_ = surface_id_allocator_.GenerateId(); |
| 57 surface_factory_.Create(local_frame_id_); | 57 surface_factory_.Create(local_frame_id_); |
| 58 } | 58 } |
| 59 may_contain_video_ = frame.metadata.may_contain_video; | 59 may_contain_video_ = frame.metadata.may_contain_video; |
| 60 surface_factory_.SubmitCompositorFrame(local_frame_id_, std::move(frame), | 60 surface_factory_.SubmitCompositorFrame(local_frame_id_, std::move(frame), |
| 61 callback); | 61 callback); |
| 62 last_submitted_frame_size_ = frame_size; | 62 last_submitted_frame_size_ = frame_size; |
| 63 window()->delegate()->OnScheduleWindowPaint(window()); | 63 window()->delegate()->OnScheduleWindowPaint(window()); |
| 64 } | 64 } |
| 65 | 65 |
| 66 cc::SurfaceId ServerWindowSurface::GetSurfaceId() const { | 66 cc::SurfaceId ServerWindowSurface::GetSurfaceId() const { |
| 67 if (local_frame_id_.is_null()) | 67 if (!local_frame_id_.is_valid()) |
| 68 return cc::SurfaceId(); | 68 return cc::SurfaceId(); |
| 69 return cc::SurfaceId(frame_sink_id_, local_frame_id_); | 69 return cc::SurfaceId(frame_sink_id_, local_frame_id_); |
| 70 } | 70 } |
| 71 | 71 |
| 72 cc::SurfaceSequence ServerWindowSurface::CreateSurfaceSequence() { | 72 cc::SurfaceSequence ServerWindowSurface::CreateSurfaceSequence() { |
| 73 return surface_sequence_generator_.CreateSurfaceSequence(); | 73 return surface_sequence_generator_.CreateSurfaceSequence(); |
| 74 } | 74 } |
| 75 | 75 |
| 76 ServerWindow* ServerWindowSurface::window() { | 76 ServerWindow* ServerWindowSurface::window() { |
| 77 return manager_->window(); | 77 return manager_->window(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 void ServerWindowSurface::ReturnResources( | 80 void ServerWindowSurface::ReturnResources( |
| 81 const cc::ReturnedResourceArray& resources) { | 81 const cc::ReturnedResourceArray& resources) { |
| 82 if (!client_ || !base::MessageLoop::current()) | 82 if (!client_ || !base::MessageLoop::current()) |
| 83 return; | 83 return; |
| 84 client_->ReturnResources(mojo::Array<cc::ReturnedResource>::From(resources)); | 84 client_->ReturnResources(mojo::Array<cc::ReturnedResource>::From(resources)); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void ServerWindowSurface::SetBeginFrameSource( | 87 void ServerWindowSurface::SetBeginFrameSource( |
| 88 cc::BeginFrameSource* begin_frame_source) { | 88 cc::BeginFrameSource* begin_frame_source) { |
| 89 // TODO(tansell): Implement this. | 89 // TODO(tansell): Implement this. |
| 90 } | 90 } |
| 91 | 91 |
| 92 } // namespace ws | 92 } // namespace ws |
| 93 } // namespace ui | 93 } // namespace ui |
| OLD | NEW |