| 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 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 | 401 |
| 402 UpdateResource(true); | 402 UpdateResource(true); |
| 403 } | 403 } |
| 404 | 404 |
| 405 cc::LocalFrameId old_local_frame_id = local_frame_id_; | 405 cc::LocalFrameId old_local_frame_id = local_frame_id_; |
| 406 if (needs_commit_to_new_surface_ || !local_frame_id_.is_valid()) { | 406 if (needs_commit_to_new_surface_ || !local_frame_id_.is_valid()) { |
| 407 needs_commit_to_new_surface_ = false; | 407 needs_commit_to_new_surface_ = false; |
| 408 local_frame_id_ = id_allocator_.GenerateId(); | 408 local_frame_id_ = id_allocator_.GenerateId(); |
| 409 } | 409 } |
| 410 | 410 |
| 411 UpdateSurface(true); | 411 UpdateSurface(false); |
| 412 | 412 |
| 413 if (old_local_frame_id != local_frame_id_) { | 413 if (old_local_frame_id != local_frame_id_) { |
| 414 float contents_surface_to_layer_scale = 1.0; | 414 float contents_surface_to_layer_scale = 1.0; |
| 415 // The bounds must be updated before switching to the new surface, because | 415 // The bounds must be updated before switching to the new surface, because |
| 416 // the layer may be mirrored, in which case a surface change causes the | 416 // the layer may be mirrored, in which case a surface change causes the |
| 417 // mirror layer to update its surface using the latest bounds. | 417 // mirror layer to update its surface using the latest bounds. |
| 418 window_->layer()->SetBounds( | 418 window_->layer()->SetBounds( |
| 419 gfx::Rect(window_->layer()->bounds().origin(), content_size_)); | 419 gfx::Rect(window_->layer()->bounds().origin(), content_size_)); |
| 420 window_->layer()->SetShowSurface( | 420 window_->layer()->SetShowSurface( |
| 421 cc::SurfaceId(frame_sink_id_, local_frame_id_), | 421 cc::SurfaceId(frame_sink_id_, local_frame_id_), |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 void Surface::CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces() { | 546 void Surface::CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces() { |
| 547 if (HasLayerHierarchyChanged()) | 547 if (HasLayerHierarchyChanged()) |
| 548 SetSurfaceHierarchyNeedsCommitToNewSurfaces(); | 548 SetSurfaceHierarchyNeedsCommitToNewSurfaces(); |
| 549 } | 549 } |
| 550 | 550 |
| 551 void Surface::OnLostResources() { | 551 void Surface::OnLostResources() { |
| 552 if (!local_frame_id_.is_valid()) | 552 if (!local_frame_id_.is_valid()) |
| 553 return; | 553 return; |
| 554 | 554 |
| 555 UpdateResource(false); | 555 UpdateResource(false); |
| 556 UpdateSurface(false); | 556 UpdateSurface(true); |
| 557 } | 557 } |
| 558 | 558 |
| 559 void Surface::OnWindowAddedToRootWindow(aura::Window* window) { | 559 void Surface::OnWindowAddedToRootWindow(aura::Window* window) { |
| 560 window->layer()->GetCompositor()->AddFrameSink(frame_sink_id_); | 560 window->layer()->GetCompositor()->AddFrameSink(frame_sink_id_); |
| 561 } | 561 } |
| 562 | 562 |
| 563 void Surface::OnWindowRemovingFromRootWindow(aura::Window* window, | 563 void Surface::OnWindowRemovingFromRootWindow(aura::Window* window, |
| 564 aura::Window* new_root) { | 564 aura::Window* new_root) { |
| 565 window->layer()->GetCompositor()->RemoveFrameSink(frame_sink_id_); | 565 window->layer()->GetCompositor()->RemoveFrameSink(frame_sink_id_); |
| 566 } | 566 } |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 | 765 |
| 766 int64_t Surface::GetPropertyInternal(const void* key, | 766 int64_t Surface::GetPropertyInternal(const void* key, |
| 767 int64_t default_value) const { | 767 int64_t default_value) const { |
| 768 std::map<const void*, Value>::const_iterator iter = prop_map_.find(key); | 768 std::map<const void*, Value>::const_iterator iter = prop_map_.find(key); |
| 769 if (iter == prop_map_.end()) | 769 if (iter == prop_map_.end()) |
| 770 return default_value; | 770 return default_value; |
| 771 return iter->second.value; | 771 return iter->second.value; |
| 772 } | 772 } |
| 773 | 773 |
| 774 } // namespace exo | 774 } // namespace exo |
| OLD | NEW |