| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/test_delegating_output_surface.h" | 5 #include "cc/test/test_delegating_output_surface.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "cc/output/begin_frame_args.h" | 10 #include "cc/output/begin_frame_args.h" |
| 11 #include "cc/output/copy_output_request.h" |
| 11 #include "cc/output/texture_mailbox_deleter.h" | 12 #include "cc/output/texture_mailbox_deleter.h" |
| 12 #include "cc/test/begin_frame_args_test.h" | 13 #include "cc/test/begin_frame_args_test.h" |
| 13 | 14 |
| 14 static constexpr uint32_t kCompositorClientId = 1; | 15 static constexpr uint32_t kCompositorClientId = 1; |
| 15 | 16 |
| 16 namespace cc { | 17 namespace cc { |
| 17 | 18 |
| 18 TestDelegatingOutputSurface::TestDelegatingOutputSurface( | 19 TestDelegatingOutputSurface::TestDelegatingOutputSurface( |
| 19 scoped_refptr<ContextProvider> compositor_context_provider, | 20 scoped_refptr<ContextProvider> compositor_context_provider, |
| 20 scoped_refptr<ContextProvider> worker_context_provider, | 21 scoped_refptr<ContextProvider> worker_context_provider, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 50 | 51 |
| 51 capabilities_.delegated_rendering = true; | 52 capabilities_.delegated_rendering = true; |
| 52 // Since this OutputSurface and the Display are tightly coupled and in the | 53 // Since this OutputSurface and the Display are tightly coupled and in the |
| 53 // same process/thread, the LayerTreeHostImpl can reclaim resources from | 54 // same process/thread, the LayerTreeHostImpl can reclaim resources from |
| 54 // the Display. | 55 // the Display. |
| 55 capabilities_.can_force_reclaim_resources = true; | 56 capabilities_.can_force_reclaim_resources = true; |
| 56 capabilities_.delegated_sync_points_required = | 57 capabilities_.delegated_sync_points_required = |
| 57 !context_shared_with_compositor; | 58 !context_shared_with_compositor; |
| 58 } | 59 } |
| 59 | 60 |
| 60 TestDelegatingOutputSurface::~TestDelegatingOutputSurface() {} | 61 TestDelegatingOutputSurface::~TestDelegatingOutputSurface() { |
| 62 DCHECK(copy_requests_.empty()); |
| 63 } |
| 64 |
| 65 void TestDelegatingOutputSurface::RequestCopyOfOutput( |
| 66 std::unique_ptr<CopyOutputRequest> request) { |
| 67 copy_requests_.push_back(std::move(request)); |
| 68 } |
| 61 | 69 |
| 62 bool TestDelegatingOutputSurface::BindToClient(OutputSurfaceClient* client) { | 70 bool TestDelegatingOutputSurface::BindToClient(OutputSurfaceClient* client) { |
| 63 if (!OutputSurface::BindToClient(client)) | 71 if (!OutputSurface::BindToClient(client)) |
| 64 return false; | 72 return false; |
| 65 | 73 |
| 66 // We want the Display's output surface to hear about lost context, and since | 74 // We want the Display's output surface to hear about lost context, and since |
| 67 // this shares a context with it (when delegated_sync_points_required is | 75 // this shares a context with it (when delegated_sync_points_required is |
| 68 // false), we should not be listening for lost context callbacks on the | 76 // false), we should not be listening for lost context callbacks on the |
| 69 // context here. | 77 // context here. |
| 70 if (!capabilities_.delegated_sync_points_required && context_provider()) | 78 if (!capabilities_.delegated_sync_points_required && context_provider()) |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 | 116 |
| 109 gfx::Size frame_size = | 117 gfx::Size frame_size = |
| 110 frame.delegated_frame_data->render_pass_list.back()->output_rect.size(); | 118 frame.delegated_frame_data->render_pass_list.back()->output_rect.size(); |
| 111 display_->Resize(frame_size); | 119 display_->Resize(frame_size); |
| 112 | 120 |
| 113 surface_factory_->SubmitCompositorFrame( | 121 surface_factory_->SubmitCompositorFrame( |
| 114 delegated_surface_id_, std::move(frame), | 122 delegated_surface_id_, std::move(frame), |
| 115 base::Bind(&TestDelegatingOutputSurface::DrawCallback, | 123 base::Bind(&TestDelegatingOutputSurface::DrawCallback, |
| 116 weak_ptrs_.GetWeakPtr())); | 124 weak_ptrs_.GetWeakPtr())); |
| 117 | 125 |
| 126 for (std::unique_ptr<CopyOutputRequest>& copy_request : copy_requests_) |
| 127 surface_factory_->RequestCopyOfSurface(delegated_surface_id_, |
| 128 std::move(copy_request)); |
| 129 copy_requests_.clear(); |
| 130 |
| 118 if (!display_->has_scheduler()) | 131 if (!display_->has_scheduler()) |
| 119 display_->DrawAndSwap(); | 132 display_->DrawAndSwap(); |
| 120 } | 133 } |
| 121 | 134 |
| 122 void TestDelegatingOutputSurface::DrawCallback() { | 135 void TestDelegatingOutputSurface::DrawCallback() { |
| 123 client_->DidSwapBuffersComplete(); | 136 client_->DidSwapBuffersComplete(); |
| 124 } | 137 } |
| 125 | 138 |
| 126 void TestDelegatingOutputSurface::ForceReclaimResources() { | 139 void TestDelegatingOutputSurface::ForceReclaimResources() { |
| 127 if (capabilities_.can_force_reclaim_resources && | 140 if (capabilities_.can_force_reclaim_resources && |
| (...skipping 28 matching lines...) Expand all Loading... |
| 156 void TestDelegatingOutputSurface::DisplayOutputSurfaceLost() { | 169 void TestDelegatingOutputSurface::DisplayOutputSurfaceLost() { |
| 157 DidLoseOutputSurface(); | 170 DidLoseOutputSurface(); |
| 158 } | 171 } |
| 159 | 172 |
| 160 void TestDelegatingOutputSurface::DisplaySetMemoryPolicy( | 173 void TestDelegatingOutputSurface::DisplaySetMemoryPolicy( |
| 161 const ManagedMemoryPolicy& policy) { | 174 const ManagedMemoryPolicy& policy) { |
| 162 SetMemoryPolicy(policy); | 175 SetMemoryPolicy(policy); |
| 163 } | 176 } |
| 164 | 177 |
| 165 } // namespace cc | 178 } // namespace cc |
| OLD | NEW |