OLD | NEW |
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 "cc/output/compositor_frame.h" | 7 #include "cc/output/compositor_frame.h" |
8 #include "cc/quads/render_pass.h" | 8 #include "cc/quads/render_pass.h" |
9 #include "cc/quads/shared_quad_state.h" | 9 #include "cc/quads/shared_quad_state.h" |
10 #include "cc/quads/surface_draw_quad.h" | 10 #include "cc/quads/surface_draw_quad.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 if (!window->visible()) | 112 if (!window->visible()) |
113 return; | 113 return; |
114 | 114 |
115 ServerWindowSurface* default_surface = | 115 ServerWindowSurface* default_surface = |
116 window->surface_manager() ? window->surface_manager()->GetDefaultSurface() | 116 window->surface_manager() ? window->surface_manager()->GetDefaultSurface() |
117 : nullptr; | 117 : nullptr; |
118 | 118 |
119 const gfx::Rect absolute_bounds = | 119 const gfx::Rect absolute_bounds = |
120 window->bounds() + parent_to_root_origin_offset; | 120 window->bounds() + parent_to_root_origin_offset; |
121 std::vector<ServerWindow*> children(window->GetChildren()); | 121 std::vector<ServerWindow*> children(window->GetChildren()); |
122 // TODO(rjkroege, fsamuel): Make sure we're handling alpha correctly. | |
123 const float combined_opacity = opacity * window->opacity(); | 122 const float combined_opacity = opacity * window->opacity(); |
124 for (auto it = children.rbegin(); it != children.rend(); ++it) { | 123 for (auto it = children.rbegin(); it != children.rend(); ++it) { |
125 DrawWindowTree(pass, *it, absolute_bounds.OffsetFromOrigin(), | 124 DrawWindowTree(pass, *it, absolute_bounds.OffsetFromOrigin(), |
126 combined_opacity); | 125 combined_opacity); |
127 } | 126 } |
128 | 127 |
129 if (!window->surface_manager() || !window->surface_manager()->ShouldDraw()) | 128 if (!window->surface_manager() || !window->surface_manager()->ShouldDraw()) |
130 return; | 129 return; |
131 | 130 |
132 ServerWindowSurface* underlay_surface = | 131 ServerWindowSurface* underlay_surface = |
133 window->surface_manager()->GetUnderlaySurface(); | 132 window->surface_manager()->GetUnderlaySurface(); |
134 if (!default_surface && !underlay_surface) | 133 if (!default_surface && !underlay_surface) |
135 return; | 134 return; |
136 | 135 |
137 if (default_surface) { | 136 if (default_surface) { |
138 gfx::Transform quad_to_target_transform; | 137 gfx::Transform quad_to_target_transform; |
139 quad_to_target_transform.Translate(absolute_bounds.x(), | 138 quad_to_target_transform.Translate(absolute_bounds.x(), |
140 absolute_bounds.y()); | 139 absolute_bounds.y()); |
141 | 140 |
142 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); | 141 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); |
143 | 142 |
144 const gfx::Rect bounds_at_origin(window->bounds().size()); | 143 const gfx::Rect bounds_at_origin(window->bounds().size()); |
145 // TODO(fsamuel): These clipping and visible rects are incorrect. They need | 144 // TODO(fsamuel): These clipping and visible rects are incorrect. They need |
146 // to be populated from CompositorFrame structs. | 145 // to be populated from CompositorFrame structs. |
147 sqs->SetAll(quad_to_target_transform, | 146 sqs->SetAll(quad_to_target_transform, |
148 bounds_at_origin.size() /* layer_bounds */, | 147 bounds_at_origin.size() /* layer_bounds */, |
149 bounds_at_origin /* visible_layer_bounds */, | 148 bounds_at_origin /* visible_layer_bounds */, |
150 bounds_at_origin /* clip_rect */, false /* is_clipped */, | 149 bounds_at_origin /* clip_rect */, false /* is_clipped */, |
151 window->opacity(), SkXfermode::kSrcOver_Mode, | 150 combined_opacity, SkXfermode::kSrcOver_Mode, |
152 0 /* sorting-context_id */); | 151 0 /* sorting-context_id */); |
153 auto quad = pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>(); | 152 auto quad = pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>(); |
154 quad->SetAll(sqs, bounds_at_origin /* rect */, | 153 quad->SetAll(sqs, bounds_at_origin /* rect */, |
155 gfx::Rect() /* opaque_rect */, | 154 gfx::Rect() /* opaque_rect */, |
156 bounds_at_origin /* visible_rect */, true /* needs_blending*/, | 155 bounds_at_origin /* visible_rect */, true /* needs_blending*/, |
157 default_surface->id()); | 156 default_surface->id()); |
158 } | 157 } |
159 if (underlay_surface) { | 158 if (underlay_surface) { |
160 const gfx::Rect underlay_absolute_bounds = | 159 const gfx::Rect underlay_absolute_bounds = |
161 absolute_bounds - window->underlay_offset(); | 160 absolute_bounds - window->underlay_offset(); |
162 gfx::Transform quad_to_target_transform; | 161 gfx::Transform quad_to_target_transform; |
163 quad_to_target_transform.Translate(underlay_absolute_bounds.x(), | 162 quad_to_target_transform.Translate(underlay_absolute_bounds.x(), |
164 underlay_absolute_bounds.y()); | 163 underlay_absolute_bounds.y()); |
165 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); | 164 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); |
166 const gfx::Rect bounds_at_origin( | 165 const gfx::Rect bounds_at_origin( |
167 underlay_surface->last_submitted_frame_size()); | 166 underlay_surface->last_submitted_frame_size()); |
168 sqs->SetAll(quad_to_target_transform, | 167 sqs->SetAll(quad_to_target_transform, |
169 bounds_at_origin.size() /* layer_bounds */, | 168 bounds_at_origin.size() /* layer_bounds */, |
170 bounds_at_origin /* visible_layer_bounds */, | 169 bounds_at_origin /* visible_layer_bounds */, |
171 bounds_at_origin /* clip_rect */, false /* is_clipped */, | 170 bounds_at_origin /* clip_rect */, false /* is_clipped */, |
172 window->opacity(), SkXfermode::kSrcOver_Mode, | 171 combined_opacity, SkXfermode::kSrcOver_Mode, |
173 0 /* sorting-context_id */); | 172 0 /* sorting-context_id */); |
174 | 173 |
175 auto quad = pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>(); | 174 auto quad = pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>(); |
176 quad->SetAll(sqs, bounds_at_origin /* rect */, | 175 quad->SetAll(sqs, bounds_at_origin /* rect */, |
177 gfx::Rect() /* opaque_rect */, | 176 gfx::Rect() /* opaque_rect */, |
178 bounds_at_origin /* visible_rect */, true /* needs_blending*/, | 177 bounds_at_origin /* visible_rect */, true /* needs_blending*/, |
179 underlay_surface->id()); | 178 underlay_surface->id()); |
180 } | 179 } |
181 } | 180 } |
182 | 181 |
183 } // namespace ws | 182 } // namespace ws |
184 | 183 |
185 } // namespace ui | 184 } // namespace ui |
OLD | NEW |