1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_OUTPUT_MANAGER_H_
#define UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_OUTPUT_MANAGER_H_
#include <memory>
#include <ostream>
#include "base/containers/flat_map.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "ui/ozone/platform/wayland/common/wayland_object.h"
#include "ui/ozone/platform/wayland/host/wayland_output.h"
#include "ui/ozone/platform/wayland/host/wayland_screen.h"
struct wl_output;
namespace ui {
class WaylandConnection;
class WaylandOutput;
class WaylandOutputManager : public WaylandOutput::Delegate {
public:
using OutputList =
base::flat_map<WaylandOutput::Id, std::unique_ptr<WaylandOutput>>;
explicit WaylandOutputManager(WaylandConnection* connection);
WaylandOutputManager(const WaylandOutputManager&) = delete;
WaylandOutputManager& operator=(const WaylandOutputManager&) = delete;
~WaylandOutputManager() override;
// Says if at least one output has already been announced by a Wayland
// compositor.
bool IsOutputReady() const;
void AddWaylandOutput(WaylandOutput::Id output_id, wl_output* output);
void RemoveWaylandOutput(WaylandOutput::Id output_id);
void InitializeAllXdgOutputs();
void InitializeAllColorManagementOutputs();
// Creates a platform screen.
std::unique_ptr<WaylandScreen> CreateWaylandScreen();
// Feeds a new platform screen with existing outputs.
void InitWaylandScreen(WaylandScreen* screen);
// Returns the output_id (i.e. the output's assigned global name).
WaylandOutput::Id GetOutputId(wl_output* output_resource) const;
WaylandOutput* GetOutput(WaylandOutput::Id id) const;
WaylandOutput* GetPrimaryOutput() const;
const OutputList& GetAllOutputs() const;
WaylandScreen* wayland_screen() const { return wayland_screen_.get(); }
void DumpState(std::ostream& out) const;
private:
// WaylandOutput::Delegate:
void OnOutputHandleMetrics(const WaylandOutput::Metrics& metrics) override;
OutputList output_list_;
const raw_ptr<WaylandConnection> connection_;
// Non-owned wayland screen instance.
base::WeakPtr<WaylandScreen> wayland_screen_;
};
} // namespace ui
#endif // UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_OUTPUT_MANAGER_H_
|