mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 17:17:42 +00:00
Clipboard: Remove-unused bpp metadata
It's just more attack surface, and can be deduced from the format anyway.
This commit is contained in:
parent
4427da989f
commit
6c2ea4c4e9
2 changed files with 24 additions and 2 deletions
|
@ -161,7 +161,6 @@ void Clipboard::set_bitmap(const Gfx::Bitmap& bitmap)
|
||||||
metadata.set("height", String::number(bitmap.height()));
|
metadata.set("height", String::number(bitmap.height()));
|
||||||
metadata.set("format", String::number((int)bitmap.format()));
|
metadata.set("format", String::number((int)bitmap.format()));
|
||||||
metadata.set("pitch", String::number(bitmap.pitch()));
|
metadata.set("pitch", String::number(bitmap.pitch()));
|
||||||
metadata.set("bpp", String::number(bitmap.bpp()));
|
|
||||||
set_data({ bitmap.scanline(0), bitmap.size_in_bytes() }, "image/x-serenityos", metadata);
|
set_data({ bitmap.scanline(0), bitmap.size_in_bytes() }, "image/x-serenityos", metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,29 @@ String ClipboardHistoryModel::column_name(int column) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char* bpp_for_format_resilient(String format)
|
||||||
|
{
|
||||||
|
unsigned format_uint = format.to_uint().value_or(static_cast<unsigned>(Gfx::BitmapFormat::Invalid));
|
||||||
|
// Cannot use Gfx::Bitmap::bpp_for_format here, as we have to accept invalid enum values.
|
||||||
|
switch (static_cast<Gfx::BitmapFormat>(format_uint)) {
|
||||||
|
case Gfx::BitmapFormat::Indexed1:
|
||||||
|
return "1";
|
||||||
|
case Gfx::BitmapFormat::Indexed2:
|
||||||
|
return "2";
|
||||||
|
case Gfx::BitmapFormat::Indexed4:
|
||||||
|
return "4";
|
||||||
|
case Gfx::BitmapFormat::Indexed8:
|
||||||
|
return "8";
|
||||||
|
case Gfx::BitmapFormat::RGB32:
|
||||||
|
case Gfx::BitmapFormat::RGBA32:
|
||||||
|
return "32";
|
||||||
|
case Gfx::BitmapFormat::Invalid:
|
||||||
|
/* fall-through */
|
||||||
|
default:
|
||||||
|
return "?";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GUI::Variant ClipboardHistoryModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) const
|
GUI::Variant ClipboardHistoryModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) const
|
||||||
{
|
{
|
||||||
if (role != GUI::ModelRole::Display)
|
if (role != GUI::ModelRole::Display)
|
||||||
|
@ -67,7 +90,7 @@ GUI::Variant ClipboardHistoryModel::data(const GUI::ModelIndex& index, GUI::Mode
|
||||||
builder.append('x');
|
builder.append('x');
|
||||||
builder.append(data_and_type.metadata.get("height").value_or("?"));
|
builder.append(data_and_type.metadata.get("height").value_or("?"));
|
||||||
builder.append('x');
|
builder.append('x');
|
||||||
builder.append(data_and_type.metadata.get("bpp").value_or("?"));
|
builder.append(bpp_for_format_resilient(data_and_type.metadata.get("height").value_or("0")));
|
||||||
builder.append(" bitmap");
|
builder.append(" bitmap");
|
||||||
builder.append("]");
|
builder.append("]");
|
||||||
return builder.to_string();
|
return builder.to_string();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue