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

Side by Side Diff: services/ui/ws/frame_generator.cc

Issue 2547243002: Set device scale factor in CompositorFrame and scale frame size in WS. (Closed)
Patch Set: 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
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 "services/ui/ws/frame_generator.h" 5 #include "services/ui/ws/frame_generator.h"
6 6
7 #include "base/containers/adapters.h" 7 #include "base/containers/adapters.h"
8 #include "cc/output/compositor_frame.h" 8 #include "cc/output/compositor_frame.h"
9 #include "cc/quads/render_pass.h" 9 #include "cc/quads/render_pass.h"
10 #include "cc/quads/render_pass_draw_quad.h" 10 #include "cc/quads/render_pass_draw_quad.h"
11 #include "cc/quads/shared_quad_state.h" 11 #include "cc/quads/shared_quad_state.h"
12 #include "cc/quads/surface_draw_quad.h" 12 #include "cc/quads/surface_draw_quad.h"
13 #include "cc/surfaces/surface_id.h" 13 #include "cc/surfaces/surface_id.h"
14 #include "services/ui/ws/frame_generator_delegate.h" 14 #include "services/ui/ws/frame_generator_delegate.h"
15 #include "services/ui/ws/server_window.h" 15 #include "services/ui/ws/server_window.h"
16 #include "services/ui/ws/server_window_compositor_frame_sink_manager.h" 16 #include "services/ui/ws/server_window_compositor_frame_sink_manager.h"
17 #include "services/ui/ws/server_window_delegate.h" 17 #include "services/ui/ws/server_window_delegate.h"
18 18
19 namespace ui { 19 namespace ui {
20 20
21 namespace ws { 21 namespace ws {
22 22
23 FrameGenerator::FrameGenerator(FrameGeneratorDelegate* delegate, 23 FrameGenerator::FrameGenerator(FrameGeneratorDelegate* delegate,
24 ServerWindow* root_window) 24 ServerWindow* root_window,
25 float device_scale_factor)
25 : delegate_(delegate), 26 : delegate_(delegate),
26 root_window_(root_window), 27 root_window_(root_window),
28 device_scale_factor_(device_scale_factor),
27 top_level_root_surface_id_( 29 top_level_root_surface_id_(
28 cc::FrameSinkId(0, 0), 30 cc::FrameSinkId(0, 0),
29 cc::LocalFrameId(0, base::UnguessableToken::Create())), 31 cc::LocalFrameId(0, base::UnguessableToken::Create())),
30 binding_(this), 32 binding_(this),
31 weak_factory_(this) { 33 weak_factory_(this) {
32 DCHECK(delegate_); 34 DCHECK(delegate_);
33 } 35 }
34 36
35 FrameGenerator::~FrameGenerator() { 37 FrameGenerator::~FrameGenerator() {
36 RemoveDeadSurfaceReferences(); 38 RemoveDeadSurfaceReferences();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 AddNewParentReferences(ref.child_id, surface_id); 87 AddNewParentReferences(ref.child_id, surface_id);
86 88
87 // Move the existing reference to list of references to remove after we submit 89 // Move the existing reference to list of references to remove after we submit
88 // the next CompositorFrame. Update local reference cache to be the new 90 // the next CompositorFrame. Update local reference cache to be the new
89 // reference. If this is the display root surface then removing this reference 91 // reference. If this is the display root surface then removing this reference
90 // will recursively remove any references it held. 92 // will recursively remove any references it held.
91 dead_references_.push_back(ref); 93 dead_references_.push_back(ref);
92 ref.child_id = surface_id; 94 ref.child_id = surface_id;
93 } 95 }
94 96
97 void FrameGenerator::UpdateDeviceScaleFactor(float device_scale_factor) {
sky 2016/12/03 16:28:30 Generally for trivial functions like this we use u
riajiang 2016/12/09 19:31:44 Done.
98 device_scale_factor_ = device_scale_factor;
99 }
100
95 void FrameGenerator::DidReceiveCompositorFrameAck() {} 101 void FrameGenerator::DidReceiveCompositorFrameAck() {}
96 102
97 void FrameGenerator::OnBeginFrame(const cc::BeginFrameArgs& begin_frame_arags) { 103 void FrameGenerator::OnBeginFrame(const cc::BeginFrameArgs& begin_frame_arags) {
98 if (!root_window_->visible()) 104 if (!root_window_->visible())
99 return; 105 return;
100 106
101 // TODO(fsamuel): We should add a trace for generating a top level frame. 107 // TODO(fsamuel): We should add a trace for generating a top level frame.
102 cc::CompositorFrame frame(GenerateCompositorFrame(root_window_->bounds())); 108 cc::CompositorFrame frame(GenerateCompositorFrame(root_window_->bounds()));
103 109
104 if (compositor_frame_sink_) { 110 if (compositor_frame_sink_) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 cc::FilterOperations filters; 154 cc::FilterOperations filters;
149 filters.Append(cc::FilterOperation::CreateInvertFilter(1.f)); 155 filters.Append(cc::FilterOperation::CreateInvertFilter(1.f));
150 quad->SetNew(shared_state, output_rect, output_rect, render_pass_id, 156 quad->SetNew(shared_state, output_rect, output_rect, render_pass_id,
151 0 /* mask_resource_id */, gfx::Vector2dF() /* mask_uv_scale */, 157 0 /* mask_resource_id */, gfx::Vector2dF() /* mask_uv_scale */,
152 gfx::Size() /* mask_texture_size */, filters, 158 gfx::Size() /* mask_texture_size */, filters,
153 gfx::Vector2dF() /* filters_scale */, 159 gfx::Vector2dF() /* filters_scale */,
154 gfx::PointF() /* filters_origin */, 160 gfx::PointF() /* filters_origin */,
155 cc::FilterOperations() /* background_filters */); 161 cc::FilterOperations() /* background_filters */);
156 frame.render_pass_list.push_back(std::move(invert_pass)); 162 frame.render_pass_list.push_back(std::move(invert_pass));
157 } 163 }
164 frame.metadata.device_scale_factor = device_scale_factor_;
158 165
159 return frame; 166 return frame;
160 } 167 }
161 168
162 void FrameGenerator::DrawWindowTree( 169 void FrameGenerator::DrawWindowTree(
163 cc::RenderPass* pass, 170 cc::RenderPass* pass,
164 ServerWindow* window, 171 ServerWindow* window,
165 const gfx::Vector2d& parent_to_root_origin_offset, 172 const gfx::Vector2d& parent_to_root_origin_offset,
166 float opacity) { 173 float opacity) {
167 if (!window->visible()) 174 if (!window->visible())
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 cc::SurfaceId underlay_surface_id = 360 cc::SurfaceId underlay_surface_id =
354 window->compositor_frame_sink_manager()->GetLatestSurfaceId( 361 window->compositor_frame_sink_manager()->GetLatestSurfaceId(
355 mojom::CompositorFrameSinkType::UNDERLAY); 362 mojom::CompositorFrameSinkType::UNDERLAY);
356 if (underlay_surface_id.is_valid()) 363 if (underlay_surface_id.is_valid())
357 RemoveFrameSinkReference(underlay_surface_id.frame_sink_id()); 364 RemoveFrameSinkReference(underlay_surface_id.frame_sink_id());
358 } 365 }
359 366
360 } // namespace ws 367 } // namespace ws
361 368
362 } // namespace ui 369 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698