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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 factory_.SubmitCompositorFrame( | 79 factory_.SubmitCompositorFrame( |
80 delegated_surface_id_, std::move(frame), | 80 delegated_surface_id_, std::move(frame), |
81 base::Bind(&SurfaceDisplayOutputSurface::SwapBuffersComplete, | 81 base::Bind(&SurfaceDisplayOutputSurface::SwapBuffersComplete, |
82 base::Unretained(this))); | 82 base::Unretained(this))); |
83 } | 83 } |
84 | 84 |
85 bool SurfaceDisplayOutputSurface::BindToClient(OutputSurfaceClient* client) { | 85 bool SurfaceDisplayOutputSurface::BindToClient(OutputSurfaceClient* client) { |
86 DCHECK(thread_checker_.CalledOnValidThread()); | 86 DCHECK(thread_checker_.CalledOnValidThread()); |
87 | 87 |
88 surface_manager_->RegisterSurfaceFactoryClient( | 88 surface_manager_->RegisterSurfaceFactoryClient( |
89 surface_id_allocator_->id_namespace(), this); | 89 surface_id_allocator_->client_id(), this); |
90 | 90 |
91 if (!OutputSurface::BindToClient(client)) | 91 if (!OutputSurface::BindToClient(client)) |
92 return false; | 92 return false; |
93 | 93 |
94 // 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 |
95 // 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 |
96 // callbacks on the context here. | 96 // callbacks on the context here. |
97 if (context_provider()) | 97 if (context_provider()) |
98 context_provider()->SetLostContextCallback(base::Closure()); | 98 context_provider()->SetLostContextCallback(base::Closure()); |
99 | 99 |
100 // Avoid initializing GL context here, as this should be sharing the | 100 // Avoid initializing GL context here, as this should be sharing the |
101 // Display's context. | 101 // Display's context. |
102 display_->Initialize(this); | 102 display_->Initialize(this); |
103 return true; | 103 return true; |
104 } | 104 } |
105 | 105 |
106 void SurfaceDisplayOutputSurface::ForceReclaimResources() { | 106 void SurfaceDisplayOutputSurface::ForceReclaimResources() { |
107 if (!delegated_surface_id_.is_null()) { | 107 if (!delegated_surface_id_.is_null()) { |
108 factory_.SubmitCompositorFrame(delegated_surface_id_, CompositorFrame(), | 108 factory_.SubmitCompositorFrame(delegated_surface_id_, CompositorFrame(), |
109 SurfaceFactory::DrawCallback()); | 109 SurfaceFactory::DrawCallback()); |
110 } | 110 } |
111 } | 111 } |
112 | 112 |
113 void SurfaceDisplayOutputSurface::DetachFromClient() { | 113 void SurfaceDisplayOutputSurface::DetachFromClient() { |
114 DCHECK(HasClient()); | 114 DCHECK(HasClient()); |
115 // Unregister the SurfaceFactoryClient here instead of the dtor so that only | 115 // Unregister the SurfaceFactoryClient here instead of the dtor so that only |
116 // one client is alive for this namespace at any given time. | 116 // one client is alive for this namespace at any given time. |
117 surface_manager_->UnregisterSurfaceFactoryClient( | 117 surface_manager_->UnregisterSurfaceFactoryClient( |
118 surface_id_allocator_->id_namespace()); | 118 surface_id_allocator_->client_id()); |
119 if (!delegated_surface_id_.is_null()) | 119 if (!delegated_surface_id_.is_null()) |
120 factory_.Destroy(delegated_surface_id_); | 120 factory_.Destroy(delegated_surface_id_); |
121 | 121 |
122 OutputSurface::DetachFromClient(); | 122 OutputSurface::DetachFromClient(); |
123 } | 123 } |
124 | 124 |
125 void SurfaceDisplayOutputSurface::BindFramebuffer() { | 125 void SurfaceDisplayOutputSurface::BindFramebuffer() { |
126 // This is a delegating output surface, no framebuffer/direct drawing support. | 126 // This is a delegating output surface, no framebuffer/direct drawing support. |
127 NOTREACHED(); | 127 NOTREACHED(); |
128 } | 128 } |
(...skipping 28 matching lines...) Expand all Loading... |
157 SetMemoryPolicy(policy); | 157 SetMemoryPolicy(policy); |
158 } | 158 } |
159 | 159 |
160 void SurfaceDisplayOutputSurface::SwapBuffersComplete(SurfaceDrawStatus drawn) { | 160 void SurfaceDisplayOutputSurface::SwapBuffersComplete(SurfaceDrawStatus drawn) { |
161 // TODO(danakj): Why the lost check? | 161 // TODO(danakj): Why the lost check? |
162 if (!output_surface_lost_) | 162 if (!output_surface_lost_) |
163 client_->DidSwapBuffersComplete(); | 163 client_->DidSwapBuffersComplete(); |
164 } | 164 } |
165 | 165 |
166 } // namespace cc | 166 } // namespace cc |
OLD | NEW |