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

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

Issue 2739113002: Simplify calls for scale factor (Closed)
Patch Set: nit Created 3 years, 9 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 | content/browser/renderer_host/render_widget_host_view_android.cc » ('j') | 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/client_compositor_frame_sink.h" 16 #include "services/ui/public/cpp/client_compositor_frame_sink.h"
17 #include "services/ui/public/cpp/gpu/context_provider_command_buffer.h" 17 #include "services/ui/public/cpp/gpu/context_provider_command_buffer.h"
18 #include "ui/aura/mus/window_port_mus.h" 18 #include "ui/aura/mus/window_port_mus.h"
19 #include "ui/aura/window.h" 19 #include "ui/aura/window.h"
20 #include "ui/display/screen.h" 20 #include "ui/base/layout.h"
21 #include "ui/gfx/geometry/dip_util.h" 21 #include "ui/gfx/geometry/dip_util.h"
22 22
23 namespace content { 23 namespace content {
24 24
25 MusBrowserCompositorOutputSurface::MusBrowserCompositorOutputSurface( 25 MusBrowserCompositorOutputSurface::MusBrowserCompositorOutputSurface(
26 aura::Window* window, 26 aura::Window* window,
27 scoped_refptr<ui::ContextProviderCommandBuffer> context, 27 scoped_refptr<ui::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>
(...skipping 12 matching lines...) Expand all
43 43
44 MusBrowserCompositorOutputSurface::~MusBrowserCompositorOutputSurface() {} 44 MusBrowserCompositorOutputSurface::~MusBrowserCompositorOutputSurface() {}
45 45
46 cc::BeginFrameSource* MusBrowserCompositorOutputSurface::GetBeginFrameSource() { 46 cc::BeginFrameSource* MusBrowserCompositorOutputSurface::GetBeginFrameSource() {
47 return begin_frame_source_; 47 return begin_frame_source_;
48 } 48 }
49 49
50 void MusBrowserCompositorOutputSurface::SwapBuffers( 50 void MusBrowserCompositorOutputSurface::SwapBuffers(
51 cc::OutputSurfaceFrame frame) { 51 cc::OutputSurfaceFrame frame) {
52 cc::CompositorFrame ui_frame; 52 cc::CompositorFrame ui_frame;
53 ui_frame.metadata.device_scale_factor = display::Screen::GetScreen() 53 ui_frame.metadata.device_scale_factor =
54 ->GetDisplayNearestWindow(window_) 54 ui::GetScaleFactorForNativeView(window_);
55 .device_scale_factor();
56 ui_frame.metadata.latency_info = std::move(frame.latency_info); 55 ui_frame.metadata.latency_info = std::move(frame.latency_info);
57 // Reset latency_info to known empty state after moving contents. 56 // Reset latency_info to known empty state after moving contents.
58 frame.latency_info.clear(); 57 frame.latency_info.clear();
59 const int render_pass_id = 1; 58 const int render_pass_id = 1;
60 const gfx::Rect bounds_in_dip = gfx::Rect(window_->bounds().size()); 59 const gfx::Rect bounds_in_dip = gfx::Rect(window_->bounds().size());
61 const gfx::Rect bounds_in_pixels = gfx::ConvertRectToPixel( 60 const gfx::Rect bounds_in_pixels = gfx::ConvertRectToPixel(
62 ui_frame.metadata.device_scale_factor, bounds_in_dip); 61 ui_frame.metadata.device_scale_factor, bounds_in_dip);
63 std::unique_ptr<cc::RenderPass> pass = cc::RenderPass::Create(); 62 std::unique_ptr<cc::RenderPass> pass = cc::RenderPass::Create();
64 pass->SetNew(render_pass_id, bounds_in_pixels, bounds_in_pixels, 63 pass->SetNew(render_pass_id, bounds_in_pixels, bounds_in_pixels,
65 gfx::Transform()); 64 gfx::Transform());
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 181
183 const gpu::Mailbox& MusBrowserCompositorOutputSurface::GetMailboxFromResourceId( 182 const gpu::Mailbox& MusBrowserCompositorOutputSurface::GetMailboxFromResourceId(
184 uint32_t id) { 183 uint32_t id) {
185 DCHECK_LT(id, mailboxes_.size()); 184 DCHECK_LT(id, mailboxes_.size());
186 DCHECK(std::find(free_resource_ids_.begin(), free_resource_ids_.end(), id) == 185 DCHECK(std::find(free_resource_ids_.begin(), free_resource_ids_.end(), id) ==
187 free_resource_ids_.end()); 186 free_resource_ids_.end());
188 return mailboxes_[id]; 187 return mailboxes_[id];
189 } 188 }
190 189
191 } // namespace content 190 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/render_widget_host_view_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698