| 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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 factory_owner_->surface_ = nullptr; | 238 factory_owner_->surface_ = nullptr; |
| 239 | 239 |
| 240 // Call pending frame callbacks with a null frame time to indicate that they | 240 // Call pending frame callbacks with a null frame time to indicate that they |
| 241 // have been cancelled. | 241 // have been cancelled. |
| 242 frame_callbacks_.splice(frame_callbacks_.end(), pending_frame_callbacks_); | 242 frame_callbacks_.splice(frame_callbacks_.end(), pending_frame_callbacks_); |
| 243 active_frame_callbacks_.splice(active_frame_callbacks_.end(), | 243 active_frame_callbacks_.splice(active_frame_callbacks_.end(), |
| 244 frame_callbacks_); | 244 frame_callbacks_); |
| 245 for (const auto& frame_callback : active_frame_callbacks_) | 245 for (const auto& frame_callback : active_frame_callbacks_) |
| 246 frame_callback.Run(base::TimeTicks()); | 246 frame_callback.Run(base::TimeTicks()); |
| 247 | 247 |
| 248 if (begin_frame_source_) | 248 if (begin_frame_source_ && needs_begin_frame_) |
| 249 begin_frame_source_->RemoveObserver(this); | 249 begin_frame_source_->RemoveObserver(this); |
| 250 | 250 |
| 251 if (!local_frame_id_.is_null()) | 251 if (!local_frame_id_.is_null()) |
| 252 factory_owner_->surface_factory_->Destroy(local_frame_id_); | 252 factory_owner_->surface_factory_->Destroy(local_frame_id_); |
| 253 | 253 |
| 254 surface_manager_->UnregisterSurfaceFactoryClient( | 254 surface_manager_->UnregisterSurfaceFactoryClient( |
| 255 factory_owner_->frame_sink_id_); | 255 factory_owner_->frame_sink_id_); |
| 256 } | 256 } |
| 257 | 257 |
| 258 // static | 258 // static |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 return value; | 615 return value; |
| 616 } | 616 } |
| 617 | 617 |
| 618 void Surface::WillDraw() { | 618 void Surface::WillDraw() { |
| 619 active_frame_callbacks_.splice(active_frame_callbacks_.end(), | 619 active_frame_callbacks_.splice(active_frame_callbacks_.end(), |
| 620 frame_callbacks_); | 620 frame_callbacks_); |
| 621 UpdateNeedsBeginFrame(); | 621 UpdateNeedsBeginFrame(); |
| 622 } | 622 } |
| 623 | 623 |
| 624 void Surface::SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) { | 624 void Surface::SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) { |
| 625 if (begin_frame_source_ && needs_begin_frame_) { |
| 626 begin_frame_source_->RemoveObserver(this); |
| 627 needs_begin_frame_ = false; |
| 628 } |
| 625 begin_frame_source_ = begin_frame_source; | 629 begin_frame_source_ = begin_frame_source; |
| 626 UpdateNeedsBeginFrame(); | 630 UpdateNeedsBeginFrame(); |
| 627 } | 631 } |
| 628 | 632 |
| 629 void Surface::CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces() { | 633 void Surface::CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces() { |
| 630 if (HasLayerHierarchyChanged()) | 634 if (HasLayerHierarchyChanged()) |
| 631 SetSurfaceHierarchyNeedsCommitToNewSurfaces(); | 635 SetSurfaceHierarchyNeedsCommitToNewSurfaces(); |
| 632 } | 636 } |
| 633 | 637 |
| 634 void Surface::OnLostResources() { | 638 void Surface::OnLostResources() { |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 836 solid_quad->SetNew(quad_state, quad_rect, quad_rect, SK_ColorBLACK, false); | 840 solid_quad->SetNew(quad_state, quad_rect, quad_rect, SK_ColorBLACK, false); |
| 837 } | 841 } |
| 838 | 842 |
| 839 frame.render_pass_list.push_back(std::move(render_pass)); | 843 frame.render_pass_list.push_back(std::move(render_pass)); |
| 840 | 844 |
| 841 factory_owner_->surface_factory_->SubmitCompositorFrame( | 845 factory_owner_->surface_factory_->SubmitCompositorFrame( |
| 842 local_frame_id_, std::move(frame), cc::SurfaceFactory::DrawCallback()); | 846 local_frame_id_, std::move(frame), cc::SurfaceFactory::DrawCallback()); |
| 843 } | 847 } |
| 844 | 848 |
| 845 void Surface::UpdateNeedsBeginFrame() { | 849 void Surface::UpdateNeedsBeginFrame() { |
| 846 if (!begin_frame_source_) { | 850 if (!begin_frame_source_) |
| 847 needs_begin_frame_ = false; | |
| 848 return; | 851 return; |
| 849 } | |
| 850 | 852 |
| 851 bool needs_begin_frame = !active_frame_callbacks_.empty(); | 853 bool needs_begin_frame = !active_frame_callbacks_.empty(); |
| 852 if (needs_begin_frame == needs_begin_frame_) | 854 if (needs_begin_frame == needs_begin_frame_) |
| 853 return; | 855 return; |
| 854 | 856 |
| 855 needs_begin_frame_ = needs_begin_frame; | 857 needs_begin_frame_ = needs_begin_frame; |
| 856 if (needs_begin_frame) | 858 if (needs_begin_frame) |
| 857 begin_frame_source_->AddObserver(this); | 859 begin_frame_source_->AddObserver(this); |
| 858 else | 860 else |
| 859 begin_frame_source_->RemoveObserver(this); | 861 begin_frame_source_->RemoveObserver(this); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 879 | 881 |
| 880 int64_t Surface::GetPropertyInternal(const void* key, | 882 int64_t Surface::GetPropertyInternal(const void* key, |
| 881 int64_t default_value) const { | 883 int64_t default_value) const { |
| 882 std::map<const void*, Value>::const_iterator iter = prop_map_.find(key); | 884 std::map<const void*, Value>::const_iterator iter = prop_map_.find(key); |
| 883 if (iter == prop_map_.end()) | 885 if (iter == prop_map_.end()) |
| 884 return default_value; | 886 return default_value; |
| 885 return iter->second.value; | 887 return iter->second.value; |
| 886 } | 888 } |
| 887 | 889 |
| 888 } // namespace exo | 890 } // namespace exo |
| OLD | NEW |