diff options
author | Russell King <rmk@arm.linux.org.uk> | 2014-08-15 12:15:57 +0100 |
---|---|---|
committer | Russell King <rmk@arm.linux.org.uk> | 2014-11-22 23:17:48 +0000 |
commit | 61928ab905e70ffb420923e42cee76c35ec91c9a (patch) | |
tree | e1466156ee68fc2849ac27bd663dbfa1d7127f30 /src/common_drm.c | |
parent | 5c129c6c463e851ddbc74327c86e8d95cacff225 (diff) |
src: add common_drm_covering_crtc()
Add our own copy of the xf86_covering_crtc() - it would be nice if the
X server allowed DDX modules to use this, but it doesn't, so we have
to provide our own copy. We need this to identify which CRTC should
be associated with a drawable.
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
Diffstat (limited to 'src/common_drm.c')
-rw-r--r-- | src/common_drm.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/common_drm.c b/src/common_drm.c index 4ab4968..e844a1e 100644 --- a/src/common_drm.c +++ b/src/common_drm.c @@ -15,7 +15,11 @@ #include <xf86drmMode.h> #include "xf86.h" + +#include "boxutil.h" + #include "common_drm.h" +#include "common_drm_helper.h" #include "xf86_OSproc.h" #include "xf86Crtc.h" #include "xf86cmap.h" @@ -1091,3 +1095,40 @@ void common_drm_FreeScreen(FREE_SCREEN_ARGS_DECL) free(drm); } } + +/* + * Helpers for DRI2 and textured Xv + */ +_X_EXPORT +xf86CrtcPtr common_drm_covering_crtc(ScrnInfoPtr pScrn, BoxPtr box, + xf86CrtcPtr desired, BoxPtr box_ret) +{ + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); + xf86CrtcPtr crtc, best_crtc; + BoxRec crtc_box, cover_box; + int coverage, best_coverage, c; + + best_crtc = NULL; + best_coverage = 0; + box_ret->x1 = box_ret->x2 = box_ret->y1 = box_ret->y2 = 0; + for (c = 0; c < xf86_config->num_crtc; c++) { + crtc = xf86_config->crtc[c]; + if (!crtc->enabled) + continue; + crtc_box.x1 = crtc->x; + crtc_box.x2 = crtc->x + xf86ModeWidth(&crtc->mode, crtc->rotation); + crtc_box.y1 = crtc->y; + crtc_box.y2 = crtc->y + xf86ModeHeight(&crtc->mode, crtc->rotation); + box_intersect(&cover_box, &crtc_box, box); + coverage = box_area(&cover_box); + if (coverage && crtc == desired) { + *box_ret = crtc_box; + return crtc; + } else if (coverage > best_coverage) { + *box_ret = crtc_box; + best_crtc = crtc; + best_coverage = coverage; + } + } + return best_crtc; +} |