Chromium Code Reviews| 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.h" | 5 #include "cc/surfaces/surface.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 static const int kFrameIndexStart = 2; | 24 static const int kFrameIndexStart = 2; |
| 25 | 25 |
| 26 Surface::Surface(const SurfaceId& id, base::WeakPtr<SurfaceFactory> factory) | 26 Surface::Surface(const SurfaceId& id, base::WeakPtr<SurfaceFactory> factory) |
| 27 : surface_id_(id), | 27 : surface_id_(id), |
| 28 previous_frame_surface_id_(id), | 28 previous_frame_surface_id_(id), |
| 29 factory_(factory), | 29 factory_(factory), |
| 30 frame_index_(kFrameIndexStart), | 30 frame_index_(kFrameIndexStart), |
| 31 destroyed_(false) {} | 31 destroyed_(false) {} |
| 32 | 32 |
| 33 Surface::~Surface() { | 33 Surface::~Surface() { |
| 34 ClearCopyRequests(); | 34 ClearCopyRequests(); |
|
danakj
2017/02/23 22:52:28
Can you change this things name maybe so it doesn'
| |
| 35 for (auto& request : copy_requests_) | |
| 36 request->SendEmptyResult(); | |
| 35 if (factory_) { | 37 if (factory_) { |
| 36 if (pending_frame_) | 38 if (pending_frame_) |
| 37 UnrefFrameResources(*pending_frame_); | 39 UnrefFrameResources(*pending_frame_); |
| 38 if (active_frame_) | 40 if (active_frame_) |
| 39 UnrefFrameResources(*active_frame_); | 41 UnrefFrameResources(*active_frame_); |
| 40 } | 42 } |
| 41 if (!draw_callback_.is_null()) | 43 if (!draw_callback_.is_null()) |
| 42 draw_callback_.Run(); | 44 draw_callback_.Run(); |
| 43 | 45 |
| 44 for (auto& observer : observers_) | 46 for (auto& observer : observers_) |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 active_frame_.reset(); | 96 active_frame_.reset(); |
| 95 } | 97 } |
| 96 | 98 |
| 97 void Surface::RequestCopyOfOutput( | 99 void Surface::RequestCopyOfOutput( |
| 98 std::unique_ptr<CopyOutputRequest> copy_request) { | 100 std::unique_ptr<CopyOutputRequest> copy_request) { |
| 99 if (!active_frame_ || active_frame_->render_pass_list.empty()) { | 101 if (!active_frame_ || active_frame_->render_pass_list.empty()) { |
| 100 copy_request->SendEmptyResult(); | 102 copy_request->SendEmptyResult(); |
| 101 return; | 103 return; |
| 102 } | 104 } |
| 103 | 105 |
| 104 std::vector<std::unique_ptr<CopyOutputRequest>>& copy_requests = | |
| 105 active_frame_->render_pass_list.back()->copy_requests; | |
| 106 | |
| 107 if (copy_request->has_source()) { | 106 if (copy_request->has_source()) { |
| 108 const base::UnguessableToken& source = copy_request->source(); | 107 const base::UnguessableToken& source = copy_request->source(); |
| 109 // Remove existing CopyOutputRequests made on the Surface by the same | 108 // Remove existing CopyOutputRequests made on the Surface by the same |
| 110 // source. | 109 // source. |
| 111 auto to_remove = | 110 auto to_remove = |
| 112 std::remove_if(copy_requests.begin(), copy_requests.end(), | 111 std::remove_if(copy_requests_.begin(), copy_requests_.end(), |
| 113 [&source](const std::unique_ptr<CopyOutputRequest>& x) { | 112 [&source](const std::unique_ptr<CopyOutputRequest>& x) { |
| 114 return x->has_source() && x->source() == source; | 113 return x->has_source() && x->source() == source; |
| 115 }); | 114 }); |
| 116 copy_requests.erase(to_remove, copy_requests.end()); | 115 copy_requests_.erase(to_remove, copy_requests_.end()); |
| 117 } | 116 } |
| 118 copy_requests.push_back(std::move(copy_request)); | 117 copy_requests_.push_back(std::move(copy_request)); |
| 119 } | 118 } |
| 120 | 119 |
| 121 void Surface::NotifySurfaceIdAvailable(const SurfaceId& surface_id) { | 120 void Surface::NotifySurfaceIdAvailable(const SurfaceId& surface_id) { |
| 122 auto it = blocking_surfaces_.find(surface_id); | 121 auto it = blocking_surfaces_.find(surface_id); |
| 123 // This surface may no longer have blockers if the deadline has passed. | 122 // This surface may no longer have blockers if the deadline has passed. |
| 124 if (it == blocking_surfaces_.end()) | 123 if (it == blocking_surfaces_.end()) |
| 125 return; | 124 return; |
| 126 | 125 |
| 127 blocking_surfaces_.erase(it); | 126 blocking_surfaces_.erase(it); |
| 128 | 127 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 if (!active_frame_) | 244 if (!active_frame_) |
| 246 return; | 245 return; |
| 247 | 246 |
| 248 for (const auto& render_pass : active_frame_->render_pass_list) { | 247 for (const auto& render_pass : active_frame_->render_pass_list) { |
| 249 for (auto& request : render_pass->copy_requests) { | 248 for (auto& request : render_pass->copy_requests) { |
| 250 copy_requests->insert( | 249 copy_requests->insert( |
| 251 std::make_pair(render_pass->id, std::move(request))); | 250 std::make_pair(render_pass->id, std::move(request))); |
| 252 } | 251 } |
| 253 render_pass->copy_requests.clear(); | 252 render_pass->copy_requests.clear(); |
| 254 } | 253 } |
| 254 | |
| 255 if (active_frame_->render_pass_list.size() > 0) { | |
| 256 int root_pass_id = active_frame_->render_pass_list.back()->id; | |
| 257 for (auto& request : copy_requests_) { | |
| 258 copy_requests->insert(std::make_pair(root_pass_id, std::move(request))); | |
| 259 } | |
| 260 copy_requests_.clear(); | |
| 261 } else { | |
| 262 for (auto& request : copy_requests_) | |
| 263 request->SendEmptyResult(); | |
| 264 copy_requests_.clear(); | |
| 265 } | |
| 255 } | 266 } |
| 256 | 267 |
| 257 const CompositorFrame& Surface::GetActiveFrame() const { | 268 const CompositorFrame& Surface::GetActiveFrame() const { |
| 258 DCHECK(active_frame_); | 269 DCHECK(active_frame_); |
| 259 return active_frame_.value(); | 270 return active_frame_.value(); |
| 260 } | 271 } |
| 261 | 272 |
| 262 const CompositorFrame& Surface::GetPendingFrame() { | 273 const CompositorFrame& Surface::GetPendingFrame() { |
| 263 DCHECK(pending_frame_); | 274 DCHECK(pending_frame_); |
| 264 return pending_frame_.value(); | 275 return pending_frame_.value(); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 314 void Surface::ClearCopyRequests() { | 325 void Surface::ClearCopyRequests() { |
| 315 if (active_frame_) { | 326 if (active_frame_) { |
| 316 for (const auto& render_pass : active_frame_->render_pass_list) { | 327 for (const auto& render_pass : active_frame_->render_pass_list) { |
| 317 for (const auto& copy_request : render_pass->copy_requests) | 328 for (const auto& copy_request : render_pass->copy_requests) |
| 318 copy_request->SendEmptyResult(); | 329 copy_request->SendEmptyResult(); |
| 319 } | 330 } |
| 320 } | 331 } |
| 321 } | 332 } |
| 322 | 333 |
| 323 } // namespace cc | 334 } // namespace cc |
| OLD | NEW |