OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "components/exo/exo_compositor_frame_sink.h" | |
6 | |
7 #include "cc/surfaces/surface_manager.h" | |
8 #include "ui/aura/env.h" | |
9 | |
10 namespace exo { | |
11 | |
12 //////////////////////////////////////////////////////////////////////////////// | |
13 // ExoComopositorFrameSink, public: | |
14 | |
15 ExoCompositorFrameSink::ExoCompositorFrameSink( | |
16 const cc::FrameSinkId& frame_sink_id, | |
17 cc::SurfaceManager* surface_manager) | |
18 : frame_sink_id_(frame_sink_id), | |
19 surface_manager_(surface_manager), | |
20 surface_factory_(frame_sink_id, surface_manager, this) { | |
21 surface_manager_->RegisterFrameSinkId(frame_sink_id_); | |
22 surface_manager_->RegisterSurfaceFactoryClient(frame_sink_id_, this); | |
23 } | |
24 | |
25 //////////////////////////////////////////////////////////////////////////////// | |
26 // cc::SurfaceFactoryClient overrides: | |
27 | |
28 void ExoCompositorFrameSink::ReturnResources( | |
29 const cc::ReturnedResourceArray& resources) { | |
30 for (auto& resource : resources) { | |
Fady Samuel
2016/11/16 21:29:40
So I see the problem here. This should actually ha
jbauman
2016/11/16 22:01:56
The release callbacks can outlive the exo::Surface
| |
31 auto it = release_callbacks_.find(resource.id); | |
32 DCHECK(it != release_callbacks_.end()); | |
33 it->second.second->Run(resource.sync_token, resource.lost); | |
34 release_callbacks_.erase(it); | |
35 } | |
36 } | |
37 | |
38 void ExoCompositorFrameSink::WillDrawSurface(const cc::LocalFrameId& id, | |
39 const gfx::Rect& damage_rect) {} | |
40 | |
41 void ExoCompositorFrameSink::SetBeginFrameSource( | |
42 cc::BeginFrameSource* begin_frame_source) { | |
43 if (begin_frame_source_ && added_frame_observer_) { | |
44 begin_frame_source_->RemoveObserver(this); | |
45 added_frame_observer_ = false; | |
46 } | |
47 begin_frame_source_ = begin_frame_source; | |
48 UpdateNeedsBeginFrameInternal(); | |
49 } | |
50 | |
51 //////////////////////////////////////////////////////////////////////////////// | |
52 // To be cc::mojom::MojoCompositorFrameSink overrides: | |
53 | |
54 void ExoCompositorFrameSink::SubmitCompositorFrame( | |
55 cc::CompositorFrame frame, | |
56 const cc::LocalFrameId& local_frame_id) { | |
57 if (local_frame_id != last_local_frame_id_) { | |
58 surface_factory_.Create(local_frame_id); | |
59 } | |
60 // UpdateSurface(true); // surface_factory.SubmitCompositorFrame happens here | |
61 surface_factory_.SubmitCompositorFrame(local_frame_id, std::move(frame), | |
62 cc::SurfaceFactory::DrawCallback()); | |
63 if (last_local_frame_id_.is_valid() && | |
64 local_frame_id != last_local_frame_id_) { | |
65 surface_factory_.SetPreviousFrameSurface(local_frame_id, | |
66 last_local_frame_id_); | |
67 surface_factory_.Destroy(last_local_frame_id_); | |
68 } | |
69 last_local_frame_id_ = local_frame_id; | |
70 } | |
71 | |
72 //////////////////////////////////////////////////////////////////////////////// | |
73 // cc::BeginFrameObserver overrides: | |
74 | |
75 void ExoCompositorFrameSink::OnBeginFrame(const cc::BeginFrameArgs& args) { | |
76 UpdateNeedsBeginFrameInternal(); | |
77 last_begin_frame_args_ = args; | |
78 } | |
79 | |
80 const cc::BeginFrameArgs& ExoCompositorFrameSink::LastUsedBeginFrameArgs() | |
81 const { | |
82 return last_begin_frame_args_; | |
83 } | |
84 | |
85 void ExoCompositorFrameSink::OnBeginFrameSourcePausedChanged(bool paused) {} | |
86 | |
87 //////////////////////////////////////////////////////////////////////////////// | |
88 // ExoComopositorFrameSink, private: | |
89 | |
90 ExoCompositorFrameSink::~ExoCompositorFrameSink() { | |
91 if (last_local_frame_id_.is_valid()) | |
92 surface_factory_.Destroy(last_local_frame_id_); | |
93 | |
94 if (surface_factory_.manager()) | |
95 surface_factory_.manager()->InvalidateFrameSinkId(frame_sink_id_); | |
96 } | |
97 | |
98 void ExoCompositorFrameSink::UpdateNeedsBeginFrameInternal() { | |
99 if (!begin_frame_source_) | |
100 return; | |
101 | |
102 if (needs_begin_frame_ == added_frame_observer_) | |
103 return; | |
104 | |
105 added_frame_observer_ = needs_begin_frame_; | |
106 if (needs_begin_frame_) | |
107 begin_frame_source_->AddObserver(this); | |
108 else | |
109 begin_frame_source_->RemoveObserver(this); | |
110 } | |
111 | |
112 void ExoCompositorFrameSink::DidRecieveCompositorFrameAck() { | |
113 // TODO(staraz): Clean up resources | |
114 ack_pending_count_--; | |
115 } | |
116 | |
117 } // namespace exo | |
OLD | NEW |