| 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 #ifndef CONTENT_BROWSER_RENDERER_HOST_OFFSCREEN_CANVAS_SURFACE_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_OFFSCREEN_CANVAS_SURFACE_IMPL_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_OFFSCREEN_CANVAS_SURFACE_IMPL_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_OFFSCREEN_CANVAS_SURFACE_IMPL_H_ |
| 7 | 7 |
| 8 #include "cc/ipc/frame_sink_manager.mojom.h" | |
| 9 #include "cc/surfaces/surface_id.h" | 8 #include "cc/surfaces/surface_id.h" |
| 10 #include "mojo/public/cpp/bindings/strong_binding.h" | 9 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 11 #include "third_party/WebKit/public/platform/modules/offscreencanvas/offscreen_c
anvas_surface.mojom.h" | 10 #include "third_party/WebKit/public/platform/modules/offscreencanvas/offscreen_c
anvas_surface.mojom.h" |
| 12 | 11 |
| 13 namespace content { | 12 namespace content { |
| 14 | 13 |
| 15 // The browser owned object for an offscreen canvas connection. Holds | 14 // The browser owned object for an offscreen canvas connection. Holds |
| 16 // connections to both the renderer and frame sink manager. | 15 // connections to both the renderer and frame sink manager. |
| 17 class CONTENT_EXPORT OffscreenCanvasSurfaceImpl | 16 class CONTENT_EXPORT OffscreenCanvasSurfaceImpl |
| 18 : public blink::mojom::OffscreenCanvasSurface { | 17 : public blink::mojom::OffscreenCanvasSurface { |
| 19 public: | 18 public: |
| 20 OffscreenCanvasSurfaceImpl(const cc::FrameSinkId& parent_frame_sink_id, | 19 OffscreenCanvasSurfaceImpl( |
| 21 const cc::FrameSinkId& frame_sink_id, | 20 const cc::FrameSinkId& parent_frame_sink_id, |
| 22 cc::mojom::FrameSinkManagerClientPtr client); | 21 const cc::FrameSinkId& frame_sink_id, |
| 22 blink::mojom::OffscreenCanvasSurfaceClientPtr client); |
| 23 ~OffscreenCanvasSurfaceImpl() override; | 23 ~OffscreenCanvasSurfaceImpl() override; |
| 24 | 24 |
| 25 static void Create(const cc::FrameSinkId& parent_frame_sink_id, | 25 static void Create(const cc::FrameSinkId& parent_frame_sink_id, |
| 26 const cc::FrameSinkId& frame_sink_id, | 26 const cc::FrameSinkId& frame_sink_id, |
| 27 cc::mojom::FrameSinkManagerClientPtr client, | 27 blink::mojom::OffscreenCanvasSurfaceClientPtr client, |
| 28 blink::mojom::OffscreenCanvasSurfaceRequest request); | 28 blink::mojom::OffscreenCanvasSurfaceRequest request); |
| 29 | 29 |
| 30 // Creates a MojoCompositorFrameSink connection to FrameSinkManager for an | 30 // Creates a MojoCompositorFrameSink connection to FrameSinkManager for an |
| 31 // offscreen canvas client. The corresponding private interface will be owned | 31 // offscreen canvas client. The corresponding private interface will be owned |
| 32 // here to control CompositorFrameSink lifetime. This should only ever be | 32 // here to control CompositorFrameSink lifetime. This should only ever be |
| 33 // called once. | 33 // called once. |
| 34 void CreateCompositorFrameSink( | 34 void CreateCompositorFrameSink( |
| 35 cc::mojom::MojoCompositorFrameSinkClientPtr client, | 35 cc::mojom::MojoCompositorFrameSinkClientPtr client, |
| 36 cc::mojom::MojoCompositorFrameSinkRequest request); | 36 cc::mojom::MojoCompositorFrameSinkRequest request); |
| 37 | 37 |
| 38 void OnSurfaceCreated(const cc::SurfaceInfo& surface_info); | 38 void OnSurfaceCreated(const cc::SurfaceInfo& surface_info); |
| 39 | 39 |
| 40 // blink::mojom::OffscreenCanvasSurface implementation. | 40 // blink::mojom::OffscreenCanvasSurface implementation. |
| 41 void Require(const cc::SurfaceId& surface_id, | 41 void Require(const cc::SurfaceId& surface_id, |
| 42 const cc::SurfaceSequence& sequence) override; | 42 const cc::SurfaceSequence& sequence) override; |
| 43 void Satisfy(const cc::SurfaceSequence& sequence) override; | 43 void Satisfy(const cc::SurfaceSequence& sequence) override; |
| 44 | 44 |
| 45 const cc::FrameSinkId& frame_sink_id() const { return frame_sink_id_; } | 45 const cc::FrameSinkId& frame_sink_id() const { return frame_sink_id_; } |
| 46 | 46 |
| 47 const cc::FrameSinkId& parent_frame_sink_id() const { | 47 const cc::FrameSinkId& parent_frame_sink_id() const { |
| 48 return parent_frame_sink_id_; | 48 return parent_frame_sink_id_; |
| 49 } | 49 } |
| 50 | 50 |
| 51 const cc::LocalSurfaceId& current_local_surface_id() const { | 51 const cc::LocalSurfaceId& current_local_surface_id() const { |
| 52 return current_local_surface_id_; | 52 return current_local_surface_id_; |
| 53 } | 53 } |
| 54 | 54 |
| 55 private: | 55 private: |
| 56 cc::mojom::FrameSinkManagerClientPtr client_; | 56 blink::mojom::OffscreenCanvasSurfaceClientPtr client_; |
| 57 mojo::StrongBindingPtr<blink::mojom::OffscreenCanvasSurface> binding_; | 57 mojo::StrongBindingPtr<blink::mojom::OffscreenCanvasSurface> binding_; |
| 58 | 58 |
| 59 // Private connection for the CompositorFrameSink. The CompositorFrameSink | 59 // Private connection for the CompositorFrameSink. The CompositorFrameSink |
| 60 // will not be destroyed until both private and offscreen canvas client | 60 // will not be destroyed until both private and offscreen canvas client |
| 61 // connections are closed. | 61 // connections are closed. |
| 62 cc::mojom::MojoCompositorFrameSinkPrivatePtr compositor_frame_sink_private_; | 62 cc::mojom::MojoCompositorFrameSinkPrivatePtr compositor_frame_sink_private_; |
| 63 | 63 |
| 64 // Surface-related state | 64 // Surface-related state |
| 65 const cc::FrameSinkId frame_sink_id_; | 65 const cc::FrameSinkId frame_sink_id_; |
| 66 cc::LocalSurfaceId current_local_surface_id_; | 66 cc::LocalSurfaceId current_local_surface_id_; |
| 67 const cc::FrameSinkId parent_frame_sink_id_; | 67 const cc::FrameSinkId parent_frame_sink_id_; |
| 68 | 68 |
| 69 bool has_created_compositor_frame_sink_ = false; | 69 bool has_created_compositor_frame_sink_ = false; |
| 70 | 70 |
| 71 DISALLOW_COPY_AND_ASSIGN(OffscreenCanvasSurfaceImpl); | 71 DISALLOW_COPY_AND_ASSIGN(OffscreenCanvasSurfaceImpl); |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 } // namespace content | 74 } // namespace content |
| 75 | 75 |
| 76 #endif // CONTENT_BROWSER_RENDERER_HOST_OFFSCREEN_CANVAS_SURFACE_IMPL_H_ | 76 #endif // CONTENT_BROWSER_RENDERER_HOST_OFFSCREEN_CANVAS_SURFACE_IMPL_H_ |
| OLD | NEW |