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" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 TRACE_EVENT0("cc", "SurfaceFactory::SubmitCompositorFrame"); | 51 TRACE_EVENT0("cc", "SurfaceFactory::SubmitCompositorFrame"); |
52 DCHECK(local_surface_id.is_valid()); | 52 DCHECK(local_surface_id.is_valid()); |
53 | 53 |
54 for (ui::LatencyInfo& latency : frame.metadata.latency_info) { | 54 for (ui::LatencyInfo& latency : frame.metadata.latency_info) { |
55 if (latency.latency_components().size() > 0) { | 55 if (latency.latency_components().size() > 0) { |
56 latency.AddLatencyNumber(ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, | 56 latency.AddLatencyNumber(ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, |
57 0, 0); | 57 0, 0); |
58 } | 58 } |
59 } | 59 } |
60 | 60 |
| 61 SurfaceId surface_id(frame_sink_id_, local_surface_id); |
| 62 gfx::Size frame_size; |
| 63 if (!frame.render_pass_list.empty()) |
| 64 frame_size = frame.render_pass_list.back()->output_rect.size(); |
| 65 float device_scale_factor = frame.metadata.device_scale_factor; |
| 66 SurfaceInfo surface_info(surface_id, device_scale_factor, frame_size); |
| 67 |
61 std::unique_ptr<Surface> surface; | 68 std::unique_ptr<Surface> surface; |
62 bool create_new_surface = | 69 bool create_new_surface = |
63 (!current_surface_ || | 70 (!current_surface_ || |
64 local_surface_id != current_surface_->surface_id().local_surface_id()); | 71 local_surface_id != current_surface_->surface_id().local_surface_id()); |
65 if (!create_new_surface) { | 72 if (!create_new_surface) { |
66 surface = std::move(current_surface_); | 73 surface = std::move(current_surface_); |
67 } else { | 74 } else { |
68 surface = Create(local_surface_id); | 75 surface = Create(surface_info); |
69 } | 76 } |
70 surface->QueueFrame(std::move(frame), callback, will_draw_callback); | 77 surface->QueueFrame(std::move(frame), callback, will_draw_callback); |
71 | 78 |
72 if (current_surface_ && create_new_surface) { | 79 if (current_surface_ && create_new_surface) { |
73 surface->SetPreviousFrameSurface(current_surface_.get()); | 80 surface->SetPreviousFrameSurface(current_surface_.get()); |
74 Destroy(std::move(current_surface_)); | 81 Destroy(std::move(current_surface_)); |
75 } | 82 } |
76 current_surface_ = std::move(surface); | 83 current_surface_ = std::move(surface); |
77 } | 84 } |
78 | 85 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 } | 134 } |
128 | 135 |
129 void SurfaceFactory::OnSurfaceDependenciesChanged( | 136 void SurfaceFactory::OnSurfaceDependenciesChanged( |
130 Surface* surface, | 137 Surface* surface, |
131 const SurfaceDependencies& added_dependencies, | 138 const SurfaceDependencies& added_dependencies, |
132 const SurfaceDependencies& removed_dependencies) {} | 139 const SurfaceDependencies& removed_dependencies) {} |
133 | 140 |
134 void SurfaceFactory::OnSurfaceDiscarded(Surface* surface) {} | 141 void SurfaceFactory::OnSurfaceDiscarded(Surface* surface) {} |
135 | 142 |
136 std::unique_ptr<Surface> SurfaceFactory::Create( | 143 std::unique_ptr<Surface> SurfaceFactory::Create( |
137 const LocalSurfaceId& local_surface_id) { | 144 const SurfaceInfo& surface_info) { |
138 seen_first_frame_activation_ = false; | 145 seen_first_frame_activation_ = false; |
139 std::unique_ptr<Surface> surface = | 146 std::unique_ptr<Surface> surface = |
140 manager_->CreateSurface(weak_factory_.GetWeakPtr(), local_surface_id); | 147 manager_->CreateSurface(weak_factory_.GetWeakPtr(), surface_info); |
141 surface->AddObserver(this); | 148 surface->AddObserver(this); |
142 return surface; | 149 return surface; |
143 } | 150 } |
144 | 151 |
145 void SurfaceFactory::Destroy(std::unique_ptr<Surface> surface) { | 152 void SurfaceFactory::Destroy(std::unique_ptr<Surface> surface) { |
146 surface->RemoveObserver(this); | 153 surface->RemoveObserver(this); |
147 manager_->DestroySurface(std::move(surface)); | 154 manager_->DestroySurface(std::move(surface)); |
148 } | 155 } |
149 | 156 |
150 } // namespace cc | 157 } // namespace cc |
OLD | NEW |