Skip to content

Commit

Permalink
small improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
ammen99 committed Jan 23, 2024
1 parent 2e68b66 commit 6dafd30
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions src/core/output-layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ struct output_layout_output_t
bool is_externally_managed = false;
bool is_nested_compositor = false;
bool inhibited = false;
std::map<int, std::vector<uint32_t>> bit_depths;
std::map<int, std::vector<uint32_t>> formats_for_depth;
int current_bit_depth = RENDER_BIT_DEPTH_DEFAULT;

std::unique_ptr<wf::output_impl_t> output;
Expand Down Expand Up @@ -299,17 +299,11 @@ struct output_layout_output_t
on_commit.connect(&handle->events.commit);
}

bit_depths =
{{8, {
DRM_FORMAT_XRGB8888,
DRM_FORMAT_INVALID,
}},
{10, {
DRM_FORMAT_XRGB2101010,
DRM_FORMAT_XBGR2101010,
DRM_FORMAT_XRGB8888,
DRM_FORMAT_INVALID,
}},
formats_for_depth[8] = {DRM_FORMAT_XRGB8888};
formats_for_depth[10] = {
DRM_FORMAT_XRGB2101010,
DRM_FORMAT_XBGR2101010,
DRM_FORMAT_XRGB8888,
};
}

Expand Down Expand Up @@ -646,20 +640,18 @@ struct output_layout_output_t

if (current_state.depth != current_bit_depth)
{
const std::vector<uint32_t> fmts = bit_depths[current_state.depth];

for (size_t i = 0; fmts[i] != DRM_FORMAT_INVALID; i++)
for (auto fmt : formats_for_depth[current_state.depth])
{
wlr_output_set_render_format(handle, fmts[i]);
wlr_output_set_render_format(handle, fmt);
if (wlr_output_test(handle))
{
wlr_output_commit(handle);
current_bit_depth = current_state.depth;
LOGD("Set output format to ", get_format_name(fmts[i]), " on output ", handle->name);
LOGD("Set output format to ", get_format_name(fmt), " on output ", handle->name);
break;
}

LOGD("Failed to set output format ", get_format_name(fmts[i]), " on output ", handle->name);
LOGD("Failed to set output format ", get_format_name(fmt), " on output ", handle->name);
}
}
}
Expand Down

0 comments on commit 6dafd30

Please sign in to comment.