| Index: components/exo/surface.h
|
| diff --git a/components/exo/surface.h b/components/exo/surface.h
|
| index 4db760ee667bd9d554ec78335cc3e0cbf1c34d67..0bb6b98b383070bb14fbce39c196ff9ab503ab99 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 "third_party/skia/include/core/SkRegion.h"
|
| #include "ui/compositor/compositor_observer.h"
|
| #include "ui/gfx/geometry/rect.h"
|
| @@ -24,6 +26,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.
|
| @@ -49,14 +52,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;
|
|
|
| @@ -75,6 +104,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_;
|
|
|
| @@ -96,6 +131,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_;
|
|
|
| @@ -104,6 +153,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);
|
| };
|
|
|
|
|