drm_hwcomposer: Add adjustments for cursor plane commits

This change adds special handling for buffers that may be committed to the
cursor plane. Some drivers may enforce size constraints on cursor plane
commits, which can be satisfied by padding the buffer beyond its nominal
width and height. This change adds behavior to extract that padding
(i.e. the aligned dimensions) by analyzing the buffer pitch, size, and
format.

When the cursor usage flag is set on a buffer, the aligned dimensions
should be used in place of the nominal dimensions for creating the
framebuffer, checking compatibility to the cursor plane, and for setting
the display and crop rects during commit.

Change-Id: I1cc2aa2f9cd23173cae87ae6e486c3b140b78ad5
Signed-off-by: Andrew Wolfers <aswolfers@google.com>
diff --git a/drm/DrmPlane.cpp b/drm/DrmPlane.cpp
index 0fe060d..2251a78 100644
--- a/drm/DrmPlane.cpp
+++ b/drm/DrmPlane.cpp
@@ -284,6 +284,13 @@
   auto disp = opt_disp.value();
   auto src = opt_src.value();
 
+  if (type_ == DRM_PLANE_TYPE_CURSOR) {
+    disp.right = disp.left + static_cast<int>(layer.bi->width);
+    disp.bottom = disp.top + static_cast<int>(layer.bi->height);
+    src = {0, 0, static_cast<float>(layer.bi->width),
+           static_cast<float>(layer.bi->height)};
+  }
+
   if (!crtc_property_.AtomicSet(pset, crtc_id) ||
       !fb_property_.AtomicSet(pset, layer.fb->GetFbId()) ||
       !crtc_x_property_.AtomicSet(pset, disp.left) ||