#ifndef UI_DISPLAY_MANAGER_DISPLAY_MANAGER_UTILITIES_H_
#define UI_DISPLAY_MANAGER_DISPLAY_MANAGER_UTILITIES_H_
#include <vector>
#include "base/functional/identity.h"
#include "base/ranges/algorithm.h"
#include "ui/display/display.h"
#include "ui/display/display_layout.h"
#include "ui/display/manager/display_manager_export.h"
#include "ui/display/manager/managed_display_info.h"
namespace gfx {
class Rect;
class Size;
}
namespace display {
class ManagedDisplayInfo;
class ManagedDisplayMode;
using DisplayInfoList = std::vector<ManagedDisplayInfo>;
DISPLAY_MANAGER_EXPORT ManagedDisplayInfo::ManagedDisplayModeList
CreateInternalManagedDisplayModeList(const ManagedDisplayMode& native_mode);
struct UnifiedDisplayModeParam {
UnifiedDisplayModeParam(float dsf, float scale, bool is_default);
float device_scale_factor = 1.0f;
float display_bounds_scale = 1.0f;
bool is_default_mode = false;
};
DISPLAY_MANAGER_EXPORT ManagedDisplayInfo::ManagedDisplayModeList
CreateUnifiedManagedDisplayModeList(
const ManagedDisplayMode& native_mode,
const std::vector<UnifiedDisplayModeParam>& modes_param_list);
bool ForceFirstDisplayInternal();
DISPLAY_MANAGER_EXPORT bool ComputeBoundary(const gfx::Rect& a_bounds,
const gfx::Rect& b_bounds,
gfx::Rect* a_edge,
gfx::Rect* b_edge);
DISPLAY_MANAGER_EXPORT bool ComputeBoundary(const Display& display_a,
const Display& display_b,
gfx::Rect* a_edge_in_screen,
gfx::Rect* b_edge_in_screen);
DISPLAY_MANAGER_EXPORT void SortDisplayIdList(DisplayIdList* list);
DISPLAY_MANAGER_EXPORT bool IsDisplayIdListSorted(const DisplayIdList& list);
template <typename Range, typename UnaryOperation = base::identity>
DisplayIdList GenerateDisplayIdList(Range&& range, UnaryOperation op = {}) {
DisplayIdList list;
base::ranges::transform(range, std::back_inserter(list), op);
SortDisplayIdList(&list);
return list;
}
DISPLAY_MANAGER_EXPORT DisplayIdList CreateDisplayIdList(const Displays& list);
DISPLAY_MANAGER_EXPORT DisplayIdList
CreateDisplayIdList(const DisplayInfoList& updated_displays);
DISPLAY_MANAGER_EXPORT std::string DisplayIdListToString(
const DisplayIdList& list);
DISPLAY_MANAGER_EXPORT int64_t GetDisplayIdWithoutOutputIndex(int64_t id);
struct DISPLAY_MANAGER_EXPORT MixedMirrorModeParams {
MixedMirrorModeParams(int64_t src_id, const DisplayIdList& dst_ids);
MixedMirrorModeParams(const MixedMirrorModeParams& mixed_params);
~MixedMirrorModeParams();
int64_t source_id;
DisplayIdList destination_ids;
};
enum class MirrorMode {
kOff = 0,
kNormal,
kMixed,
};
enum class MixedMirrorModeParamsErrors {
kSuccess = 0,
kErrorSingleDisplay,
kErrorSourceIdNotFound,
kErrorDestinationIdsEmpty,
kErrorDestinationIdNotFound,
kErrorDuplicateId,
};
DISPLAY_MANAGER_EXPORT MixedMirrorModeParamsErrors
ValidateParamsForMixedMirrorMode(
const DisplayIdList& connected_display_ids,
const MixedMirrorModeParams& mixed_mode_params);
}
#endif