Index: services/ui/surfaces/gpu_compositor_frame_sink.cc |
diff --git a/services/ui/ws/gpu_compositor_frame_sink.cc b/services/ui/surfaces/gpu_compositor_frame_sink.cc |
similarity index 81% |
rename from services/ui/ws/gpu_compositor_frame_sink.cc |
rename to services/ui/surfaces/gpu_compositor_frame_sink.cc |
index 17ffc59a6842f9de6755454c221cb99fef5d6933..3126f6e70c97b19136a1e3993525b135e7e7c5d2 100644 |
--- a/services/ui/ws/gpu_compositor_frame_sink.cc |
+++ b/services/ui/surfaces/gpu_compositor_frame_sink.cc |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "services/ui/ws/gpu_compositor_frame_sink.h" |
+#include "services/ui/surfaces/gpu_compositor_frame_sink.h" |
#include "base/callback.h" |
#include "base/message_loop/message_loop.h" |
@@ -24,28 +24,38 @@ |
#endif |
namespace ui { |
-namespace ws { |
GpuCompositorFrameSink::GpuCompositorFrameSink( |
- scoped_refptr<DisplayCompositor> display_compositor, |
+ DisplayCompositor* display_compositor, |
const cc::FrameSinkId& frame_sink_id, |
- gfx::AcceleratedWidget widget, |
+ gpu::SurfaceHandle surface_handle, |
gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
- scoped_refptr<SurfacesContextProvider> context_provider, |
+ scoped_refptr<cc::InProcessContextProvider> context_provider, |
cc::mojom::MojoCompositorFrameSinkRequest request, |
+ cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request, |
cc::mojom::MojoCompositorFrameSinkClientPtr client) |
: frame_sink_id_(frame_sink_id), |
task_runner_(base::ThreadTaskRunnerHandle::Get()), |
display_compositor_(display_compositor), |
surface_factory_(frame_sink_id_, display_compositor_->manager(), this), |
client_(std::move(client)), |
- binding_(this, std::move(request)) { |
+ binding_(this, std::move(request)), |
+ private_binding_(this, std::move(private_request)) { |
display_compositor_->manager()->RegisterFrameSinkId(frame_sink_id_); |
display_compositor_->manager()->RegisterSurfaceFactoryClient(frame_sink_id_, |
this); |
- if (widget != gfx::kNullAcceleratedWidget) |
- InitDisplay(widget, gpu_memory_buffer_manager, std::move(context_provider)); |
+ if (surface_handle != gpu::kNullSurfaceHandle) { |
+ InitDisplay(surface_handle, gpu_memory_buffer_manager, |
+ std::move(context_provider)); |
+ } |
+ |
+ binding_.set_connection_error_handler(base::Bind( |
+ &GpuCompositorFrameSink::OnClientConnectionLost, base::Unretained(this))); |
+ |
+ private_binding_.set_connection_error_handler( |
+ base::Bind(&GpuCompositorFrameSink::OnPrivateConnectionLost, |
+ base::Unretained(this))); |
} |
GpuCompositorFrameSink::~GpuCompositorFrameSink() { |
@@ -114,9 +124,9 @@ void GpuCompositorFrameSink::RemoveChildFrameSink( |
} |
void GpuCompositorFrameSink::InitDisplay( |
- gfx::AcceleratedWidget widget, |
+ gpu::SurfaceHandle surface_handle, |
gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
- scoped_refptr<SurfacesContextProvider> context_provider) { |
+ scoped_refptr<cc::InProcessContextProvider> context_provider) { |
// TODO(rjkroege): If there is something better to do than CHECK, add it. |
CHECK(context_provider->BindToCurrentThread()); |
@@ -128,14 +138,15 @@ void GpuCompositorFrameSink::InitDisplay( |
if (context_provider->ContextCapabilities().surfaceless) { |
#if defined(USE_OZONE) |
display_output_surface = base::MakeUnique<DirectOutputSurfaceOzone>( |
- context_provider, widget, synthetic_begin_frame_source.get(), |
- gpu_memory_buffer_manager, GL_TEXTURE_2D, GL_RGB); |
+ std::move(context_provider), surface_handle, |
+ synthetic_begin_frame_source.get(), gpu_memory_buffer_manager, |
+ GL_TEXTURE_2D, GL_RGB); |
#else |
NOTREACHED(); |
#endif |
} else { |
display_output_surface = base::MakeUnique<DirectOutputSurface>( |
- context_provider, synthetic_begin_frame_source.get()); |
+ std::move(context_provider), synthetic_begin_frame_source.get()); |
} |
int max_frames_pending = |
@@ -217,5 +228,18 @@ void GpuCompositorFrameSink::UpdateNeedsBeginFramesInternal() { |
begin_frame_source_->RemoveObserver(this); |
} |
-} // namespace ws |
+void GpuCompositorFrameSink::OnClientConnectionLost() { |
+ client_connection_lost_ = true; |
+ // Request destruction of |this| only if both connections are lost. |
+ display_compositor_->OnCompositorFrameSinkClientConnectionLost( |
+ frame_sink_id_, private_connection_lost_); |
+} |
+ |
+void GpuCompositorFrameSink::OnPrivateConnectionLost() { |
+ private_connection_lost_ = true; |
+ // Request destruction of |this| only if both connections are lost. |
+ display_compositor_->OnCompositorFrameSinkPrivateConnectionLost( |
+ frame_sink_id_, client_connection_lost_); |
+} |
+ |
} // namespace ui |