summaryrefslogtreecommitdiff
path: root/src/drmmode_display.c
diff options
context:
space:
mode:
authorMichel Dänzer <michel.daenzer@amd.com>2017-12-22 18:33:58 +0100
committerMichel Dänzer <michel@daenzer.net>2017-12-27 16:57:17 +0100
commit69e20839bfeb3ee0b0a732d72de0a32d6c5435fc (patch)
tree7731b5dc00f69041610040b33d0088fcf7e86813 /src/drmmode_display.c
parentdfccaa7043ccb157a1f8be7313123792bb7e7001 (diff)
Keep track of how many SW cursors are visible on each screen
And use this to determine when we cannot use page flipping for DRI clients. We previously did this based on whether the HW cursor cannot be used on at least one CRTC, which had at least two issues: * Even while the HW cursor cannot be used, no SW cursor may actually be visible (e.g. because all cursors are disabled), in which case we can use page flipping for DRI clients anyway * Even while the HW cursor can be used, there may be SW cursors visible from non-core pointer devices, in which case we cannot use page flipping for DRI clients anyway Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'src/drmmode_display.c')
-rw-r--r--src/drmmode_display.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 55551ee..0471794 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -34,6 +34,7 @@
#include <time.h>
#include "cursorstr.h"
#include "damagestr.h"
+#include "inputstr.h"
#include "list.h"
#include "micmap.h"
#include "xf86cmap.h"
@@ -2431,6 +2432,57 @@ void drmmode_fini(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
drmmode_crtc_scanout_free(config->crtc[c]->driver_private);
}
+static void drmmode_sprite_do_set_cursor(struct amdgpu_device_priv *device_priv,
+ ScrnInfoPtr scrn, int x, int y)
+{
+ AMDGPUInfoPtr info = AMDGPUPTR(scrn);
+ CursorPtr cursor = device_priv->cursor;
+ Bool sprite_visible = device_priv->sprite_visible;
+
+ if (cursor) {
+ x -= cursor->bits->xhot;
+ y -= cursor->bits->yhot;
+
+ device_priv->sprite_visible =
+ x < scrn->virtualX && y < scrn->virtualY &&
+ (x + cursor->bits->width > 0) &&
+ (y + cursor->bits->height > 0);
+ } else {
+ device_priv->sprite_visible = FALSE;
+ }
+
+ info->sprites_visible += device_priv->sprite_visible - sprite_visible;
+}
+
+void drmmode_sprite_set_cursor(DeviceIntPtr pDev, ScreenPtr pScreen,
+ CursorPtr pCursor, int x, int y)
+{
+ ScrnInfoPtr scrn = xf86ScreenToScrn(pScreen);
+ AMDGPUInfoPtr info = AMDGPUPTR(scrn);
+ struct amdgpu_device_priv *device_priv =
+ dixLookupScreenPrivate(&pDev->devPrivates,
+ &amdgpu_device_private_key, pScreen);
+
+ device_priv->cursor = pCursor;
+ drmmode_sprite_do_set_cursor(device_priv, scrn, x, y);
+
+ info->SetCursor(pDev, pScreen, pCursor, x, y);
+}
+
+void drmmode_sprite_move_cursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x,
+ int y)
+{
+ ScrnInfoPtr scrn = xf86ScreenToScrn(pScreen);
+ AMDGPUInfoPtr info = AMDGPUPTR(scrn);
+ struct amdgpu_device_priv *device_priv =
+ dixLookupScreenPrivate(&pDev->devPrivates,
+ &amdgpu_device_private_key, pScreen);
+
+ drmmode_sprite_do_set_cursor(device_priv, scrn, x, y);
+
+ info->MoveCursor(pDev, pScreen, x, y);
+}
+
void drmmode_set_cursor(ScrnInfoPtr scrn, drmmode_ptr drmmode, int id,
struct amdgpu_buffer *bo)
{