Chromium Code Reviews| Index: cc/surfaces/surface.cc |
| diff --git a/cc/surfaces/surface.cc b/cc/surfaces/surface.cc |
| index ed99a1b018b0d061746f520227ad76db349a534e..f0a6da0407b9ef6776523622cc0da9dad0235182 100644 |
| --- a/cc/surfaces/surface.cc |
| +++ b/cc/surfaces/surface.cc |
| @@ -31,8 +31,8 @@ Surface::Surface(SurfaceId id, SurfaceFactory* factory) |
| Surface::~Surface() { |
| ClearCopyRequests(); |
| - if (current_frame_ && factory_) { |
| - UnrefFrameResources(current_frame_->delegated_frame_data.get()); |
| + if (current_frame_.delegated_frame_data && factory_) { |
| + UnrefFrameResources(current_frame_.delegated_frame_data.get()); |
| } |
| if (!draw_callback_.is_null()) |
| draw_callback_.Run(SurfaceDrawStatus::DRAW_SKIPPED); |
| @@ -51,39 +51,37 @@ void Surface::SetGpuMemoryBufferClientId(int gpu_memory_buffer_client_id) { |
| gpu_memory_buffer_client_id_ = gpu_memory_buffer_client_id; |
| } |
| -void Surface::QueueFrame(std::unique_ptr<CompositorFrame> frame, |
| - const DrawCallback& callback) { |
| +void Surface::QueueFrame(CompositorFrame frame, const DrawCallback& callback) { |
| DCHECK(factory_); |
| ClearCopyRequests(); |
| - if (frame) { |
| - TakeLatencyInfo(&frame->metadata.latency_info); |
| + if (frame.delegated_frame_data) { |
| + TakeLatencyInfo(&frame.metadata.latency_info); |
| } |
| - std::unique_ptr<CompositorFrame> previous_frame = std::move(current_frame_); |
| + CompositorFrame previous_frame = std::move(current_frame_); |
| current_frame_ = std::move(frame); |
| - if (current_frame_) { |
| + if (current_frame_.delegated_frame_data) { |
| factory_->ReceiveFromChild( |
| - current_frame_->delegated_frame_data->resource_list); |
| + current_frame_.delegated_frame_data->resource_list); |
| } |
| // Empty frames shouldn't be drawn and shouldn't contribute damage, so don't |
| // increment frame index for them. |
| - if (current_frame_ && |
| - !current_frame_->delegated_frame_data->render_pass_list.empty()) |
| + if (current_frame_.delegated_frame_data && |
| + !current_frame_.delegated_frame_data->render_pass_list.empty()) { |
| ++frame_index_; |
| + } |
| previous_frame_surface_id_ = surface_id(); |
| std::vector<SurfaceId> new_referenced_surfaces; |
| - if (current_frame_) { |
| - new_referenced_surfaces = current_frame_->metadata.referenced_surfaces; |
| - } |
| + new_referenced_surfaces = current_frame_.metadata.referenced_surfaces; |
| + |
| + if (previous_frame.delegated_frame_data) |
| + UnrefFrameResources(previous_frame.delegated_frame_data.get()); |
| - if (previous_frame) { |
| - UnrefFrameResources(previous_frame->delegated_frame_data.get()); |
| - } |
| if (!draw_callback_.is_null()) |
| draw_callback_.Run(SurfaceDrawStatus::DRAW_SKIPPED); |
| draw_callback_ = callback; |
| @@ -92,8 +90,8 @@ void Surface::QueueFrame(std::unique_ptr<CompositorFrame> frame, |
| (referenced_surfaces_ != new_referenced_surfaces); |
| referenced_surfaces_ = new_referenced_surfaces; |
| std::vector<uint32_t> satisfies_sequences; |
| - if (current_frame_) |
| - current_frame_->metadata.satisfies_sequences.swap(satisfies_sequences); |
| + current_frame_.metadata.satisfies_sequences.swap(satisfies_sequences); |
|
danakj
2016/06/27 19:53:00
you can use move instead for this, and merge it wi
Fady Samuel
2016/06/28 17:19:10
Done.
|
| + |
| if (referenced_surfaces_changed || !satisfies_sequences.empty()) { |
| // Notify the manager that sequences were satisfied either if some new |
| // sequences were satisfied, or if the set of referenced surfaces changed |
| @@ -105,10 +103,10 @@ void Surface::QueueFrame(std::unique_ptr<CompositorFrame> frame, |
| void Surface::RequestCopyOfOutput( |
| std::unique_ptr<CopyOutputRequest> copy_request) { |
| - if (current_frame_ && |
| - !current_frame_->delegated_frame_data->render_pass_list.empty()) { |
| + if (current_frame_.delegated_frame_data && |
| + !current_frame_.delegated_frame_data->render_pass_list.empty()) { |
| std::vector<std::unique_ptr<CopyOutputRequest>>& copy_requests = |
| - current_frame_->delegated_frame_data->render_pass_list.back() |
| + current_frame_.delegated_frame_data->render_pass_list.back() |
| ->copy_requests; |
| if (void* source = copy_request->source()) { |
| @@ -131,9 +129,9 @@ void Surface::TakeCopyOutputRequests( |
| std::multimap<RenderPassId, std::unique_ptr<CopyOutputRequest>>* |
| copy_requests) { |
| DCHECK(copy_requests->empty()); |
| - if (current_frame_) { |
| + if (current_frame_.delegated_frame_data) { |
| for (const auto& render_pass : |
| - current_frame_->delegated_frame_data->render_pass_list) { |
| + current_frame_.delegated_frame_data->render_pass_list) { |
| for (auto& request : render_pass->copy_requests) { |
| copy_requests->insert( |
| std::make_pair(render_pass->id, std::move(request))); |
| @@ -144,20 +142,20 @@ void Surface::TakeCopyOutputRequests( |
| } |
| const CompositorFrame* Surface::GetEligibleFrame() { |
| - return current_frame_.get(); |
| + return ¤t_frame_; |
|
danakj
2016/06/27 19:53:00
There are callers that check if this is null. What
Fady Samuel
2016/06/28 17:19:10
I've let the compiler help me with the analysis. :
danakj
2016/06/28 19:01:09
Ya ok this should work for now. Eventually we're n
Fady Samuel
2016/06/28 19:24:19
The primary goal of this CL is to make Surface hol
|
| } |
| void Surface::TakeLatencyInfo(std::vector<ui::LatencyInfo>* latency_info) { |
| - if (!current_frame_) |
| + if (!current_frame_.delegated_frame_data) |
| return; |
| if (latency_info->empty()) { |
| - current_frame_->metadata.latency_info.swap(*latency_info); |
| + current_frame_.metadata.latency_info.swap(*latency_info); |
| return; |
| } |
| - std::copy(current_frame_->metadata.latency_info.begin(), |
| - current_frame_->metadata.latency_info.end(), |
| + std::copy(current_frame_.metadata.latency_info.begin(), |
| + current_frame_.metadata.latency_info.end(), |
| std::back_inserter(*latency_info)); |
| - current_frame_->metadata.latency_info.clear(); |
| + current_frame_.metadata.latency_info.clear(); |
| } |
| void Surface::RunDrawCallbacks(SurfaceDrawStatus drawn) { |
| @@ -195,9 +193,9 @@ void Surface::UnrefFrameResources(DelegatedFrameData* frame_data) { |
| } |
| void Surface::ClearCopyRequests() { |
| - if (current_frame_) { |
| + if (current_frame_.delegated_frame_data) { |
| for (const auto& render_pass : |
| - current_frame_->delegated_frame_data->render_pass_list) { |
| + current_frame_.delegated_frame_data->render_pass_list) { |
| for (const auto& copy_request : render_pass->copy_requests) |
| copy_request->SendEmptyResult(); |
| } |