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

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

Issue 2065573003: Mus: Delete unused Mandoline Surfaces code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix mus_ws_unittests 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #elif defined(USE_OZONE) 43 #elif defined(USE_OZONE)
44 #include "ui/ozone/public/ozone_platform.h" 44 #include "ui/ozone/public/ozone_platform.h"
45 #endif 45 #endif
46 46
47 namespace mus { 47 namespace mus {
48 48
49 namespace ws { 49 namespace ws {
50 namespace { 50 namespace {
51 51
52 // DrawWindowTree recursively visits ServerWindows, creating a SurfaceDrawQuad 52 // DrawWindowTree recursively visits ServerWindows, creating a SurfaceDrawQuad
53 // for each that lacks one. A ServerWindow may hold a CompositorFrame that 53 // for each that lacks one.
54 // references other ServerWindows in SurfaceDrawQuads. We should not create new
55 // SurfaceDrawQuads for these |referenced_window_ids|. Instead,
56 // cc::SurfaceAggregator will do the heavy lifting here by expanding those
57 // references to generate one top-level display CompositorFrame.
58 void DrawWindowTree(cc::RenderPass* pass, 54 void DrawWindowTree(cc::RenderPass* pass,
59 ServerWindow* window, 55 ServerWindow* window,
60 const gfx::Vector2d& parent_to_root_origin_offset, 56 const gfx::Vector2d& parent_to_root_origin_offset,
61 float opacity, 57 float opacity) {
62 std::set<WindowId>* referenced_window_ids) {
63 if (!window->visible()) 58 if (!window->visible())
64 return; 59 return;
65 60
66 ServerWindowSurface* default_surface = 61 ServerWindowSurface* default_surface =
67 window->surface_manager() ? window->surface_manager()->GetDefaultSurface() 62 window->surface_manager() ? window->surface_manager()->GetDefaultSurface()
68 : nullptr; 63 : nullptr;
69 64
70 if (default_surface) {
71 // Accumulate referenced windows in each ServerWindow's CompositorFrame.
72 referenced_window_ids->insert(
73 default_surface->referenced_window_ids().begin(),
74 default_surface->referenced_window_ids().end());
75 }
76
77 const gfx::Rect absolute_bounds = 65 const gfx::Rect absolute_bounds =
78 window->bounds() + parent_to_root_origin_offset; 66 window->bounds() + parent_to_root_origin_offset;
79 std::vector<ServerWindow*> children(window->GetChildren()); 67 std::vector<ServerWindow*> children(window->GetChildren());
80 // TODO(rjkroege, fsamuel): Make sure we're handling alpha correctly. 68 // TODO(rjkroege, fsamuel): Make sure we're handling alpha correctly.
81 const float combined_opacity = opacity * window->opacity(); 69 const float combined_opacity = opacity * window->opacity();
82 for (auto it = children.rbegin(); it != children.rend(); ++it) { 70 for (auto it = children.rbegin(); it != children.rend(); ++it) {
83 DrawWindowTree(pass, *it, absolute_bounds.OffsetFromOrigin(), 71 DrawWindowTree(pass, *it, absolute_bounds.OffsetFromOrigin(),
84 combined_opacity, referenced_window_ids); 72 combined_opacity);
85 } 73 }
86 74
87 if (!window->surface_manager() || !window->surface_manager()->ShouldDraw()) 75 if (!window->surface_manager() || !window->surface_manager()->ShouldDraw())
88 return; 76 return;
89 77
90 // If an ancestor has already referenced this window, then we do not need
91 // to create a SurfaceDrawQuad for it.
92 const bool draw_default_surface =
93 default_surface && (referenced_window_ids->count(window->id()) == 0);
94
95 ServerWindowSurface* underlay_surface = 78 ServerWindowSurface* underlay_surface =
96 window->surface_manager()->GetUnderlaySurface(); 79 window->surface_manager()->GetUnderlaySurface();
97 if (!draw_default_surface && !underlay_surface) 80 if (!default_surface && !underlay_surface)
98 return; 81 return;
99 82
100 if (draw_default_surface) { 83 if (default_surface) {
101 gfx::Transform quad_to_target_transform; 84 gfx::Transform quad_to_target_transform;
102 quad_to_target_transform.Translate(absolute_bounds.x(), 85 quad_to_target_transform.Translate(absolute_bounds.x(),
103 absolute_bounds.y()); 86 absolute_bounds.y());
104 87
105 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); 88 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState();
106 89
107 const gfx::Rect bounds_at_origin(window->bounds().size()); 90 const gfx::Rect bounds_at_origin(window->bounds().size());
108 // TODO(fsamuel): These clipping and visible rects are incorrect. They need 91 // TODO(fsamuel): These clipping and visible rects are incorrect. They need
109 // to be populated from CompositorFrame structs. 92 // to be populated from CompositorFrame structs.
110 sqs->SetAll(quad_to_target_transform, 93 sqs->SetAll(quad_to_target_transform,
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 metrics_.device_scale_factor = device_scale_factor; 302 metrics_.device_scale_factor = device_scale_factor;
320 delegate_->OnViewportMetricsChanged(old_metrics, metrics_); 303 delegate_->OnViewportMetricsChanged(old_metrics, metrics_);
321 } 304 }
322 305
323 std::unique_ptr<cc::CompositorFrame> 306 std::unique_ptr<cc::CompositorFrame>
324 DefaultPlatformDisplay::GenerateCompositorFrame() { 307 DefaultPlatformDisplay::GenerateCompositorFrame() {
325 std::unique_ptr<cc::RenderPass> render_pass = cc::RenderPass::Create(); 308 std::unique_ptr<cc::RenderPass> render_pass = cc::RenderPass::Create();
326 render_pass->damage_rect = dirty_rect_; 309 render_pass->damage_rect = dirty_rect_;
327 render_pass->output_rect = gfx::Rect(metrics_.size_in_pixels); 310 render_pass->output_rect = gfx::Rect(metrics_.size_in_pixels);
328 311
329 std::set<WindowId> referenced_window_ids;
330 DrawWindowTree(render_pass.get(), delegate_->GetRootWindow(), gfx::Vector2d(), 312 DrawWindowTree(render_pass.get(), delegate_->GetRootWindow(), gfx::Vector2d(),
331 1.0f, &referenced_window_ids); 313 1.0f);
332 314
333 std::unique_ptr<cc::DelegatedFrameData> frame_data( 315 std::unique_ptr<cc::DelegatedFrameData> frame_data(
334 new cc::DelegatedFrameData); 316 new cc::DelegatedFrameData);
335 frame_data->device_scale_factor = metrics_.device_scale_factor; 317 frame_data->device_scale_factor = metrics_.device_scale_factor;
336 frame_data->render_pass_list.push_back(std::move(render_pass)); 318 frame_data->render_pass_list.push_back(std::move(render_pass));
337 319
338 std::unique_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame); 320 std::unique_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame);
339 frame->delegated_frame_data = std::move(frame_data); 321 frame->delegated_frame_data = std::move(frame_data);
340 return frame; 322 return frame;
341 } 323 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 404
423 void DefaultPlatformDisplay::RequestCopyOfOutput( 405 void DefaultPlatformDisplay::RequestCopyOfOutput(
424 std::unique_ptr<cc::CopyOutputRequest> output_request) { 406 std::unique_ptr<cc::CopyOutputRequest> output_request) {
425 if (display_compositor_) 407 if (display_compositor_)
426 display_compositor_->RequestCopyOfOutput(std::move(output_request)); 408 display_compositor_->RequestCopyOfOutput(std::move(output_request));
427 } 409 }
428 410
429 } // namespace ws 411 } // namespace ws
430 412
431 } // namespace mus 413 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/public/cpp/surfaces/surfaces_type_converters.cc ('k') | components/mus/ws/server_window_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698