Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: components/exo/surface.cc

Issue 2425923003: Replaced is_null() with is_valid in SurfaceId and related classes. (Closed)
Patch Set: Rebase Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_ && needs_begin_frame_) 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_valid())
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
259 Surface* Surface::AsSurface(const aura::Window* window) { 259 Surface* Surface::AsSurface(const aura::Window* window) {
260 return window->GetProperty(kSurfaceKey); 260 return window->GetProperty(kSurfaceKey);
261 } 261 }
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 // We update contents if Attach() has been called since last commit. 468 // We update contents if Attach() has been called since last commit.
469 if (has_pending_contents_) { 469 if (has_pending_contents_) {
470 has_pending_contents_ = false; 470 has_pending_contents_ = false;
471 471
472 current_buffer_ = std::move(pending_buffer_); 472 current_buffer_ = std::move(pending_buffer_);
473 473
474 UpdateResource(true); 474 UpdateResource(true);
475 } 475 }
476 476
477 cc::LocalFrameId old_local_frame_id = local_frame_id_; 477 cc::LocalFrameId old_local_frame_id = local_frame_id_;
478 if (needs_commit_to_new_surface_ || local_frame_id_.is_null()) { 478 if (needs_commit_to_new_surface_ || !local_frame_id_.is_valid()) {
479 needs_commit_to_new_surface_ = false; 479 needs_commit_to_new_surface_ = false;
480 local_frame_id_ = factory_owner_->id_allocator_->GenerateId(); 480 local_frame_id_ = factory_owner_->id_allocator_->GenerateId();
481 factory_owner_->surface_factory_->Create(local_frame_id_); 481 factory_owner_->surface_factory_->Create(local_frame_id_);
482 } 482 }
483 483
484 UpdateSurface(true); 484 UpdateSurface(true);
485 485
486 if (!old_local_frame_id.is_null() && old_local_frame_id != local_frame_id_) { 486 if (old_local_frame_id.is_valid() && old_local_frame_id != local_frame_id_) {
487 factory_owner_->surface_factory_->SetPreviousFrameSurface( 487 factory_owner_->surface_factory_->SetPreviousFrameSurface(
488 local_frame_id_, old_local_frame_id); 488 local_frame_id_, old_local_frame_id);
489 factory_owner_->surface_factory_->Destroy(old_local_frame_id); 489 factory_owner_->surface_factory_->Destroy(old_local_frame_id);
490 } 490 }
491 491
492 if (old_local_frame_id != local_frame_id_) { 492 if (old_local_frame_id != local_frame_id_) {
493 float contents_surface_to_layer_scale = 1.0; 493 float contents_surface_to_layer_scale = 1.0;
494 // The bounds must be updated before switching to the new surface, because 494 // The bounds must be updated before switching to the new surface, because
495 // the layer may be mirrored, in which case a surface change causes the 495 // the layer may be mirrored, in which case a surface change causes the
496 // mirror layer to update its surface using the latest bounds. 496 // mirror layer to update its surface using the latest bounds.
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 begin_frame_source_ = begin_frame_source; 629 begin_frame_source_ = begin_frame_source;
630 UpdateNeedsBeginFrame(); 630 UpdateNeedsBeginFrame();
631 } 631 }
632 632
633 void Surface::CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces() { 633 void Surface::CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces() {
634 if (HasLayerHierarchyChanged()) 634 if (HasLayerHierarchyChanged())
635 SetSurfaceHierarchyNeedsCommitToNewSurfaces(); 635 SetSurfaceHierarchyNeedsCommitToNewSurfaces();
636 } 636 }
637 637
638 void Surface::OnLostResources() { 638 void Surface::OnLostResources() {
639 if (local_frame_id_.is_null()) 639 if (!local_frame_id_.is_valid())
640 return; 640 return;
641 641
642 UpdateResource(false); 642 UpdateResource(false);
643 UpdateSurface(false); 643 UpdateSurface(false);
644 } 644 }
645 645
646 void Surface::OnWindowAddedToRootWindow(aura::Window* window) { 646 void Surface::OnWindowAddedToRootWindow(aura::Window* window) {
647 window->layer()->GetCompositor()->AddFrameSink( 647 window->layer()->GetCompositor()->AddFrameSink(
648 factory_owner_->frame_sink_id_); 648 factory_owner_->frame_sink_id_);
649 } 649 }
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 881
882 int64_t Surface::GetPropertyInternal(const void* key, 882 int64_t Surface::GetPropertyInternal(const void* key,
883 int64_t default_value) const { 883 int64_t default_value) const {
884 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);
885 if (iter == prop_map_.end()) 885 if (iter == prop_map_.end())
886 return default_value; 886 return default_value;
887 return iter->second.value; 887 return iter->second.value;
888 } 888 }
889 889
890 } // namespace exo 890 } // namespace exo
OLDNEW
« no previous file with comments | « cc/test/test_compositor_frame_sink.cc ('k') | content/browser/frame_host/render_widget_host_view_child_frame.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698