Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(191)

Side by Side Diff: content/browser/compositor/mus_browser_compositor_output_surface.cc

Issue 2568783002: [mus] Use external BeginFrameSource in browser client. (Closed)
Patch Set: rebase. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/compositor/mus_browser_compositor_output_surface.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
26 ui::Window* window, 26 ui::Window* window,
27 scoped_refptr<ContextProviderCommandBuffer> context, 27 scoped_refptr<ContextProviderCommandBuffer> context,
28 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, 28 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
29 const UpdateVSyncParametersCallback& update_vsync_parameters_callback, 29 const UpdateVSyncParametersCallback& update_vsync_parameters_callback,
30 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator> 30 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator>
31 overlay_candidate_validator) 31 overlay_candidate_validator)
32 : GpuBrowserCompositorOutputSurface(std::move(context), 32 : GpuBrowserCompositorOutputSurface(std::move(context),
33 update_vsync_parameters_callback, 33 update_vsync_parameters_callback,
34 std::move(overlay_candidate_validator)), 34 std::move(overlay_candidate_validator)),
35 ui_window_(window), 35 ui_window_(window),
36 window_(nullptr) { 36 window_(nullptr),
37 begin_frame_source_(nullptr) {
37 ui_compositor_frame_sink_ = ui_window_->RequestCompositorFrameSink( 38 ui_compositor_frame_sink_ = ui_window_->RequestCompositorFrameSink(
38 ui::mojom::CompositorFrameSinkType::DEFAULT, context, 39 ui::mojom::CompositorFrameSinkType::DEFAULT, context,
39 gpu_memory_buffer_manager); 40 gpu_memory_buffer_manager);
40 ui_compositor_frame_sink_->BindToClient(this); 41 ui_compositor_frame_sink_->BindToClient(this);
41 } 42 }
42 43
43 MusBrowserCompositorOutputSurface::MusBrowserCompositorOutputSurface( 44 MusBrowserCompositorOutputSurface::MusBrowserCompositorOutputSurface(
44 aura::Window* window, 45 aura::Window* window,
45 scoped_refptr<ContextProviderCommandBuffer> context, 46 scoped_refptr<ContextProviderCommandBuffer> context,
46 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, 47 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
47 const UpdateVSyncParametersCallback& update_vsync_parameters_callback, 48 const UpdateVSyncParametersCallback& update_vsync_parameters_callback,
48 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator> 49 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator>
49 overlay_candidate_validator) 50 overlay_candidate_validator)
50 : GpuBrowserCompositorOutputSurface(std::move(context), 51 : GpuBrowserCompositorOutputSurface(std::move(context),
51 update_vsync_parameters_callback, 52 update_vsync_parameters_callback,
52 std::move(overlay_candidate_validator)), 53 std::move(overlay_candidate_validator)),
53 ui_window_(nullptr), 54 ui_window_(nullptr),
54 window_(window) { 55 window_(window),
56 begin_frame_source_(nullptr) {
55 aura::WindowPortMus* window_port = aura::WindowPortMus::Get(window_); 57 aura::WindowPortMus* window_port = aura::WindowPortMus::Get(window_);
56 DCHECK(window_port); 58 DCHECK(window_port);
57 compositor_frame_sink_ = window_port->RequestCompositorFrameSink( 59 compositor_frame_sink_ = window_port->RequestCompositorFrameSink(
58 ui::mojom::CompositorFrameSinkType::DEFAULT, context, 60 ui::mojom::CompositorFrameSinkType::DEFAULT, context,
59 gpu_memory_buffer_manager); 61 gpu_memory_buffer_manager);
60 compositor_frame_sink_->BindToClient(this); 62 compositor_frame_sink_->BindToClient(this);
61 } 63 }
62 64
63 MusBrowserCompositorOutputSurface::~MusBrowserCompositorOutputSurface() {} 65 MusBrowserCompositorOutputSurface::~MusBrowserCompositorOutputSurface() {}
64 66
67 cc::BeginFrameSource* MusBrowserCompositorOutputSurface::GetBeginFrameSource() {
68 return begin_frame_source_;
69 }
70
65 void MusBrowserCompositorOutputSurface::SwapBuffers( 71 void MusBrowserCompositorOutputSurface::SwapBuffers(
66 cc::OutputSurfaceFrame frame) { 72 cc::OutputSurfaceFrame frame) {
67 const gfx::Rect bounds = ui_window_ ? gfx::Rect(ui_window_->bounds().size()) 73 const gfx::Rect bounds = ui_window_ ? gfx::Rect(ui_window_->bounds().size())
68 : gfx::Rect(window_->bounds().size()); 74 : gfx::Rect(window_->bounds().size());
69 cc::CompositorFrame ui_frame; 75 cc::CompositorFrame ui_frame;
70 ui_frame.metadata.latency_info = std::move(frame.latency_info); 76 ui_frame.metadata.latency_info = std::move(frame.latency_info);
71 // Reset latency_info to known empty state after moving contents. 77 // Reset latency_info to known empty state after moving contents.
72 frame.latency_info.clear(); 78 frame.latency_info.clear();
73 const int render_pass_id = 1; 79 const int render_pass_id = 1;
74 std::unique_ptr<cc::RenderPass> pass = cc::RenderPass::Create(); 80 std::unique_ptr<cc::RenderPass> pass = cc::RenderPass::Create();
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 // TODO(mfomitchev): Remove ui_compositor_frame_sink_ once we complete the 140 // TODO(mfomitchev): Remove ui_compositor_frame_sink_ once we complete the
135 // switch to Aura-Mus. 141 // switch to Aura-Mus.
136 if (ui_compositor_frame_sink_) 142 if (ui_compositor_frame_sink_)
137 ui_compositor_frame_sink_->SubmitCompositorFrame(std::move(ui_frame)); 143 ui_compositor_frame_sink_->SubmitCompositorFrame(std::move(ui_frame));
138 else 144 else
139 compositor_frame_sink_->SubmitCompositorFrame(std::move(ui_frame)); 145 compositor_frame_sink_->SubmitCompositorFrame(std::move(ui_frame));
140 return; 146 return;
141 } 147 }
142 148
143 void MusBrowserCompositorOutputSurface::SetBeginFrameSource( 149 void MusBrowserCompositorOutputSurface::SetBeginFrameSource(
144 cc::BeginFrameSource* source) {} 150 cc::BeginFrameSource* source) {
151 begin_frame_source_ = source;
152 }
145 153
146 void MusBrowserCompositorOutputSurface::ReclaimResources( 154 void MusBrowserCompositorOutputSurface::ReclaimResources(
147 const cc::ReturnedResourceArray& resources) { 155 const cc::ReturnedResourceArray& resources) {
148 for (const auto& resource : resources) { 156 for (const auto& resource : resources) {
149 DCHECK_EQ(1, resource.count); 157 DCHECK_EQ(1, resource.count);
150 const gpu::Mailbox& mailbox = GetMailboxFromResourceId(resource.id); 158 const gpu::Mailbox& mailbox = GetMailboxFromResourceId(resource.id);
151 GetCommandBufferProxy()->ReturnFrontBuffer(mailbox, resource.sync_token, 159 GetCommandBufferProxy()->ReturnFrontBuffer(mailbox, resource.sync_token,
152 resource.lost); 160 resource.lost);
153 FreeResourceId(resource.id); 161 FreeResourceId(resource.id);
154 } 162 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 206
199 const gpu::Mailbox& MusBrowserCompositorOutputSurface::GetMailboxFromResourceId( 207 const gpu::Mailbox& MusBrowserCompositorOutputSurface::GetMailboxFromResourceId(
200 uint32_t id) { 208 uint32_t id) {
201 DCHECK_LT(id, mailboxes_.size()); 209 DCHECK_LT(id, mailboxes_.size());
202 DCHECK(std::find(free_resource_ids_.begin(), free_resource_ids_.end(), id) == 210 DCHECK(std::find(free_resource_ids_.begin(), free_resource_ids_.end(), id) ==
203 free_resource_ids_.end()); 211 free_resource_ids_.end());
204 return mailboxes_[id]; 212 return mailboxes_[id];
205 } 213 }
206 214
207 } // namespace content 215 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/compositor/mus_browser_compositor_output_surface.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698