| 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 "content/browser/compositor/mus_browser_compositor_output_surface.h" | 5 #include "content/browser/compositor/mus_browser_compositor_output_surface.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "cc/output/compositor_frame.h" | 9 #include "cc/output/compositor_frame.h" |
| 10 #include "cc/output/output_surface_frame.h" | 10 #include "cc/output/output_surface_frame.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 cc::SyntheticBeginFrameSource* begin_frame_source, | 26 cc::SyntheticBeginFrameSource* begin_frame_source, |
| 27 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator> | 27 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator> |
| 28 overlay_candidate_validator) | 28 overlay_candidate_validator) |
| 29 : GpuBrowserCompositorOutputSurface(std::move(context), | 29 : GpuBrowserCompositorOutputSurface(std::move(context), |
| 30 std::move(vsync_manager), | 30 std::move(vsync_manager), |
| 31 begin_frame_source, | 31 begin_frame_source, |
| 32 std::move(overlay_candidate_validator)), | 32 std::move(overlay_candidate_validator)), |
| 33 ui_window_(window) { | 33 ui_window_(window) { |
| 34 ui_compositor_frame_sink_ = ui_window_->RequestCompositorFrameSink( | 34 ui_compositor_frame_sink_ = ui_window_->RequestCompositorFrameSink( |
| 35 ui::mojom::CompositorFrameSinkType::DEFAULT, context); | 35 ui::mojom::CompositorFrameSinkType::DEFAULT, context); |
| 36 ui_compositor_frame_sink_->BindToClient(this); |
| 36 } | 37 } |
| 37 | 38 |
| 38 MusBrowserCompositorOutputSurface::~MusBrowserCompositorOutputSurface() {} | 39 MusBrowserCompositorOutputSurface::~MusBrowserCompositorOutputSurface() {} |
| 39 | 40 |
| 40 void MusBrowserCompositorOutputSurface::SwapBuffers( | 41 void MusBrowserCompositorOutputSurface::SwapBuffers( |
| 41 cc::OutputSurfaceFrame frame) { | 42 cc::OutputSurfaceFrame frame) { |
| 42 const gfx::Rect bounds(ui_window_->bounds().size()); | 43 const gfx::Rect bounds(ui_window_->bounds().size()); |
| 43 cc::CompositorFrame ui_frame; | 44 cc::CompositorFrame ui_frame; |
| 44 ui_frame.metadata.latency_info = std::move(frame.latency_info); | 45 ui_frame.metadata.latency_info = std::move(frame.latency_info); |
| 45 // Reset latency_info to known empty state after moving contents. | 46 // Reset latency_info to known empty state after moving contents. |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 quad->SetAll(sqs, rect, rect, rect, needs_blending, resource.id, gfx::Size(), | 103 quad->SetAll(sqs, rect, rect, rect, needs_blending, resource.id, gfx::Size(), |
| 103 premultiplied_alpha, uv_top_left, uv_bottom_right, | 104 premultiplied_alpha, uv_top_left, uv_bottom_right, |
| 104 background_color, vertex_opacity, y_flipped, nearest_neighbor, | 105 background_color, vertex_opacity, y_flipped, nearest_neighbor, |
| 105 secure_output_only); | 106 secure_output_only); |
| 106 | 107 |
| 107 ui_frame.delegated_frame_data->render_pass_list.push_back(std::move(pass)); | 108 ui_frame.delegated_frame_data->render_pass_list.push_back(std::move(pass)); |
| 108 ui_compositor_frame_sink_->SubmitCompositorFrame(std::move(ui_frame)); | 109 ui_compositor_frame_sink_->SubmitCompositorFrame(std::move(ui_frame)); |
| 109 return; | 110 return; |
| 110 } | 111 } |
| 111 | 112 |
| 112 bool MusBrowserCompositorOutputSurface::BindToClient( | |
| 113 cc::OutputSurfaceClient* client) { | |
| 114 if (!GpuBrowserCompositorOutputSurface::BindToClient(client)) | |
| 115 return false; | |
| 116 ui_compositor_frame_sink_->BindToClient(this); | |
| 117 return true; | |
| 118 } | |
| 119 | |
| 120 void MusBrowserCompositorOutputSurface::SetBeginFrameSource( | 113 void MusBrowserCompositorOutputSurface::SetBeginFrameSource( |
| 121 cc::BeginFrameSource* source) {} | 114 cc::BeginFrameSource* source) {} |
| 122 | 115 |
| 123 void MusBrowserCompositorOutputSurface::ReclaimResources( | 116 void MusBrowserCompositorOutputSurface::ReclaimResources( |
| 124 const cc::ReturnedResourceArray& resources) { | 117 const cc::ReturnedResourceArray& resources) { |
| 125 for (const auto& resource : resources) { | 118 for (const auto& resource : resources) { |
| 126 DCHECK_EQ(1, resource.count); | 119 DCHECK_EQ(1, resource.count); |
| 127 const gpu::Mailbox& mailbox = GetMailboxFromResourceId(resource.id); | 120 const gpu::Mailbox& mailbox = GetMailboxFromResourceId(resource.id); |
| 128 GetCommandBufferProxy()->ReturnFrontBuffer(mailbox, resource.sync_token, | 121 GetCommandBufferProxy()->ReturnFrontBuffer(mailbox, resource.sync_token, |
| 129 resource.lost); | 122 resource.lost); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 | 168 |
| 176 const gpu::Mailbox& MusBrowserCompositorOutputSurface::GetMailboxFromResourceId( | 169 const gpu::Mailbox& MusBrowserCompositorOutputSurface::GetMailboxFromResourceId( |
| 177 uint32_t id) { | 170 uint32_t id) { |
| 178 DCHECK_LT(id, mailboxes_.size()); | 171 DCHECK_LT(id, mailboxes_.size()); |
| 179 DCHECK(std::find(free_resource_ids_.begin(), free_resource_ids_.end(), id) == | 172 DCHECK(std::find(free_resource_ids_.begin(), free_resource_ids_.end(), id) == |
| 180 free_resource_ids_.end()); | 173 free_resource_ids_.end()); |
| 181 return mailboxes_[id]; | 174 return mailboxes_[id]; |
| 182 } | 175 } |
| 183 | 176 |
| 184 } // namespace content | 177 } // namespace content |
| OLD | NEW |