| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "cc/surfaces/surface_manager.h" | 5 #include "cc/surfaces/surface_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <queue> | 10 #include <queue> |
| 11 #include <utility> | 11 #include <utility> |
| 12 | 12 |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "cc/surfaces/direct_surface_reference_factory.h" |
| 14 #include "cc/surfaces/surface.h" | 15 #include "cc/surfaces/surface.h" |
| 15 #include "cc/surfaces/surface_factory_client.h" | 16 #include "cc/surfaces/surface_factory_client.h" |
| 16 #include "cc/surfaces/surface_id_allocator.h" | 17 #include "cc/surfaces/surface_id_allocator.h" |
| 17 | 18 |
| 18 namespace cc { | 19 namespace cc { |
| 19 | 20 |
| 20 SurfaceManager::FrameSinkSourceMapping::FrameSinkSourceMapping() | 21 SurfaceManager::FrameSinkSourceMapping::FrameSinkSourceMapping() |
| 21 : client(nullptr), source(nullptr) {} | 22 : client(nullptr), source(nullptr) {} |
| 22 | 23 |
| 23 SurfaceManager::FrameSinkSourceMapping::FrameSinkSourceMapping( | 24 SurfaceManager::FrameSinkSourceMapping::FrameSinkSourceMapping( |
| 24 const FrameSinkSourceMapping& other) = default; | 25 const FrameSinkSourceMapping& other) = default; |
| 25 | 26 |
| 26 SurfaceManager::FrameSinkSourceMapping::~FrameSinkSourceMapping() { | 27 SurfaceManager::FrameSinkSourceMapping::~FrameSinkSourceMapping() { |
| 27 DCHECK(is_empty()) << "client: " << client | 28 DCHECK(is_empty()) << "client: " << client |
| 28 << ", children: " << children.size(); | 29 << ", children: " << children.size(); |
| 29 } | 30 } |
| 30 | 31 |
| 31 SurfaceManager::SurfaceManager(LifetimeType lifetime_type) | 32 SurfaceManager::SurfaceManager(LifetimeType lifetime_type) |
| 32 : lifetime_type_(lifetime_type), | 33 : lifetime_type_(lifetime_type), |
| 33 root_surface_id_(FrameSinkId(0u, 0u), | 34 root_surface_id_(FrameSinkId(0u, 0u), |
| 34 LocalFrameId(1u, base::UnguessableToken::Create())), | 35 LocalFrameId(1u, base::UnguessableToken::Create())), |
| 35 weak_factory_(this) { | 36 weak_factory_(this) { |
| 36 thread_checker_.DetachFromThread(); | 37 thread_checker_.DetachFromThread(); |
| 38 reference_factory_ = |
| 39 new DirectSurfaceReferenceFactory(weak_factory_.GetWeakPtr()); |
| 37 } | 40 } |
| 38 | 41 |
| 39 SurfaceManager::~SurfaceManager() { | 42 SurfaceManager::~SurfaceManager() { |
| 40 DCHECK(thread_checker_.CalledOnValidThread()); | 43 DCHECK(thread_checker_.CalledOnValidThread()); |
| 41 for (SurfaceDestroyList::iterator it = surfaces_to_destroy_.begin(); | 44 for (SurfaceDestroyList::iterator it = surfaces_to_destroy_.begin(); |
| 42 it != surfaces_to_destroy_.end(); | 45 it != surfaces_to_destroy_.end(); |
| 43 ++it) { | 46 ++it) { |
| 44 DeregisterSurface((*it)->surface_id()); | 47 DeregisterSurface((*it)->surface_id()); |
| 45 } | 48 } |
| 46 surfaces_to_destroy_.clear(); | 49 surfaces_to_destroy_.clear(); |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 } | 496 } |
| 494 | 497 |
| 495 void SurfaceManager::SurfaceCreated(const SurfaceId& surface_id, | 498 void SurfaceManager::SurfaceCreated(const SurfaceId& surface_id, |
| 496 const gfx::Size& frame_size, | 499 const gfx::Size& frame_size, |
| 497 float device_scale_factor) { | 500 float device_scale_factor) { |
| 498 CHECK(thread_checker_.CalledOnValidThread()); | 501 CHECK(thread_checker_.CalledOnValidThread()); |
| 499 for (auto& observer : observer_list_) | 502 for (auto& observer : observer_list_) |
| 500 observer.OnSurfaceCreated(surface_id, frame_size, device_scale_factor); | 503 observer.OnSurfaceCreated(surface_id, frame_size, device_scale_factor); |
| 501 } | 504 } |
| 502 | 505 |
| 503 base::WeakPtr<SurfaceManager> SurfaceManager::GetWeakPtr() { | |
| 504 return weak_factory_.GetWeakPtr(); | |
| 505 } | |
| 506 | |
| 507 } // namespace cc | 506 } // namespace cc |
| OLD | NEW |