| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/browser/renderer_host/offscreen_canvas_compositor_frame_sink_p
rovider_impl.h" | |
| 6 | |
| 7 #include "base/memory/ptr_util.h" | |
| 8 #include "content/browser/compositor/surface_utils.h" | |
| 9 #include "content/browser/renderer_host/offscreen_canvas_compositor_frame_sink.h
" | |
| 10 #include "content/browser/renderer_host/offscreen_canvas_compositor_frame_sink_m
anager.h" | |
| 11 #include "mojo/public/cpp/bindings/strong_binding.h" | |
| 12 | |
| 13 namespace content { | |
| 14 | |
| 15 OffscreenCanvasCompositorFrameSinkProviderImpl:: | |
| 16 OffscreenCanvasCompositorFrameSinkProviderImpl() {} | |
| 17 | |
| 18 OffscreenCanvasCompositorFrameSinkProviderImpl:: | |
| 19 ~OffscreenCanvasCompositorFrameSinkProviderImpl() {} | |
| 20 | |
| 21 void OffscreenCanvasCompositorFrameSinkProviderImpl::Add( | |
| 22 blink::mojom::OffscreenCanvasCompositorFrameSinkProviderRequest request) { | |
| 23 bindings_.AddBinding(this, std::move(request)); | |
| 24 } | |
| 25 | |
| 26 void OffscreenCanvasCompositorFrameSinkProviderImpl::CreateCompositorFrameSink( | |
| 27 const cc::FrameSinkId& frame_sink_id, | |
| 28 cc::mojom::MojoCompositorFrameSinkClientPtr client, | |
| 29 cc::mojom::MojoCompositorFrameSinkRequest request) { | |
| 30 compositor_frame_sinks_[frame_sink_id] = | |
| 31 base::MakeUnique<OffscreenCanvasCompositorFrameSink>( | |
| 32 this, frame_sink_id, std::move(request), std::move(client)); | |
| 33 | |
| 34 OffscreenCanvasCompositorFrameSinkManager::GetInstance() | |
| 35 ->RegisterFrameSinkToParent(frame_sink_id); | |
| 36 } | |
| 37 | |
| 38 cc::SurfaceManager* | |
| 39 OffscreenCanvasCompositorFrameSinkProviderImpl::GetSurfaceManager() { | |
| 40 return content::GetSurfaceManager(); | |
| 41 } | |
| 42 | |
| 43 void OffscreenCanvasCompositorFrameSinkProviderImpl:: | |
| 44 OnCompositorFrameSinkClientConnectionLost( | |
| 45 const cc::FrameSinkId& frame_sink_id) { | |
| 46 // TODO(fsamuel, xlai): Investigate why this function is not fired when user | |
| 47 // close down the window that has OffscreenCanvas commit(). | |
| 48 compositor_frame_sinks_.erase(frame_sink_id); | |
| 49 } | |
| 50 | |
| 51 void OffscreenCanvasCompositorFrameSinkProviderImpl:: | |
| 52 OnCompositorFrameSinkClientDestroyed(const cc::FrameSinkId& frame_sink_id) { | |
| 53 OffscreenCanvasCompositorFrameSinkManager::GetInstance() | |
| 54 ->UnregisterFrameSinkFromParent(frame_sink_id); | |
| 55 } | |
| 56 | |
| 57 } // namespace content | |
| OLD | NEW |