OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/surfaces/surface_display_output_surface.h" | 5 #include "cc/surfaces/surface_display_output_surface.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "cc/output/compositor_frame.h" | 8 #include "cc/output/compositor_frame.h" |
9 #include "cc/output/compositor_frame_ack.h" | 9 #include "cc/output/compositor_frame_ack.h" |
10 #include "cc/surfaces/display.h" | 10 #include "cc/surfaces/display.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 } | 69 } |
70 delegated_surface_id_ = surface_id_allocator_->GenerateId(); | 70 delegated_surface_id_ = surface_id_allocator_->GenerateId(); |
71 factory_.Create(delegated_surface_id_); | 71 factory_.Create(delegated_surface_id_); |
72 last_swap_frame_size_ = frame_size; | 72 last_swap_frame_size_ = frame_size; |
73 } | 73 } |
74 display_->SetSurfaceId(delegated_surface_id_, | 74 display_->SetSurfaceId(delegated_surface_id_, |
75 frame.metadata.device_scale_factor); | 75 frame.metadata.device_scale_factor); |
76 | 76 |
77 client_->DidSwapBuffers(); | 77 client_->DidSwapBuffers(); |
78 | 78 |
79 std::unique_ptr<CompositorFrame> frame_copy(new CompositorFrame); | |
80 *frame_copy = std::move(frame); | |
81 factory_.SubmitCompositorFrame( | 79 factory_.SubmitCompositorFrame( |
82 delegated_surface_id_, std::move(frame_copy), | 80 delegated_surface_id_, std::move(frame), |
83 base::Bind(&SurfaceDisplayOutputSurface::SwapBuffersComplete, | 81 base::Bind(&SurfaceDisplayOutputSurface::SwapBuffersComplete, |
84 base::Unretained(this))); | 82 base::Unretained(this))); |
85 } | 83 } |
86 | 84 |
87 bool SurfaceDisplayOutputSurface::BindToClient(OutputSurfaceClient* client) { | 85 bool SurfaceDisplayOutputSurface::BindToClient(OutputSurfaceClient* client) { |
88 DCHECK(thread_checker_.CalledOnValidThread()); | 86 DCHECK(thread_checker_.CalledOnValidThread()); |
89 | 87 |
90 surface_manager_->RegisterSurfaceFactoryClient( | 88 surface_manager_->RegisterSurfaceFactoryClient( |
91 surface_id_allocator_->id_namespace(), this); | 89 surface_id_allocator_->id_namespace(), this); |
92 | 90 |
93 if (!OutputSurface::BindToClient(client)) | 91 if (!OutputSurface::BindToClient(client)) |
94 return false; | 92 return false; |
95 | 93 |
96 // We want the Display's output surface to hear about lost context, and since | 94 // We want the Display's output surface to hear about lost context, and since |
97 // this shares a context with it, we should not be listening for lost context | 95 // this shares a context with it, we should not be listening for lost context |
98 // callbacks on the context here. | 96 // callbacks on the context here. |
99 if (context_provider()) | 97 if (context_provider()) |
100 context_provider()->SetLostContextCallback(base::Closure()); | 98 context_provider()->SetLostContextCallback(base::Closure()); |
101 | 99 |
102 // Avoid initializing GL context here, as this should be sharing the | 100 // Avoid initializing GL context here, as this should be sharing the |
103 // Display's context. | 101 // Display's context. |
104 display_->Initialize(this); | 102 display_->Initialize(this); |
105 return true; | 103 return true; |
106 } | 104 } |
107 | 105 |
108 void SurfaceDisplayOutputSurface::ForceReclaimResources() { | 106 void SurfaceDisplayOutputSurface::ForceReclaimResources() { |
109 if (!delegated_surface_id_.is_null()) { | 107 if (!delegated_surface_id_.is_null()) { |
110 factory_.SubmitCompositorFrame(delegated_surface_id_, nullptr, | 108 factory_.SubmitCompositorFrame(delegated_surface_id_, CompositorFrame(), |
111 SurfaceFactory::DrawCallback()); | 109 SurfaceFactory::DrawCallback()); |
112 } | 110 } |
113 } | 111 } |
114 | 112 |
115 void SurfaceDisplayOutputSurface::DetachFromClient() { | 113 void SurfaceDisplayOutputSurface::DetachFromClient() { |
116 DCHECK(HasClient()); | 114 DCHECK(HasClient()); |
117 // Unregister the SurfaceFactoryClient here instead of the dtor so that only | 115 // Unregister the SurfaceFactoryClient here instead of the dtor so that only |
118 // one client is alive for this namespace at any given time. | 116 // one client is alive for this namespace at any given time. |
119 surface_manager_->UnregisterSurfaceFactoryClient( | 117 surface_manager_->UnregisterSurfaceFactoryClient( |
120 surface_id_allocator_->id_namespace()); | 118 surface_id_allocator_->id_namespace()); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 SetMemoryPolicy(policy); | 157 SetMemoryPolicy(policy); |
160 } | 158 } |
161 | 159 |
162 void SurfaceDisplayOutputSurface::SwapBuffersComplete(SurfaceDrawStatus drawn) { | 160 void SurfaceDisplayOutputSurface::SwapBuffersComplete(SurfaceDrawStatus drawn) { |
163 // TODO(danakj): Why the lost check? | 161 // TODO(danakj): Why the lost check? |
164 if (!output_surface_lost_) | 162 if (!output_surface_lost_) |
165 client_->DidSwapBuffersComplete(); | 163 client_->DidSwapBuffersComplete(); |
166 } | 164 } |
167 | 165 |
168 } // namespace cc | 166 } // namespace cc |
OLD | NEW |