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

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

Issue 2099893002: Mus: Fixes rendering of transparent containers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 if (!window->visible()) 58 if (!window->visible())
59 return; 59 return;
60 60
61 ServerWindowSurface* default_surface = 61 ServerWindowSurface* default_surface =
62 window->surface_manager() ? window->surface_manager()->GetDefaultSurface() 62 window->surface_manager() ? window->surface_manager()->GetDefaultSurface()
63 : nullptr; 63 : nullptr;
64 64
65 const gfx::Rect absolute_bounds = 65 const gfx::Rect absolute_bounds =
66 window->bounds() + parent_to_root_origin_offset; 66 window->bounds() + parent_to_root_origin_offset;
67 std::vector<ServerWindow*> children(window->GetChildren()); 67 std::vector<ServerWindow*> children(window->GetChildren());
68 // TODO(rjkroege, fsamuel): Make sure we're handling alpha correctly.
69 const float combined_opacity = opacity * window->opacity(); 68 const float combined_opacity = opacity * window->opacity();
70 for (auto it = children.rbegin(); it != children.rend(); ++it) { 69 for (auto it = children.rbegin(); it != children.rend(); ++it) {
71 DrawWindowTree(pass, *it, absolute_bounds.OffsetFromOrigin(), 70 DrawWindowTree(pass, *it, absolute_bounds.OffsetFromOrigin(),
72 combined_opacity); 71 combined_opacity);
73 } 72 }
74 73
75 if (!window->surface_manager() || !window->surface_manager()->ShouldDraw()) 74 if (!window->surface_manager() || !window->surface_manager()->ShouldDraw())
76 return; 75 return;
77 76
78 ServerWindowSurface* underlay_surface = 77 ServerWindowSurface* underlay_surface =
79 window->surface_manager()->GetUnderlaySurface(); 78 window->surface_manager()->GetUnderlaySurface();
80 if (!default_surface && !underlay_surface) 79 if (!default_surface && !underlay_surface)
81 return; 80 return;
82 81
83 if (default_surface) { 82 if (default_surface) {
84 gfx::Transform quad_to_target_transform; 83 gfx::Transform quad_to_target_transform;
85 quad_to_target_transform.Translate(absolute_bounds.x(), 84 quad_to_target_transform.Translate(absolute_bounds.x(),
86 absolute_bounds.y()); 85 absolute_bounds.y());
87 86
88 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); 87 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState();
89 88
90 const gfx::Rect bounds_at_origin(window->bounds().size()); 89 const gfx::Rect bounds_at_origin(window->bounds().size());
91 // TODO(fsamuel): These clipping and visible rects are incorrect. They need 90 // TODO(fsamuel): These clipping and visible rects are incorrect. They need
92 // to be populated from CompositorFrame structs. 91 // to be populated from CompositorFrame structs.
93 sqs->SetAll(quad_to_target_transform, 92 sqs->SetAll(quad_to_target_transform,
94 bounds_at_origin.size() /* layer_bounds */, 93 bounds_at_origin.size() /* layer_bounds */,
95 bounds_at_origin /* visible_layer_bounds */, 94 bounds_at_origin /* visible_layer_bounds */,
96 bounds_at_origin /* clip_rect */, false /* is_clipped */, 95 bounds_at_origin /* clip_rect */, false /* is_clipped */,
97 window->opacity(), SkXfermode::kSrcOver_Mode, 96 combined_opacity, SkXfermode::kSrcOver_Mode,
98 0 /* sorting-context_id */); 97 0 /* sorting-context_id */);
99 auto quad = pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>(); 98 auto quad = pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>();
100 quad->SetAll(sqs, bounds_at_origin /* rect */, 99 quad->SetAll(sqs, bounds_at_origin /* rect */,
101 gfx::Rect() /* opaque_rect */, 100 gfx::Rect() /* opaque_rect */,
102 bounds_at_origin /* visible_rect */, true /* needs_blending*/, 101 bounds_at_origin /* visible_rect */, true /* needs_blending*/,
103 default_surface->id()); 102 default_surface->id());
104 } 103 }
105 if (underlay_surface) { 104 if (underlay_surface) {
106 const gfx::Rect underlay_absolute_bounds = 105 const gfx::Rect underlay_absolute_bounds =
107 absolute_bounds - window->underlay_offset(); 106 absolute_bounds - window->underlay_offset();
108 gfx::Transform quad_to_target_transform; 107 gfx::Transform quad_to_target_transform;
109 quad_to_target_transform.Translate(underlay_absolute_bounds.x(), 108 quad_to_target_transform.Translate(underlay_absolute_bounds.x(),
110 underlay_absolute_bounds.y()); 109 underlay_absolute_bounds.y());
111 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); 110 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState();
112 const gfx::Rect bounds_at_origin( 111 const gfx::Rect bounds_at_origin(
113 underlay_surface->last_submitted_frame_size()); 112 underlay_surface->last_submitted_frame_size());
114 sqs->SetAll(quad_to_target_transform, 113 sqs->SetAll(quad_to_target_transform,
115 bounds_at_origin.size() /* layer_bounds */, 114 bounds_at_origin.size() /* layer_bounds */,
116 bounds_at_origin /* visible_layer_bounds */, 115 bounds_at_origin /* visible_layer_bounds */,
117 bounds_at_origin /* clip_rect */, false /* is_clipped */, 116 bounds_at_origin /* clip_rect */, false /* is_clipped */,
118 window->opacity(), SkXfermode::kSrcOver_Mode, 117 combined_opacity, SkXfermode::kSrcOver_Mode,
119 0 /* sorting-context_id */); 118 0 /* sorting-context_id */);
120 119
121 auto quad = pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>(); 120 auto quad = pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>();
122 quad->SetAll(sqs, bounds_at_origin /* rect */, 121 quad->SetAll(sqs, bounds_at_origin /* rect */,
123 gfx::Rect() /* opaque_rect */, 122 gfx::Rect() /* opaque_rect */,
124 bounds_at_origin /* visible_rect */, true /* needs_blending*/, 123 bounds_at_origin /* visible_rect */, true /* needs_blending*/,
125 underlay_surface->id()); 124 underlay_surface->id());
126 } 125 }
127 } 126 }
128 127
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 408
410 void DefaultPlatformDisplay::RequestCopyOfOutput( 409 void DefaultPlatformDisplay::RequestCopyOfOutput(
411 std::unique_ptr<cc::CopyOutputRequest> output_request) { 410 std::unique_ptr<cc::CopyOutputRequest> output_request) {
412 if (display_compositor_) 411 if (display_compositor_)
413 display_compositor_->RequestCopyOfOutput(std::move(output_request)); 412 display_compositor_->RequestCopyOfOutput(std::move(output_request));
414 } 413 }
415 414
416 } // namespace ws 415 } // namespace ws
417 416
418 } // namespace mus 417 } // namespace mus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698