| Index: components/exo/surface.h
|
| diff --git a/components/exo/surface.h b/components/exo/surface.h
|
| index 744587db667507e671e4996c4dfc6d5276691dc9..91c904290e83daf3a5193bb5cda448b2ebc49bf0 100644
|
| --- a/components/exo/surface.h
|
| +++ b/components/exo/surface.h
|
| @@ -16,11 +16,12 @@
|
| #include "base/memory/weak_ptr.h"
|
| #include "base/observer_list.h"
|
| #include "cc/resources/transferable_resource.h"
|
| +#include "cc/scheduler/begin_frame_source.h"
|
| #include "cc/surfaces/surface_factory_client.h"
|
| #include "third_party/skia/include/core/SkRegion.h"
|
| #include "third_party/skia/include/core/SkXfermode.h"
|
| #include "ui/aura/window.h"
|
| -#include "ui/compositor/compositor.h"
|
| +#include "ui/aura/window_observer.h"
|
| #include "ui/gfx/geometry/rect.h"
|
|
|
| namespace base {
|
| @@ -88,7 +89,9 @@ class SurfaceFactoryOwner : public base::RefCounted<SurfaceFactoryOwner>,
|
|
|
| // This class represents a rectangular area that is displayed on the screen.
|
| // It has a location, size and pixel contents.
|
| -class Surface : public ui::ContextFactoryObserver {
|
| +class Surface : public ui::ContextFactoryObserver,
|
| + public aura::WindowObserver,
|
| + public cc::BeginFrameObserver {
|
| public:
|
| using PropertyDeallocator = void (*)(int64_t value);
|
|
|
| @@ -204,21 +207,32 @@ class Surface : public ui::ContextFactoryObserver {
|
| // Returns a trace value representing the state of the surface.
|
| std::unique_ptr<base::trace_event::TracedValue> AsTracedValue() const;
|
|
|
| - bool HasPendingDamageForTesting(const gfx::Rect& damage) const {
|
| - return pending_damage_.contains(gfx::RectToSkIRect(damage));
|
| - }
|
| -
|
| - // Overridden from ui::ContextFactoryObserver.
|
| - void OnLostResources() override;
|
| + // Called when surface is being scheduled for a draw.
|
| + void WillDraw();
|
|
|
| - void WillDraw(const cc::LocalFrameId& local_frame_id);
|
| + // Called when the begin frame source has changed.
|
| + void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source);
|
|
|
| // Check whether this Surface and its children need to create new cc::Surface
|
| // IDs for their contents next time they get new buffer contents.
|
| void CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces();
|
|
|
| + // Returns the active contents size.
|
| gfx::Size content_size() const { return content_size_; }
|
|
|
| + // Overridden from ui::ContextFactoryObserver:
|
| + void OnLostResources() override;
|
| +
|
| + // Overridden from aura::WindowObserver:
|
| + void OnWindowAddedToRootWindow(aura::Window* window) override;
|
| + void OnWindowRemovingFromRootWindow(aura::Window* window,
|
| + aura::Window* new_root) override;
|
| +
|
| + // Overridden from cc::BeginFrameObserver:
|
| + void OnBeginFrame(const cc::BeginFrameArgs& args) override;
|
| + const cc::BeginFrameArgs& LastUsedBeginFrameArgs() const override;
|
| + void OnBeginFrameSourcePausedChanged(bool paused) override {}
|
| +
|
| // Sets the |value| of the given surface |property|. Setting to the default
|
| // value (e.g., NULL) removes the property. The caller is responsible for the
|
| // lifetime of any object set as a property on the Surface.
|
| @@ -235,6 +249,10 @@ class Surface : public ui::ContextFactoryObserver {
|
| template <typename T>
|
| void ClearProperty(const SurfaceProperty<T>* property);
|
|
|
| + bool HasPendingDamageForTesting(const gfx::Rect& damage) const {
|
| + return pending_damage_.contains(gfx::RectToSkIRect(damage));
|
| + }
|
| +
|
| private:
|
| struct State {
|
| State();
|
| @@ -295,6 +313,9 @@ class Surface : public ui::ContextFactoryObserver {
|
| // current_resource_.
|
| void UpdateSurface(bool full_damage);
|
|
|
| + // Adds/Removes begin frame observer based on state.
|
| + void UpdateNeedsBeginFrame();
|
| +
|
| int64_t SetPropertyInternal(const void* key,
|
| const char* name,
|
| PropertyDeallocator deallocator,
|
| @@ -344,9 +365,8 @@ class Surface : public ui::ContextFactoryObserver {
|
| // These lists contains the callbacks to notify the client when it is a good
|
| // time to start producing a new frame. These callbacks move to
|
| // |frame_callbacks_| when Commit() is called. Later they are moved to
|
| - // |active_frame_callbacks_| when the effect of the Commit() is reflected in
|
| - // the compositor's active layer tree. The callbacks fire once we're notified
|
| - // that the compositor started drawing that active layer tree.
|
| + // |active_frame_callbacks_| when the effect of the Commit() is scheduled to
|
| + // be drawn. They fire at the first begin frame notification after this.
|
| std::list<FrameCallback> pending_frame_callbacks_;
|
| std::list<FrameCallback> frame_callbacks_;
|
| std::list<FrameCallback> active_frame_callbacks_;
|
| @@ -386,6 +406,11 @@ class Surface : public ui::ContextFactoryObserver {
|
| // maintains.
|
| SurfaceDelegate* delegate_ = nullptr;
|
|
|
| + // The begin frame source being observed.
|
| + cc::BeginFrameSource* begin_frame_source_ = nullptr;
|
| + cc::BeginFrameArgs last_begin_frame_args_;
|
| + bool needs_begin_frame_ = false;
|
| +
|
| struct Value {
|
| const char* name;
|
| int64_t value;
|
|
|