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_output_surface.h" | 5 #include "cc/test/fake_output_surface.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "cc/output/output_surface_client.h" | 9 #include "cc/output/output_surface_client.h" |
10 #include "cc/resources/returned_resource.h" | 10 #include "cc/resources/returned_resource.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 std::move(worker_context_provider), | 39 std::move(worker_context_provider), |
40 std::move(software_device)) { | 40 std::move(software_device)) { |
41 capabilities_.delegated_rendering = delegated_rendering; | 41 capabilities_.delegated_rendering = delegated_rendering; |
42 } | 42 } |
43 | 43 |
44 FakeOutputSurface::~FakeOutputSurface() = default; | 44 FakeOutputSurface::~FakeOutputSurface() = default; |
45 | 45 |
46 void FakeOutputSurface::SwapBuffers(CompositorFrame frame) { | 46 void FakeOutputSurface::SwapBuffers(CompositorFrame frame) { |
47 ReturnResourcesHeldByParent(); | 47 ReturnResourcesHeldByParent(); |
48 | 48 |
49 std::unique_ptr<CompositorFrame> frame_copy(new CompositorFrame); | 49 last_sent_frame_.reset(new CompositorFrame(std::move(frame))); |
50 *frame_copy = std::move(frame); | 50 ++num_sent_frames_; |
51 if (frame_copy->delegated_frame_data || !context_provider()) { | |
52 last_sent_frame_ = std::move(frame_copy); | |
53 | 51 |
| 52 if (last_sent_frame_->delegated_frame_data) { |
| 53 auto* frame_data = last_sent_frame_->delegated_frame_data.get(); |
| 54 last_swap_rect_ = frame_data->render_pass_list.back()->damage_rect; |
| 55 last_swap_rect_valid_ = true; |
| 56 } else if (context_provider()) { |
| 57 last_swap_rect_ = last_sent_frame_->gl_frame_data->sub_buffer_rect; |
| 58 last_swap_rect_valid_ = true; |
| 59 } else { |
| 60 // Unknown for direct software frames. |
| 61 last_swap_rect_ = gfx::Rect(); |
| 62 last_swap_rect_valid_ = false; |
| 63 } |
| 64 |
| 65 if (last_sent_frame_->delegated_frame_data || !context_provider()) { |
54 if (last_sent_frame_->delegated_frame_data) { | 66 if (last_sent_frame_->delegated_frame_data) { |
55 resources_held_by_parent_.insert( | 67 auto* frame_data = last_sent_frame_->delegated_frame_data.get(); |
56 resources_held_by_parent_.end(), | 68 resources_held_by_parent_.insert(resources_held_by_parent_.end(), |
57 last_sent_frame_->delegated_frame_data->resource_list.begin(), | 69 frame_data->resource_list.begin(), |
58 last_sent_frame_->delegated_frame_data->resource_list.end()); | 70 frame_data->resource_list.end()); |
59 } | 71 } |
| 72 } |
60 | 73 |
61 ++num_sent_frames_; | |
62 } else { | |
63 last_swap_rect_ = frame_copy->gl_frame_data->sub_buffer_rect; | |
64 last_sent_frame_ = std::move(frame_copy); | |
65 ++num_sent_frames_; | |
66 } | |
67 PostSwapBuffersComplete(); | 74 PostSwapBuffersComplete(); |
68 } | 75 } |
69 | 76 |
70 void FakeOutputSurface::BindFramebuffer() { | 77 void FakeOutputSurface::BindFramebuffer() { |
71 if (framebuffer_) { | 78 if (framebuffer_) { |
72 context_provider_->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, | 79 context_provider_->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, |
73 framebuffer_); | 80 framebuffer_); |
74 } else { | 81 } else { |
75 OutputSurface::BindFramebuffer(); | 82 OutputSurface::BindFramebuffer(); |
76 } | 83 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 // Return the last frame's resources immediately. | 139 // Return the last frame's resources immediately. |
133 ReturnedResourceArray resources; | 140 ReturnedResourceArray resources; |
134 for (const auto& resource : resources_held_by_parent_) | 141 for (const auto& resource : resources_held_by_parent_) |
135 resources.push_back(resource.ToReturnedResource()); | 142 resources.push_back(resource.ToReturnedResource()); |
136 resources_held_by_parent_.clear(); | 143 resources_held_by_parent_.clear(); |
137 client_->ReclaimResources(resources); | 144 client_->ReclaimResources(resources); |
138 } | 145 } |
139 } | 146 } |
140 | 147 |
141 } // namespace cc | 148 } // namespace cc |
OLD | NEW |