Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: content/browser/renderer_host/offscreen_canvas_surface_impl.h

Issue 2810703004: Add observers to FrameSinkManagerHost. (Closed)
Patch Set: Make more better. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/surfaces/surface_id.h" 8 #include "cc/surfaces/frame_sink_id.h"
9 #include "mojo/public/cpp/bindings/strong_binding.h" 9 #include "cc/surfaces/surface_info.h"
10 #include "content/browser/compositor/frame_sink_observer.h"
11 #include "content/common/content_export.h"
12 #include "mojo/public/cpp/bindings/binding.h"
10 #include "third_party/WebKit/public/platform/modules/offscreencanvas/offscreen_c anvas_surface.mojom.h" 13 #include "third_party/WebKit/public/platform/modules/offscreencanvas/offscreen_c anvas_surface.mojom.h"
11 14
12 namespace content { 15 namespace content {
13 16
17 class OffscreenCanvasProviderImpl;
18
14 // The browser owned object for an offscreen canvas connection. Holds 19 // The browser owned object for an offscreen canvas connection. Holds
15 // connections to both the renderer and frame sink manager. 20 // connections to both the renderer and frame sink manager.
16 class CONTENT_EXPORT OffscreenCanvasSurfaceImpl 21 class CONTENT_EXPORT OffscreenCanvasSurfaceImpl
17 : public blink::mojom::OffscreenCanvasSurface { 22 : public blink::mojom::OffscreenCanvasSurface,
Fady Samuel 2017/04/28 04:58:00 Maybe this thing is actually an "OffscreenCanvasEm
kylechar 2017/05/01 19:07:48 OffscreenCanvasEmbedder works too.
23 public FrameSinkObserver {
18 public: 24 public:
19 OffscreenCanvasSurfaceImpl( 25 OffscreenCanvasSurfaceImpl(
20 const cc::FrameSinkId& parent_frame_sink_id, 26 const cc::FrameSinkId& parent_frame_sink_id,
21 const cc::FrameSinkId& frame_sink_id, 27 const cc::FrameSinkId& frame_sink_id,
22 blink::mojom::OffscreenCanvasSurfaceClientPtr client); 28 OffscreenCanvasProviderImpl* provider,
29 blink::mojom::OffscreenCanvasSurfaceClientPtr client,
30 blink::mojom::OffscreenCanvasSurfaceRequest request);
23 ~OffscreenCanvasSurfaceImpl() override; 31 ~OffscreenCanvasSurfaceImpl() override;
24 32
25 static void Create(const cc::FrameSinkId& parent_frame_sink_id, 33 const cc::FrameSinkId& frame_sink_id() const { return frame_sink_id_; }
26 const cc::FrameSinkId& frame_sink_id, 34
27 blink::mojom::OffscreenCanvasSurfaceClientPtr client, 35 const cc::FrameSinkId& parent_frame_sink_id() const {
28 blink::mojom::OffscreenCanvasSurfaceRequest request); 36 return parent_frame_sink_id_;
37 }
38
39 const cc::LocalSurfaceId& local_surface_id() const {
40 return local_surface_id_;
41 }
29 42
30 // Creates a MojoCompositorFrameSink connection to FrameSinkManager for an 43 // Creates a MojoCompositorFrameSink connection to FrameSinkManager for an
31 // offscreen canvas client. The corresponding private interface will be owned 44 // offscreen canvas client. The corresponding private interface will be owned
32 // here to control CompositorFrameSink lifetime. This should only ever be 45 // here to control CompositorFrameSink lifetime. This should only ever be
33 // called once. 46 // called once.
34 void CreateCompositorFrameSink( 47 void CreateCompositorFrameSink(
35 cc::mojom::MojoCompositorFrameSinkClientPtr client, 48 cc::mojom::MojoCompositorFrameSinkClientPtr client,
36 cc::mojom::MojoCompositorFrameSinkRequest request); 49 cc::mojom::MojoCompositorFrameSinkRequest request);
37 50
38 void OnSurfaceCreated(const cc::SurfaceInfo& surface_info);
39
40 // blink::mojom::OffscreenCanvasSurface implementation. 51 // blink::mojom::OffscreenCanvasSurface implementation.
41 void Require(const cc::SurfaceId& surface_id, 52 void Require(const cc::SurfaceId& surface_id,
42 const cc::SurfaceSequence& sequence) override; 53 const cc::SurfaceSequence& sequence) override;
43 void Satisfy(const cc::SurfaceSequence& sequence) override; 54 void Satisfy(const cc::SurfaceSequence& sequence) override;
44 55
45 const cc::FrameSinkId& frame_sink_id() const { return frame_sink_id_; } 56 // FrameSinkObserver implementation.
46 57 void OnSurfaceCreated(const cc::SurfaceInfo& surface_info) override;
47 const cc::FrameSinkId& parent_frame_sink_id() const {
48 return parent_frame_sink_id_;
49 }
50
51 const cc::LocalSurfaceId& current_local_surface_id() const {
52 return current_local_surface_id_;
53 }
54 58
55 private: 59 private:
60 // Registered as a callback for when |binding_| is closed.
61 void OnSurfaceConnectionClosed();
62
56 blink::mojom::OffscreenCanvasSurfaceClientPtr client_; 63 blink::mojom::OffscreenCanvasSurfaceClientPtr client_;
57 mojo::StrongBindingPtr<blink::mojom::OffscreenCanvasSurface> binding_; 64 mojo::Binding<blink::mojom::OffscreenCanvasSurface> binding_;
58 65
59 // Private connection for the CompositorFrameSink. The CompositorFrameSink 66 // Private connection for the CompositorFrameSink. The CompositorFrameSink
60 // will not be destroyed until both private and offscreen canvas client 67 // will not be destroyed until both private and offscreen canvas client
61 // connections are closed. 68 // connections are closed.
62 cc::mojom::MojoCompositorFrameSinkPrivatePtr compositor_frame_sink_private_; 69 cc::mojom::MojoCompositorFrameSinkPrivatePtr compositor_frame_sink_private_;
63 70
71 OffscreenCanvasProviderImpl* provider_;
72
64 // Surface-related state 73 // Surface-related state
65 const cc::FrameSinkId frame_sink_id_; 74 const cc::FrameSinkId frame_sink_id_;
66 cc::LocalSurfaceId current_local_surface_id_; 75 cc::LocalSurfaceId local_surface_id_;
67 const cc::FrameSinkId parent_frame_sink_id_; 76 const cc::FrameSinkId parent_frame_sink_id_;
68 77
69 bool has_created_compositor_frame_sink_ = false; 78 bool has_created_compositor_frame_sink_ = false;
70 79
71 DISALLOW_COPY_AND_ASSIGN(OffscreenCanvasSurfaceImpl); 80 DISALLOW_COPY_AND_ASSIGN(OffscreenCanvasSurfaceImpl);
72 }; 81 };
73 82
74 } // namespace content 83 } // namespace content
75 84
76 #endif // CONTENT_BROWSER_RENDERER_HOST_OFFSCREEN_CANVAS_SURFACE_IMPL_H_ 85 #endif // CONTENT_BROWSER_RENDERER_HOST_OFFSCREEN_CANVAS_SURFACE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698