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

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

Issue 2493223002: Change exo::SurfaceFactoryOwner to exo::ExoCompositorFrameSink (Closed)
Patch Set: rebase Created 4 years, 1 month 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/exo_compositor_frame_sink.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
(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 : frame_sink_id_(frame_sink_id) {
18 id_allocator_.reset(new cc::SurfaceIdAllocator());
19 }
20
21 void ExoCompositorFrameSink::Init(cc::SurfaceManager* surface_manager) {
22 surface_factory_.reset(
23 new cc::SurfaceFactory(frame_sink_id_, surface_manager, this));
24 }
25
26 void ExoCompositorFrameSink::UnregisterSurface(
27 const cc::SurfaceId& surface_id) {
28 if (surface_id.local_frame_id().is_valid())
29 surface_factory_->Destroy(surface_id.local_frame_id());
30 }
31
32 const cc::SurfaceId& ExoCompositorFrameSink::CommitToNewSurface(
33 const cc::LocalFrameId& old_local_frame_id) {
34 cc::LocalFrameId local_frame_id = id_allocator_->GenerateId();
35 surface_factory_->Create(local_frame_id);
36
37 if (old_local_frame_id.is_valid()) {
38 surface_factory_->SetPreviousFrameSurface(local_frame_id,
39 old_local_frame_id);
40 surface_factory_->Destroy(old_local_frame_id);
41 }
42
43 return std::move(cc::SurfaceId(frame_sink_id_, local_frame_id));
Fady Samuel 2016/11/15 16:01:32 This isn't safe. You're returning a reference to a
Alex Z. 2016/11/15 22:27:30 Done.
44 }
45 ////////////////////////////////////////////////////////////////////////////////
46 // cc::SurfaceFactoryClient overrides:
47
48 void ExoCompositorFrameSink::ReturnResources(
49 const cc::ReturnedResourceArray& resources) {
50 for (auto& resource : resources) {
51 auto it = release_callbacks_.find(resource.id);
52 DCHECK(it != release_callbacks_.end());
53 it->second.second->Run(resource.sync_token, resource.lost);
54 release_callbacks_.erase(it);
55 }
56 }
57
58 void ExoCompositorFrameSink::WillDrawSurface(const cc::LocalFrameId& id,
59 const gfx::Rect& damage_rect) {}
60
61 void ExoCompositorFrameSink::SetBeginFrameSource(
62 cc::BeginFrameSource* begin_frame_source) {
63 if (begin_frame_source_ && added_frame_observer_) {
64 begin_frame_source_->RemoveObserver(this);
65 added_frame_observer_ = false;
66 }
67 begin_frame_source_ = begin_frame_source;
68 UpdateNeedsBeginFrameInternal();
69 }
70
71 ////////////////////////////////////////////////////////////////////////////////
72 // cc::BeginFrameObserver overrides:
73
74 void ExoCompositorFrameSink::OnBeginFrame(const cc::BeginFrameArgs& args) {
75 UpdateNeedsBeginFrameInternal();
76 last_begin_frame_args_ = args;
77 }
78
79 const cc::BeginFrameArgs& ExoCompositorFrameSink::LastUsedBeginFrameArgs()
80 const {
81 return last_begin_frame_args_;
82 }
83
84 void ExoCompositorFrameSink::OnBeginFrameSourcePausedChanged(bool paused) {}
85
86 ////////////////////////////////////////////////////////////////////////////////
87 // ExoComopositorFrameSink, private:
88
89 ExoCompositorFrameSink::~ExoCompositorFrameSink() {
90 if (surface_factory_->manager())
91 surface_factory_->manager()->InvalidateFrameSinkId(frame_sink_id_);
92 }
93
94 void ExoCompositorFrameSink::UpdateNeedsBeginFrameInternal() {
95 if (!begin_frame_source_)
96 return;
97
98 if (needs_begin_frame_ == added_frame_observer_)
99 return;
100
101 added_frame_observer_ = needs_begin_frame_;
102 if (needs_begin_frame_)
103 begin_frame_source_->AddObserver(this);
104 else
105 begin_frame_source_->RemoveObserver(this);
106 }
107
108 } // namespace exo
OLDNEW
« no previous file with comments | « components/exo/exo_compositor_frame_sink.h ('k') | components/exo/surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698