| 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 <memory> |
| 7 #include <utility> | 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 10 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 11 #include "cc/surfaces/surface_manager.h" | 12 #include "cc/surfaces/surface_manager.h" |
| 12 #include "content/browser/compositor/frame_sink_manager_host.h" | 13 #include "content/browser/compositor/frame_sink_manager_host.h" |
| 13 #include "content/browser/compositor/surface_utils.h" | 14 #include "content/browser/compositor/surface_utils.h" |
| 14 #include "content/browser/renderer_host/offscreen_canvas_compositor_frame_sink_m
anager.h" | 15 #include "content/browser/renderer_host/offscreen_canvas_compositor_frame_sink_m
anager.h" |
| 15 | 16 |
| 16 namespace content { | 17 namespace content { |
| 17 | 18 |
| 18 OffscreenCanvasSurfaceImpl::OffscreenCanvasSurfaceImpl( | 19 OffscreenCanvasSurfaceImpl::OffscreenCanvasSurfaceImpl( |
| 19 const cc::FrameSinkId& parent_frame_sink_id, | 20 const cc::FrameSinkId& parent_frame_sink_id, |
| 20 const cc::FrameSinkId& frame_sink_id, | 21 const cc::FrameSinkId& frame_sink_id, |
| 21 cc::mojom::FrameSinkManagerClientPtr client) | 22 blink::mojom::OffscreenCanvasSurfaceClientPtr client) |
| 22 : client_(std::move(client)), | 23 : client_(std::move(client)), |
| 23 frame_sink_id_(frame_sink_id), | 24 frame_sink_id_(frame_sink_id), |
| 24 parent_frame_sink_id_(parent_frame_sink_id) { | 25 parent_frame_sink_id_(parent_frame_sink_id) { |
| 25 OffscreenCanvasCompositorFrameSinkManager::GetInstance() | 26 OffscreenCanvasCompositorFrameSinkManager::GetInstance() |
| 26 ->RegisterOffscreenCanvasSurfaceInstance(frame_sink_id_, this); | 27 ->RegisterOffscreenCanvasSurfaceInstance(frame_sink_id_, this); |
| 27 } | 28 } |
| 28 | 29 |
| 29 OffscreenCanvasSurfaceImpl::~OffscreenCanvasSurfaceImpl() { | 30 OffscreenCanvasSurfaceImpl::~OffscreenCanvasSurfaceImpl() { |
| 30 if (has_created_compositor_frame_sink_) { | 31 if (has_created_compositor_frame_sink_) { |
| 31 GetFrameSinkManagerHost()->UnregisterFrameSinkHierarchy( | 32 GetFrameSinkManagerHost()->UnregisterFrameSinkHierarchy( |
| 32 parent_frame_sink_id_, frame_sink_id_); | 33 parent_frame_sink_id_, frame_sink_id_); |
| 33 } | 34 } |
| 34 OffscreenCanvasCompositorFrameSinkManager::GetInstance() | 35 OffscreenCanvasCompositorFrameSinkManager::GetInstance() |
| 35 ->UnregisterOffscreenCanvasSurfaceInstance(frame_sink_id_); | 36 ->UnregisterOffscreenCanvasSurfaceInstance(frame_sink_id_); |
| 36 } | 37 } |
| 37 | 38 |
| 38 // static | 39 // static |
| 39 void OffscreenCanvasSurfaceImpl::Create( | 40 void OffscreenCanvasSurfaceImpl::Create( |
| 40 const cc::FrameSinkId& parent_frame_sink_id, | 41 const cc::FrameSinkId& parent_frame_sink_id, |
| 41 const cc::FrameSinkId& frame_sink_id, | 42 const cc::FrameSinkId& frame_sink_id, |
| 42 cc::mojom::FrameSinkManagerClientPtr client, | 43 blink::mojom::OffscreenCanvasSurfaceClientPtr client, |
| 43 blink::mojom::OffscreenCanvasSurfaceRequest request) { | 44 blink::mojom::OffscreenCanvasSurfaceRequest request) { |
| 44 std::unique_ptr<OffscreenCanvasSurfaceImpl> impl = | 45 std::unique_ptr<OffscreenCanvasSurfaceImpl> impl = |
| 45 base::MakeUnique<OffscreenCanvasSurfaceImpl>( | 46 base::MakeUnique<OffscreenCanvasSurfaceImpl>( |
| 46 parent_frame_sink_id, frame_sink_id, std::move(client)); | 47 parent_frame_sink_id, frame_sink_id, std::move(client)); |
| 47 OffscreenCanvasSurfaceImpl* surface_service = impl.get(); | 48 OffscreenCanvasSurfaceImpl* surface_service = impl.get(); |
| 48 surface_service->binding_ = | 49 surface_service->binding_ = |
| 49 mojo::MakeStrongBinding(std::move(impl), std::move(request)); | 50 mojo::MakeStrongBinding(std::move(impl), std::move(request)); |
| 50 } | 51 } |
| 51 | 52 |
| 52 void OffscreenCanvasSurfaceImpl::CreateCompositorFrameSink( | 53 void OffscreenCanvasSurfaceImpl::CreateCompositorFrameSink( |
| (...skipping 27 matching lines...) Expand all Loading... |
| 80 void OffscreenCanvasSurfaceImpl::Require(const cc::SurfaceId& surface_id, | 81 void OffscreenCanvasSurfaceImpl::Require(const cc::SurfaceId& surface_id, |
| 81 const cc::SurfaceSequence& sequence) { | 82 const cc::SurfaceSequence& sequence) { |
| 82 GetSurfaceManager()->RequireSequence(surface_id, sequence); | 83 GetSurfaceManager()->RequireSequence(surface_id, sequence); |
| 83 } | 84 } |
| 84 | 85 |
| 85 void OffscreenCanvasSurfaceImpl::Satisfy(const cc::SurfaceSequence& sequence) { | 86 void OffscreenCanvasSurfaceImpl::Satisfy(const cc::SurfaceSequence& sequence) { |
| 86 GetSurfaceManager()->SatisfySequence(sequence); | 87 GetSurfaceManager()->SatisfySequence(sequence); |
| 87 } | 88 } |
| 88 | 89 |
| 89 } // namespace content | 90 } // namespace content |
| OLD | NEW |