| 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" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 std::move(display_output_surface), std::move(scheduler), | 48 std::move(display_output_surface), std::move(scheduler), |
| 49 base::MakeUnique<TextureMailboxDeleter>(task_runner))); | 49 base::MakeUnique<TextureMailboxDeleter>(task_runner))); |
| 50 | 50 |
| 51 capabilities_.delegated_rendering = true; | 51 capabilities_.delegated_rendering = true; |
| 52 // Since this OutputSurface and the Display are tightly coupled and in the | 52 // Since this OutputSurface and the Display are tightly coupled and in the |
| 53 // same process/thread, the LayerTreeHostImpl can reclaim resources from | 53 // same process/thread, the LayerTreeHostImpl can reclaim resources from |
| 54 // the Display. | 54 // the Display. |
| 55 capabilities_.can_force_reclaim_resources = true; | 55 capabilities_.can_force_reclaim_resources = true; |
| 56 capabilities_.delegated_sync_points_required = | 56 capabilities_.delegated_sync_points_required = |
| 57 !context_shared_with_compositor; | 57 !context_shared_with_compositor; |
| 58 | |
| 59 surface_id_allocator_->RegisterSurfaceClientId(surface_manager_.get()); | |
| 60 } | 58 } |
| 61 | 59 |
| 62 TestDelegatingOutputSurface::~TestDelegatingOutputSurface() {} | 60 TestDelegatingOutputSurface::~TestDelegatingOutputSurface() {} |
| 63 | 61 |
| 64 bool TestDelegatingOutputSurface::BindToClient(OutputSurfaceClient* client) { | 62 bool TestDelegatingOutputSurface::BindToClient(OutputSurfaceClient* client) { |
| 65 if (!OutputSurface::BindToClient(client)) | 63 if (!OutputSurface::BindToClient(client)) |
| 66 return false; | 64 return false; |
| 67 | 65 |
| 68 // We want the Display's output surface to hear about lost context, and since | 66 // We want the Display's output surface to hear about lost context, and since |
| 69 // this shares a context with it (when delegated_sync_points_required is | 67 // this shares a context with it (when delegated_sync_points_required is |
| 70 // false), we should not be listening for lost context callbacks on the | 68 // false), we should not be listening for lost context callbacks on the |
| 71 // context here. | 69 // context here. |
| 72 if (!capabilities_.delegated_sync_points_required && context_provider()) | 70 if (!capabilities_.delegated_sync_points_required && context_provider()) |
| 73 context_provider()->SetLostContextCallback(base::Closure()); | 71 context_provider()->SetLostContextCallback(base::Closure()); |
| 74 | 72 |
| 73 surface_manager_->RegisterSurfaceClientId(surface_id_allocator_->client_id()); |
| 75 surface_manager_->RegisterSurfaceFactoryClient( | 74 surface_manager_->RegisterSurfaceFactoryClient( |
| 76 surface_id_allocator_->client_id(), this); | 75 surface_id_allocator_->client_id(), this); |
| 77 display_->Initialize(this, surface_manager_.get(), | 76 display_->Initialize(this, surface_manager_.get(), |
| 78 surface_id_allocator_->client_id()); | 77 surface_id_allocator_->client_id()); |
| 79 bound_ = true; | 78 bound_ = true; |
| 80 return true; | 79 return true; |
| 81 } | 80 } |
| 82 | 81 |
| 83 void TestDelegatingOutputSurface::DetachFromClient() { | 82 void TestDelegatingOutputSurface::DetachFromClient() { |
| 84 // Some tests make BindToClient fail on purpose. ^__^ | 83 // Some tests make BindToClient fail on purpose. ^__^ |
| 85 if (bound_) { | 84 if (bound_) { |
| 86 if (!delegated_surface_id_.is_null()) | 85 if (!delegated_surface_id_.is_null()) |
| 87 surface_factory_->Destroy(delegated_surface_id_); | 86 surface_factory_->Destroy(delegated_surface_id_); |
| 88 surface_manager_->UnregisterSurfaceFactoryClient( | 87 surface_manager_->UnregisterSurfaceFactoryClient( |
| 89 surface_id_allocator_->client_id()); | 88 surface_id_allocator_->client_id()); |
| 89 surface_manager_->InvalidateSurfaceClientId( |
| 90 surface_id_allocator_->client_id()); |
| 90 bound_ = false; | 91 bound_ = false; |
| 91 } | 92 } |
| 92 display_ = nullptr; | 93 display_ = nullptr; |
| 93 surface_factory_ = nullptr; | 94 surface_factory_ = nullptr; |
| 94 surface_id_allocator_ = nullptr; | 95 surface_id_allocator_ = nullptr; |
| 95 surface_manager_ = nullptr; | 96 surface_manager_ = nullptr; |
| 96 weak_ptrs_.InvalidateWeakPtrs(); | 97 weak_ptrs_.InvalidateWeakPtrs(); |
| 97 OutputSurface::DetachFromClient(); | 98 OutputSurface::DetachFromClient(); |
| 98 } | 99 } |
| 99 | 100 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 void TestDelegatingOutputSurface::DisplayOutputSurfaceLost() { | 156 void TestDelegatingOutputSurface::DisplayOutputSurfaceLost() { |
| 156 DidLoseOutputSurface(); | 157 DidLoseOutputSurface(); |
| 157 } | 158 } |
| 158 | 159 |
| 159 void TestDelegatingOutputSurface::DisplaySetMemoryPolicy( | 160 void TestDelegatingOutputSurface::DisplaySetMemoryPolicy( |
| 160 const ManagedMemoryPolicy& policy) { | 161 const ManagedMemoryPolicy& policy) { |
| 161 SetMemoryPolicy(policy); | 162 SetMemoryPolicy(policy); |
| 162 } | 163 } |
| 163 | 164 |
| 164 } // namespace cc | 165 } // namespace cc |
| OLD | NEW |