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

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

Issue 2458833003: Revert of [M55] Generalize layer mirroring for phantom windows (Closed)
Patch Set: 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
« no previous file with comments | « components/exo/surface.h ('k') | components/exo/surface_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 203
204 Surface::Surface() 204 Surface::Surface()
205 : window_(new aura::Window(new CustomWindowDelegate(this))), 205 : window_(new aura::Window(new CustomWindowDelegate(this))),
206 surface_manager_( 206 surface_manager_(
207 aura::Env::GetInstance()->context_factory()->GetSurfaceManager()), 207 aura::Env::GetInstance()->context_factory()->GetSurfaceManager()),
208 factory_owner_(new SurfaceFactoryOwner) { 208 factory_owner_(new SurfaceFactoryOwner) {
209 window_->SetType(ui::wm::WINDOW_TYPE_CONTROL); 209 window_->SetType(ui::wm::WINDOW_TYPE_CONTROL);
210 window_->SetName("ExoSurface"); 210 window_->SetName("ExoSurface");
211 window_->SetProperty(kSurfaceKey, this); 211 window_->SetProperty(kSurfaceKey, this);
212 window_->Init(ui::LAYER_SOLID_COLOR); 212 window_->Init(ui::LAYER_SOLID_COLOR);
213 window_->set_layer_owner_delegate(this);
213 window_->SetEventTargeter(base::WrapUnique(new CustomWindowTargeter)); 214 window_->SetEventTargeter(base::WrapUnique(new CustomWindowTargeter));
214 window_->set_owned_by_parent(false); 215 window_->set_owned_by_parent(false);
215 factory_owner_->surface_ = this; 216 factory_owner_->surface_ = this;
216 factory_owner_->frame_sink_id_ = 217 factory_owner_->frame_sink_id_ =
217 aura::Env::GetInstance()->context_factory()->AllocateFrameSinkId(); 218 aura::Env::GetInstance()->context_factory()->AllocateFrameSinkId();
218 factory_owner_->id_allocator_.reset(new cc::SurfaceIdAllocator()); 219 factory_owner_->id_allocator_.reset(new cc::SurfaceIdAllocator());
219 surface_manager_->RegisterFrameSinkId(factory_owner_->frame_sink_id_); 220 surface_manager_->RegisterFrameSinkId(factory_owner_->frame_sink_id_);
220 factory_owner_->surface_factory_.reset(new cc::SurfaceFactory( 221 factory_owner_->surface_factory_.reset(new cc::SurfaceFactory(
221 factory_owner_->frame_sink_id_, surface_manager_, factory_owner_.get())); 222 factory_owner_->frame_sink_id_, surface_manager_, factory_owner_.get()));
222 aura::Env::GetInstance()->context_factory()->AddObserver(this); 223 aura::Env::GetInstance()->context_factory()->AddObserver(this);
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 UpdateSurface(true); 480 UpdateSurface(true);
480 481
481 if (!old_local_frame_id.is_null() && old_local_frame_id != local_frame_id_) { 482 if (!old_local_frame_id.is_null() && old_local_frame_id != local_frame_id_) {
482 factory_owner_->surface_factory_->SetPreviousFrameSurface( 483 factory_owner_->surface_factory_->SetPreviousFrameSurface(
483 local_frame_id_, old_local_frame_id); 484 local_frame_id_, old_local_frame_id);
484 factory_owner_->surface_factory_->Destroy(old_local_frame_id); 485 factory_owner_->surface_factory_->Destroy(old_local_frame_id);
485 } 486 }
486 487
487 if (old_local_frame_id != local_frame_id_) { 488 if (old_local_frame_id != local_frame_id_) {
488 float contents_surface_to_layer_scale = 1.0; 489 float contents_surface_to_layer_scale = 1.0;
489 // The bounds must be updated before switching to the new surface, because
490 // the layer may be mirrored, in which case a surface change causes the
491 // mirror layer to update its surface using the latest bounds.
492 window_->layer()->SetBounds(
493 gfx::Rect(window_->layer()->bounds().origin(), content_size_));
494 window_->layer()->SetShowSurface( 490 window_->layer()->SetShowSurface(
495 cc::SurfaceId(factory_owner_->frame_sink_id_, local_frame_id_), 491 cc::SurfaceId(factory_owner_->frame_sink_id_, local_frame_id_),
496 base::Bind(&SatisfyCallback, base::Unretained(surface_manager_)), 492 base::Bind(&SatisfyCallback, base::Unretained(surface_manager_)),
497 base::Bind(&RequireCallback, base::Unretained(surface_manager_)), 493 base::Bind(&RequireCallback, base::Unretained(surface_manager_)),
498 content_size_, contents_surface_to_layer_scale, content_size_); 494 content_size_, contents_surface_to_layer_scale, content_size_);
495 window_->layer()->SetBounds(
496 gfx::Rect(window_->layer()->bounds().origin(), content_size_));
499 window_->layer()->SetFillsBoundsOpaquely( 497 window_->layer()->SetFillsBoundsOpaquely(
500 state_.blend_mode == SkXfermode::kSrc_Mode || 498 state_.blend_mode == SkXfermode::kSrc_Mode ||
501 state_.opaque_region.contains( 499 state_.opaque_region.contains(
502 gfx::RectToSkIRect(gfx::Rect(content_size_)))); 500 gfx::RectToSkIRect(gfx::Rect(content_size_))));
503 } 501 }
504 502
505 // Reset damage. 503 // Reset damage.
506 pending_damage_.setEmpty(); 504 pending_damage_.setEmpty();
507 505
508 DCHECK(!current_resource_.id || 506 DCHECK(!current_resource_.id ||
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 return observers_.HasObserver(observer); 602 return observers_.HasObserver(observer);
605 } 603 }
606 604
607 std::unique_ptr<base::trace_event::TracedValue> Surface::AsTracedValue() const { 605 std::unique_ptr<base::trace_event::TracedValue> Surface::AsTracedValue() const {
608 std::unique_ptr<base::trace_event::TracedValue> value( 606 std::unique_ptr<base::trace_event::TracedValue> value(
609 new base::trace_event::TracedValue()); 607 new base::trace_event::TracedValue());
610 value->SetString("name", window_->layer()->name()); 608 value->SetString("name", window_->layer()->name());
611 return value; 609 return value;
612 } 610 }
613 611
612 ////////////////////////////////////////////////////////////////////////////////
613 // ui::LayerOwnerDelegate overrides:
614
615 void Surface::OnLayerRecreated(ui::Layer* old_layer, ui::Layer* new_layer) {
616 if (!current_buffer_.buffer())
617 return;
618
619 // TODO(reveman): Give the client a chance to provide new contents.
620 SetSurfaceLayerContents(new_layer);
621 }
622
614 void Surface::WillDraw(const cc::LocalFrameId& id) { 623 void Surface::WillDraw(const cc::LocalFrameId& id) {
615 while (!active_frame_callbacks_.empty()) { 624 while (!active_frame_callbacks_.empty()) {
616 active_frame_callbacks_.front().Run(base::TimeTicks::Now()); 625 active_frame_callbacks_.front().Run(base::TimeTicks::Now());
617 active_frame_callbacks_.pop_front(); 626 active_frame_callbacks_.pop_front();
618 } 627 }
619 } 628 }
620 629
621 void Surface::CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces() { 630 void Surface::CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces() {
622 if (HasLayerHierarchyChanged()) 631 if (HasLayerHierarchyChanged())
623 SetSurfaceHierarchyNeedsCommitToNewSurfaces(); 632 SetSurfaceHierarchyNeedsCommitToNewSurfaces();
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 return false; 687 return false;
679 } 688 }
680 689
681 void Surface::SetSurfaceHierarchyNeedsCommitToNewSurfaces() { 690 void Surface::SetSurfaceHierarchyNeedsCommitToNewSurfaces() {
682 needs_commit_to_new_surface_ = true; 691 needs_commit_to_new_surface_ = true;
683 for (auto& sub_surface_entry : pending_sub_surfaces_) { 692 for (auto& sub_surface_entry : pending_sub_surfaces_) {
684 sub_surface_entry.first->SetSurfaceHierarchyNeedsCommitToNewSurfaces(); 693 sub_surface_entry.first->SetSurfaceHierarchyNeedsCommitToNewSurfaces();
685 } 694 }
686 } 695 }
687 696
697 void Surface::SetSurfaceLayerContents(ui::Layer* layer) {
698 if (local_frame_id_.is_null())
699 return;
700
701 gfx::Size layer_size = layer->bounds().size();
702 float contents_surface_to_layer_scale = 1.0f;
703
704 layer->SetShowSurface(
705 cc::SurfaceId(factory_owner_->frame_sink_id_, local_frame_id_),
706 base::Bind(&SatisfyCallback, base::Unretained(surface_manager_)),
707 base::Bind(&RequireCallback, base::Unretained(surface_manager_)),
708 layer_size, contents_surface_to_layer_scale, layer_size);
709 }
710
688 void Surface::UpdateResource(bool client_usage) { 711 void Surface::UpdateResource(bool client_usage) {
689 std::unique_ptr<cc::SingleReleaseCallback> texture_mailbox_release_callback; 712 std::unique_ptr<cc::SingleReleaseCallback> texture_mailbox_release_callback;
690 713
691 cc::TextureMailbox texture_mailbox; 714 cc::TextureMailbox texture_mailbox;
692 if (current_buffer_.buffer()) { 715 if (current_buffer_.buffer()) {
693 texture_mailbox_release_callback = 716 texture_mailbox_release_callback =
694 current_buffer_.buffer()->ProduceTextureMailbox( 717 current_buffer_.buffer()->ProduceTextureMailbox(
695 &texture_mailbox, state_.only_visible_on_secure_output, 718 &texture_mailbox, state_.only_visible_on_secure_output,
696 client_usage); 719 client_usage);
697 } 720 }
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 849
827 int64_t Surface::GetPropertyInternal(const void* key, 850 int64_t Surface::GetPropertyInternal(const void* key,
828 int64_t default_value) const { 851 int64_t default_value) const {
829 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);
830 if (iter == prop_map_.end()) 853 if (iter == prop_map_.end())
831 return default_value; 854 return default_value;
832 return iter->second.value; 855 return iter->second.value;
833 } 856 }
834 857
835 } // namespace exo 858 } // namespace exo
OLDNEW
« no previous file with comments | « components/exo/surface.h ('k') | components/exo/surface_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698