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

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

Issue 2851243002: Finish offscreen canvas using FrameSinkMangerHost. (Closed)
Patch Set: Add public dep. 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
« no previous file with comments | « content/browser/renderer_host/offscreen_canvas_surface_impl.h ('k') | content/test/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/bind_helpers.h"
11 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
12 #include "cc/surfaces/surface_manager.h" 11 #include "cc/surfaces/surface_manager.h"
13 #include "content/browser/compositor/frame_sink_manager_host.h" 12 #include "content/browser/compositor/frame_sink_manager_host.h"
14 #include "content/browser/compositor/surface_utils.h" 13 #include "content/browser/compositor/surface_utils.h"
15 #include "content/browser/renderer_host/offscreen_canvas_compositor_frame_sink_m anager.h"
16 14
17 namespace content { 15 namespace content {
18 16
19 OffscreenCanvasSurfaceImpl::OffscreenCanvasSurfaceImpl( 17 OffscreenCanvasSurfaceImpl::OffscreenCanvasSurfaceImpl(
20 const cc::FrameSinkId& parent_frame_sink_id, 18 const cc::FrameSinkId& parent_frame_sink_id,
21 const cc::FrameSinkId& frame_sink_id, 19 const cc::FrameSinkId& frame_sink_id,
22 blink::mojom::OffscreenCanvasSurfaceClientPtr client) 20 blink::mojom::OffscreenCanvasSurfaceClientPtr client,
21 blink::mojom::OffscreenCanvasSurfaceRequest request,
22 DestroyCallback destroy_callback)
23 : client_(std::move(client)), 23 : client_(std::move(client)),
24 binding_(this, std::move(request)),
25 destroy_callback_(std::move(destroy_callback)),
24 frame_sink_id_(frame_sink_id), 26 frame_sink_id_(frame_sink_id),
25 parent_frame_sink_id_(parent_frame_sink_id) { 27 parent_frame_sink_id_(parent_frame_sink_id) {
26 OffscreenCanvasCompositorFrameSinkManager::GetInstance() 28 binding_.set_connection_error_handler(
27 ->RegisterOffscreenCanvasSurfaceInstance(frame_sink_id_, this); 29 base::Bind(&OffscreenCanvasSurfaceImpl::OnSurfaceConnectionClosed,
30 base::Unretained(this)));
31 GetFrameSinkManagerHost()->AddObserver(this);
28 } 32 }
29 33
30 OffscreenCanvasSurfaceImpl::~OffscreenCanvasSurfaceImpl() { 34 OffscreenCanvasSurfaceImpl::~OffscreenCanvasSurfaceImpl() {
31 if (has_created_compositor_frame_sink_) { 35 if (has_created_compositor_frame_sink_) {
32 GetFrameSinkManagerHost()->UnregisterFrameSinkHierarchy( 36 GetFrameSinkManagerHost()->UnregisterFrameSinkHierarchy(
33 parent_frame_sink_id_, frame_sink_id_); 37 parent_frame_sink_id_, frame_sink_id_);
34 } 38 }
35 OffscreenCanvasCompositorFrameSinkManager::GetInstance() 39 GetFrameSinkManagerHost()->RemoveObserver(this);
36 ->UnregisterOffscreenCanvasSurfaceInstance(frame_sink_id_);
37 }
38
39 // static
40 void OffscreenCanvasSurfaceImpl::Create(
41 const cc::FrameSinkId& parent_frame_sink_id,
42 const cc::FrameSinkId& frame_sink_id,
43 blink::mojom::OffscreenCanvasSurfaceClientPtr client,
44 blink::mojom::OffscreenCanvasSurfaceRequest request) {
45 std::unique_ptr<OffscreenCanvasSurfaceImpl> impl =
46 base::MakeUnique<OffscreenCanvasSurfaceImpl>(
47 parent_frame_sink_id, frame_sink_id, std::move(client));
48 OffscreenCanvasSurfaceImpl* surface_service = impl.get();
49 surface_service->binding_ =
50 mojo::MakeStrongBinding(std::move(impl), std::move(request));
51 } 40 }
52 41
53 void OffscreenCanvasSurfaceImpl::CreateCompositorFrameSink( 42 void OffscreenCanvasSurfaceImpl::CreateCompositorFrameSink(
54 cc::mojom::MojoCompositorFrameSinkClientPtr client, 43 cc::mojom::MojoCompositorFrameSinkClientPtr client,
55 cc::mojom::MojoCompositorFrameSinkRequest request) { 44 cc::mojom::MojoCompositorFrameSinkRequest request) {
56 if (has_created_compositor_frame_sink_) { 45 if (has_created_compositor_frame_sink_) {
57 DLOG(ERROR) << "CreateCompositorFrameSink() called more than once."; 46 DLOG(ERROR) << "CreateCompositorFrameSink() called more than once.";
58 return; 47 return;
59 } 48 }
60 49
61 GetFrameSinkManagerHost()->CreateCompositorFrameSink( 50 GetFrameSinkManagerHost()->CreateCompositorFrameSink(
62 frame_sink_id_, std::move(request), 51 frame_sink_id_, std::move(request),
63 mojo::MakeRequest(&compositor_frame_sink_private_), std::move(client)); 52 mojo::MakeRequest(&compositor_frame_sink_private_), std::move(client));
64 53
65 GetFrameSinkManagerHost()->RegisterFrameSinkHierarchy(parent_frame_sink_id_, 54 GetFrameSinkManagerHost()->RegisterFrameSinkHierarchy(parent_frame_sink_id_,
66 frame_sink_id_); 55 frame_sink_id_);
67 has_created_compositor_frame_sink_ = true; 56 has_created_compositor_frame_sink_ = true;
68 } 57 }
69 58
70 void OffscreenCanvasSurfaceImpl::OnSurfaceCreated( 59 void OffscreenCanvasSurfaceImpl::OnSurfaceCreated(
71 const cc::SurfaceInfo& surface_info) { 60 const cc::SurfaceInfo& surface_info) {
72 DCHECK_EQ(surface_info.id().frame_sink_id(), frame_sink_id_); 61 if (surface_info.id().frame_sink_id() != frame_sink_id_)
73 if (!current_local_surface_id_.is_valid() || 62 return;
74 surface_info.id().local_surface_id() != current_local_surface_id_) { 63
75 current_local_surface_id_ = surface_info.id().local_surface_id(); 64 local_surface_id_ = surface_info.id().local_surface_id();
76 if (client_) 65 if (client_)
77 client_->OnSurfaceCreated(surface_info); 66 client_->OnSurfaceCreated(surface_info);
78 }
79 } 67 }
80 68
81 void OffscreenCanvasSurfaceImpl::Require(const cc::SurfaceId& surface_id, 69 void OffscreenCanvasSurfaceImpl::Require(const cc::SurfaceId& surface_id,
82 const cc::SurfaceSequence& sequence) { 70 const cc::SurfaceSequence& sequence) {
83 GetSurfaceManager()->RequireSequence(surface_id, sequence); 71 GetSurfaceManager()->RequireSequence(surface_id, sequence);
84 } 72 }
85 73
86 void OffscreenCanvasSurfaceImpl::Satisfy(const cc::SurfaceSequence& sequence) { 74 void OffscreenCanvasSurfaceImpl::Satisfy(const cc::SurfaceSequence& sequence) {
87 GetSurfaceManager()->SatisfySequence(sequence); 75 GetSurfaceManager()->SatisfySequence(sequence);
88 } 76 }
89 77
78 void OffscreenCanvasSurfaceImpl::OnSurfaceConnectionClosed() {
79 std::move(destroy_callback_).Run();
80 }
81
90 } // namespace content 82 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/offscreen_canvas_surface_impl.h ('k') | content/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698