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

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

Issue 2493223002: Change exo::SurfaceFactoryOwner to exo::ExoCompositorFrameSink (Closed)
Patch Set: Moved ExoCompositorFrameSink into its own file 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
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 <list>
6 #include <memory>
7 #include <set>
8 #include <utility>
9
10 #include "base/callback.h"
11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/weak_ptr.h"
14 #include "base/observer_list.h"
15 #include "cc/ipc/compositor_frame.mojom.h"
16 #include "cc/ipc/mojo_compositor_frame_sink.mojom.h"
17 #include "cc/resources/transferable_resource.h"
18 #include "cc/scheduler/begin_frame_source.h"
19 #include "cc/surfaces/surface_factory.h"
20 #include "cc/surfaces/surface_factory_client.h"
21 #include "cc/surfaces/surface_id_allocator.h"
22 #include "mojo/public/cpp/bindings/binding.h"
23 #include "third_party/skia/include/core/SkRegion.h"
24 #include "third_party/skia/include/core/SkXfermode.h"
25 #include "ui/aura/window.h"
26 #include "ui/aura/window_observer.h"
27 #include "ui/gfx/geometry/rect.h"
28
29 namespace cc {
30 class SurfaceFactory;
31 }
32
33 namespace exo {
34
35 // This class owns the SurfaceFactory and keeps track of references to the
36 // contents of Buffers. It's keeped alive by references from
37 // release_callbacks_. It's destroyed when its owning Surface is destroyed and
38 // the last outstanding release callback is called.
39 class ExoCompositorFrameSink : public base::RefCounted<ExoCompositorFrameSink>,
40 public cc::SurfaceFactoryClient,
41 public cc::BeginFrameObserver {
42 public:
43 ExoCompositorFrameSink();
44
45 void Init(cc::SurfaceManager* surface_manager);
46 void UnregisterSurface(const cc::SurfaceId& surface_id);
47 const cc::SurfaceId& CommitToNewSurface(
48 const cc::LocalFrameId& old_local_frame_id);
49
50 // Overridden from cc::SurfaceFactoryClient:
51 void ReturnResources(const cc::ReturnedResourceArray& resources) override;
52 void WillDrawSurface(const cc::LocalFrameId& id,
53 const gfx::Rect& damage_rect) override;
54 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override;
55
56 // cc::mojom::MojoCompositorFrameSink:
57 void SetNeedsBeginFrame(bool needs_begin_frame);
58 void SubmitCompositorFrame(cc::CompositorFrame frame);
59
60 // cc::BeginFrameObserver:
61 void OnBeginFrame(const cc::BeginFrameArgs& args) override;
62 const cc::BeginFrameArgs& LastUsedBeginFrameArgs() const override;
63 void OnBeginFrameSourcePausedChanged(bool paused) override;
64
65 const cc::FrameSinkId& frame_sink_id() { return frame_sink_id_; }
66
67 private:
68 friend class base::RefCounted<ExoCompositorFrameSink>;
69 friend class Surface;
70
71 ~ExoCompositorFrameSink() override;
72 void UpdateNeedsBeginFrameInternal();
73
74 std::map<int,
75 std::pair<scoped_refptr<ExoCompositorFrameSink>,
76 std::unique_ptr<cc::SingleReleaseCallback>>>
77 release_callbacks_;
78 cc::BeginFrameSource* begin_frame_source_ = nullptr;
79 cc::BeginFrameArgs last_begin_frame_args_;
80 cc::FrameSinkId frame_sink_id_;
81 std::unique_ptr<cc::SurfaceIdAllocator> id_allocator_;
82 std::unique_ptr<cc::SurfaceFactory> surface_factory_;
83
84 bool needs_begin_frame_ = false;
85 bool added_frame_observer_ = false;
86 };
87
88 } // namespace exo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698