Index: components/exo/surface.h |
diff --git a/components/exo/surface.h b/components/exo/surface.h |
index 158a78c42da86d77c5ebd6ccdcf69f276849b359..10d105189f6a74bf31dc6d8f5828da30eb320f0e 100644 |
--- a/components/exo/surface.h |
+++ b/components/exo/surface.h |
@@ -6,10 +6,12 @@ |
#define COMPONENTS_EXO_SURFACE_H_ |
#include <list> |
+#include <utility> |
#include "base/callback.h" |
#include "base/macros.h" |
#include "base/memory/weak_ptr.h" |
+#include "base/observer_list.h" |
#include "cc/base/region.h" |
#include "third_party/skia/include/core/SkRegion.h" |
#include "ui/compositor/compositor_observer.h" |
@@ -25,6 +27,7 @@ class TracedValue; |
namespace exo { |
class Buffer; |
class SurfaceDelegate; |
+class SurfaceObserver; |
// This class represents a rectangular area that is displayed on the screen. |
// It has a location, size and pixel contents. |
@@ -50,14 +53,40 @@ class Surface : public views::View, public ui::CompositorObserver { |
// This sets the region of the surface that contains opaque content. |
void SetOpaqueRegion(const SkRegion& region); |
+ // Functions that control sub-surface state. All sub-surface state is |
+ // double-buffered and will be applied when Commit() is called. |
+ void AddSubSurface(Surface* sub_surface); |
+ void RemoveSubSurface(Surface* sub_surface); |
+ void SetSubSurfacePosition(Surface* sub_surface, const gfx::Point& position); |
+ void PlaceSubSurfaceAbove(Surface* sub_surface, Surface* reference); |
+ void PlaceSubSurfaceBelow(Surface* sub_surface, Surface* sibling); |
+ |
// Surface state (damage regions, attached buffers, etc.) is double-buffered. |
// A Commit() call atomically applies all pending state, replacing the |
- // current state. |
+ // current state. Commit() is not guaranteed to be synchronous. See |
+ // CommitSurfaceHierarchy() below. |
void Commit(); |
+ // This will synchronously commit all pending state of the surface and its |
+ // descendants by recursively calling CommitSurfaceHierarchy() for each |
+ // sub-surface with pending state. |
+ void CommitSurfaceHierarchy(); |
+ |
+ // Returns true if surface is in synchronized mode. |
+ bool IsSynchronized() const; |
+ |
// Set the surface delegate. |
void SetSurfaceDelegate(SurfaceDelegate* delegate); |
+ // Returns true if surface has been assigned a surface delegate. |
+ bool HasSurfaceDelegate() const; |
+ |
+ // Surface does not own observers. It is the responsibility of the observer |
+ // to remove itself when it is done observing. |
+ void AddSurfaceObserver(SurfaceObserver* observer); |
+ void RemoveSurfaceObserver(SurfaceObserver* observer); |
+ bool HasSurfaceObserver(const SurfaceObserver* observer) const; |
+ |
// Returns a trace value representing the state of the surface. |
scoped_refptr<base::trace_event::TracedValue> AsTracedValue() const; |
@@ -76,6 +105,12 @@ class Surface : public views::View, public ui::CompositorObserver { |
void OnCompositingShuttingDown(ui::Compositor* compositor) override; |
private: |
+ bool needs_commit_surface_hierarchy() const { |
+ return needs_commit_surface_hierarchy_; |
+ } |
+ |
+ bool has_contents() const { return has_contents_; } |
+ |
// The buffer that will become the content of surface when Commit() is called. |
base::WeakPtr<Buffer> pending_buffer_; |
@@ -97,6 +132,20 @@ class Surface : public views::View, public ui::CompositorObserver { |
// The opaque region to take effect when Commit() is called. |
SkRegion pending_opaque_region_; |
+ // The stack of sub-surfaces to take effect when Commit() is called. |
+ // Bottom-most sub-surface at the front of the list and top-most sub-surface |
+ // at the back. |
+ using SubSurfaceEntry = std::pair<Surface*, gfx::Point>; |
+ using SubSurfaceEntryList = std::list<SubSurfaceEntry>; |
+ SubSurfaceEntryList pending_sub_surfaces_; |
+ |
+ // This is true if a call to Commit() as been made but |
+ // CommitSurfaceHierarchy() has not yet been called. |
+ bool needs_commit_surface_hierarchy_; |
+ |
+ // This is true when surface has some contents assigned to it. |
+ bool has_contents_; |
+ |
// The compsitor being observer or null if not observing a compositor. |
ui::Compositor* compositor_; |
@@ -105,6 +154,9 @@ class Surface : public views::View, public ui::CompositorObserver { |
// maintains. |
SurfaceDelegate* delegate_; |
+ // Surface observer list. Surface does not own the observers. |
+ base::ObserverList<SurfaceObserver, true> observers_; |
+ |
DISALLOW_COPY_AND_ASSIGN(Surface); |
}; |