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

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

Issue 2932893002: BrowserMainLoop owns FrameSinkManagerHost (Closed)
Patch Set: Added a comment that works everywhere Created 3 years, 6 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 #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 <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "cc/surfaces/surface_manager.h" 11 #include "cc/surfaces/surface_manager.h"
12 #include "components/viz/host/frame_sink_manager_host.h" 12 #include "components/viz/host/frame_sink_manager_host.h"
13 #include "content/browser/compositor/surface_utils.h" 13 #include "content/browser/compositor/surface_utils.h"
14 14
15 namespace content { 15 namespace content {
16 16
17 OffscreenCanvasSurfaceImpl::OffscreenCanvasSurfaceImpl( 17 OffscreenCanvasSurfaceImpl::OffscreenCanvasSurfaceImpl(
18 viz::FrameSinkManagerHost* frame_sink_manager_host,
18 const cc::FrameSinkId& parent_frame_sink_id, 19 const cc::FrameSinkId& parent_frame_sink_id,
19 const cc::FrameSinkId& frame_sink_id, 20 const cc::FrameSinkId& frame_sink_id,
20 blink::mojom::OffscreenCanvasSurfaceClientPtr client, 21 blink::mojom::OffscreenCanvasSurfaceClientPtr client,
21 blink::mojom::OffscreenCanvasSurfaceRequest request, 22 blink::mojom::OffscreenCanvasSurfaceRequest request,
22 DestroyCallback destroy_callback) 23 DestroyCallback destroy_callback)
23 : client_(std::move(client)), 24 : frame_sink_manager_host_(frame_sink_manager_host),
25 client_(std::move(client)),
24 binding_(this, std::move(request)), 26 binding_(this, std::move(request)),
25 destroy_callback_(std::move(destroy_callback)), 27 destroy_callback_(std::move(destroy_callback)),
26 frame_sink_id_(frame_sink_id), 28 frame_sink_id_(frame_sink_id),
27 parent_frame_sink_id_(parent_frame_sink_id) { 29 parent_frame_sink_id_(parent_frame_sink_id) {
28 binding_.set_connection_error_handler( 30 binding_.set_connection_error_handler(
29 base::Bind(&OffscreenCanvasSurfaceImpl::OnSurfaceConnectionClosed, 31 base::Bind(&OffscreenCanvasSurfaceImpl::OnSurfaceConnectionClosed,
30 base::Unretained(this))); 32 base::Unretained(this)));
31 GetFrameSinkManagerHost()->AddObserver(this); 33 frame_sink_manager_host_->AddObserver(this);
32 } 34 }
33 35
34 OffscreenCanvasSurfaceImpl::~OffscreenCanvasSurfaceImpl() { 36 OffscreenCanvasSurfaceImpl::~OffscreenCanvasSurfaceImpl() {
35 if (has_created_compositor_frame_sink_) { 37 if (has_created_compositor_frame_sink_) {
36 GetFrameSinkManagerHost()->UnregisterFrameSinkHierarchy( 38 frame_sink_manager_host_->UnregisterFrameSinkHierarchy(
37 parent_frame_sink_id_, frame_sink_id_); 39 parent_frame_sink_id_, frame_sink_id_);
38 } 40 }
39 GetFrameSinkManagerHost()->RemoveObserver(this); 41 frame_sink_manager_host_->RemoveObserver(this);
40 } 42 }
41 43
42 void OffscreenCanvasSurfaceImpl::CreateCompositorFrameSink( 44 void OffscreenCanvasSurfaceImpl::CreateCompositorFrameSink(
43 cc::mojom::MojoCompositorFrameSinkClientPtr client, 45 cc::mojom::MojoCompositorFrameSinkClientPtr client,
44 cc::mojom::MojoCompositorFrameSinkRequest request) { 46 cc::mojom::MojoCompositorFrameSinkRequest request) {
45 if (has_created_compositor_frame_sink_) { 47 if (has_created_compositor_frame_sink_) {
46 DLOG(ERROR) << "CreateCompositorFrameSink() called more than once."; 48 DLOG(ERROR) << "CreateCompositorFrameSink() called more than once.";
47 return; 49 return;
48 } 50 }
49 51
50 GetFrameSinkManagerHost()->CreateCompositorFrameSink( 52 frame_sink_manager_host_->CreateCompositorFrameSink(
51 frame_sink_id_, std::move(request), 53 frame_sink_id_, std::move(request),
52 mojo::MakeRequest(&compositor_frame_sink_private_), std::move(client)); 54 mojo::MakeRequest(&compositor_frame_sink_private_), std::move(client));
53 55
54 GetFrameSinkManagerHost()->RegisterFrameSinkHierarchy(parent_frame_sink_id_, 56 frame_sink_manager_host_->RegisterFrameSinkHierarchy(parent_frame_sink_id_,
55 frame_sink_id_); 57 frame_sink_id_);
56 has_created_compositor_frame_sink_ = true; 58 has_created_compositor_frame_sink_ = true;
57 } 59 }
58 60
59 void OffscreenCanvasSurfaceImpl::OnSurfaceCreated( 61 void OffscreenCanvasSurfaceImpl::OnSurfaceCreated(
60 const cc::SurfaceInfo& surface_info) { 62 const cc::SurfaceInfo& surface_info) {
61 if (surface_info.id().frame_sink_id() != frame_sink_id_) 63 if (surface_info.id().frame_sink_id() != frame_sink_id_)
62 return; 64 return;
63 65
64 local_surface_id_ = surface_info.id().local_surface_id(); 66 local_surface_id_ = surface_info.id().local_surface_id();
65 if (client_) 67 if (client_)
66 client_->OnSurfaceCreated(surface_info); 68 client_->OnSurfaceCreated(surface_info);
67 } 69 }
68 70
69 void OffscreenCanvasSurfaceImpl::Require(const cc::SurfaceId& surface_id, 71 void OffscreenCanvasSurfaceImpl::Require(const cc::SurfaceId& surface_id,
70 const cc::SurfaceSequence& sequence) { 72 const cc::SurfaceSequence& sequence) {
71 GetSurfaceManager()->RequireSequence(surface_id, sequence); 73 GetSurfaceManager()->RequireSequence(surface_id, sequence);
72 } 74 }
73 75
74 void OffscreenCanvasSurfaceImpl::Satisfy(const cc::SurfaceSequence& sequence) { 76 void OffscreenCanvasSurfaceImpl::Satisfy(const cc::SurfaceSequence& sequence) {
75 GetSurfaceManager()->SatisfySequence(sequence); 77 GetSurfaceManager()->SatisfySequence(sequence);
76 } 78 }
77 79
78 void OffscreenCanvasSurfaceImpl::OnSurfaceConnectionClosed() { 80 void OffscreenCanvasSurfaceImpl::OnSurfaceConnectionClosed() {
79 std::move(destroy_callback_).Run(); 81 std::move(destroy_callback_).Run();
80 } 82 }
81 83
82 } // namespace content 84 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698