| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/exo/surface.h" | 5 #include "components/exo/surface.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 factory_owner_->surface_ = nullptr; | 232 factory_owner_->surface_ = nullptr; |
| 233 | 233 |
| 234 // Call pending frame callbacks with a null frame time to indicate that they | 234 // Call pending frame callbacks with a null frame time to indicate that they |
| 235 // have been cancelled. | 235 // have been cancelled. |
| 236 frame_callbacks_.splice(frame_callbacks_.end(), pending_frame_callbacks_); | 236 frame_callbacks_.splice(frame_callbacks_.end(), pending_frame_callbacks_); |
| 237 active_frame_callbacks_.splice(active_frame_callbacks_.end(), | 237 active_frame_callbacks_.splice(active_frame_callbacks_.end(), |
| 238 frame_callbacks_); | 238 frame_callbacks_); |
| 239 for (const auto& frame_callback : active_frame_callbacks_) | 239 for (const auto& frame_callback : active_frame_callbacks_) |
| 240 frame_callback.Run(base::TimeTicks()); | 240 frame_callback.Run(base::TimeTicks()); |
| 241 | 241 |
| 242 if (!local_frame_id_.is_null()) | 242 if (local_frame_id_.is_valid()) |
| 243 factory_owner_->surface_factory_->Destroy(local_frame_id_); | 243 factory_owner_->surface_factory_->Destroy(local_frame_id_); |
| 244 } | 244 } |
| 245 | 245 |
| 246 // static | 246 // static |
| 247 Surface* Surface::AsSurface(const aura::Window* window) { | 247 Surface* Surface::AsSurface(const aura::Window* window) { |
| 248 return window->GetProperty(kSurfaceKey); | 248 return window->GetProperty(kSurfaceKey); |
| 249 } | 249 } |
| 250 | 250 |
| 251 cc::SurfaceId Surface::GetSurfaceId() const { | 251 cc::SurfaceId Surface::GetSurfaceId() const { |
| 252 return cc::SurfaceId(factory_owner_->frame_sink_id_, local_frame_id_); | 252 return cc::SurfaceId(factory_owner_->frame_sink_id_, local_frame_id_); |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 | 439 |
| 440 if (delegate_) { | 440 if (delegate_) { |
| 441 delegate_->OnSurfaceCommit(); | 441 delegate_->OnSurfaceCommit(); |
| 442 } else { | 442 } else { |
| 443 CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces(); | 443 CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces(); |
| 444 CommitSurfaceHierarchy(); | 444 CommitSurfaceHierarchy(); |
| 445 } | 445 } |
| 446 } | 446 } |
| 447 | 447 |
| 448 void Surface::OnLostResources() { | 448 void Surface::OnLostResources() { |
| 449 if (local_frame_id_.is_null()) | 449 if (!local_frame_id_.is_valid()) |
| 450 return; | 450 return; |
| 451 | 451 |
| 452 UpdateResource(false); | 452 UpdateResource(false); |
| 453 UpdateSurface(false); | 453 UpdateSurface(false); |
| 454 } | 454 } |
| 455 | 455 |
| 456 void Surface::CommitSurfaceHierarchy() { | 456 void Surface::CommitSurfaceHierarchy() { |
| 457 DCHECK(needs_commit_surface_hierarchy_); | 457 DCHECK(needs_commit_surface_hierarchy_); |
| 458 needs_commit_surface_hierarchy_ = false; | 458 needs_commit_surface_hierarchy_ = false; |
| 459 has_pending_layer_changes_ = false; | 459 has_pending_layer_changes_ = false; |
| 460 | 460 |
| 461 state_ = pending_state_; | 461 state_ = pending_state_; |
| 462 pending_state_.only_visible_on_secure_output = false; | 462 pending_state_.only_visible_on_secure_output = false; |
| 463 | 463 |
| 464 // We update contents if Attach() has been called since last commit. | 464 // We update contents if Attach() has been called since last commit. |
| 465 if (has_pending_contents_) { | 465 if (has_pending_contents_) { |
| 466 has_pending_contents_ = false; | 466 has_pending_contents_ = false; |
| 467 | 467 |
| 468 current_buffer_ = std::move(pending_buffer_); | 468 current_buffer_ = std::move(pending_buffer_); |
| 469 | 469 |
| 470 UpdateResource(true); | 470 UpdateResource(true); |
| 471 } | 471 } |
| 472 | 472 |
| 473 cc::LocalFrameId old_local_frame_id = local_frame_id_; | 473 cc::LocalFrameId old_local_frame_id = local_frame_id_; |
| 474 if (needs_commit_to_new_surface_ || local_frame_id_.is_null()) { | 474 if (needs_commit_to_new_surface_ || !local_frame_id_.is_valid()) { |
| 475 needs_commit_to_new_surface_ = false; | 475 needs_commit_to_new_surface_ = false; |
| 476 local_frame_id_ = factory_owner_->id_allocator_->GenerateId(); | 476 local_frame_id_ = factory_owner_->id_allocator_->GenerateId(); |
| 477 factory_owner_->surface_factory_->Create(local_frame_id_); | 477 factory_owner_->surface_factory_->Create(local_frame_id_); |
| 478 } | 478 } |
| 479 | 479 |
| 480 UpdateSurface(true); | 480 UpdateSurface(true); |
| 481 | 481 |
| 482 if (!old_local_frame_id.is_null() && old_local_frame_id != local_frame_id_) { | 482 if (old_local_frame_id.is_valid() && old_local_frame_id != local_frame_id_) { |
| 483 factory_owner_->surface_factory_->SetPreviousFrameSurface( | 483 factory_owner_->surface_factory_->SetPreviousFrameSurface( |
| 484 local_frame_id_, old_local_frame_id); | 484 local_frame_id_, old_local_frame_id); |
| 485 factory_owner_->surface_factory_->Destroy(old_local_frame_id); | 485 factory_owner_->surface_factory_->Destroy(old_local_frame_id); |
| 486 } | 486 } |
| 487 | 487 |
| 488 if (old_local_frame_id != local_frame_id_) { | 488 if (old_local_frame_id != local_frame_id_) { |
| 489 float contents_surface_to_layer_scale = 1.0; | 489 float contents_surface_to_layer_scale = 1.0; |
| 490 window_->layer()->SetShowSurface( | 490 window_->layer()->SetShowSurface( |
| 491 cc::SurfaceId(factory_owner_->frame_sink_id_, local_frame_id_), | 491 cc::SurfaceId(factory_owner_->frame_sink_id_, local_frame_id_), |
| 492 base::Bind(&SatisfyCallback, base::Unretained(surface_manager_)), | 492 base::Bind(&SatisfyCallback, base::Unretained(surface_manager_)), |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 } | 688 } |
| 689 | 689 |
| 690 void Surface::SetSurfaceHierarchyNeedsCommitToNewSurfaces() { | 690 void Surface::SetSurfaceHierarchyNeedsCommitToNewSurfaces() { |
| 691 needs_commit_to_new_surface_ = true; | 691 needs_commit_to_new_surface_ = true; |
| 692 for (auto& sub_surface_entry : pending_sub_surfaces_) { | 692 for (auto& sub_surface_entry : pending_sub_surfaces_) { |
| 693 sub_surface_entry.first->SetSurfaceHierarchyNeedsCommitToNewSurfaces(); | 693 sub_surface_entry.first->SetSurfaceHierarchyNeedsCommitToNewSurfaces(); |
| 694 } | 694 } |
| 695 } | 695 } |
| 696 | 696 |
| 697 void Surface::SetSurfaceLayerContents(ui::Layer* layer) { | 697 void Surface::SetSurfaceLayerContents(ui::Layer* layer) { |
| 698 if (local_frame_id_.is_null()) | 698 if (!local_frame_id_.is_valid()) |
| 699 return; | 699 return; |
| 700 | 700 |
| 701 gfx::Size layer_size = layer->bounds().size(); | 701 gfx::Size layer_size = layer->bounds().size(); |
| 702 float contents_surface_to_layer_scale = 1.0f; | 702 float contents_surface_to_layer_scale = 1.0f; |
| 703 | 703 |
| 704 layer->SetShowSurface( | 704 layer->SetShowSurface( |
| 705 cc::SurfaceId(factory_owner_->frame_sink_id_, local_frame_id_), | 705 cc::SurfaceId(factory_owner_->frame_sink_id_, local_frame_id_), |
| 706 base::Bind(&SatisfyCallback, base::Unretained(surface_manager_)), | 706 base::Bind(&SatisfyCallback, base::Unretained(surface_manager_)), |
| 707 base::Bind(&RequireCallback, base::Unretained(surface_manager_)), | 707 base::Bind(&RequireCallback, base::Unretained(surface_manager_)), |
| 708 layer_size, contents_surface_to_layer_scale, layer_size); | 708 layer_size, contents_surface_to_layer_scale, layer_size); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 | 849 |
| 850 int64_t Surface::GetPropertyInternal(const void* key, | 850 int64_t Surface::GetPropertyInternal(const void* key, |
| 851 int64_t default_value) const { | 851 int64_t default_value) const { |
| 852 std::map<const void*, Value>::const_iterator iter = prop_map_.find(key); | 852 std::map<const void*, Value>::const_iterator iter = prop_map_.find(key); |
| 853 if (iter == prop_map_.end()) | 853 if (iter == prop_map_.end()) |
| 854 return default_value; | 854 return default_value; |
| 855 return iter->second.value; | 855 return iter->second.value; |
| 856 } | 856 } |
| 857 | 857 |
| 858 } // namespace exo | 858 } // namespace exo |
| OLD | NEW |