| 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 "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" |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 !window->compositor_frame_sink_manager()->ShouldDraw()) | 159 !window->compositor_frame_sink_manager()->ShouldDraw()) |
| 160 return; | 160 return; |
| 161 | 161 |
| 162 cc::SurfaceId underlay_surface_id = | 162 cc::SurfaceId underlay_surface_id = |
| 163 window->compositor_frame_sink_manager()->GetLatestSurfaceId( | 163 window->compositor_frame_sink_manager()->GetLatestSurfaceId( |
| 164 mojom::CompositorFrameSinkType::UNDERLAY); | 164 mojom::CompositorFrameSinkType::UNDERLAY); |
| 165 cc::SurfaceId default_surface_id = | 165 cc::SurfaceId default_surface_id = |
| 166 window->compositor_frame_sink_manager()->GetLatestSurfaceId( | 166 window->compositor_frame_sink_manager()->GetLatestSurfaceId( |
| 167 mojom::CompositorFrameSinkType::DEFAULT); | 167 mojom::CompositorFrameSinkType::DEFAULT); |
| 168 | 168 |
| 169 if (underlay_surface_id.is_null() && default_surface_id.is_null()) | 169 if (!underlay_surface_id.is_valid() && !default_surface_id.is_valid()) |
| 170 return; | 170 return; |
| 171 | 171 |
| 172 if (!default_surface_id.is_null()) { | 172 if (default_surface_id.is_valid()) { |
| 173 gfx::Transform quad_to_target_transform; | 173 gfx::Transform quad_to_target_transform; |
| 174 quad_to_target_transform.Translate(absolute_bounds.x(), | 174 quad_to_target_transform.Translate(absolute_bounds.x(), |
| 175 absolute_bounds.y()); | 175 absolute_bounds.y()); |
| 176 | 176 |
| 177 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); | 177 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); |
| 178 | 178 |
| 179 const gfx::Rect bounds_at_origin(window->bounds().size()); | 179 const gfx::Rect bounds_at_origin(window->bounds().size()); |
| 180 // TODO(fsamuel): These clipping and visible rects are incorrect. They need | 180 // TODO(fsamuel): These clipping and visible rects are incorrect. They need |
| 181 // to be populated from CompositorFrame structs. | 181 // to be populated from CompositorFrame structs. |
| 182 sqs->SetAll(quad_to_target_transform, | 182 sqs->SetAll(quad_to_target_transform, |
| 183 bounds_at_origin.size() /* layer_bounds */, | 183 bounds_at_origin.size() /* layer_bounds */, |
| 184 bounds_at_origin /* visible_layer_bounds */, | 184 bounds_at_origin /* visible_layer_bounds */, |
| 185 bounds_at_origin /* clip_rect */, false /* is_clipped */, | 185 bounds_at_origin /* clip_rect */, false /* is_clipped */, |
| 186 combined_opacity, SkXfermode::kSrcOver_Mode, | 186 combined_opacity, SkXfermode::kSrcOver_Mode, |
| 187 0 /* sorting-context_id */); | 187 0 /* sorting-context_id */); |
| 188 auto* quad = pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>(); | 188 auto* quad = pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>(); |
| 189 AddOrUpdateSurfaceReference(mojom::CompositorFrameSinkType::DEFAULT, | 189 AddOrUpdateSurfaceReference(mojom::CompositorFrameSinkType::DEFAULT, |
| 190 window); | 190 window); |
| 191 quad->SetAll(sqs, bounds_at_origin /* rect */, | 191 quad->SetAll(sqs, bounds_at_origin /* rect */, |
| 192 gfx::Rect() /* opaque_rect */, | 192 gfx::Rect() /* opaque_rect */, |
| 193 bounds_at_origin /* visible_rect */, true /* needs_blending*/, | 193 bounds_at_origin /* visible_rect */, true /* needs_blending*/, |
| 194 default_surface_id); | 194 default_surface_id); |
| 195 } | 195 } |
| 196 if (!underlay_surface_id.is_null()) { | 196 if (underlay_surface_id.is_valid()) { |
| 197 const gfx::Rect underlay_absolute_bounds = | 197 const gfx::Rect underlay_absolute_bounds = |
| 198 absolute_bounds - window->underlay_offset(); | 198 absolute_bounds - window->underlay_offset(); |
| 199 gfx::Transform quad_to_target_transform; | 199 gfx::Transform quad_to_target_transform; |
| 200 quad_to_target_transform.Translate(underlay_absolute_bounds.x(), | 200 quad_to_target_transform.Translate(underlay_absolute_bounds.x(), |
| 201 underlay_absolute_bounds.y()); | 201 underlay_absolute_bounds.y()); |
| 202 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); | 202 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); |
| 203 const gfx::Rect bounds_at_origin( | 203 const gfx::Rect bounds_at_origin( |
| 204 window->compositor_frame_sink_manager()->GetLatestFrameSize( | 204 window->compositor_frame_sink_manager()->GetLatestFrameSize( |
| 205 mojom::CompositorFrameSinkType::UNDERLAY)); | 205 mojom::CompositorFrameSinkType::UNDERLAY)); |
| 206 sqs->SetAll(quad_to_target_transform, | 206 sqs->SetAll(quad_to_target_transform, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 218 bounds_at_origin /* visible_rect */, true /* needs_blending*/, | 218 bounds_at_origin /* visible_rect */, true /* needs_blending*/, |
| 219 underlay_surface_id); | 219 underlay_surface_id); |
| 220 } | 220 } |
| 221 } | 221 } |
| 222 | 222 |
| 223 void FrameGenerator::AddOrUpdateSurfaceReference( | 223 void FrameGenerator::AddOrUpdateSurfaceReference( |
| 224 mojom::CompositorFrameSinkType type, | 224 mojom::CompositorFrameSinkType type, |
| 225 ServerWindow* window) { | 225 ServerWindow* window) { |
| 226 cc::SurfaceId surface_id = | 226 cc::SurfaceId surface_id = |
| 227 window->compositor_frame_sink_manager()->GetLatestSurfaceId(type); | 227 window->compositor_frame_sink_manager()->GetLatestSurfaceId(type); |
| 228 if (surface_id.is_null()) | 228 if (!surface_id.is_valid()) |
| 229 return; | 229 return; |
| 230 auto it = dependencies_.find(surface_id.frame_sink_id()); | 230 auto it = dependencies_.find(surface_id.frame_sink_id()); |
| 231 if (it == dependencies_.end()) { | 231 if (it == dependencies_.end()) { |
| 232 SurfaceDependency dependency = { | 232 SurfaceDependency dependency = { |
| 233 surface_id.local_frame_id(), | 233 surface_id.local_frame_id(), |
| 234 surface_sequence_generator_.CreateSurfaceSequence()}; | 234 surface_sequence_generator_.CreateSurfaceSequence()}; |
| 235 dependencies_[surface_id.frame_sink_id()] = dependency; | 235 dependencies_[surface_id.frame_sink_id()] = dependency; |
| 236 GetDisplayCompositor()->AddSurfaceReference(surface_id, | 236 GetDisplayCompositor()->AddSurfaceReference(surface_id, |
| 237 dependency.sequence); | 237 dependency.sequence); |
| 238 // Observe |window_surface|'s window so that we can release references when | 238 // Observe |window_surface|'s window so that we can release references when |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 ServerWindowCompositorFrameSinkManager* compositor_frame_sink_manager = | 288 ServerWindowCompositorFrameSinkManager* compositor_frame_sink_manager = |
| 289 window->compositor_frame_sink_manager(); | 289 window->compositor_frame_sink_manager(); |
| 290 // If FrameGenerator was observing |window|, then that means it had a | 290 // If FrameGenerator was observing |window|, then that means it had a |
| 291 // CompositorFrame at some point in time and should have a | 291 // CompositorFrame at some point in time and should have a |
| 292 // ServerWindowCompositorFrameSinkManager. | 292 // ServerWindowCompositorFrameSinkManager. |
| 293 DCHECK(compositor_frame_sink_manager); | 293 DCHECK(compositor_frame_sink_manager); |
| 294 | 294 |
| 295 cc::SurfaceId default_surface_id = | 295 cc::SurfaceId default_surface_id = |
| 296 window->compositor_frame_sink_manager()->GetLatestSurfaceId( | 296 window->compositor_frame_sink_manager()->GetLatestSurfaceId( |
| 297 mojom::CompositorFrameSinkType::DEFAULT); | 297 mojom::CompositorFrameSinkType::DEFAULT); |
| 298 if (!default_surface_id.is_null()) | 298 if (default_surface_id.is_valid()) |
| 299 ReleaseFrameSinkReference(default_surface_id.frame_sink_id()); | 299 ReleaseFrameSinkReference(default_surface_id.frame_sink_id()); |
| 300 | 300 |
| 301 cc::SurfaceId underlay_surface_id = | 301 cc::SurfaceId underlay_surface_id = |
| 302 window->compositor_frame_sink_manager()->GetLatestSurfaceId( | 302 window->compositor_frame_sink_manager()->GetLatestSurfaceId( |
| 303 mojom::CompositorFrameSinkType::UNDERLAY); | 303 mojom::CompositorFrameSinkType::UNDERLAY); |
| 304 if (!underlay_surface_id.is_null()) | 304 if (underlay_surface_id.is_valid()) |
| 305 ReleaseFrameSinkReference(underlay_surface_id.frame_sink_id()); | 305 ReleaseFrameSinkReference(underlay_surface_id.frame_sink_id()); |
| 306 } | 306 } |
| 307 | 307 |
| 308 } // namespace ws | 308 } // namespace ws |
| 309 | 309 |
| 310 } // namespace ui | 310 } // namespace ui |
| OLD | NEW |