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

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

Powered by Google App Engine
This is Rietveld 408576698