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

Side by Side Diff: components/mus/ws/platform_display.cc

Issue 2098953003: Make cc::CompositorFrames movable [Part 2 of 2] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Android compiles locally Created 4 years, 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/mus/ws/platform_display.h" 5 #include "components/mus/ws/platform_display.h"
6 6
7 #include "base/numerics/safe_conversions.h" 7 #include "base/numerics/safe_conversions.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "cc/ipc/quads.mojom.h" 9 #include "cc/ipc/quads.mojom.h"
10 #include "cc/output/compositor_frame.h" 10 #include "cc/output/compositor_frame.h"
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 ui::PlatformImeController* ime = platform_window_->GetPlatformImeController(); 251 ui::PlatformImeController* ime = platform_window_->GetPlatformImeController();
252 if (ime) 252 if (ime)
253 ime->SetImeVisibility(visible); 253 ime->SetImeVisibility(visible);
254 } 254 }
255 255
256 void DefaultPlatformDisplay::Draw() { 256 void DefaultPlatformDisplay::Draw() {
257 if (!delegate_->GetRootWindow()->visible()) 257 if (!delegate_->GetRootWindow()->visible())
258 return; 258 return;
259 259
260 // TODO(fsamuel): We should add a trace for generating a top level frame. 260 // TODO(fsamuel): We should add a trace for generating a top level frame.
261 std::unique_ptr<cc::CompositorFrame> frame(GenerateCompositorFrame()); 261 cc::CompositorFrame frame(GenerateCompositorFrame());
262 frame_pending_ = true; 262 frame_pending_ = true;
263 if (display_compositor_) { 263 if (display_compositor_) {
264 display_compositor_->SubmitCompositorFrame( 264 display_compositor_->SubmitCompositorFrame(
265 std::move(frame), base::Bind(&DefaultPlatformDisplay::DidDraw, 265 std::move(frame), base::Bind(&DefaultPlatformDisplay::DidDraw,
266 weak_factory_.GetWeakPtr())); 266 weak_factory_.GetWeakPtr()));
267 } 267 }
268 dirty_rect_ = gfx::Rect(); 268 dirty_rect_ = gfx::Rect();
269 } 269 }
270 270
271 void DefaultPlatformDisplay::DidDraw(cc::SurfaceDrawStatus status) { 271 void DefaultPlatformDisplay::DidDraw(cc::SurfaceDrawStatus status) {
(...skipping 28 matching lines...) Expand all
300 if (metrics_.size_in_pixels == size && 300 if (metrics_.size_in_pixels == size &&
301 metrics_.device_scale_factor == device_scale_factor) 301 metrics_.device_scale_factor == device_scale_factor)
302 return; 302 return;
303 303
304 ViewportMetrics old_metrics = metrics_; 304 ViewportMetrics old_metrics = metrics_;
305 metrics_.size_in_pixels = size; 305 metrics_.size_in_pixels = size;
306 metrics_.device_scale_factor = device_scale_factor; 306 metrics_.device_scale_factor = device_scale_factor;
307 delegate_->OnViewportMetricsChanged(old_metrics, metrics_); 307 delegate_->OnViewportMetricsChanged(old_metrics, metrics_);
308 } 308 }
309 309
310 std::unique_ptr<cc::CompositorFrame> 310 cc::CompositorFrame DefaultPlatformDisplay::GenerateCompositorFrame() {
311 DefaultPlatformDisplay::GenerateCompositorFrame() {
312 std::unique_ptr<cc::RenderPass> render_pass = cc::RenderPass::Create(); 311 std::unique_ptr<cc::RenderPass> render_pass = cc::RenderPass::Create();
313 render_pass->damage_rect = dirty_rect_; 312 render_pass->damage_rect = dirty_rect_;
314 render_pass->output_rect = gfx::Rect(metrics_.size_in_pixels); 313 render_pass->output_rect = gfx::Rect(metrics_.size_in_pixels);
315 314
316 DrawWindowTree(render_pass.get(), delegate_->GetRootWindow(), gfx::Vector2d(), 315 DrawWindowTree(render_pass.get(), delegate_->GetRootWindow(), gfx::Vector2d(),
317 1.0f); 316 1.0f);
318 317
319 std::unique_ptr<cc::DelegatedFrameData> frame_data( 318 std::unique_ptr<cc::DelegatedFrameData> frame_data(
320 new cc::DelegatedFrameData); 319 new cc::DelegatedFrameData);
321 frame_data->device_scale_factor = metrics_.device_scale_factor; 320 frame_data->device_scale_factor = metrics_.device_scale_factor;
322 frame_data->render_pass_list.push_back(std::move(render_pass)); 321 frame_data->render_pass_list.push_back(std::move(render_pass));
323 322
324 std::unique_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame); 323 cc::CompositorFrame frame;
325 frame->delegated_frame_data = std::move(frame_data); 324 frame.delegated_frame_data = std::move(frame_data);
326 return frame; 325 return frame;
327 } 326 }
328 327
329 void DefaultPlatformDisplay::OnBoundsChanged(const gfx::Rect& new_bounds) { 328 void DefaultPlatformDisplay::OnBoundsChanged(const gfx::Rect& new_bounds) {
330 UpdateMetrics(new_bounds.size(), metrics_.device_scale_factor); 329 UpdateMetrics(new_bounds.size(), metrics_.device_scale_factor);
331 } 330 }
332 331
333 void DefaultPlatformDisplay::OnDamageRect(const gfx::Rect& damaged_region) { 332 void DefaultPlatformDisplay::OnDamageRect(const gfx::Rect& damaged_region) {
334 dirty_rect_.Union(damaged_region); 333 dirty_rect_.Union(damaged_region);
335 WantToDraw(); 334 WantToDraw();
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 407
409 void DefaultPlatformDisplay::RequestCopyOfOutput( 408 void DefaultPlatformDisplay::RequestCopyOfOutput(
410 std::unique_ptr<cc::CopyOutputRequest> output_request) { 409 std::unique_ptr<cc::CopyOutputRequest> output_request) {
411 if (display_compositor_) 410 if (display_compositor_)
412 display_compositor_->RequestCopyOfOutput(std::move(output_request)); 411 display_compositor_->RequestCopyOfOutput(std::move(output_request));
413 } 412 }
414 413
415 } // namespace ws 414 } // namespace ws
416 415
417 } // namespace mus 416 } // namespace mus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698