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

Side by Side Diff: components/exo/compositor_frame_sink_holder.cc

Issue 2868473002: Implement aura::Window::CreateCompositorFrameSink() (Closed)
Patch Set: Address review issues 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 | « components/exo/compositor_frame_sink_holder.h ('k') | components/exo/surface.h » ('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 "components/exo/compositor_frame_sink_holder.h" 5 #include "components/exo/compositor_frame_sink_holder.h"
6 6
7 #include "cc/output/compositor_frame_sink.h"
7 #include "cc/resources/returned_resource.h" 8 #include "cc/resources/returned_resource.h"
8 #include "components/exo/surface.h" 9 #include "components/exo/surface.h"
9 10
10 namespace exo { 11 namespace exo {
11 12
12 //////////////////////////////////////////////////////////////////////////////// 13 ////////////////////////////////////////////////////////////////////////////////
13 // CompositorFrameSinkHolder, public: 14 // CompositorFrameSinkHolder, public:
14 15
15 CompositorFrameSinkHolder::CompositorFrameSinkHolder( 16 CompositorFrameSinkHolder::CompositorFrameSinkHolder(
16 Surface* surface, 17 Surface* surface,
17 const cc::FrameSinkId& frame_sink_id, 18 std::unique_ptr<cc::CompositorFrameSink> frame_sink)
18 cc::SurfaceManager* surface_manager)
19 : surface_(surface), 19 : surface_(surface),
20 frame_sink_( 20 frame_sink_(std::move(frame_sink)),
21 new CompositorFrameSink(frame_sink_id, surface_manager, this)),
22 begin_frame_source_(base::MakeUnique<cc::ExternalBeginFrameSource>(this)),
23 weak_factory_(this) { 21 weak_factory_(this) {
24 surface_->AddSurfaceObserver(this); 22 surface_->AddSurfaceObserver(this);
25 surface_->SetBeginFrameSource(begin_frame_source_.get()); 23 frame_sink_->BindToClient(this);
24 }
25
26 CompositorFrameSinkHolder::~CompositorFrameSinkHolder() {
27 frame_sink_->DetachFromClient();
28 if (surface_)
29 surface_->RemoveSurfaceObserver(this);
30
31 // Release all resources which aren't returned from CompositorFrameSink.
32 for (auto& callback : release_callbacks_)
33 callback.second.Run(gpu::SyncToken(), false);
26 } 34 }
27 35
28 bool CompositorFrameSinkHolder::HasReleaseCallbackForResource( 36 bool CompositorFrameSinkHolder::HasReleaseCallbackForResource(
29 cc::ResourceId id) { 37 cc::ResourceId id) {
30 return release_callbacks_.find(id) != release_callbacks_.end(); 38 return release_callbacks_.find(id) != release_callbacks_.end();
31 } 39 }
32 40
33 void CompositorFrameSinkHolder::SetResourceReleaseCallback( 41 void CompositorFrameSinkHolder::SetResourceReleaseCallback(
34 cc::ResourceId id, 42 cc::ResourceId id,
35 const cc::ReleaseCallback& callback) { 43 const cc::ReleaseCallback& callback) {
36 DCHECK(!callback.is_null()); 44 DCHECK(!callback.is_null());
37 release_callbacks_[id] = callback; 45 release_callbacks_[id] = callback;
38 } 46 }
39 47
40 //////////////////////////////////////////////////////////////////////////////// 48 ////////////////////////////////////////////////////////////////////////////////
41 // cc::mojom::MojoCompositorFrameSinkClient overrides: 49 // cc::CompositorFrameSinkClient overrides:
42 50
43 void CompositorFrameSinkHolder::DidReceiveCompositorFrameAck( 51 void CompositorFrameSinkHolder::SetBeginFrameSource(
44 const cc::ReturnedResourceArray& resources) { 52 cc::BeginFrameSource* source) {
45 ReclaimResources(resources);
46 if (surface_) 53 if (surface_)
47 surface_->DidReceiveCompositorFrameAck(); 54 surface_->SetBeginFrameSource(source);
48 }
49
50 void CompositorFrameSinkHolder::OnBeginFrame(const cc::BeginFrameArgs& args) {
51 begin_frame_source_->OnBeginFrame(args);
52 } 55 }
53 56
54 void CompositorFrameSinkHolder::ReclaimResources( 57 void CompositorFrameSinkHolder::ReclaimResources(
55 const cc::ReturnedResourceArray& resources) { 58 const cc::ReturnedResourceArray& resources) {
56 for (auto& resource : resources) { 59 for (auto& resource : resources) {
57 auto it = release_callbacks_.find(resource.id); 60 auto it = release_callbacks_.find(resource.id);
58 DCHECK(it != release_callbacks_.end()); 61 DCHECK(it != release_callbacks_.end());
59 if (it != release_callbacks_.end()) { 62 if (it != release_callbacks_.end()) {
60 it->second.Run(resource.sync_token, resource.lost); 63 it->second.Run(resource.sync_token, resource.lost);
61 release_callbacks_.erase(it); 64 release_callbacks_.erase(it);
62 } 65 }
63 } 66 }
64 } 67 }
65 68
66 //////////////////////////////////////////////////////////////////////////////// 69 void CompositorFrameSinkHolder::DidReceiveCompositorFrameAck() {
67 // cc::ExternalBeginFrameSourceClient overrides: 70 if (surface_)
68 71 surface_->DidReceiveCompositorFrameAck();
69 void CompositorFrameSinkHolder::OnNeedsBeginFrames(bool needs_begin_frames) {
70 frame_sink_->SetNeedsBeginFrame(needs_begin_frames);
71 }
72
73 void CompositorFrameSinkHolder::OnDidFinishFrame(const cc::BeginFrameAck& ack) {
74 // If there was damage, the submitted CompositorFrame includes the ack.
75 if (!ack.has_damage)
76 frame_sink_->BeginFrameDidNotSwap(ack);
77 } 72 }
78 73
79 //////////////////////////////////////////////////////////////////////////////// 74 ////////////////////////////////////////////////////////////////////////////////
80 // SurfaceObserver overrides: 75 // SurfaceObserver overrides:
81 76
82 void CompositorFrameSinkHolder::OnSurfaceDestroying(Surface* surface) { 77 void CompositorFrameSinkHolder::OnSurfaceDestroying(Surface* surface) {
83 surface_->RemoveSurfaceObserver(this); 78 surface_->RemoveSurfaceObserver(this);
84 surface_ = nullptr; 79 surface_ = nullptr;
85 } 80 }
86 81
87 ////////////////////////////////////////////////////////////////////////////////
88 // ExoComopositorFrameSink, private:
89
90 CompositorFrameSinkHolder::~CompositorFrameSinkHolder() {
91 if (surface_)
92 surface_->RemoveSurfaceObserver(this);
93 }
94
95 } // namespace exo 82 } // namespace exo
OLDNEW
« no previous file with comments | « components/exo/compositor_frame_sink_holder.h ('k') | components/exo/surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698