hwc2: set cursor position
am: 603115b31b

Change-Id: Ia029e934071c8f35e12c8af4561db695296603ec
diff --git a/hwc2/hwc2.cpp b/hwc2/hwc2.cpp
index ff1969e..387cd7c 100644
--- a/hwc2/hwc2.cpp
+++ b/hwc2/hwc2.cpp
@@ -244,11 +244,11 @@
     return HWC2_ERROR_NONE;
 }
 
-hwc2_error_t set_cursor_position(hwc2_device_t* /*device*/,
-        hwc2_display_t /*display*/, hwc2_layer_t /*layer*/, int32_t /*x*/,
-        int32_t /*y*/)
+hwc2_error_t set_cursor_position(hwc2_device_t *device, hwc2_display_t display,
+        hwc2_layer_t layer, int32_t x, int32_t y)
 {
-    return HWC2_ERROR_NONE;
+    hwc2_dev *dev = reinterpret_cast<hwc2_context *>(device)->hwc2_dev;
+    return dev->set_cursor_position(display, layer, x, y);
 }
 
 hwc2_error_t set_layer_buffer(hwc2_device_t* /*device*/,
diff --git a/hwc2/hwc2.h b/hwc2/hwc2.h
index 4b6bf16..5f3d575 100644
--- a/hwc2/hwc2.h
+++ b/hwc2/hwc2.h
@@ -201,6 +201,7 @@
     hwc2_error_t set_layer_transform(hwc2_layer_t lyr_id,
                     hwc_transform_t transform);
     hwc2_error_t set_layer_color(hwc2_layer_t lyr_id, const hwc_color_t &color);
+    hwc2_error_t set_cursor_position(hwc2_layer_t lyr_id, int32_t x, int32_t y);
 
     static hwc2_display_t get_next_id();
 
@@ -293,6 +294,8 @@
                     hwc_transform_t transform);
     hwc2_error_t set_layer_color(hwc2_display_t dpy_id, hwc2_layer_t lyr_id,
                     const hwc_color_t &color);
+    hwc2_error_t set_cursor_position(hwc2_display_t dpy_id, hwc2_layer_t lyr_id,
+                    int32_t x, int32_t y);
 
     /* Callback functions */
     void hotplug(hwc2_display_t dpy_id, hwc2_connection_t connection);
diff --git a/hwc2/hwc2_dev.cpp b/hwc2/hwc2_dev.cpp
index 959ffe7..e1ced5d 100644
--- a/hwc2/hwc2_dev.cpp
+++ b/hwc2/hwc2_dev.cpp
@@ -239,6 +239,18 @@
     return displays.find(dpy_id)->second.set_layer_color(lyr_id, color);
 }
 
+hwc2_error_t hwc2_dev::set_cursor_position(hwc2_display_t dpy_id,
+        hwc2_layer_t lyr_id, int32_t x, int32_t y)
+{
+    auto it = displays.find(dpy_id);
+    if (it == displays.end()) {
+        ALOGE("dpy %" PRIu64 ": invalid display handle", dpy_id);
+        return HWC2_ERROR_BAD_DISPLAY;
+    }
+
+    return displays.find(dpy_id)->second.set_cursor_position(lyr_id, x, y);
+}
+
 void hwc2_dev::hotplug(hwc2_display_t dpy_id, hwc2_connection_t connection)
 {
     auto it = displays.find(dpy_id);
diff --git a/hwc2/hwc2_display.cpp b/hwc2/hwc2_display.cpp
index 6d99b8f..5f42458 100644
--- a/hwc2/hwc2_display.cpp
+++ b/hwc2/hwc2_display.cpp
@@ -373,6 +373,21 @@
     return HWC2_ERROR_NONE;
 }
 
+hwc2_error_t hwc2_display::set_cursor_position(hwc2_layer_t lyr_id,
+        int32_t /*x*/, int32_t /*y*/)
+{
+    auto it = layers.find(lyr_id);
+    if (it == layers.end()) {
+        ALOGE("dpy %" PRIu64 ": lyr %" PRIu64 ": bad layer handle", id, lyr_id);
+        return HWC2_ERROR_BAD_LAYER;
+    }
+
+    /* Cursors are not supported on flounder. During validate, any layers marked
+     * HWC2_COMPOSITION_CURSOR will be changed to HWC2_COMPOSITION_CLIENT.
+     * No need to store the cursor position. */
+    return HWC2_ERROR_NONE;
+}
+
 hwc2_display_t hwc2_display::get_next_id()
 {
     return display_cnt++;