Skip to content

Commit

Permalink
[display] Validate pixel formats
Browse files Browse the repository at this point in the history
Bug: ZX-2329
Test: Locally modify virtcon to pass wrong display format
Change-Id: I7812dd82803a5b362626ba1bd681a080d1d68ad7
  • Loading branch information
dgstevens authored and CQ bot account: [email protected] committed Oct 12, 2018
1 parent 84dbfd6 commit dbdbcaf
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions system/dev/display/display/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -924,9 +924,25 @@ bool Client::CheckConfig(fidl::Builder* resp_builder) {
};
invalid = (!frame_contains(image_frame, layer->src_frame)
|| !frame_contains(display_frame, layer->dest_frame));

if (!invalid) {
invalid = true;
for (auto fmt : display_config.pixel_formats_) {
if (fmt == layer->image.pixel_format) {
invalid = false;
break;
}
}
}
} else if (layer_node.layer->pending_layer_.type == LAYER_CURSOR) {
// The image is already set, so nothing to do here, and there's
// nothing that could make this invald.
invalid = true;
auto& cursor_cfg = layer_node.layer->pending_layer_.cfg.cursor;
for (auto& cursor_info : display_config.cursor_infos_) {
if (cursor_info.format == cursor_cfg.image.pixel_format) {
invalid = false;
break;
}
}
} else if (layer_node.layer->pending_layer_.type == LAYER_COLOR) {
// There aren't any API constraints on valid colors.
layer_node.layer->pending_layer_.cfg.color.color =
Expand Down

0 comments on commit dbdbcaf

Please sign in to comment.