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_COMPOSITOR_FRAME_SINK_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_OFFSCREEN_CANVAS_COMPOSITOR_FRAME_SINK_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_OFFSCREEN_CANVAS_COMPOSITOR_FRAME_SINK_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_OFFSCREEN_CANVAS_COMPOSITOR_FRAME_SINK_H_ |
7 | 7 |
8 #include "cc/surfaces/surface_factory.h" | 8 #include "cc/surfaces/surface_factory.h" |
9 #include "cc/surfaces/surface_factory_client.h" | 9 #include "cc/surfaces/surface_factory_client.h" |
10 #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" |
11 | 11 |
12 namespace content { | 12 namespace content { |
13 | 13 |
14 class OffscreenCanvasCompositorFrameSink | 14 class CONTENT_EXPORT OffscreenCanvasCompositorFrameSink |
15 : public cc::mojom::MojoCompositorFrameSink, | 15 : public cc::mojom::MojoCompositorFrameSink, |
16 public cc::SurfaceFactoryClient { | 16 public cc::SurfaceFactoryClient { |
17 public: | 17 public: |
18 OffscreenCanvasCompositorFrameSink( | 18 OffscreenCanvasCompositorFrameSink( |
19 const cc::SurfaceId& surface_id, | 19 const cc::SurfaceId& surface_id, |
20 cc::mojom::MojoCompositorFrameSinkClientPtr client); | 20 cc::mojom::MojoCompositorFrameSinkClientPtr client); |
21 ~OffscreenCanvasCompositorFrameSink() override; | 21 ~OffscreenCanvasCompositorFrameSink() override; |
22 | 22 |
23 static void Create(const cc::SurfaceId& surface_id, | 23 static void Create(const cc::SurfaceId& surface_id, |
24 cc::mojom::MojoCompositorFrameSinkClientPtr client, | 24 cc::mojom::MojoCompositorFrameSinkClientPtr client, |
25 cc::mojom::MojoCompositorFrameSinkRequest request); | 25 cc::mojom::MojoCompositorFrameSinkRequest request); |
26 | 26 |
27 // cc::mojom::MojoCompositorFrameSink implementation. | 27 // cc::mojom::MojoCompositorFrameSink implementation. |
28 void SubmitCompositorFrame(cc::CompositorFrame frame) override; | 28 void SubmitCompositorFrame(cc::CompositorFrame frame) override; |
29 void SetNeedsBeginFrame(bool needs_begin_frame) override; | 29 void SetNeedsBeginFrame(bool needs_begin_frame) override; |
30 | 30 |
31 // cc::SurfaceFactoryClient implementation. | 31 // cc::SurfaceFactoryClient implementation. |
32 void ReturnResources(const cc::ReturnedResourceArray& resources) override; | 32 void ReturnResources(const cc::ReturnedResourceArray& resources) override; |
33 void WillDrawSurface(const cc::LocalFrameId& id, | 33 void WillDrawSurface(const cc::LocalFrameId& id, |
34 const gfx::Rect& damage_rect) override; | 34 const gfx::Rect& damage_rect) override; |
35 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override; | 35 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override; |
36 | 36 |
37 const cc::FrameSinkId& frame_sink_id() const { | |
38 return surface_id_.frame_sink_id(); | |
39 } | |
40 | |
41 base::WeakPtr<OffscreenCanvasCompositorFrameSink> GetWeakPtr() { | |
Fady Samuel
2016/11/14 21:15:40
Why does this need a weak ptr?
xlai (Olivia)
2016/11/15 17:16:18
Done. My mistake of not doing a clean delete after
| |
42 return weak_factory_.GetWeakPtr(); | |
43 } | |
44 | |
37 private: | 45 private: |
38 void DidReceiveCompositorFrameAck(); | 46 void DidReceiveCompositorFrameAck(); |
39 | 47 |
40 cc::SurfaceId surface_id_; | 48 cc::SurfaceId surface_id_; |
41 std::unique_ptr<cc::SurfaceFactory> surface_factory_; | 49 std::unique_ptr<cc::SurfaceFactory> surface_factory_; |
42 cc::mojom::MojoCompositorFrameSinkClientPtr client_; | 50 cc::mojom::MojoCompositorFrameSinkClientPtr client_; |
43 int ack_pending_count_ = 0; | 51 int ack_pending_count_ = 0; |
44 cc::ReturnedResourceArray surface_returned_resources_; | 52 cc::ReturnedResourceArray surface_returned_resources_; |
45 | 53 |
54 base::WeakPtrFactory<OffscreenCanvasCompositorFrameSink> weak_factory_; | |
55 | |
46 DISALLOW_COPY_AND_ASSIGN(OffscreenCanvasCompositorFrameSink); | 56 DISALLOW_COPY_AND_ASSIGN(OffscreenCanvasCompositorFrameSink); |
47 }; | 57 }; |
48 | 58 |
49 } // namespace content | 59 } // namespace content |
50 | 60 |
51 #endif // CONTENT_BROWSER_RENDERER_HOST_OFFSCREEN_CANVAS_COMPOSITOR_FRAME_SINK_ H_ | 61 #endif // CONTENT_BROWSER_RENDERER_HOST_OFFSCREEN_CANVAS_COMPOSITOR_FRAME_SINK_ H_ |
OLD | NEW |