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

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

Issue 1412093006: components: Add Exosphere component. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 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 2015 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 #ifndef COMPONENTS_EXO_SURFACE_H_
6 #define COMPONENTS_EXO_SURFACE_H_
7
8 #include <list>
9
10 #include "base/callback.h"
11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "cc/base/region.h"
14 #include "cc/resources/texture_mailbox.h"
15 #include "ui/compositor/compositor_observer.h"
16 #include "ui/gfx/geometry/rect.h"
17 #include "ui/views/view.h"
18
19 namespace base {
20 namespace trace_event {
21 class TracedValue;
22 }
23 }
24
25 namespace cc {
26 class SingleReleaseCallback;
27 }
28
29 namespace exo {
30 class Buffer;
31 class SurfaceDelegate;
32
33 // This class represents a rectangular area that is displayed on the screen.
34 // It has a location, size and pixel contents.
35 class Surface : public views::View, public ui::CompositorObserver {
36 public:
37 Surface();
38 ~Surface() override;
39
40 // Set a buffer as the content of this surface. A buffer can only be attached
41 // to one surface at a time.
42 void Attach(Buffer* buffer, const gfx::Point& point);
43
44 // Describe the regions where the pending buffer is different from the
45 // current surface contents, and where the surface therefore needs to be
46 // repainted.
47 void Damage(const gfx::Rect& rect);
48
49 // Request notification when the next frame is displayed. Useful for
50 // throttling redrawing operations, and driving animations.
51 using FrameCallback = base::Callback<void(base::TimeTicks frame_time)>;
52 void RequestFrameCallback(const FrameCallback& callback);
53
54 // This sets the region of the surface that contains opaque content.
55 void SetOpaqueRegion(const cc::Region& region);
56
57 // Surface state (damage regions, attached buffers, etc.) is double-buffered.
58 // A Commit() call atomically applies all pending state, replacing the
59 // current state.
60 void Commit();
61
62 // Set the surface delegate.
63 void SetSurfaceDelegate(SurfaceDelegate* delegate);
64
65 // Returns a trace value representing the state of the surface.
66 scoped_refptr<base::trace_event::TracedValue> AsTracedValue() const;
67
68 bool HasPendingDamageForTesting() const { return !pending_damage_.IsEmpty(); }
69
70 // Overridden from views::View:
71 gfx::Size GetPreferredSize() const override;
72
73 // Overridden from ui::CompositorObserver:
74 void OnCompositingDidCommit(ui::Compositor* compositor) override;
75 void OnCompositingStarted(ui::Compositor* compositor,
76 base::TimeTicks start_time) override;
77 void OnCompositingEnded(ui::Compositor* compositor) override {}
78 void OnCompositingAborted(ui::Compositor* compositor) override {}
79 void OnCompositingLockStateChanged(ui::Compositor* compositor) override {}
80 void OnCompositingShuttingDown(ui::Compositor* compositor) override;
81
82 private:
83 // The mailbox to be used by |layer_| after next call to Commit().
84 cc::TextureMailbox pending_mailbox_;
85
86 // The callback to release the pending mailbox. This is set when Attach()
87 // is called, we give it to the Layer when Commit() is called.
88 scoped_ptr<cc::SingleReleaseCallback> pending_mailbox_release_callback_;
89
90 // The damage region to schedule paint for when Commit() is called.
91 // TODO(reveman): Use cc::Region here after adding a version of
92 // ui::Layer::SchedulePaint that takes a cc::Region.
93 gfx::Rect pending_damage_;
94
95 // These lists contains the callbacks to notify the client when it is a good
96 // time to start producing a new frame. These callbacks move to
97 // |frame_callbacks_| when Commit() is called. Later they are moved to
98 // |active_frame_callbacks_| when the effect of the Commit() is reflected in
99 // the compositor's active layer tree. The callbacks fire once we're notified
100 // that the compositor started drawing that active layer tree.
101 std::list<FrameCallback> pending_frame_callbacks_;
102 std::list<FrameCallback> frame_callbacks_;
103 std::list<FrameCallback> active_frame_callbacks_;
104
105 // The opaque region to take effect when Commit() is called.
106 cc::Region pending_opaque_region_;
107
108 // The compsitor being observer or null if not observing a compositor.
109 ui::Compositor* compositor_;
110
111 // This can be set to have some functions delegated. E.g. ShellSurface class
112 // can set this to handle Commit() and apply any double buffered state it
113 // maintains.
114 SurfaceDelegate* delegate_;
115
116 DISALLOW_COPY_AND_ASSIGN(Surface);
117 };
118
119 } // namespace exo
120
121 #endif // COMPONENTS_EXO_SURFACE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698