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

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

Issue 2374183006: Remove GLFrameData from CompositorFrame. (Closed)
Patch Set: Rebase. Created 4 years, 2 months 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
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/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 = std::move(frame.latency_info);
45 // Reset latency_info to known empty state after moving contents.
46 frame.latency_info.clear();
43 ui_frame.delegated_frame_data = base::MakeUnique<cc::DelegatedFrameData>(); 47 ui_frame.delegated_frame_data = base::MakeUnique<cc::DelegatedFrameData>();
44 const cc::RenderPassId render_pass_id(1, 1); 48 const cc::RenderPassId render_pass_id(1, 1);
45 std::unique_ptr<cc::RenderPass> pass = cc::RenderPass::Create(); 49 std::unique_ptr<cc::RenderPass> pass = cc::RenderPass::Create();
46 const bool has_transparent_background = true; 50 const bool has_transparent_background = true;
47 pass->SetAll(render_pass_id, bounds, bounds, gfx::Transform(), 51 pass->SetAll(render_pass_id, bounds, bounds, gfx::Transform(),
48 has_transparent_background); 52 has_transparent_background);
49 // The SharedQuadState is owned by the SharedQuadStateList 53 // The SharedQuadState is owned by the SharedQuadStateList
50 // shared_quad_state_list. 54 // shared_quad_state_list.
51 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); 55 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState();
52 sqs->SetAll(gfx::Transform(), bounds.size(), bounds, bounds, 56 sqs->SetAll(gfx::Transform(), bounds.size(), bounds, bounds,
53 false /* is_clipped */, 1.f /* opacity */, SkXfermode::kSrc_Mode, 57 false /* is_clipped */, 1.f /* opacity */, SkXfermode::kSrc_Mode,
54 0 /* sorting_context_id */); 58 0 /* sorting_context_id */);
55 59
56 cc::TransferableResource resource; 60 cc::TransferableResource resource;
57 resource.id = AllocateResourceId(); 61 resource.id = AllocateResourceId();
58 resource.format = cc::ResourceFormat::RGBA_8888; 62 resource.format = cc::ResourceFormat::RGBA_8888;
59 resource.filter = GL_LINEAR; 63 resource.filter = GL_LINEAR;
60 resource.size = frame.gl_frame_data->size; 64 resource.size = frame.size;
61 65
62 const gpu::Mailbox& mailbox = GetMailboxFromResourceId(resource.id); 66 const gpu::Mailbox& mailbox = GetMailboxFromResourceId(resource.id);
63 DCHECK(!mailbox.IsZero()); 67 DCHECK(!mailbox.IsZero());
64 const gfx::Rect rect(frame.gl_frame_data->size); 68 const gfx::Rect rect(frame.size);
65 69
66 // Call parent's SwapBuffers to generate the front buffer, and then send the 70 // Call parent's SwapBuffers to generate the front buffer, and then send the
67 // front buffer to mus. 71 // front buffer to mus.
68 // TODO(penghuang): we should avoid extra copies here by sending frames to mus 72 // TODO(penghuang): we should avoid extra copies here by sending frames to mus
69 // directly from renderer. 73 // directly from renderer.
70 GpuBrowserCompositorOutputSurface::SwapBuffers(std::move(frame)); 74 GpuBrowserCompositorOutputSurface::SwapBuffers(std::move(frame));
71 GetCommandBufferProxy()->TakeFrontBuffer(mailbox); 75 GetCommandBufferProxy()->TakeFrontBuffer(mailbox);
72 76
73 auto* gl = context_provider()->ContextGL(); 77 auto* gl = context_provider()->ContextGL();
74 const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM(); 78 const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM();
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 160
157 const gpu::Mailbox& MusBrowserCompositorOutputSurface::GetMailboxFromResourceId( 161 const gpu::Mailbox& MusBrowserCompositorOutputSurface::GetMailboxFromResourceId(
158 uint32_t id) { 162 uint32_t id) {
159 DCHECK_LT(id, mailboxes_.size()); 163 DCHECK_LT(id, mailboxes_.size());
160 DCHECK(std::find(free_resource_ids_.begin(), free_resource_ids_.end(), id) == 164 DCHECK(std::find(free_resource_ids_.begin(), free_resource_ids_.end(), id) ==
161 free_resource_ids_.end()); 165 free_resource_ids_.end());
162 return mailboxes_[id]; 166 return mailboxes_[id];
163 } 167 }
164 168
165 } // namespace content 169 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698