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 #include "content/browser/renderer_host/offscreen_canvas_surface_impl.h" | 5 #include "content/browser/renderer_host/offscreen_canvas_surface_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 10 matching lines...) Expand all Loading... | |
21 const cc::FrameSinkId& frame_sink_id, | 21 const cc::FrameSinkId& frame_sink_id, |
22 cc::mojom::DisplayCompositorClientPtr client) | 22 cc::mojom::DisplayCompositorClientPtr client) |
23 : client_(std::move(client)), | 23 : client_(std::move(client)), |
24 frame_sink_id_(frame_sink_id), | 24 frame_sink_id_(frame_sink_id), |
25 parent_frame_sink_id_(parent_frame_sink_id) { | 25 parent_frame_sink_id_(parent_frame_sink_id) { |
26 OffscreenCanvasCompositorFrameSinkManager::GetInstance() | 26 OffscreenCanvasCompositorFrameSinkManager::GetInstance() |
27 ->RegisterOffscreenCanvasSurfaceInstance(frame_sink_id_, this); | 27 ->RegisterOffscreenCanvasSurfaceInstance(frame_sink_id_, this); |
28 } | 28 } |
29 | 29 |
30 OffscreenCanvasSurfaceImpl::~OffscreenCanvasSurfaceImpl() { | 30 OffscreenCanvasSurfaceImpl::~OffscreenCanvasSurfaceImpl() { |
31 if (frame_sink_id_.is_valid()) { | 31 if (has_registered_frame_sink_hierarchy_) { |
32 OffscreenCanvasCompositorFrameSinkManager::GetInstance() | 32 content::GetDisplayCompositor()->UnregisterFrameSinkHierarchy( |
xlai (Olivia)
2017/04/03 15:42:59
Previously this is done in destroy of OffscreenCan
kylechar
2017/04/03 16:00:19
The GpuCompositorFrameSink in DisplayCompositor is
| |
33 ->UnregisterOffscreenCanvasSurfaceInstance(frame_sink_id_); | 33 parent_frame_sink_id_, frame_sink_id_); |
34 } | 34 } |
35 OffscreenCanvasCompositorFrameSinkManager::GetInstance() | |
36 ->UnregisterOffscreenCanvasSurfaceInstance(frame_sink_id_); | |
35 } | 37 } |
36 | 38 |
37 // static | 39 // static |
38 void OffscreenCanvasSurfaceImpl::Create( | 40 void OffscreenCanvasSurfaceImpl::Create( |
39 const cc::FrameSinkId& parent_frame_sink_id, | 41 const cc::FrameSinkId& parent_frame_sink_id, |
40 const cc::FrameSinkId& frame_sink_id, | 42 const cc::FrameSinkId& frame_sink_id, |
41 cc::mojom::DisplayCompositorClientPtr client, | 43 cc::mojom::DisplayCompositorClientPtr client, |
42 blink::mojom::OffscreenCanvasSurfaceRequest request) { | 44 blink::mojom::OffscreenCanvasSurfaceRequest request) { |
43 std::unique_ptr<OffscreenCanvasSurfaceImpl> impl = | 45 std::unique_ptr<OffscreenCanvasSurfaceImpl> impl = |
44 base::MakeUnique<OffscreenCanvasSurfaceImpl>( | 46 base::MakeUnique<OffscreenCanvasSurfaceImpl>( |
45 parent_frame_sink_id, frame_sink_id, std::move(client)); | 47 parent_frame_sink_id, frame_sink_id, std::move(client)); |
46 OffscreenCanvasSurfaceImpl* surface_service = impl.get(); | 48 OffscreenCanvasSurfaceImpl* surface_service = impl.get(); |
47 surface_service->binding_ = | 49 surface_service->binding_ = |
48 mojo::MakeStrongBinding(std::move(impl), std::move(request)); | 50 mojo::MakeStrongBinding(std::move(impl), std::move(request)); |
49 } | 51 } |
50 | 52 |
53 void OffscreenCanvasSurfaceImpl::CreateCompositorFrameSink( | |
54 cc::mojom::MojoCompositorFrameSinkClientPtr client, | |
55 cc::mojom::MojoCompositorFrameSinkRequest request) { | |
56 DCHECK(!compositor_frame_sink_private_.is_bound()); | |
57 | |
58 content::GetDisplayCompositor()->CreateCompositorFrameSink( | |
59 frame_sink_id_, std::move(request), | |
60 mojo::MakeRequest(&compositor_frame_sink_private_), std::move(client)); | |
61 | |
62 content::GetDisplayCompositor()->RegisterFrameSinkHierarchy( | |
63 parent_frame_sink_id_, frame_sink_id_); | |
64 has_registered_frame_sink_hierarchy_ = true; | |
65 } | |
66 | |
51 void OffscreenCanvasSurfaceImpl::OnSurfaceCreated( | 67 void OffscreenCanvasSurfaceImpl::OnSurfaceCreated( |
52 const cc::SurfaceInfo& surface_info) { | 68 const cc::SurfaceInfo& surface_info) { |
53 DCHECK_EQ(surface_info.id().frame_sink_id(), frame_sink_id_); | 69 DCHECK_EQ(surface_info.id().frame_sink_id(), frame_sink_id_); |
54 if (!current_local_surface_id_.is_valid() || | 70 if (!current_local_surface_id_.is_valid() || |
55 surface_info.id().local_surface_id() != current_local_surface_id_) { | 71 surface_info.id().local_surface_id() != current_local_surface_id_) { |
56 current_local_surface_id_ = surface_info.id().local_surface_id(); | 72 current_local_surface_id_ = surface_info.id().local_surface_id(); |
57 if (client_) | 73 if (client_) |
58 client_->OnSurfaceCreated(surface_info); | 74 client_->OnSurfaceCreated(surface_info); |
59 } | 75 } |
60 } | 76 } |
61 | 77 |
62 void OffscreenCanvasSurfaceImpl::Require(const cc::SurfaceId& surface_id, | 78 void OffscreenCanvasSurfaceImpl::Require(const cc::SurfaceId& surface_id, |
63 const cc::SurfaceSequence& sequence) { | 79 const cc::SurfaceSequence& sequence) { |
64 GetSurfaceManager()->RequireSequence(surface_id, sequence); | 80 GetSurfaceManager()->RequireSequence(surface_id, sequence); |
65 } | 81 } |
66 | 82 |
67 void OffscreenCanvasSurfaceImpl::Satisfy(const cc::SurfaceSequence& sequence) { | 83 void OffscreenCanvasSurfaceImpl::Satisfy(const cc::SurfaceSequence& sequence) { |
68 GetSurfaceManager()->SatisfySequence(sequence); | 84 GetSurfaceManager()->SatisfySequence(sequence); |
69 } | 85 } |
70 | 86 |
71 } // namespace content | 87 } // namespace content |
OLD | NEW |