summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorAaron Plattner <aplattner@nvidia.com>2011-08-25 15:41:55 -0700
committerKeith Packard <keithp@keithp.com>2011-10-03 11:30:04 -0700
commit57cd32e93425597317b4b7722859155419836e4c (patch)
tree3a249171d1c4ec059c79bda01054015ecc4e7def /hw
parent245cb8e94fd15990e1b7d6622added460f104dba (diff)
xfree86/modes: Make cursor position transform a helper function
When the driver can handle the crtc transform in hardware, it sets crtc->driverIsPerformingTransform, which turns off both the shadow layer and the cursor's position-transforming code. However, some drivers actually do require the cursor position to still be transformed in these cases. Move the cursor position transform into a helper function that can be called by such drivers. Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/xfree86/modes/xf86Crtc.h8
-rw-r--r--hw/xfree86/modes/xf86Cursors.c57
2 files changed, 39 insertions, 26 deletions
diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h
index 0d7a6a63c..ffb2efff4 100644
--- a/hw/xfree86/modes/xf86Crtc.h
+++ b/hw/xfree86/modes/xf86Crtc.h
@@ -948,6 +948,14 @@ xf86_hide_cursors (ScrnInfoPtr scrn);
extern _X_EXPORT void
xf86_cursors_fini (ScreenPtr screen);
+/**
+ * Transform the cursor's coordinates based on the crtc transform. Normally
+ * this is done by the server, but if crtc->driverIsPerformingTransform is TRUE,
+ * then the server does not transform the cursor position automatically.
+ */
+extern _X_EXPORT void
+xf86CrtcTransformCursorPos (xf86CrtcPtr crtc, int *x, int *y);
+
/*
* For overlay video, compute the relevant CRTC and
* clip video to that.
diff --git a/hw/xfree86/modes/xf86Cursors.c b/hw/xfree86/modes/xf86Cursors.c
index 02dea5c49..4a03428ea 100644
--- a/hw/xfree86/modes/xf86Cursors.c
+++ b/hw/xfree86/modes/xf86Cursors.c
@@ -337,7 +337,36 @@ xf86_show_cursors (ScrnInfoPtr scrn)
xf86_crtc_show_cursor (crtc);
}
}
-
+
+void xf86CrtcTransformCursorPos (xf86CrtcPtr crtc, int *x, int *y)
+{
+ ScrnInfoPtr scrn = crtc->scrn;
+ ScreenPtr screen = scrn->pScreen;
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+ xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
+ xf86CursorScreenPtr ScreenPriv =
+ (xf86CursorScreenPtr)dixLookupPrivate(&screen->devPrivates,
+ xf86CursorScreenKey);
+ struct pict_f_vector v;
+ int dx, dy;
+
+ v.v[0] = (*x + ScreenPriv->HotX) + 0.5;
+ v.v[1] = (*y + ScreenPriv->HotY) + 0.5;
+ v.v[2] = 1;
+ pixman_f_transform_point (&crtc->f_framebuffer_to_crtc, &v);
+ /* cursor will have 0.5 added to it already so floor is sufficent */
+ *x = floor (v.v[0]);
+ *y = floor (v.v[1]);
+ /*
+ * Transform position of cursor upper left corner
+ */
+ xf86_crtc_rotate_coord_back (crtc->rotation, cursor_info->MaxWidth,
+ cursor_info->MaxHeight, ScreenPriv->HotX,
+ ScreenPriv->HotY, &dx, &dy);
+ *x -= dx;
+ *y -= dy;
+}
+
static void
xf86_crtc_set_cursor_position (xf86CrtcPtr crtc, int x, int y)
{
@@ -346,36 +375,12 @@ xf86_crtc_set_cursor_position (xf86CrtcPtr crtc, int x, int y)
xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
DisplayModePtr mode = &crtc->mode;
Bool in_range;
- int dx, dy;
/*
* Transform position of cursor on screen
*/
if (crtc->transform_in_use && !crtc->driverIsPerformingTransform)
- {
- ScreenPtr screen = scrn->pScreen;
- xf86CursorScreenPtr ScreenPriv =
- (xf86CursorScreenPtr)dixLookupPrivate(&screen->devPrivates,
- xf86CursorScreenKey);
- struct pict_f_vector v;
-
- v.v[0] = (x + ScreenPriv->HotX) + 0.5;
- v.v[1] = (y + ScreenPriv->HotY) + 0.5;
- v.v[2] = 1;
- pixman_f_transform_point (&crtc->f_framebuffer_to_crtc, &v);
- /* cursor will have 0.5 added to it already so floor is sufficent */
- x = floor (v.v[0]);
- y = floor (v.v[1]);
- /*
- * Transform position of cursor upper left corner
- */
- xf86_crtc_rotate_coord_back (crtc->rotation,
- cursor_info->MaxWidth,
- cursor_info->MaxHeight,
- ScreenPriv->HotX, ScreenPriv->HotY, &dx, &dy);
- x -= dx;
- y -= dy;
- }
+ xf86CrtcTransformCursorPos(crtc, &x, &y);
else
{
x -= crtc->x;