| 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 "cc/output/compositor_frame.h" | 7 #include "cc/output/compositor_frame.h" |
| 8 #include "cc/output/copy_output_request.h" | 8 #include "cc/output/copy_output_request.h" |
| 9 #include "cc/surfaces/surface_factory.h" | 9 #include "cc/surfaces/surface_factory.h" |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 ReturnedResourceArray current_resources; | 26 ReturnedResourceArray current_resources; |
| 27 TransferableResource::ReturnResources( | 27 TransferableResource::ReturnResources( |
| 28 current_frame_->delegated_frame_data->resource_list, | 28 current_frame_->delegated_frame_data->resource_list, |
| 29 ¤t_resources); | 29 ¤t_resources); |
| 30 factory_->UnrefResources(current_resources); | 30 factory_->UnrefResources(current_resources); |
| 31 } | 31 } |
| 32 } | 32 } |
| 33 | 33 |
| 34 void Surface::QueueFrame(scoped_ptr<CompositorFrame> frame, | 34 void Surface::QueueFrame(scoped_ptr<CompositorFrame> frame, |
| 35 const base::Closure& callback) { | 35 const base::Closure& callback) { |
| 36 TakeLatencyInfo(&frame->metadata.latency_info); | |
| 37 scoped_ptr<CompositorFrame> previous_frame = current_frame_.Pass(); | 36 scoped_ptr<CompositorFrame> previous_frame = current_frame_.Pass(); |
| 38 current_frame_ = frame.Pass(); | 37 current_frame_ = frame.Pass(); |
| 39 factory_->ReceiveFromChild( | 38 factory_->ReceiveFromChild( |
| 40 current_frame_->delegated_frame_data->resource_list); | 39 current_frame_->delegated_frame_data->resource_list); |
| 41 ++frame_index_; | 40 ++frame_index_; |
| 42 | 41 |
| 43 if (previous_frame) { | 42 if (previous_frame) { |
| 44 ReturnedResourceArray previous_resources; | 43 ReturnedResourceArray previous_resources; |
| 45 TransferableResource::ReturnResources( | 44 TransferableResource::ReturnResources( |
| 46 previous_frame->delegated_frame_data->resource_list, | 45 previous_frame->delegated_frame_data->resource_list, |
| 47 &previous_resources); | 46 &previous_resources); |
| 48 factory_->UnrefResources(previous_resources); | 47 factory_->UnrefResources(previous_resources); |
| 49 } | 48 } |
| 50 if (!draw_callback_.is_null()) | 49 if (!draw_callback_.is_null()) |
| 51 draw_callback_.Run(); | 50 draw_callback_.Run(); |
| 52 draw_callback_ = callback; | 51 draw_callback_ = callback; |
| 53 } | 52 } |
| 54 | 53 |
| 55 void Surface::RequestCopyOfOutput(scoped_ptr<CopyOutputRequest> copy_request) { | 54 void Surface::RequestCopyOfOutput(scoped_ptr<CopyOutputRequest> copy_request) { |
| 56 // TODO(jbauman): Make this work. | 55 // TODO(jbauman): Make this work. |
| 57 copy_request->SendEmptyResult(); | 56 copy_request->SendEmptyResult(); |
| 58 } | 57 } |
| 59 | 58 |
| 60 const CompositorFrame* Surface::GetEligibleFrame() { | 59 const CompositorFrame* Surface::GetEligibleFrame() { |
| 61 return current_frame_.get(); | 60 return current_frame_.get(); |
| 62 } | 61 } |
| 63 | 62 |
| 64 void Surface::TakeLatencyInfo(std::vector<ui::LatencyInfo>* latency_info) { | |
| 65 if (!current_frame_) | |
| 66 return; | |
| 67 if (latency_info->empty()) { | |
| 68 current_frame_->metadata.latency_info.swap(*latency_info); | |
| 69 return; | |
| 70 } | |
| 71 std::copy(current_frame_->metadata.latency_info.begin(), | |
| 72 current_frame_->metadata.latency_info.end(), | |
| 73 std::back_inserter(*latency_info)); | |
| 74 current_frame_->metadata.latency_info.clear(); | |
| 75 } | |
| 76 | |
| 77 void Surface::RunDrawCallbacks() { | 63 void Surface::RunDrawCallbacks() { |
| 78 if (!draw_callback_.is_null()) { | 64 if (!draw_callback_.is_null()) { |
| 79 base::Closure callback = draw_callback_; | 65 base::Closure callback = draw_callback_; |
| 80 draw_callback_ = base::Closure(); | 66 draw_callback_ = base::Closure(); |
| 81 callback.Run(); | 67 callback.Run(); |
| 82 } | 68 } |
| 83 } | 69 } |
| 84 | 70 |
| 85 } // namespace cc | 71 } // namespace cc |
| OLD | NEW |