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 SurfaceAggregatorClient* surface_aggregator_client, |
| 25 SurfaceResourceHolderClient* resource_holder_client) |
23 : frame_sink_id_(frame_sink_id), | 26 : frame_sink_id_(frame_sink_id), |
24 manager_(manager), | 27 manager_(manager), |
25 client_(client), | 28 client_(client), |
26 holder_(client), | 29 surface_aggregator_client_(surface_aggregator_client), |
| 30 holder_(resource_holder_client), |
27 needs_sync_points_(true), | 31 needs_sync_points_(true), |
28 weak_factory_(this) {} | 32 weak_factory_(this) {} |
29 | 33 |
30 SurfaceFactory::~SurfaceFactory() { | 34 SurfaceFactory::~SurfaceFactory() { |
31 // This is to prevent troubles when a factory that resides in a client is | 35 // 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 | 36 // 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 | 37 // resources to the client while it's in the middle of destruction and this |
34 // could cause a crash or some unexpected behaviour. | 38 // could cause a crash or some unexpected behaviour. |
35 DCHECK(!current_surface_) << "Please call EvictSurface before destruction"; | 39 DCHECK(!current_surface_) << "Please call EvictSurface before destruction"; |
36 } | 40 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 manager_->SurfaceModified(current_surface_->surface_id()); | 92 manager_->SurfaceModified(current_surface_->surface_id()); |
89 } | 93 } |
90 | 94 |
91 void SurfaceFactory::ClearSurface() { | 95 void SurfaceFactory::ClearSurface() { |
92 if (!current_surface_) | 96 if (!current_surface_) |
93 return; | 97 return; |
94 current_surface_->EvictFrame(); | 98 current_surface_->EvictFrame(); |
95 manager_->SurfaceModified(current_surface_->surface_id()); | 99 manager_->SurfaceModified(current_surface_->surface_id()); |
96 } | 100 } |
97 | 101 |
98 void SurfaceFactory::WillDrawSurface(const LocalSurfaceId& id, | |
99 const gfx::Rect& damage_rect) { | |
100 client_->WillDrawSurface(id, damage_rect); | |
101 } | |
102 | |
103 void SurfaceFactory::ReceiveFromChild( | 102 void SurfaceFactory::ReceiveFromChild( |
104 const TransferableResourceArray& resources) { | 103 const TransferableResourceArray& resources) { |
105 holder_.ReceiveFromChild(resources); | 104 holder_.ReceiveFromChild(resources); |
106 } | 105 } |
107 | 106 |
108 void SurfaceFactory::RefResources(const TransferableResourceArray& resources) { | 107 void SurfaceFactory::RefResources(const TransferableResourceArray& resources) { |
109 holder_.RefResources(resources); | 108 holder_.RefResources(resources); |
110 } | 109 } |
111 | 110 |
112 void SurfaceFactory::UnrefResources(const ReturnedResourceArray& resources) { | 111 void SurfaceFactory::UnrefResources(const ReturnedResourceArray& resources) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 surface->AddObserver(this); | 149 surface->AddObserver(this); |
151 return surface; | 150 return surface; |
152 } | 151 } |
153 | 152 |
154 void SurfaceFactory::Destroy(std::unique_ptr<Surface> surface) { | 153 void SurfaceFactory::Destroy(std::unique_ptr<Surface> surface) { |
155 surface->RemoveObserver(this); | 154 surface->RemoveObserver(this); |
156 manager_->DestroySurface(std::move(surface)); | 155 manager_->DestroySurface(std::move(surface)); |
157 } | 156 } |
158 | 157 |
159 } // namespace cc | 158 } // namespace cc |
OLD | NEW |