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_ = base::MakeUnique<CompositorFrame>(std::move(frame)); |
vmpstr
2016/07/19 23:27:01
nit: maybe just
last_sent_frame_.reset(new Compos
danakj
2016/07/20 01:03:25
Sure.
| |
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 } else if (!context_provider()) { | |
56 // Unknown for software frames. | |
57 last_swap_rect_ = gfx::Rect(); | |
enne (OOO)
2016/07/19 23:00:50
This is really empty and not the full rect?
danakj
2016/07/20 01:03:25
Software can partial swap, but it does it thru the
| |
58 } else { | |
59 last_swap_rect_ = last_sent_frame_->gl_frame_data->sub_buffer_rect; | |
vmpstr
2016/07/19 23:27:02
tiny nit: can you swap else and the last else if?
danakj
2016/07/20 01:03:25
Done.
| |
60 } | |
61 | |
62 if (last_sent_frame_->delegated_frame_data || !context_provider()) { | |
54 if (last_sent_frame_->delegated_frame_data) { | 63 if (last_sent_frame_->delegated_frame_data) { |
vmpstr
2016/07/19 23:27:02
isn't 62-63 kind of corresponds to the if on line
danakj
2016/07/20 01:03:25
Yes, delegated frames can be hardware or software.
| |
55 resources_held_by_parent_.insert( | 64 auto* frame_data = last_sent_frame_->delegated_frame_data.get(); |
56 resources_held_by_parent_.end(), | 65 resources_held_by_parent_.insert(resources_held_by_parent_.end(), |
57 last_sent_frame_->delegated_frame_data->resource_list.begin(), | 66 frame_data->resource_list.begin(), |
58 last_sent_frame_->delegated_frame_data->resource_list.end()); | 67 frame_data->resource_list.end()); |
59 } | 68 } |
69 } | |
60 | 70 |
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(); | 71 PostSwapBuffersComplete(); |
68 } | 72 } |
69 | 73 |
70 void FakeOutputSurface::BindFramebuffer() { | 74 void FakeOutputSurface::BindFramebuffer() { |
71 if (framebuffer_) { | 75 if (framebuffer_) { |
72 context_provider_->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, | 76 context_provider_->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, |
73 framebuffer_); | 77 framebuffer_); |
74 } else { | 78 } else { |
75 OutputSurface::BindFramebuffer(); | 79 OutputSurface::BindFramebuffer(); |
76 } | 80 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
132 // Return the last frame's resources immediately. | 136 // Return the last frame's resources immediately. |
133 ReturnedResourceArray resources; | 137 ReturnedResourceArray resources; |
134 for (const auto& resource : resources_held_by_parent_) | 138 for (const auto& resource : resources_held_by_parent_) |
135 resources.push_back(resource.ToReturnedResource()); | 139 resources.push_back(resource.ToReturnedResource()); |
136 resources_held_by_parent_.clear(); | 140 resources_held_by_parent_.clear(); |
137 client_->ReclaimResources(resources); | 141 client_->ReclaimResources(resources); |
138 } | 142 } |
139 } | 143 } |
140 | 144 |
141 } // namespace cc | 145 } // namespace cc |
OLD | NEW |