| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/surfaces/display_compositor_frame_sink.h" | 5 #include "services/ui/surfaces/display_compositor_frame_sink.h" |
| 6 | 6 |
| 7 #include "cc/output/copy_output_request.h" | 7 #include "cc/output/copy_output_request.h" |
| 8 #include "cc/output/output_surface.h" | 8 #include "cc/output/output_surface.h" |
| 9 #include "cc/output/renderer_settings.h" | 9 #include "cc/output/renderer_settings.h" |
| 10 #include "cc/output/texture_mailbox_deleter.h" | 10 #include "cc/output/texture_mailbox_deleter.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 int max_frames_pending = | 66 int max_frames_pending = |
| 67 display_output_surface->capabilities().max_frames_pending; | 67 display_output_surface->capabilities().max_frames_pending; |
| 68 DCHECK_GT(max_frames_pending, 0); | 68 DCHECK_GT(max_frames_pending, 0); |
| 69 | 69 |
| 70 std::unique_ptr<cc::DisplayScheduler> scheduler( | 70 std::unique_ptr<cc::DisplayScheduler> scheduler( |
| 71 new cc::DisplayScheduler(synthetic_begin_frame_source.get(), | 71 new cc::DisplayScheduler(synthetic_begin_frame_source.get(), |
| 72 task_runner_.get(), max_frames_pending)); | 72 task_runner_.get(), max_frames_pending)); |
| 73 | 73 |
| 74 display_.reset(new cc::Display( | 74 display_.reset(new cc::Display( |
| 75 nullptr /* bitmap_manager */, gpu_memory_buffer_manager, | 75 nullptr /* bitmap_manager */, gpu_memory_buffer_manager, |
| 76 cc::RendererSettings(), std::move(synthetic_begin_frame_source), | 76 cc::RendererSettings(), frame_sink_id_, |
| 77 std::move(synthetic_begin_frame_source), |
| 77 std::move(display_output_surface), std::move(scheduler), | 78 std::move(display_output_surface), std::move(scheduler), |
| 78 base::MakeUnique<cc::TextureMailboxDeleter>(task_runner_.get()))); | 79 base::MakeUnique<cc::TextureMailboxDeleter>(task_runner_.get()))); |
| 79 display_->Initialize(this, display_compositor_->manager(), frame_sink_id_); | 80 display_->Initialize(this, display_compositor_->manager()); |
| 80 display_->SetVisible(true); | 81 display_->SetVisible(true); |
| 81 } | 82 } |
| 82 | 83 |
| 83 DisplayCompositorFrameSink::~DisplayCompositorFrameSink() { | 84 DisplayCompositorFrameSink::~DisplayCompositorFrameSink() { |
| 84 display_compositor_->manager()->UnregisterSurfaceFactoryClient( | 85 display_compositor_->manager()->UnregisterSurfaceFactoryClient( |
| 85 frame_sink_id_); | 86 frame_sink_id_); |
| 86 display_compositor_->manager()->InvalidateFrameSinkId(frame_sink_id_); | 87 display_compositor_->manager()->InvalidateFrameSinkId(frame_sink_id_); |
| 87 } | 88 } |
| 88 | 89 |
| 89 void DisplayCompositorFrameSink::SubmitCompositorFrame( | 90 void DisplayCompositorFrameSink::SubmitCompositorFrame( |
| 90 cc::CompositorFrame frame, | 91 cc::CompositorFrame frame, |
| 91 const base::Callback<void()>& callback) { | 92 const base::Callback<void()>& callback) { |
| 92 gfx::Size frame_size = frame.render_pass_list.back()->output_rect.size(); | 93 gfx::Size frame_size = frame.render_pass_list.back()->output_rect.size(); |
| 93 if (frame_size.IsEmpty() || frame_size != display_size_) { | 94 if (frame_size.IsEmpty() || frame_size != display_size_) { |
| 94 if (!local_frame_id_.is_null()) | 95 if (!local_frame_id_.is_null()) |
| 95 factory_.Destroy(local_frame_id_); | 96 factory_.Destroy(local_frame_id_); |
| 96 local_frame_id_ = allocator_.GenerateId(); | 97 local_frame_id_ = allocator_.GenerateId(); |
| 97 factory_.Create(local_frame_id_); | 98 factory_.Create(local_frame_id_); |
| 98 display_size_ = frame_size; | 99 display_size_ = frame_size; |
| 99 display_->Resize(display_size_); | 100 display_->Resize(display_size_); |
| 100 } | 101 } |
| 101 display_->SetSurfaceId(cc::SurfaceId(frame_sink_id_, local_frame_id_), | 102 display_->SetLocalFrameId(local_frame_id_, |
| 102 frame.metadata.device_scale_factor); | 103 frame.metadata.device_scale_factor); |
| 103 factory_.SubmitCompositorFrame(local_frame_id_, std::move(frame), callback); | 104 factory_.SubmitCompositorFrame(local_frame_id_, std::move(frame), callback); |
| 104 } | 105 } |
| 105 | 106 |
| 106 void DisplayCompositorFrameSink::ReturnResources( | 107 void DisplayCompositorFrameSink::ReturnResources( |
| 107 const cc::ReturnedResourceArray& resources) { | 108 const cc::ReturnedResourceArray& resources) { |
| 108 // TODO(fsamuel): Implement this. | 109 // TODO(fsamuel): Implement this. |
| 109 } | 110 } |
| 110 | 111 |
| 111 void DisplayCompositorFrameSink::SetBeginFrameSource( | 112 void DisplayCompositorFrameSink::SetBeginFrameSource( |
| 112 cc::BeginFrameSource* begin_frame_source) { | 113 cc::BeginFrameSource* begin_frame_source) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 125 // This notification is not relevant to our client outside of tests. | 126 // This notification is not relevant to our client outside of tests. |
| 126 } | 127 } |
| 127 | 128 |
| 128 void DisplayCompositorFrameSink::DisplayDidDrawAndSwap() { | 129 void DisplayCompositorFrameSink::DisplayDidDrawAndSwap() { |
| 129 // This notification is not relevant to our client outside of tests. We | 130 // This notification is not relevant to our client outside of tests. We |
| 130 // unblock the client from the DrawCallback when the surface is going to | 131 // unblock the client from the DrawCallback when the surface is going to |
| 131 // be drawn. | 132 // be drawn. |
| 132 } | 133 } |
| 133 | 134 |
| 134 } // namespace ui | 135 } // namespace ui |
| OLD | NEW |