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

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

Issue 2644983002: Scale bounds from dip to pixels in CompositorFrame in content::MusBrowserCompositorOutputSurface. (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « no previous file | 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"
11 #include "cc/quads/render_pass.h" 11 #include "cc/quads/render_pass.h"
12 #include "cc/quads/texture_draw_quad.h" 12 #include "cc/quads/texture_draw_quad.h"
13 #include "components/display_compositor/compositor_overlay_candidate_validator.h " 13 #include "components/display_compositor/compositor_overlay_candidate_validator.h "
14 #include "gpu/command_buffer/client/gles2_interface.h" 14 #include "gpu/command_buffer/client/gles2_interface.h"
15 #include "gpu/ipc/client/command_buffer_proxy_impl.h" 15 #include "gpu/ipc/client/command_buffer_proxy_impl.h"
16 #include "services/ui/public/cpp/gpu/context_provider_command_buffer.h" 16 #include "services/ui/public/cpp/gpu/context_provider_command_buffer.h"
17 #include "services/ui/public/cpp/window.h" 17 #include "services/ui/public/cpp/window.h"
18 #include "services/ui/public/cpp/window_compositor_frame_sink.h" 18 #include "services/ui/public/cpp/window_compositor_frame_sink.h"
19 #include "ui/aura/mus/window_compositor_frame_sink.h" 19 #include "ui/aura/mus/window_compositor_frame_sink.h"
20 #include "ui/aura/mus/window_port_mus.h" 20 #include "ui/aura/mus/window_port_mus.h"
21 #include "ui/aura/window.h" 21 #include "ui/aura/window.h"
22 #include "ui/display/screen.h" 22 #include "ui/display/screen.h"
23 #include "ui/gfx/geometry/dip_util.h"
23 24
24 namespace content { 25 namespace content {
25 26
26 MusBrowserCompositorOutputSurface::MusBrowserCompositorOutputSurface( 27 MusBrowserCompositorOutputSurface::MusBrowserCompositorOutputSurface(
27 ui::Window* window, 28 ui::Window* window,
28 scoped_refptr<ui::ContextProviderCommandBuffer> context, 29 scoped_refptr<ui::ContextProviderCommandBuffer> context,
29 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, 30 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
30 const UpdateVSyncParametersCallback& update_vsync_parameters_callback, 31 const UpdateVSyncParametersCallback& update_vsync_parameters_callback,
31 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator> 32 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator>
32 overlay_candidate_validator) 33 overlay_candidate_validator)
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 } 65 }
65 66
66 MusBrowserCompositorOutputSurface::~MusBrowserCompositorOutputSurface() {} 67 MusBrowserCompositorOutputSurface::~MusBrowserCompositorOutputSurface() {}
67 68
68 cc::BeginFrameSource* MusBrowserCompositorOutputSurface::GetBeginFrameSource() { 69 cc::BeginFrameSource* MusBrowserCompositorOutputSurface::GetBeginFrameSource() {
69 return begin_frame_source_; 70 return begin_frame_source_;
70 } 71 }
71 72
72 void MusBrowserCompositorOutputSurface::SwapBuffers( 73 void MusBrowserCompositorOutputSurface::SwapBuffers(
73 cc::OutputSurfaceFrame frame) { 74 cc::OutputSurfaceFrame frame) {
74 const gfx::Rect bounds = ui_window_ ? gfx::Rect(ui_window_->bounds().size())
75 : gfx::Rect(window_->bounds().size());
76 cc::CompositorFrame ui_frame; 75 cc::CompositorFrame ui_frame;
77 ui_frame.metadata.device_scale_factor = display::Screen::GetScreen() 76 ui_frame.metadata.device_scale_factor = display::Screen::GetScreen()
78 ->GetDisplayNearestWindow(window_) 77 ->GetDisplayNearestWindow(window_)
79 .device_scale_factor(); 78 .device_scale_factor();
80 ui_frame.metadata.latency_info = std::move(frame.latency_info); 79 ui_frame.metadata.latency_info = std::move(frame.latency_info);
81 // Reset latency_info to known empty state after moving contents. 80 // Reset latency_info to known empty state after moving contents.
82 frame.latency_info.clear(); 81 frame.latency_info.clear();
83 const int render_pass_id = 1; 82 const int render_pass_id = 1;
83 const gfx::Rect bounds_in_dip = ui_window_
84 ? gfx::Rect(ui_window_->bounds().size())
85 : gfx::Rect(window_->bounds().size());
86 const gfx::Rect bounds_in_pixels = gfx::ConvertRectToPixel(
87 ui_frame.metadata.device_scale_factor, bounds_in_dip);
84 std::unique_ptr<cc::RenderPass> pass = cc::RenderPass::Create(); 88 std::unique_ptr<cc::RenderPass> pass = cc::RenderPass::Create();
85 pass->SetNew(render_pass_id, bounds, bounds, gfx::Transform()); 89 pass->SetNew(render_pass_id, bounds_in_pixels, bounds_in_pixels,
90 gfx::Transform());
86 // The SharedQuadState is owned by the SharedQuadStateList 91 // The SharedQuadState is owned by the SharedQuadStateList
87 // shared_quad_state_list. 92 // shared_quad_state_list.
88 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); 93 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState();
89 sqs->SetAll(gfx::Transform(), bounds.size(), bounds, bounds, 94 sqs->SetAll(gfx::Transform(), bounds_in_pixels.size(), bounds_in_pixels,
90 false /* is_clipped */, 1.f /* opacity */, SkBlendMode::kSrc, 95 bounds_in_pixels, false /* is_clipped */, 1.f /* opacity */,
91 0 /* sorting_context_id */); 96 SkBlendMode::kSrc, 0 /* sorting_context_id */);
92 97
93 cc::TransferableResource resource; 98 cc::TransferableResource resource;
94 resource.id = AllocateResourceId(); 99 resource.id = AllocateResourceId();
95 resource.format = cc::ResourceFormat::RGBA_8888; 100 resource.format = cc::ResourceFormat::RGBA_8888;
96 resource.filter = GL_LINEAR; 101 resource.filter = GL_LINEAR;
97 resource.size = frame.size; 102 resource.size = frame.size;
98 103
99 const gpu::Mailbox& mailbox = GetMailboxFromResourceId(resource.id); 104 const gpu::Mailbox& mailbox = GetMailboxFromResourceId(resource.id);
100 DCHECK(!mailbox.IsZero()); 105 DCHECK(!mailbox.IsZero());
101 const gfx::Rect rect(frame.size); 106 const gfx::Rect rect(frame.size);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 213
209 const gpu::Mailbox& MusBrowserCompositorOutputSurface::GetMailboxFromResourceId( 214 const gpu::Mailbox& MusBrowserCompositorOutputSurface::GetMailboxFromResourceId(
210 uint32_t id) { 215 uint32_t id) {
211 DCHECK_LT(id, mailboxes_.size()); 216 DCHECK_LT(id, mailboxes_.size());
212 DCHECK(std::find(free_resource_ids_.begin(), free_resource_ids_.end(), id) == 217 DCHECK(std::find(free_resource_ids_.begin(), free_resource_ids_.end(), id) ==
213 free_resource_ids_.end()); 218 free_resource_ids_.end());
214 return mailboxes_[id]; 219 return mailboxes_[id];
215 } 220 }
216 221
217 } // namespace content 222 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698