| Index: services/ui/ws/frame_generator.h
|
| diff --git a/services/ui/ws/frame_generator.h b/services/ui/ws/frame_generator.h
|
| index ed38ee24dad99e4e8491a23c48728f1c50f0f0f3..ef3e5028dd2badceb18abc18d53049747e2caecc 100644
|
| --- a/services/ui/ws/frame_generator.h
|
| +++ b/services/ui/ws/frame_generator.h
|
| @@ -11,9 +11,7 @@
|
| #include "base/macros.h"
|
| #include "base/timer/timer.h"
|
| #include "cc/surfaces/frame_sink_id.h"
|
| -#include "cc/surfaces/local_frame_id.h"
|
| -#include "cc/surfaces/surface_sequence.h"
|
| -#include "cc/surfaces/surface_sequence_generator.h"
|
| +#include "cc/surfaces/surface_id.h"
|
| #include "services/ui/public/interfaces/window_tree_constants.mojom.h"
|
| #include "services/ui/ws/ids.h"
|
| #include "services/ui/ws/server_window_tracker.h"
|
| @@ -56,6 +54,21 @@ class FrameGenerator : public ServerWindowTracker,
|
| // Schedules a redraw for the provided region.
|
| void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget);
|
|
|
| + // Adds a reference to new surface with |surface_id| for |window|. This
|
| + // reference is to ensure the surface is not deleted while it's still being
|
| + // displayed. The display root surface has a reference from the top level
|
| + // root. All child surfaces are embedded by the display root and receive a
|
| + // reference from it.
|
| + //
|
| + // If a new display root Surface is created, then all child surfaces will
|
| + // receive a reference from the new display root so they are not deleted with
|
| + // the old display root.
|
| + //
|
| + // If there is an existing reference to an old surface with the same
|
| + // FrameSinkId then that reference will be removed after the next
|
| + // CompositorFrame is submitted.
|
| + void OnSurfaceCreated(const cc::SurfaceId& surface_id, ServerWindow* window);
|
| +
|
| private:
|
| friend class ui::ws::test::FrameGeneratorTest;
|
|
|
| @@ -74,27 +87,30 @@ class FrameGenerator : public ServerWindowTracker,
|
| const gfx::Vector2d& parent_to_root_origin_offset,
|
| float opacity);
|
|
|
| - // Adds a reference to the current cc::Surface of the provided
|
| - // |window_compositor_frame_sink|. If an existing reference is held with a
|
| - // different LocalFrameId then release that reference first. This is called on
|
| - // each ServerWindowCompositorFrameSink as FrameGenerator walks the window
|
| - // tree to generate a CompositorFrame. This is done to make sure that the
|
| - // window surfaces are retained for the entirety of the time between
|
| - // submission of the top-level frame to drawing the frame to screen.
|
| - // TODO(fsamuel, kylechar): This will go away once we get surface lifetime
|
| - // management.
|
| - void AddOrUpdateSurfaceReference(mojom::CompositorFrameSinkType type,
|
| - ServerWindow* window);
|
| -
|
| - // Releases any retained references for the provided FrameSink.
|
| - // TODO(fsamuel, kylechar): This will go away once we get surface lifetime
|
| - // management.
|
| - void ReleaseFrameSinkReference(const cc::FrameSinkId& frame_sink_id);
|
| -
|
| - // Releases all retained references to surfaces.
|
| - // TODO(fsamuel, kylechar): This will go away once we get surface lifetime
|
| - // management.
|
| - void ReleaseAllSurfaceReferences();
|
| + // Finds the parent surface id for |window|.
|
| + cc::SurfaceId FindParentSurfaceId(ServerWindow* window);
|
| +
|
| + // Adds surface reference to local cache and surface manager.
|
| + void AddSurfaceReference(const cc::SurfaceId& parent_id,
|
| + const cc::SurfaceId& child_id);
|
| +
|
| + // Does work necessary for adding the first surface reference.
|
| + void AddFirstReference(const cc::SurfaceId& surface_id, ServerWindow* window);
|
| +
|
| + // Finds all Surfaces with references from |old_surface_id| and adds a new
|
| + // reference from |new_surface_id|. The caller should remove any references
|
| + // to |old_surface_id| afterwards to finish cleanup.
|
| + void AddNewParentReferences(const cc::SurfaceId& old_surface_id,
|
| + const cc::SurfaceId& new_surface_id);
|
| +
|
| + // Removes all references to surfaces in |dead_references_|.
|
| + void RemoveDeadSurfaceReferences();
|
| +
|
| + // Removes any retained references for the provided FrameSink.
|
| + void RemoveFrameSinkReference(const cc::FrameSinkId& frame_sink_id);
|
| +
|
| + // Removes all retained references to surfaces.
|
| + void RemoveAllSurfaceReferences();
|
|
|
| ui::DisplayCompositor* GetDisplayCompositor();
|
|
|
| @@ -102,20 +118,36 @@ class FrameGenerator : public ServerWindowTracker,
|
| void OnWindowDestroying(ServerWindow* window) override;
|
|
|
| FrameGeneratorDelegate* delegate_;
|
| - cc::FrameSinkId frame_sink_id_;
|
| ServerWindow* const root_window_;
|
| - cc::SurfaceSequenceGenerator surface_sequence_generator_;
|
| scoped_refptr<gpu::GpuChannelHost> gpu_channel_;
|
|
|
| cc::mojom::MojoCompositorFrameSinkPtr compositor_frame_sink_;
|
| gfx::AcceleratedWidget widget_ = gfx::kNullAcceleratedWidget;
|
|
|
| - struct SurfaceDependency {
|
| - cc::LocalFrameId local_frame_id;
|
| - cc::SurfaceSequence sequence;
|
| + // Represents the top level root surface id that should reference the display
|
| + // root surface. We don't know the actual value, because it's generated in
|
| + // another process, this is used internally as a placeholder.
|
| + const cc::SurfaceId top_level_root_surface_id_;
|
| +
|
| + struct SurfaceReference {
|
| + cc::SurfaceId parent_id;
|
| + cc::SurfaceId child_id;
|
| };
|
| - std::unordered_map<cc::FrameSinkId, SurfaceDependency, cc::FrameSinkIdHash>
|
| - dependencies_;
|
| +
|
| + // Active references held by this client to surfaces that could be embedded in
|
| + // a CompositorFrame submitted from FrameGenerator.
|
| + std::unordered_map<cc::FrameSinkId, SurfaceReference, cc::FrameSinkIdHash>
|
| + active_references_;
|
| +
|
| + // References to surfaces that should be removed after a CompositorFrame has
|
| + // been submitted and the surfaces are not being used.
|
| + std::vector<SurfaceReference> dead_references_;
|
| +
|
| + // If a CompositorFrame for a child surface is submitted before the first
|
| + // display root CompositorFrame, we can't add a reference from the unknown
|
| + // display root SurfaceId. Track the child SurfaceId here and add a reference
|
| + // to it when the display root SurfaceId is available.
|
| + std::vector<cc::SurfaceId> waiting_for_references_;
|
|
|
| mojo::Binding<cc::mojom::MojoCompositorFrameSinkClient> binding_;
|
|
|
|
|