| 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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 if (surface_) | 185 if (surface_) |
| 186 surface_->WillDraw(id); | 186 surface_->WillDraw(id); |
| 187 } | 187 } |
| 188 | 188 |
| 189 void SurfaceFactoryOwner::SetBeginFrameSource( | 189 void SurfaceFactoryOwner::SetBeginFrameSource( |
| 190 cc::BeginFrameSource* begin_frame_source) {} | 190 cc::BeginFrameSource* begin_frame_source) {} |
| 191 | 191 |
| 192 //////////////////////////////////////////////////////////////////////////////// | 192 //////////////////////////////////////////////////////////////////////////////// |
| 193 // SurfaceFactoryOwner, private: | 193 // SurfaceFactoryOwner, private: |
| 194 | 194 |
| 195 SurfaceFactoryOwner::~SurfaceFactoryOwner() {} | 195 SurfaceFactoryOwner::~SurfaceFactoryOwner() { |
| 196 if (surface_factory_->manager()) { |
| 197 surface_factory_->manager()->InvalidateSurfaceClientId( |
| 198 id_allocator_->client_id()); |
| 199 } |
| 200 } |
| 196 | 201 |
| 197 //////////////////////////////////////////////////////////////////////////////// | 202 //////////////////////////////////////////////////////////////////////////////// |
| 198 // Surface, public: | 203 // Surface, public: |
| 199 | 204 |
| 200 Surface::Surface() | 205 Surface::Surface() |
| 201 : window_(new aura::Window(new CustomWindowDelegate(this))), | 206 : window_(new aura::Window(new CustomWindowDelegate(this))), |
| 202 surface_manager_( | 207 surface_manager_( |
| 203 aura::Env::GetInstance()->context_factory()->GetSurfaceManager()), | 208 aura::Env::GetInstance()->context_factory()->GetSurfaceManager()), |
| 204 factory_owner_(new SurfaceFactoryOwner) { | 209 factory_owner_(new SurfaceFactoryOwner) { |
| 205 window_->SetType(ui::wm::WINDOW_TYPE_CONTROL); | 210 window_->SetType(ui::wm::WINDOW_TYPE_CONTROL); |
| 206 window_->SetName("ExoSurface"); | 211 window_->SetName("ExoSurface"); |
| 207 window_->SetProperty(kSurfaceKey, this); | 212 window_->SetProperty(kSurfaceKey, this); |
| 208 window_->Init(ui::LAYER_SOLID_COLOR); | 213 window_->Init(ui::LAYER_SOLID_COLOR); |
| 209 window_->set_layer_owner_delegate(this); | 214 window_->set_layer_owner_delegate(this); |
| 210 window_->SetEventTargeter(base::WrapUnique(new CustomWindowTargeter)); | 215 window_->SetEventTargeter(base::WrapUnique(new CustomWindowTargeter)); |
| 211 window_->set_owned_by_parent(false); | 216 window_->set_owned_by_parent(false); |
| 212 factory_owner_->surface_ = this; | 217 factory_owner_->surface_ = this; |
| 213 factory_owner_->id_allocator_ = | 218 factory_owner_->id_allocator_.reset(new cc::SurfaceIdAllocator( |
| 214 aura::Env::GetInstance()->context_factory()->CreateSurfaceIdAllocator(); | 219 aura::Env::GetInstance()->context_factory()->AllocateSurfaceClientId())); |
| 220 surface_manager_->RegisterSurfaceClientId( |
| 221 factory_owner_->id_allocator_->client_id()); |
| 215 factory_owner_->surface_factory_.reset( | 222 factory_owner_->surface_factory_.reset( |
| 216 new cc::SurfaceFactory(surface_manager_, factory_owner_.get())); | 223 new cc::SurfaceFactory(surface_manager_, factory_owner_.get())); |
| 217 aura::Env::GetInstance()->context_factory()->AddObserver(this); | 224 aura::Env::GetInstance()->context_factory()->AddObserver(this); |
| 218 } | 225 } |
| 219 | 226 |
| 220 Surface::~Surface() { | 227 Surface::~Surface() { |
| 221 aura::Env::GetInstance()->context_factory()->RemoveObserver(this); | 228 aura::Env::GetInstance()->context_factory()->RemoveObserver(this); |
| 222 FOR_EACH_OBSERVER(SurfaceObserver, observers_, OnSurfaceDestroying(this)); | 229 FOR_EACH_OBSERVER(SurfaceObserver, observers_, OnSurfaceDestroying(this)); |
| 223 | 230 |
| 224 window_->layer()->SetShowSolidColorContent(); | 231 window_->layer()->SetShowSolidColorContent(); |
| (...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 836 | 843 |
| 837 int64_t Surface::GetPropertyInternal(const void* key, | 844 int64_t Surface::GetPropertyInternal(const void* key, |
| 838 int64_t default_value) const { | 845 int64_t default_value) const { |
| 839 std::map<const void*, Value>::const_iterator iter = prop_map_.find(key); | 846 std::map<const void*, Value>::const_iterator iter = prop_map_.find(key); |
| 840 if (iter == prop_map_.end()) | 847 if (iter == prop_map_.end()) |
| 841 return default_value; | 848 return default_value; |
| 842 return iter->second.value; | 849 return iter->second.value; |
| 843 } | 850 } |
| 844 | 851 |
| 845 } // namespace exo | 852 } // namespace exo |
| OLD | NEW |