| 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_factory.h" | 5 #include "cc/surfaces/surface_factory.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| 11 #include "cc/output/compositor_frame.h" | 11 #include "cc/output/compositor_frame.h" |
| 12 #include "cc/output/copy_output_request.h" | 12 #include "cc/output/copy_output_request.h" |
| 13 #include "cc/surfaces/surface.h" | 13 #include "cc/surfaces/surface.h" |
| 14 #include "cc/surfaces/surface_factory_client.h" | 14 #include "cc/surfaces/surface_factory_client.h" |
| 15 #include "cc/surfaces/surface_info.h" | 15 #include "cc/surfaces/surface_info.h" |
| 16 #include "cc/surfaces/surface_manager.h" | 16 #include "cc/surfaces/surface_manager.h" |
| 17 #include "ui/gfx/geometry/size.h" | 17 #include "ui/gfx/geometry/size.h" |
| 18 | 18 |
| 19 namespace cc { | 19 namespace cc { |
| 20 SurfaceFactory::SurfaceFactory(const FrameSinkId& frame_sink_id, | 20 SurfaceFactory::SurfaceFactory( |
| 21 SurfaceManager* manager, | 21 const FrameSinkId& frame_sink_id, |
| 22 SurfaceFactoryClient* client) | 22 SurfaceManager* manager, |
| 23 SurfaceFactoryClient* client, |
| 24 SurfaceResourceHolderClient* resource_holder_client) |
| 23 : frame_sink_id_(frame_sink_id), | 25 : frame_sink_id_(frame_sink_id), |
| 24 manager_(manager), | 26 manager_(manager), |
| 25 client_(client), | 27 client_(client), |
| 26 holder_(client), | 28 holder_(resource_holder_client), |
| 27 needs_sync_points_(true), | 29 needs_sync_points_(true), |
| 28 weak_factory_(this) {} | 30 weak_factory_(this) {} |
| 29 | 31 |
| 30 SurfaceFactory::~SurfaceFactory() { | 32 SurfaceFactory::~SurfaceFactory() { |
| 31 // This is to prevent troubles when a factory that resides in a client is | 33 // This is to prevent troubles when a factory that resides in a client is |
| 32 // being destroyed. In such cases, the factory might attempt to return | 34 // being destroyed. In such cases, the factory might attempt to return |
| 33 // resources to the client while it's in the middle of destruction and this | 35 // resources to the client while it's in the middle of destruction and this |
| 34 // could cause a crash or some unexpected behaviour. | 36 // could cause a crash or some unexpected behaviour. |
| 35 DCHECK(!current_surface_) << "Please call EvictSurface before destruction"; | 37 DCHECK(!current_surface_) << "Please call EvictSurface before destruction"; |
| 36 } | 38 } |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 surface->AddObserver(this); | 148 surface->AddObserver(this); |
| 147 return surface; | 149 return surface; |
| 148 } | 150 } |
| 149 | 151 |
| 150 void SurfaceFactory::Destroy(std::unique_ptr<Surface> surface) { | 152 void SurfaceFactory::Destroy(std::unique_ptr<Surface> surface) { |
| 151 surface->RemoveObserver(this); | 153 surface->RemoveObserver(this); |
| 152 manager_->DestroySurface(std::move(surface)); | 154 manager_->DestroySurface(std::move(surface)); |
| 153 } | 155 } |
| 154 | 156 |
| 155 } // namespace cc | 157 } // namespace cc |
| OLD | NEW |