Commit 9af1bc63 authored by Daniele Castagna's avatar Daniele Castagna Committed by Commit Bot

viz: Reduce TextureDrawQuad byte size

This reduces the byte size of TextureDrawQuad using 1 bit for booleans
members and 2 bits for an enum with 4 values.

Since QuadList uses the size of the biggest DrawQuad to allocate any
quad, this CL will reduce the memory used by QuadList, even if
TextureDrawQuads are not used.

Bug: None

Change-Id: Ic89e932a582c1a25e530d838e7d5a9f3c68d6462
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2058835Reviewed-by: default avatarccameron <ccameron@chromium.org>
Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Commit-Queue: Daniele Castagna <dcastagna@chromium.org>
Cr-Commit-Position: refs/heads/master@{#742649}
parent 4f77ec7b
......@@ -14,7 +14,16 @@
namespace viz {
TextureDrawQuad::TextureDrawQuad() = default;
TextureDrawQuad::TextureDrawQuad()
: y_flipped(false),
nearest_neighbor(false),
premultiplied_alpha(false),
secure_output_only(false),
protected_video_type(gfx::ProtectedVideoType::kClear) {
static_assert(static_cast<int>(gfx::ProtectedVideoType::kMaxValue) < 4,
"protected_video_type needs more bits in order to represent "
"all the enum values");
}
TextureDrawQuad::TextureDrawQuad(const TextureDrawQuad& other) = default;
......
......@@ -55,23 +55,22 @@ class VIZ_COMMON_EXPORT TextureDrawQuad : public DrawQuad {
bool secure_output_only,
gfx::ProtectedVideoType protected_video_type);
bool premultiplied_alpha = false;
gfx::PointF uv_top_left;
gfx::PointF uv_bottom_right;
SkColor background_color = SK_ColorTRANSPARENT;
float vertex_opacity[4] = {0, 0, 0, 0};
bool y_flipped = false;
bool nearest_neighbor = false;
bool y_flipped : 1;
bool nearest_neighbor : 1;
bool premultiplied_alpha : 1;
// True if the quad must only be GPU composited if shown on secure outputs.
bool secure_output_only = false;
bool secure_output_only : 1;
// kClear if the contents do not require any special protection. See enum of a
// list of protected content types. Protected contents cannot be displayed via
// regular display path. They need either a protected output or a protected
// hardware overlay.
gfx::ProtectedVideoType protected_video_type =
gfx::ProtectedVideoType::kClear;
gfx::ProtectedVideoType protected_video_type : 2;
struct OverlayResources {
OverlayResources();
......
......@@ -137,11 +137,14 @@ bool StructTraits<viz::mojom::TextureQuadStateDataView, viz::DrawQuad>::Read(
quad->resources.count = 1;
quad->premultiplied_alpha = data.premultiplied_alpha();
gfx::ProtectedVideoType protected_video_type =
gfx::ProtectedVideoType::kClear;
if (!data.ReadUvTopLeft(&quad->uv_top_left) ||
!data.ReadUvBottomRight(&quad->uv_bottom_right) ||
!data.ReadProtectedVideoType(&quad->protected_video_type)) {
!data.ReadProtectedVideoType(&protected_video_type)) {
return false;
}
quad->protected_video_type = protected_video_type;
quad->background_color = data.background_color();
base::span<float> vertex_opacity_array(quad->vertex_opacity);
if (!data.ReadVertexOpacity(&vertex_opacity_array))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment