| Index: components/display_compositor/display_compositor.h
|
| diff --git a/components/display_compositor/display_compositor.h b/components/display_compositor/display_compositor.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..030018ef0b3a357ce05c8ce0631bcf865220c211
|
| --- /dev/null
|
| +++ b/components/display_compositor/display_compositor.h
|
| @@ -0,0 +1,105 @@
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef COMPONENTS_DISPLAY_COMPOSITOR_DISPLAY_COMPOSITOR_H_
|
| +#define COMPONENTS_DISPLAY_COMPOSITOR_DISPLAY_COMPOSITOR_H_
|
| +
|
| +#include <stdint.h>
|
| +
|
| +#include <memory>
|
| +#include <unordered_map>
|
| +
|
| +#include "base/macros.h"
|
| +#include "base/threading/thread_checker.h"
|
| +#include "cc/ipc/display_compositor.mojom.h"
|
| +#include "cc/surfaces/frame_sink_id.h"
|
| +#include "cc/surfaces/local_surface_id.h"
|
| +#include "cc/surfaces/surface_id.h"
|
| +#include "cc/surfaces/surface_manager.h"
|
| +#include "cc/surfaces/surface_observer.h"
|
| +#include "components/display_compositor/display_compositor_export.h"
|
| +#include "components/display_compositor/gpu_compositor_frame_sink_delegate.h"
|
| +#include "mojo/public/cpp/bindings/binding.h"
|
| +
|
| +namespace display_compositor {
|
| +
|
| +class GpuCompositorFrameSink;
|
| +
|
| +// The DisplayCompositor object is an object global to the Window Server app
|
| +// that holds the SurfaceServer and allocates new Surfaces namespaces.
|
| +// This object lives on the main thread of the Window Server.
|
| +// TODO(rjkroege, fsamuel): This object will need to change to support multiple
|
| +// displays.
|
| +class DISPLAY_COMPOSITOR_EXPORT DisplayCompositor
|
| + : public cc::SurfaceObserver,
|
| + public GpuCompositorFrameSinkDelegate,
|
| + public cc::mojom::DisplayCompositor {
|
| + public:
|
| + DisplayCompositor();
|
| + DisplayCompositor(cc::mojom::DisplayCompositorRequest request,
|
| + cc::mojom::DisplayCompositorClientPtr client);
|
| + ~DisplayCompositor() override;
|
| +
|
| + void Bind(cc::mojom::DisplayCompositorRequest request,
|
| + cc::mojom::DisplayCompositorClientPtr client);
|
| +
|
| + cc::SurfaceManager* surface_manager() { return &surface_manager_; }
|
| +
|
| + // GpuCompositorFrameSinkDelegate implementation.
|
| + void OnClientConnectionLost(const cc::FrameSinkId& frame_sink_id,
|
| + bool destroy_compositor_frame_sink) override;
|
| + void OnPrivateConnectionLost(const cc::FrameSinkId& frame_sink_id,
|
| + bool destroy_compositor_frame_sink) override;
|
| +
|
| + // cc::mojom::DisplayCompositor implementation:
|
| + void CreateDisplayCompositorFrameSink(
|
| + const cc::FrameSinkId& frame_sink_id,
|
| + gpu::SurfaceHandle surface_handle,
|
| + cc::mojom::MojoCompositorFrameSinkAssociatedRequest request,
|
| + cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request,
|
| + cc::mojom::MojoCompositorFrameSinkClientPtr client,
|
| + cc::mojom::DisplayPrivateAssociatedRequest display_private_request)
|
| + override;
|
| + void CreateOffscreenCompositorFrameSink(
|
| + const cc::FrameSinkId& frame_sink_id,
|
| + cc::mojom::MojoCompositorFrameSinkRequest request,
|
| + cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request,
|
| + cc::mojom::MojoCompositorFrameSinkClientPtr client) override;
|
| +
|
| + private:
|
| + // It is necessary to pass |frame_sink_id| by value because the id
|
| + // is owned by the GpuCompositorFrameSink in the map. When the sink is
|
| + // removed from the map, |frame_sink_id| would also be destroyed if it were a
|
| + // reference. But the map can continue to iterate and try to use it. Passing
|
| + // by value avoids this.
|
| + void DestroyCompositorFrameSink(cc::FrameSinkId frame_sink_id);
|
| +
|
| + // cc::SurfaceObserver implementation.
|
| + void OnSurfaceCreated(const cc::SurfaceInfo& surface_info) override;
|
| + void OnSurfaceDamaged(const cc::SurfaceId& surface_id,
|
| + bool* changed) override;
|
| +
|
| + // SurfaceManager should be the first object constructed and the last object
|
| + // destroyed in order to ensure that all other objects that depend on it have
|
| + // access to a valid pointer for the entirety of their liftimes.
|
| + cc::SurfaceManager surface_manager_;
|
| +
|
| + std::unordered_map<cc::FrameSinkId,
|
| + std::unique_ptr<GpuCompositorFrameSink>,
|
| + cc::FrameSinkIdHash>
|
| + compositor_frame_sinks_;
|
| +
|
| + scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
|
| +
|
| + base::ThreadChecker thread_checker_;
|
| +
|
| + cc::mojom::DisplayCompositorClientPtr client_;
|
| + mojo::Binding<cc::mojom::DisplayCompositor> binding_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(DisplayCompositor);
|
| +};
|
| +
|
| +} // namespace display_compositor
|
| +
|
| +#endif // COMPONENTS_DISPLAY_COMPOSITOR_DISPLAY_COMPOSITOR_H_
|
|
|