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

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

Issue 2383373002: Reduce SurfaceIdAllocator usage and tie SurfaceFactory to a single FrameSinkId (Closed)
Patch Set: Rebased Created 4 years, 2 months 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') | content/browser/browser_plugin/browser_plugin_guest.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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
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()) { 196 if (surface_factory_->manager()) {
197 surface_factory_->manager()->InvalidateFrameSinkId( 197 surface_factory_->manager()->InvalidateFrameSinkId(frame_sink_id_);
198 id_allocator_->frame_sink_id());
199 } 198 }
200 } 199 }
201 200
202 //////////////////////////////////////////////////////////////////////////////// 201 ////////////////////////////////////////////////////////////////////////////////
203 // Surface, public: 202 // Surface, public:
204 203
205 Surface::Surface() 204 Surface::Surface()
206 : window_(new aura::Window(new CustomWindowDelegate(this))), 205 : window_(new aura::Window(new CustomWindowDelegate(this))),
207 surface_manager_( 206 surface_manager_(
208 aura::Env::GetInstance()->context_factory()->GetSurfaceManager()), 207 aura::Env::GetInstance()->context_factory()->GetSurfaceManager()),
209 factory_owner_(new SurfaceFactoryOwner) { 208 factory_owner_(new SurfaceFactoryOwner) {
210 window_->SetType(ui::wm::WINDOW_TYPE_CONTROL); 209 window_->SetType(ui::wm::WINDOW_TYPE_CONTROL);
211 window_->SetName("ExoSurface"); 210 window_->SetName("ExoSurface");
212 window_->SetProperty(kSurfaceKey, this); 211 window_->SetProperty(kSurfaceKey, this);
213 window_->Init(ui::LAYER_SOLID_COLOR); 212 window_->Init(ui::LAYER_SOLID_COLOR);
214 window_->set_layer_owner_delegate(this); 213 window_->set_layer_owner_delegate(this);
215 window_->SetEventTargeter(base::WrapUnique(new CustomWindowTargeter)); 214 window_->SetEventTargeter(base::WrapUnique(new CustomWindowTargeter));
216 window_->set_owned_by_parent(false); 215 window_->set_owned_by_parent(false);
217 factory_owner_->surface_ = this; 216 factory_owner_->surface_ = this;
218 factory_owner_->id_allocator_.reset(new cc::SurfaceIdAllocator( 217 factory_owner_->frame_sink_id_ =
219 aura::Env::GetInstance()->context_factory()->AllocateFrameSinkId())); 218 aura::Env::GetInstance()->context_factory()->AllocateFrameSinkId();
220 surface_manager_->RegisterFrameSinkId( 219 factory_owner_->id_allocator_.reset(
221 factory_owner_->id_allocator_->frame_sink_id()); 220 new cc::SurfaceIdAllocator(factory_owner_->frame_sink_id_));
222 factory_owner_->surface_factory_.reset( 221 surface_manager_->RegisterFrameSinkId(factory_owner_->frame_sink_id_);
223 new cc::SurfaceFactory(surface_manager_, factory_owner_.get())); 222 factory_owner_->surface_factory_.reset(new cc::SurfaceFactory(
223 factory_owner_->frame_sink_id_, surface_manager_, factory_owner_.get()));
224 aura::Env::GetInstance()->context_factory()->AddObserver(this); 224 aura::Env::GetInstance()->context_factory()->AddObserver(this);
225 } 225 }
226 226
227 Surface::~Surface() { 227 Surface::~Surface() {
228 aura::Env::GetInstance()->context_factory()->RemoveObserver(this); 228 aura::Env::GetInstance()->context_factory()->RemoveObserver(this);
229 FOR_EACH_OBSERVER(SurfaceObserver, observers_, OnSurfaceDestroying(this)); 229 FOR_EACH_OBSERVER(SurfaceObserver, observers_, OnSurfaceDestroying(this));
230 230
231 window_->layer()->SetShowSolidColorContent(); 231 window_->layer()->SetShowSolidColorContent();
232 232
233 factory_owner_->surface_ = nullptr; 233 factory_owner_->surface_ = nullptr;
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 846
847 int64_t Surface::GetPropertyInternal(const void* key, 847 int64_t Surface::GetPropertyInternal(const void* key,
848 int64_t default_value) const { 848 int64_t default_value) const {
849 std::map<const void*, Value>::const_iterator iter = prop_map_.find(key); 849 std::map<const void*, Value>::const_iterator iter = prop_map_.find(key);
850 if (iter == prop_map_.end()) 850 if (iter == prop_map_.end())
851 return default_value; 851 return default_value;
852 return iter->second.value; 852 return iter->second.value;
853 } 853 }
854 854
855 } // namespace exo 855 } // namespace exo
OLDNEW
« no previous file with comments | « components/exo/surface.h ('k') | content/browser/browser_plugin/browser_plugin_guest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698