| 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 if (!surface) { | 155 if (!surface) { |
| 156 LOG(ERROR) << "Attempting to require callback on nonexistent surface"; | 156 LOG(ERROR) << "Attempting to require callback on nonexistent surface"; |
| 157 return; | 157 return; |
| 158 } | 158 } |
| 159 surface->AddDestructionDependency(sequence); | 159 surface->AddDestructionDependency(sequence); |
| 160 } | 160 } |
| 161 | 161 |
| 162 } // namespace | 162 } // namespace |
| 163 | 163 |
| 164 //////////////////////////////////////////////////////////////////////////////// | 164 //////////////////////////////////////////////////////////////////////////////// |
| 165 // SurfaceFactoryOwner, public: | |
| 166 | |
| 167 SurfaceFactoryOwner::SurfaceFactoryOwner() {} | |
| 168 | |
| 169 //////////////////////////////////////////////////////////////////////////////// | |
| 170 // cc::SurfaceFactoryClient overrides: | |
| 171 | |
| 172 void SurfaceFactoryOwner::ReturnResources( | |
| 173 const cc::ReturnedResourceArray& resources) { | |
| 174 scoped_refptr<SurfaceFactoryOwner> holder(this); | |
| 175 for (auto& resource : resources) { | |
| 176 auto it = release_callbacks_.find(resource.id); | |
| 177 DCHECK(it != release_callbacks_.end()); | |
| 178 it->second.second->Run(resource.sync_token, resource.lost); | |
| 179 release_callbacks_.erase(it); | |
| 180 } | |
| 181 } | |
| 182 | |
| 183 void SurfaceFactoryOwner::WillDrawSurface(const cc::LocalFrameId& id, | |
| 184 const gfx::Rect& damage_rect) { | |
| 185 if (surface_) | |
| 186 surface_->WillDraw(); | |
| 187 } | |
| 188 | |
| 189 void SurfaceFactoryOwner::SetBeginFrameSource( | |
| 190 cc::BeginFrameSource* begin_frame_source) { | |
| 191 if (surface_) | |
| 192 surface_->SetBeginFrameSource(begin_frame_source); | |
| 193 } | |
| 194 | |
| 195 //////////////////////////////////////////////////////////////////////////////// | |
| 196 // SurfaceFactoryOwner, private: | |
| 197 | |
| 198 SurfaceFactoryOwner::~SurfaceFactoryOwner() { | |
| 199 if (surface_factory_->manager()) | |
| 200 surface_factory_->manager()->InvalidateFrameSinkId(frame_sink_id_); | |
| 201 } | |
| 202 | |
| 203 //////////////////////////////////////////////////////////////////////////////// | |
| 204 // Surface, public: | 165 // Surface, public: |
| 205 | 166 |
| 206 Surface::Surface() | 167 Surface::Surface() |
| 207 : window_(new aura::Window(new CustomWindowDelegate(this))), | 168 : window_(new aura::Window(new CustomWindowDelegate(this))), |
| 208 surface_manager_( | 169 surface_manager_( |
| 209 aura::Env::GetInstance()->context_factory()->GetSurfaceManager()), | 170 aura::Env::GetInstance()->context_factory()->GetSurfaceManager()), |
| 210 factory_owner_(new SurfaceFactoryOwner) { | 171 factory_owner_(new ExoCompositorFrameSink) { |
| 211 window_->SetType(ui::wm::WINDOW_TYPE_CONTROL); | 172 window_->SetType(ui::wm::WINDOW_TYPE_CONTROL); |
| 212 window_->SetName("ExoSurface"); | 173 window_->SetName("ExoSurface"); |
| 213 window_->SetProperty(kSurfaceKey, this); | 174 window_->SetProperty(kSurfaceKey, this); |
| 214 window_->Init(ui::LAYER_SOLID_COLOR); | 175 window_->Init(ui::LAYER_SOLID_COLOR); |
| 215 window_->SetEventTargeter(base::WrapUnique(new CustomWindowTargeter)); | 176 window_->SetEventTargeter(base::WrapUnique(new CustomWindowTargeter)); |
| 216 window_->set_owned_by_parent(false); | 177 window_->set_owned_by_parent(false); |
| 217 window_->AddObserver(this); | 178 window_->AddObserver(this); |
| 218 factory_owner_->surface_ = this; | 179 factory_owner_->surface_ = this; |
| 219 factory_owner_->frame_sink_id_ = | 180 factory_owner_->frame_sink_id_ = |
| 220 aura::Env::GetInstance()->context_factory()->AllocateFrameSinkId(); | 181 aura::Env::GetInstance()->context_factory()->AllocateFrameSinkId(); |
| (...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 881 | 842 |
| 882 int64_t Surface::GetPropertyInternal(const void* key, | 843 int64_t Surface::GetPropertyInternal(const void* key, |
| 883 int64_t default_value) const { | 844 int64_t default_value) const { |
| 884 std::map<const void*, Value>::const_iterator iter = prop_map_.find(key); | 845 std::map<const void*, Value>::const_iterator iter = prop_map_.find(key); |
| 885 if (iter == prop_map_.end()) | 846 if (iter == prop_map_.end()) |
| 886 return default_value; | 847 return default_value; |
| 887 return iter->second.value; | 848 return iter->second.value; |
| 888 } | 849 } |
| 889 | 850 |
| 890 } // namespace exo | 851 } // namespace exo |
| OLD | NEW |