Skip to content

Commit

Permalink
viz: Add support for YUVVideoDrawQuad CALayers
Browse files Browse the repository at this point in the history
Creating separate mailboxes for each plane of an IOSurface will result
in creating a YUVVideoDrawQuad instead of a TextureDrawQuad. Add support
for promoting these quads to overlays.

Bug: 1201865, 1173132
Change-Id: I59001946b3573cc7d2c2db3146f821fdb0443d41
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2876586
Reviewed-by: Chris Blume <cblume@chromium.org>
Commit-Queue: ccameron <ccameron@chromium.org>
Cr-Commit-Position: refs/heads/master@{#880599}
  • Loading branch information
ccameron-chromium authored and Chromium LUCI CQ committed May 7, 2021
1 parent 9608c9a commit 8b8ff24
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions components/viz/service/display/ca_layer_overlay.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ enum CALayerResult {
CA_LAYER_FAILED_PICTURE_CONTENT = 12,
// CA_LAYER_FAILED_RENDER_PASS = 13,
CA_LAYER_FAILED_SURFACE_CONTENT = 14,
CA_LAYER_FAILED_YUV_VIDEO_CONTENT = 15,
// CA_LAYER_FAILED_YUV_VIDEO_CONTENT = 15,
CA_LAYER_FAILED_DIFFERENT_CLIP_SETTINGS = 16,
CA_LAYER_FAILED_DIFFERENT_VERTEX_OPACITIES = 17,
// CA_LAYER_FAILED_RENDER_PASS_FILTER_SCALE = 18,
Expand All @@ -64,6 +64,8 @@ enum CALayerResult {
CA_LAYER_FAILED_QUAD_ROUNDED_CORNER_CLIP_MISMATCH = 25,
CA_LAYER_FAILED_QUAD_ROUNDED_CORNER_NOT_UNIFORM = 26,
CA_LAYER_FAILED_TOO_MANY_QUADS = 27,
CA_LAYER_FAILED_YUV_NOT_CANDIDATE = 28,
CA_LAYER_FAILED_Y_UV_TEXCOORD_MISMATCH = 29,
CA_LAYER_FAILED_COUNT,
};

Expand Down Expand Up @@ -167,6 +169,31 @@ CALayerResult FromTextureQuad(DisplayResourceProvider* resource_provider,
return CA_LAYER_SUCCESS;
}

CALayerResult FromYUVVideoQuad(DisplayResourceProvider* resource_provider,
const YUVVideoDrawQuad* quad,
CALayerOverlay* ca_layer_overlay) {
// For YUVVideoDrawQuads, the Y and UV planes alias the same underlying
// IOSurface. Ensure all planes are overlays and have the same contents
// rect. Then use the Y plane as the resource for the overlay.
ResourceId y_resource_id = quad->y_plane_resource_id();
if (!resource_provider->IsOverlayCandidate(y_resource_id) ||
!resource_provider->IsOverlayCandidate(quad->u_plane_resource_id()) ||
!resource_provider->IsOverlayCandidate(quad->v_plane_resource_id())) {
return CA_LAYER_FAILED_YUV_NOT_CANDIDATE;
}
gfx::RectF ya_contents_rect =
gfx::ScaleRect(quad->ya_tex_coord_rect, 1.f / quad->ya_tex_size.width(),
1.f / quad->ya_tex_size.height());
gfx::RectF uv_contents_rect =
gfx::ScaleRect(quad->uv_tex_coord_rect, 1.f / quad->uv_tex_size.width(),
1.f / quad->uv_tex_size.height());
if (ya_contents_rect != uv_contents_rect)
return CA_LAYER_FAILED_Y_UV_TEXCOORD_MISMATCH;
ca_layer_overlay->contents_resource_id = y_resource_id;
ca_layer_overlay->contents_rect = ya_contents_rect;
return CA_LAYER_SUCCESS;
}

CALayerResult FromTileQuad(DisplayResourceProvider* resource_provider,
const TileDrawQuad* quad,
CALayerOverlay* ca_layer_overlay) {
Expand Down Expand Up @@ -279,7 +306,9 @@ class CALayerOverlayProcessorInternal {
case DrawQuad::Material::kSurfaceContent:
return CA_LAYER_FAILED_SURFACE_CONTENT;
case DrawQuad::Material::kYuvVideoContent:
return CA_LAYER_FAILED_YUV_VIDEO_CONTENT;
return FromYUVVideoQuad(resource_provider,
YUVVideoDrawQuad::MaterialCast(quad),
ca_layer_overlay);
default:
break;
}
Expand Down

0 comments on commit 8b8ff24

Please sign in to comment.