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/quads/render_pass.h" | 11 #include "cc/quads/render_pass.h" |
11 #include "cc/quads/texture_draw_quad.h" | 12 #include "cc/quads/texture_draw_quad.h" |
12 #include "components/display_compositor/compositor_overlay_candidate_validator.h " | 13 #include "components/display_compositor/compositor_overlay_candidate_validator.h " |
13 #include "content/common/gpu/client/context_provider_command_buffer.h" | 14 #include "content/common/gpu/client/context_provider_command_buffer.h" |
14 #include "gpu/command_buffer/client/gles2_interface.h" | 15 #include "gpu/command_buffer/client/gles2_interface.h" |
15 #include "gpu/ipc/client/command_buffer_proxy_impl.h" | 16 #include "gpu/ipc/client/command_buffer_proxy_impl.h" |
16 #include "services/ui/public/cpp/window.h" | 17 #include "services/ui/public/cpp/window.h" |
17 #include "services/ui/public/cpp/window_surface.h" | 18 #include "services/ui/public/cpp/window_surface.h" |
18 | 19 |
19 namespace content { | 20 namespace content { |
20 | 21 |
21 MusBrowserCompositorOutputSurface::MusBrowserCompositorOutputSurface( | 22 MusBrowserCompositorOutputSurface::MusBrowserCompositorOutputSurface( |
22 ui::Window* window, | 23 ui::Window* window, |
23 scoped_refptr<ContextProviderCommandBuffer> context, | 24 scoped_refptr<ContextProviderCommandBuffer> context, |
24 scoped_refptr<ui::CompositorVSyncManager> vsync_manager, | 25 scoped_refptr<ui::CompositorVSyncManager> vsync_manager, |
25 cc::SyntheticBeginFrameSource* begin_frame_source, | 26 cc::SyntheticBeginFrameSource* begin_frame_source, |
26 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator> | 27 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator> |
27 overlay_candidate_validator) | 28 overlay_candidate_validator) |
28 : GpuBrowserCompositorOutputSurface(std::move(context), | 29 : GpuBrowserCompositorOutputSurface(std::move(context), |
29 std::move(vsync_manager), | 30 std::move(vsync_manager), |
30 begin_frame_source, | 31 begin_frame_source, |
31 std::move(overlay_candidate_validator)), | 32 std::move(overlay_candidate_validator)), |
32 ui_window_(window) { | 33 ui_window_(window) { |
33 ui_window_surface_ = | 34 ui_window_surface_ = |
34 ui_window_->RequestSurface(ui::mojom::SurfaceType::DEFAULT); | 35 ui_window_->RequestSurface(ui::mojom::SurfaceType::DEFAULT); |
35 } | 36 } |
36 | 37 |
37 MusBrowserCompositorOutputSurface::~MusBrowserCompositorOutputSurface() {} | 38 MusBrowserCompositorOutputSurface::~MusBrowserCompositorOutputSurface() {} |
38 | 39 |
39 void MusBrowserCompositorOutputSurface::SwapBuffers(cc::CompositorFrame frame) { | 40 void MusBrowserCompositorOutputSurface::SwapBuffers( |
41 cc::OutputSurfaceFrame frame) { | |
40 const gfx::Rect bounds(ui_window_->bounds().size()); | 42 const gfx::Rect bounds(ui_window_->bounds().size()); |
41 cc::CompositorFrame ui_frame; | 43 cc::CompositorFrame ui_frame; |
42 ui_frame.metadata = std::move(frame.metadata); | 44 ui_frame.metadata.latency_info = frame.latency_info; |
danakj
2016/10/04 21:58:40
Keep moving this? Moving a vector is much better t
kylechar
2016/10/05 13:45:54
That seems super unsafe? We pass |frame| to GpuBro
danakj
2016/10/05 23:02:19
Oh wow. It does use the latency infoes: https://cs
kylechar
2016/10/06 14:16:55
Done.
| |
43 ui_frame.delegated_frame_data = base::MakeUnique<cc::DelegatedFrameData>(); | 45 ui_frame.delegated_frame_data = base::MakeUnique<cc::DelegatedFrameData>(); |
44 const cc::RenderPassId render_pass_id(1, 1); | 46 const cc::RenderPassId render_pass_id(1, 1); |
45 std::unique_ptr<cc::RenderPass> pass = cc::RenderPass::Create(); | 47 std::unique_ptr<cc::RenderPass> pass = cc::RenderPass::Create(); |
46 const bool has_transparent_background = true; | 48 const bool has_transparent_background = true; |
47 pass->SetAll(render_pass_id, bounds, bounds, gfx::Transform(), | 49 pass->SetAll(render_pass_id, bounds, bounds, gfx::Transform(), |
48 has_transparent_background); | 50 has_transparent_background); |
49 // The SharedQuadState is owned by the SharedQuadStateList | 51 // The SharedQuadState is owned by the SharedQuadStateList |
50 // shared_quad_state_list. | 52 // shared_quad_state_list. |
51 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); | 53 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); |
52 sqs->SetAll(gfx::Transform(), bounds.size(), bounds, bounds, | 54 sqs->SetAll(gfx::Transform(), bounds.size(), bounds, bounds, |
53 false /* is_clipped */, 1.f /* opacity */, SkXfermode::kSrc_Mode, | 55 false /* is_clipped */, 1.f /* opacity */, SkXfermode::kSrc_Mode, |
54 0 /* sorting_context_id */); | 56 0 /* sorting_context_id */); |
55 | 57 |
56 cc::TransferableResource resource; | 58 cc::TransferableResource resource; |
57 resource.id = AllocateResourceId(); | 59 resource.id = AllocateResourceId(); |
58 resource.format = cc::ResourceFormat::RGBA_8888; | 60 resource.format = cc::ResourceFormat::RGBA_8888; |
59 resource.filter = GL_LINEAR; | 61 resource.filter = GL_LINEAR; |
60 resource.size = frame.gl_frame_data->size; | 62 resource.size = frame.size; |
61 | 63 |
62 const gpu::Mailbox& mailbox = GetMailboxFromResourceId(resource.id); | 64 const gpu::Mailbox& mailbox = GetMailboxFromResourceId(resource.id); |
63 DCHECK(!mailbox.IsZero()); | 65 DCHECK(!mailbox.IsZero()); |
64 const gfx::Rect rect(frame.gl_frame_data->size); | 66 const gfx::Rect rect(frame.size); |
65 | 67 |
66 // Call parent's SwapBuffers to generate the front buffer, and then send the | 68 // Call parent's SwapBuffers to generate the front buffer, and then send the |
67 // front buffer to mus. | 69 // front buffer to mus. |
68 // TODO(penghuang): we should avoid extra copies here by sending frames to mus | 70 // TODO(penghuang): we should avoid extra copies here by sending frames to mus |
69 // directly from renderer. | 71 // directly from renderer. |
70 GpuBrowserCompositorOutputSurface::SwapBuffers(std::move(frame)); | 72 GpuBrowserCompositorOutputSurface::SwapBuffers(std::move(frame)); |
71 GetCommandBufferProxy()->TakeFrontBuffer(mailbox); | 73 GetCommandBufferProxy()->TakeFrontBuffer(mailbox); |
72 | 74 |
73 auto* gl = context_provider()->ContextGL(); | 75 auto* gl = context_provider()->ContextGL(); |
74 const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM(); | 76 const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM(); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
156 | 158 |
157 const gpu::Mailbox& MusBrowserCompositorOutputSurface::GetMailboxFromResourceId( | 159 const gpu::Mailbox& MusBrowserCompositorOutputSurface::GetMailboxFromResourceId( |
158 uint32_t id) { | 160 uint32_t id) { |
159 DCHECK_LT(id, mailboxes_.size()); | 161 DCHECK_LT(id, mailboxes_.size()); |
160 DCHECK(std::find(free_resource_ids_.begin(), free_resource_ids_.end(), id) == | 162 DCHECK(std::find(free_resource_ids_.begin(), free_resource_ids_.end(), id) == |
161 free_resource_ids_.end()); | 163 free_resource_ids_.end()); |
162 return mailboxes_[id]; | 164 return mailboxes_[id]; |
163 } | 165 } |
164 | 166 |
165 } // namespace content | 167 } // namespace content |
OLD | NEW |