Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "cc/surfaces/direct_compositor_frame_sink.h" | 5 #include "cc/surfaces/direct_compositor_frame_sink.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "cc/output/compositor_frame.h" | 8 #include "cc/output/compositor_frame.h" |
| 9 #include "cc/output/compositor_frame_sink_client.h" | 9 #include "cc/output/compositor_frame_sink_client.h" |
| 10 #include "cc/surfaces/display.h" | 10 #include "cc/surfaces/display.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 60 | 60 |
| 61 if (!CompositorFrameSink::BindToClient(client)) | 61 if (!CompositorFrameSink::BindToClient(client)) |
| 62 return false; | 62 return false; |
| 63 | 63 |
| 64 // We want the Display's output surface to hear about lost context, and since | 64 // We want the Display's output surface to hear about lost context, and since |
| 65 // this shares a context with it, we should not be listening for lost context | 65 // this shares a context with it, we should not be listening for lost context |
| 66 // callbacks on the context here. | 66 // callbacks on the context here. |
| 67 if (auto* cp = context_provider()) | 67 if (auto* cp = context_provider()) |
| 68 cp->SetLostContextCallback(base::Closure()); | 68 cp->SetLostContextCallback(base::Closure()); |
| 69 | 69 |
| 70 const bool submits_to_display_compositor = true; | |
|
Fady Samuel
2017/02/08 21:37:46
constexpr
Alex Z.
2017/02/08 21:41:43
Done.
| |
| 70 support_ = base::MakeUnique<CompositorFrameSinkSupport>( | 71 support_ = base::MakeUnique<CompositorFrameSinkSupport>( |
| 71 this, surface_manager_, frame_sink_id_, display_, false, | 72 this, surface_manager_, frame_sink_id_, false, |
| 72 capabilities_.delegated_sync_points_required); | 73 capabilities_.delegated_sync_points_required, |
| 74 submits_to_display_compositor); | |
| 73 | 75 |
| 74 begin_frame_source_ = base::MakeUnique<ExternalBeginFrameSource>(this); | 76 begin_frame_source_ = base::MakeUnique<ExternalBeginFrameSource>(this); |
| 75 client_->SetBeginFrameSource(begin_frame_source_.get()); | 77 client_->SetBeginFrameSource(begin_frame_source_.get()); |
| 78 | |
| 76 // Avoid initializing GL context here, as this should be sharing the | 79 // Avoid initializing GL context here, as this should be sharing the |
| 77 // Display's context. | 80 // Display's context. |
| 81 display_->Initialize(this, surface_manager_); | |
| 78 | 82 |
| 79 return true; | 83 return true; |
| 80 } | 84 } |
| 81 | 85 |
| 82 void DirectCompositorFrameSink::DetachFromClient() { | 86 void DirectCompositorFrameSink::DetachFromClient() { |
| 83 client_->SetBeginFrameSource(nullptr); | 87 client_->SetBeginFrameSource(nullptr); |
| 84 begin_frame_source_.reset(); | 88 begin_frame_source_.reset(); |
| 85 support_.reset(); | 89 support_.reset(); |
| 86 CompositorFrameSink::DetachFromClient(); | 90 CompositorFrameSink::DetachFromClient(); |
| 87 } | 91 } |
| 88 | 92 |
| 89 void DirectCompositorFrameSink::SubmitCompositorFrame(CompositorFrame frame) { | 93 void DirectCompositorFrameSink::SubmitCompositorFrame(CompositorFrame frame) { |
| 90 gfx::Size frame_size = frame.render_pass_list.back()->output_rect.size(); | 94 gfx::Size frame_size = frame.render_pass_list.back()->output_rect.size(); |
| 91 if (frame_size.IsEmpty() || frame_size != last_swap_frame_size_) { | 95 if (frame_size.IsEmpty() || frame_size != last_swap_frame_size_) { |
| 92 delegated_local_surface_id_ = surface_id_allocator_.GenerateId(); | 96 delegated_local_surface_id_ = surface_id_allocator_.GenerateId(); |
| 93 last_swap_frame_size_ = frame_size; | 97 last_swap_frame_size_ = frame_size; |
| 94 } | 98 } |
| 99 display_->SetLocalSurfaceId(delegated_local_surface_id_, | |
| 100 frame.metadata.device_scale_factor); | |
| 95 support_->SubmitCompositorFrame(delegated_local_surface_id_, | 101 support_->SubmitCompositorFrame(delegated_local_surface_id_, |
| 96 std::move(frame)); | 102 std::move(frame)); |
| 97 } | 103 } |
| 98 | 104 |
| 99 void DirectCompositorFrameSink::ForceReclaimResources() { | 105 void DirectCompositorFrameSink::ForceReclaimResources() { |
| 100 support_->ForceReclaimResources(); | 106 support_->ForceReclaimResources(); |
| 101 } | 107 } |
| 102 | 108 |
| 103 void DirectCompositorFrameSink::DisplayOutputSurfaceLost() { | 109 void DirectCompositorFrameSink::DisplayOutputSurfaceLost() { |
| 104 is_lost_ = true; | 110 is_lost_ = true; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 | 142 |
| 137 void DirectCompositorFrameSink::DidDrawCallback() { | 143 void DirectCompositorFrameSink::DidDrawCallback() { |
| 138 client_->DidReceiveCompositorFrameAck(); | 144 client_->DidReceiveCompositorFrameAck(); |
| 139 } | 145 } |
| 140 | 146 |
| 141 void DirectCompositorFrameSink::OnNeedsBeginFrames(bool needs_begin_frame) { | 147 void DirectCompositorFrameSink::OnNeedsBeginFrames(bool needs_begin_frame) { |
| 142 support_->SetNeedsBeginFrame(needs_begin_frame); | 148 support_->SetNeedsBeginFrame(needs_begin_frame); |
| 143 } | 149 } |
| 144 | 150 |
| 145 } // namespace cc | 151 } // namespace cc |
| OLD | NEW |