| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/test/fake_compositor_frame_sink.h" | 5 #include "cc/test/fake_compositor_frame_sink.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/threading/thread_task_runner_handle.h" | 8 #include "base/threading/thread_task_runner_handle.h" |
| 9 #include "cc/output/compositor_frame_sink_client.h" | 9 #include "cc/output/compositor_frame_sink_client.h" |
| 10 #include "cc/resources/returned_resource.h" | 10 #include "cc/resources/returned_resource.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 ReturnResourcesHeldByParent(); | 45 ReturnResourcesHeldByParent(); |
| 46 CompositorFrameSink::DetachFromClient(); | 46 CompositorFrameSink::DetachFromClient(); |
| 47 } | 47 } |
| 48 | 48 |
| 49 void FakeCompositorFrameSink::SubmitCompositorFrame(CompositorFrame frame) { | 49 void FakeCompositorFrameSink::SubmitCompositorFrame(CompositorFrame frame) { |
| 50 ReturnResourcesHeldByParent(); | 50 ReturnResourcesHeldByParent(); |
| 51 | 51 |
| 52 last_sent_frame_.reset(new CompositorFrame(std::move(frame))); | 52 last_sent_frame_.reset(new CompositorFrame(std::move(frame))); |
| 53 ++num_sent_frames_; | 53 ++num_sent_frames_; |
| 54 | 54 |
| 55 if (!last_sent_frame_->render_pass_list.empty()) { | 55 last_swap_rect_ = last_sent_frame_->render_pass_list.back()->damage_rect; |
| 56 last_swap_rect_ = last_sent_frame_->render_pass_list.back()->damage_rect; | |
| 57 last_swap_rect_valid_ = true; | |
| 58 } else { | |
| 59 last_swap_rect_ = gfx::Rect(); | |
| 60 last_swap_rect_valid_ = false; | |
| 61 } | |
| 62 | 56 |
| 63 resources_held_by_parent_.insert(resources_held_by_parent_.end(), | 57 resources_held_by_parent_.insert(resources_held_by_parent_.end(), |
| 64 last_sent_frame_->resource_list.begin(), | 58 last_sent_frame_->resource_list.begin(), |
| 65 last_sent_frame_->resource_list.end()); | 59 last_sent_frame_->resource_list.end()); |
| 66 | 60 |
| 67 base::ThreadTaskRunnerHandle::Get()->PostTask( | 61 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 68 FROM_HERE, | 62 FROM_HERE, |
| 69 base::BindOnce(&FakeCompositorFrameSink::DidReceiveCompositorFrameAck, | 63 base::BindOnce(&FakeCompositorFrameSink::DidReceiveCompositorFrameAck, |
| 70 weak_ptr_factory_.GetWeakPtr())); | 64 weak_ptr_factory_.GetWeakPtr())); |
| 71 } | 65 } |
| 72 | 66 |
| 73 void FakeCompositorFrameSink::DidReceiveCompositorFrameAck() { | 67 void FakeCompositorFrameSink::DidReceiveCompositorFrameAck() { |
| 74 client_->DidReceiveCompositorFrameAck(); | 68 client_->DidReceiveCompositorFrameAck(); |
| 75 } | 69 } |
| 76 | 70 |
| 77 void FakeCompositorFrameSink::ReturnResourcesHeldByParent() { | 71 void FakeCompositorFrameSink::ReturnResourcesHeldByParent() { |
| 78 if (last_sent_frame_) { | 72 if (last_sent_frame_) { |
| 79 // Return the last frame's resources immediately. | 73 // Return the last frame's resources immediately. |
| 80 ReturnedResourceArray resources; | 74 ReturnedResourceArray resources; |
| 81 for (const auto& resource : resources_held_by_parent_) | 75 for (const auto& resource : resources_held_by_parent_) |
| 82 resources.push_back(resource.ToReturnedResource()); | 76 resources.push_back(resource.ToReturnedResource()); |
| 83 resources_held_by_parent_.clear(); | 77 resources_held_by_parent_.clear(); |
| 84 client_->ReclaimResources(resources); | 78 client_->ReclaimResources(resources); |
| 85 } | 79 } |
| 86 } | 80 } |
| 87 | 81 |
| 88 } // namespace cc | 82 } // namespace cc |
| OLD | NEW |