diff options
Diffstat (limited to 'xorg-server/randr')
-rw-r--r-- | xorg-server/randr/Makefile.am | 6 | ||||
-rw-r--r-- | xorg-server/randr/makefile | 19 | ||||
-rw-r--r-- | xorg-server/randr/mirrcrtc.c | 174 | ||||
-rw-r--r-- | xorg-server/randr/randr.c | 15 | ||||
-rw-r--r-- | xorg-server/randr/randrstr.h | 207 | ||||
-rw-r--r-- | xorg-server/randr/rrcrtc.c | 562 | ||||
-rw-r--r-- | xorg-server/randr/rrdispatch.c | 6 | ||||
-rw-r--r-- | xorg-server/randr/rrinfo.c | 2 | ||||
-rw-r--r-- | xorg-server/randr/rroutput.c | 5 | ||||
-rw-r--r-- | xorg-server/randr/rrpixmap.c | 154 | ||||
-rw-r--r-- | xorg-server/randr/rrscreen.c | 2055 | ||||
-rw-r--r-- | xorg-server/randr/rrsdispatch.c | 132 | ||||
-rw-r--r-- | xorg-server/randr/rrsprite.c | 104 | ||||
-rw-r--r-- | xorg-server/randr/rrtransform.c | 64 | ||||
-rw-r--r-- | xorg-server/randr/rrtransform.h | 15 |
15 files changed, 1116 insertions, 2404 deletions
diff --git a/xorg-server/randr/Makefile.am b/xorg-server/randr/Makefile.am index 2b0b3a984..4842df89c 100644 --- a/xorg-server/randr/Makefile.am +++ b/xorg-server/randr/Makefile.am @@ -16,16 +16,12 @@ librandr_la_SOURCES = \ rrinfo.c \
rrmode.c \
rroutput.c \
- rrpixmap.c \
rrpointer.c \
rrproperty.c \
rrscreen.c \
rrsdispatch.c \
- rrsprite.c \
rrtransform.h \
- rrtransform.c \
- mirrcrtc.c
-
+ rrtransform.c
if XINERAMA
librandr_la_SOURCES += ${XINERAMA_SRCS}
diff --git a/xorg-server/randr/makefile b/xorg-server/randr/makefile index 44516fc31..8dac78b7f 100644 --- a/xorg-server/randr/makefile +++ b/xorg-server/randr/makefile @@ -1,19 +1,26 @@ LIBRARY=librandr
+XINERAMA=1
-CSRCS = \
- rrxinerama.c \
+XINERAMA_SRCS = rrxinerama.c
+
+librandr_la_SOURCES = \
randr.c \
+ randrstr.h \
rrcrtc.c \
rrdispatch.c \
rrinfo.c \
rrmode.c \
rroutput.c \
- rrpixmap.c \
rrpointer.c \
rrproperty.c \
rrscreen.c \
rrsdispatch.c \
- rrsprite.c \
- rrtransform.c \
- mirrcrtc.c
+ rrtransform.h \
+ rrtransform.c
+
+if XINERAMA
+librandr_la_SOURCES += ${XINERAMA_SRCS}
+endif
+
+CSRCS = $(filter %.c,$(librandr_la_SOURCES))
diff --git a/xorg-server/randr/mirrcrtc.c b/xorg-server/randr/mirrcrtc.c deleted file mode 100644 index 812b2b68b..000000000 --- a/xorg-server/randr/mirrcrtc.c +++ /dev/null @@ -1,174 +0,0 @@ -/*
- * Copyright © 2010 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that copyright
- * notice and this permission notice appear in supporting documentation, and
- * that the name of the copyright holders not be used in advertising or
- * publicity pertaining to distribution of the software without specific,
- * written prior permission. The copyright holders make no representations
- * about the suitability of this software for any purpose. It is provided "as
- * is" without express or implied warranty.
- *
- * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-#include "randrstr.h"
-
-Bool
-miRRSetScreenConfig(ScreenPtr screen,
- RRScreenConfigPtr screen_config)
-{
- RRScreenConfigRec old_screen_config;
-
- RRScreenCurrentConfig(screen, &old_screen_config);
-
- /* Check and see if nothing has changed */
- if (old_screen_config.screen_width == screen_config->screen_width &&
- old_screen_config.screen_height == screen_config->screen_height &&
- old_screen_config.screen_pixmap_width == screen_config->screen_pixmap_width &&
- old_screen_config.screen_pixmap_height == screen_config->screen_pixmap_height &&
- old_screen_config.mm_width == screen_config->mm_width &&
- old_screen_config.mm_height == screen_config->mm_height)
- return TRUE;
-
- return RRScreenSizeSet(screen,
- screen_config->screen_width,
- screen_config->screen_height,
- screen_config->screen_pixmap_width,
- screen_config->screen_pixmap_height,
- screen_config->mm_width,
- screen_config->mm_height);
-}
-
-Bool
-miRRSetCrtcConfig(RRCrtcConfigPtr crtc_config)
-{
- int x = crtc_config->x, y = crtc_config->y;
-
- if (crtc_config->pixmap) {
- x = crtc_config->pixmap_x;
- y = crtc_config->pixmap_y;
- }
- if (!RRCrtcSet(crtc_config->crtc,
- crtc_config->mode,
- x,
- y,
- crtc_config->rotation,
- crtc_config->numOutputs,
- crtc_config->outputs,
- crtc_config->pixmap))
- return FALSE;
- RRCrtcSpriteTransformSet(crtc_config->crtc,
- &crtc_config->sprite_position_transform,
- &crtc_config->sprite_image_transform,
- &crtc_config->sprite_position_f_transform,
- &crtc_config->sprite_image_f_transform);
- return TRUE;
-}
-
-Bool
-miRRDisableCrtc(RRCrtcPtr crtc)
-{
- RRCrtcConfigRec off_config;
-
- memset(&off_config, '\0', sizeof (RRCrtcConfigRec));
- off_config.crtc = crtc;
- return miRRSetCrtcConfig(&off_config);
-}
-
-/*
- * If the current crtc configuration doesn't fit
- * with the new screen config, disable it
- */
-Bool
-miRRCheckDisableCrtc(RRScreenConfigPtr new_screen_config,
- RRCrtcConfigPtr old_crtc_config)
-{
- RRCrtcPtr crtc = old_crtc_config->crtc;
-
- /* If it's already disabled, we're done */
- if (!old_crtc_config->mode)
- return TRUE;
-
- /* If the crtc isn't scanning from the screen pixmap,
- * we're done
- */
- if (old_crtc_config->pixmap)
- return TRUE;
-
- /* If the new screen configuration covers the existing CRTC space,
- * we're done
- */
- if (RRScreenCoversCrtc(new_screen_config, old_crtc_config,
- &crtc->client_current_transform, NULL))
- return TRUE;
-
- /* Disable the crtc and let it get re-enabled */
- return miRRDisableCrtc(crtc);
-}
-
-Bool
-miRRSetCrtcConfigs(ScreenPtr screen,
- RRScreenConfigPtr screen_config,
- RRCrtcConfigPtr crtc_configs,
- int num_configs)
-{
- RRScreenConfigRec old_screen_config;
- RRCrtcConfigPtr old_crtc_configs;
- int i;
-
- /*
- * Save existing state
- */
-
- RRScreenCurrentConfig(screen, &old_screen_config);
- old_crtc_configs = calloc(num_configs, sizeof (RRCrtcConfigRec));
- if (!old_crtc_configs)
- return FALSE;
-
- for (i = 0; i < num_configs; i++)
- if (!RRCrtcCurrentConfig(crtc_configs[i].crtc, &old_crtc_configs[i]))
- goto fail_save;
- /*
- * Set the new configuration. If anything goes wrong,
- * bail and restore the old configuration
- */
- for (i = 0; i < num_configs; i++)
- if (!miRRCheckDisableCrtc(screen_config, &old_crtc_configs[i]))
- goto fail_disable;
-
- if (!miRRSetScreenConfig(screen, screen_config))
- goto fail_set_screen;
-
- for (i = 0; i < num_configs; i++)
- if (!miRRSetCrtcConfig(&crtc_configs[i]))
- goto fail_set_crtc;
-
- RRFreeCrtcConfigs(old_crtc_configs, num_configs);
- return TRUE;
-
-fail_set_crtc:
- /*
- * Restore the previous configuration. Ignore any errors
- * as we just need to hope that the driver can manage to
- * get back to the previous state without trouble.
- */
- for (i = 0; i < num_configs; i++)
- (void) miRRDisableCrtc(old_crtc_configs[i].crtc);
- (void) miRRSetScreenConfig(screen, &old_screen_config);
-fail_set_screen:
-fail_disable:
- for (i = 0; i < num_configs; i++)
- (void) miRRSetCrtcConfig(&old_crtc_configs[i]);
-fail_save:
- RRFreeCrtcConfigs(old_crtc_configs, num_configs);
- return FALSE;
-}
diff --git a/xorg-server/randr/randr.c b/xorg-server/randr/randr.c index 1346d1e9c..aa1e71dcf 100644 --- a/xorg-server/randr/randr.c +++ b/xorg-server/randr/randr.c @@ -98,7 +98,6 @@ RRCloseScreen (int i, ScreenPtr pScreen) free(pScrPriv->crtcs);
free(pScrPriv->outputs);
- free(pScrPriv->scanout_info);
free(pScrPriv);
RRNScreens -= 1; /* ok, one fewer screen with RandR running */
return (*pScreen->CloseScreen) (i, pScreen);
@@ -249,8 +248,6 @@ Bool RRScreenInit(ScreenPtr pScreen) pScrPriv->rrCrtcSet = NULL;
pScrPriv->rrCrtcSetGamma = NULL;
#endif
- pScrPriv->scanout_info = NULL;
- pScrPriv->n_scanout_info = 0;
#if RANDR_10_INTERFACE
pScrPriv->rrSetConfig = 0;
pScrPriv->rotations = RR_Rotate_0;
@@ -485,18 +482,6 @@ RRVerticalRefresh (xRRModeInfo *mode) return (CARD16) refresh;
}
-RRScanoutPixmapInfo *
-RRQueryScanoutPixmapInfo(ScreenPtr screen, int *n_info)
-{
- rrScrPriv(screen);
-
- if (!pScrPriv->scanout_info && pScrPriv->rrQueryScanoutPixmaps)
- pScrPriv->scanout_info = pScrPriv->rrQueryScanoutPixmaps(screen,
- &pScrPriv->n_scanout_info);
- *n_info = pScrPriv->n_scanout_info;
- return pScrPriv->scanout_info;
-}
-
static int
ProcRRDispatch (ClientPtr client)
{
diff --git a/xorg-server/randr/randrstr.h b/xorg-server/randr/randrstr.h index ee208f569..b4acfe12a 100644 --- a/xorg-server/randr/randrstr.h +++ b/xorg-server/randr/randrstr.h @@ -55,10 +55,9 @@ #define RANDR_10_INTERFACE 1
#define RANDR_12_INTERFACE 1
#define RANDR_13_INTERFACE 1 /* requires RANDR_12_INTERFACE */
-#define RANDR_14_INTERFACE 1 /* requires RANDR_13_INTERFACE */
#define RANDR_GET_CRTC_INTERFACE 1
-#define RANDR_INTERFACE_VERSION 0x0104
+#define RANDR_INTERFACE_VERSION 0x0103
typedef XID RRMode;
typedef XID RROutput;
@@ -78,8 +77,6 @@ typedef struct _rrMode RRModeRec, *RRModePtr; typedef struct _rrPropertyValue RRPropertyValueRec, *RRPropertyValuePtr;
typedef struct _rrProperty RRPropertyRec, *RRPropertyPtr;
typedef struct _rrCrtc RRCrtcRec, *RRCrtcPtr;
-typedef struct _rrScreenConfig RRScreenConfigRec, *RRScreenConfigPtr;
-typedef struct _rrCrtcConfig RRCrtcConfigRec, *RRCrtcConfigPtr;
typedef struct _rrOutput RROutputRec, *RROutputPtr;
struct _rrMode {
@@ -123,43 +120,11 @@ struct _rrCrtc { CARD16 *gammaGreen;
void *devPrivate;
Bool transforms;
- PixmapPtr scanoutPixmap;
RRTransformRec client_pending_transform;
RRTransformRec client_current_transform;
- PictTransform client_sprite_position_transform;
- PictTransform client_sprite_image_transform;
- struct pict_f_transform client_sprite_f_position_transform;
- struct pict_f_transform client_sprite_f_image_transform;
-
PictTransform transform;
struct pict_f_transform f_transform;
struct pict_f_transform f_inverse;
- struct pict_f_transform f_sprite_position; /* crtc from screen */
- struct pict_f_transform f_sprite_image_inverse; /* image from crtc */
-};
-
-struct _rrScreenConfig {
- CARD16 screen_pixmap_width;
- CARD16 screen_pixmap_height;
- CARD16 screen_width;
- CARD16 screen_height;
- CARD32 mm_width;
- CARD32 mm_height;
-};
-
-struct _rrCrtcConfig {
- RRCrtcPtr crtc;
- int x, y;
- RRModePtr mode;
- Rotation rotation;
- int numOutputs;
- RROutputPtr *outputs;
- PictTransform sprite_position_transform;
- PictTransform sprite_image_transform;
- struct pict_f_transform sprite_position_f_transform;
- struct pict_f_transform sprite_image_f_transform;
- PixmapPtr pixmap;
- int pixmap_x, pixmap_y;
};
struct _rrOutput {
@@ -191,8 +156,6 @@ struct _rrOutput { typedef Bool (*RRScreenSetSizeProcPtr) (ScreenPtr pScreen,
CARD16 width,
CARD16 height,
- CARD16 pixWidth,
- CARD16 pixHeight,
CARD32 mmWidth,
CARD32 mmHeight);
@@ -203,8 +166,7 @@ typedef Bool (*RRCrtcSetProcPtr) (ScreenPtr pScreen, int y,
Rotation rotation,
int numOutputs,
- RROutputPtr *outputs,
- PixmapPtr scanout_pixmap);
+ RROutputPtr *outputs);
typedef Bool (*RRCrtcSetGammaProcPtr) (ScreenPtr pScreen,
RRCrtcPtr crtc);
@@ -270,35 +232,6 @@ typedef Bool (*RRSetConfigProcPtr) (ScreenPtr pScreen, #endif
-typedef struct {
- PictFormatPtr format;
- int maxWidth, maxHeight;
- int depth;
- Rotation rotations;
-} RRScanoutPixmapInfo;
-
-typedef RRScanoutPixmapInfo *(*RRQueryScanoutPixmapsPtr) (ScreenPtr pScreen,
- int *num_info);
-
-typedef PixmapPtr (*RRCreateScanoutPixmapPtr) (ScreenPtr pScreen,
- int width, int height, int depth,
- Rotation rotations,
- PictFormatPtr format);
-
-typedef void (*RRSetCrtcSpriteTransformPtr) (ScreenPtr pScreen,
- RRCrtcPtr randr_crtc,
- struct pict_f_transform *position_transform,
- struct pict_f_transform *image_transform);
-
-typedef void (*RRGetCrtcSpriteTransformPtr) (ScreenPtr pScreen,
- RRCrtcPtr randr_crtc,
- struct pict_f_transform *position_transform,
- struct pict_f_transform *image_transform);
-
-typedef Bool (*RRSetCrtcConfigsPtr) (ScreenPtr screen,
- RRScreenConfigPtr screen_config,
- RRCrtcConfigPtr crtc_configs,
- int num_configs);
typedef struct _rrScrPriv {
/*
@@ -323,12 +256,7 @@ typedef struct _rrScrPriv { RRGetPanningProcPtr rrGetPanning;
RRSetPanningProcPtr rrSetPanning;
#endif
- RRQueryScanoutPixmapsPtr rrQueryScanoutPixmaps;
- RRCreateScanoutPixmapPtr rrCreateScanoutPixmap;
- RRSetCrtcSpriteTransformPtr rrSetCrtcSpriteTransform;
- RRGetCrtcSpriteTransformPtr rrGetCrtcSpriteTransform;
- RRSetCrtcConfigsPtr rrSetCrtcConfigs;
-
+
/*
* Private part of the structure; not considered part of the ABI
*/
@@ -355,8 +283,6 @@ typedef struct _rrScrPriv { /* Last known pointer position */
RRCrtcPtr pointerCrtc;
- RRScanoutPixmapInfo *scanout_info;
- int n_scanout_info;
#ifdef RANDR_10_INTERFACE
/*
* Configuration information
@@ -371,7 +297,6 @@ typedef struct _rrScrPriv { int rate;
int size;
#endif
-
} rrScrPrivRec, *rrScrPrivPtr;
extern _X_EXPORT DevPrivateKeyRec rrPrivKeyRec;
@@ -480,15 +405,9 @@ extern _X_EXPORT Bool RRScreenSizeSet (ScreenPtr pScreen,
CARD16 width,
CARD16 height,
- CARD16 pixWidth,
- CARD16 pixHeight,
CARD32 mmWidth,
CARD32 mmHeight);
-extern _X_EXPORT void
-RRScreenCurrentConfig(ScreenPtr screen,
- RRScreenConfigPtr screen_config);
-
/*
* Send ConfigureNotify event to root window when 'something' happens
*/
@@ -548,9 +467,6 @@ RRGetRotation (ScreenPtr pScreen); extern _X_EXPORT CARD16
RRVerticalRefresh (xRRModeInfo *mode);
-extern _X_EXPORT RRScanoutPixmapInfo *
-RRQueryScanoutPixmapInfo(ScreenPtr screen, int *n_info);
-
#ifdef RANDR_10_INTERFACE
/*
* This is the old interface, deprecated but left
@@ -629,8 +545,7 @@ RRCrtcNotify (RRCrtcPtr crtc, Rotation rotation,
RRTransformPtr transform,
int numOutputs,
- RROutputPtr *outputs,
- PixmapPtr scanoutPixmap);
+ RROutputPtr *outputs);
extern _X_EXPORT void
RRDeliverCrtcEvent (ClientPtr client, WindowPtr pWin, RRCrtcPtr crtc);
@@ -645,8 +560,7 @@ RRCrtcSet (RRCrtcPtr crtc, int y,
Rotation rotation,
int numOutput,
- RROutputPtr *outputs,
- PixmapPtr scanout_pixmap);
+ RROutputPtr *outputs);
/*
* Request that the Crtc gamma be changed
@@ -675,10 +589,6 @@ RRCrtcGammaGet(RRCrtcPtr crtc); extern _X_EXPORT Bool
RRCrtcGammaNotify (RRCrtcPtr crtc);
-void
-RRModeGetScanoutSize (RRModePtr mode, struct pixman_f_transform *transform,
- int *width, int *height);
-
/*
* Set the size of the gamma table at server startup time
*/
@@ -696,6 +606,25 @@ extern _X_EXPORT void RRCrtcGetScanoutSize(RRCrtcPtr crtc, int *width, int *height);
/*
+ * Compute the complete transformation matrix including
+ * client-specified transform, rotation/reflection values and the crtc
+ * offset.
+ *
+ * Return TRUE if the resulting transform is not a simple translation.
+ */
+extern _X_EXPORT Bool
+RRTransformCompute (int x,
+ int y,
+ int width,
+ int height,
+ Rotation rotation,
+ RRTransformPtr rr_transform,
+
+ PictTransformPtr transform,
+ struct pict_f_transform *f_transform,
+ struct pict_f_transform *f_inverse);
+
+/*
* Return crtc transform
*/
extern _X_EXPORT RRTransformPtr
@@ -741,38 +670,6 @@ extern _X_EXPORT void RRCrtcInitErrorValue (void);
/*
- * Free a set of crtc configs and their attached output arrays
- */
-void
-RRFreeCrtcConfigs(RRCrtcConfigPtr configs, int num_configs);
-
-/*
- * Convert the current crtc configuration into an RRCrtcConfig
- */
-extern _X_EXPORT Bool
-RRCrtcCurrentConfig(RRCrtcPtr crtc,
- RRCrtcConfigPtr crtc_config);
-
-/*
- * Figure out whether the specific crtc_config can fit
- * within the screen_config
- */
-Bool
-RRScreenCoversCrtc(RRScreenConfigPtr screen_config,
- RRCrtcConfigPtr crtc_config,
- RRTransformPtr client_transform,
- XID *errorValue);
-
-/*
- * Set a screen and set of crtc configurations in one operation
- */
-Bool
-RRSetCrtcConfigs(ScreenPtr screen,
- RRScreenConfigPtr screen_config,
- RRCrtcConfigPtr crtc_configs,
- int num_configs);
-
-/*
* Crtc dispatch
*/
@@ -797,40 +694,12 @@ ProcRRSetCrtcTransform (ClientPtr client); extern _X_EXPORT int
ProcRRGetCrtcTransform (ClientPtr client);
-extern _X_EXPORT int
-ProcRRSetCrtcConfigs (ClientPtr client);
-
int
ProcRRGetPanning (ClientPtr client);
int
ProcRRSetPanning (ClientPtr client);
-void
-RRCrtcSpriteTransformSet(RRCrtcPtr crtc,
- PictTransform *position_transform,
- PictTransform *image_transform,
- struct pict_f_transform *f_position_transform,
- struct pict_f_transform *f_image_transform);
-
-int
-ProcRRQueryScanoutPixmaps (ClientPtr client);
-
-int
-ProcRRCreateScanoutPixmap (ClientPtr client);
-
-int
-ProcRRSetCrtcPixmapConfig (ClientPtr client);
-
-int
-ProcRRSetCrtcSpriteTransform (ClientPtr client);
-
-int
-ProcRRGetCrtcSpriteTransform (ClientPtr client);
-
-int
-ProcRRSetCrtcConfigs (ClientPtr client);
-
/* rrdispatch.c */
extern _X_EXPORT Bool
RRClientKnowsRates (ClientPtr pClient);
@@ -1020,40 +889,12 @@ ProcRRConfigureOutputProperty (ClientPtr client); extern _X_EXPORT int
ProcRRDeleteOutputProperty (ClientPtr client);
-/* rrsprite.c */
-extern _X_EXPORT int
-ProcRRSetCrtcSpriteTransform (ClientPtr client);
-
-extern _X_EXPORT int
-ProcRRGetCrtcSpriteTransform (ClientPtr client);
-
/* rrxinerama.c */
#ifdef XINERAMA
extern _X_EXPORT void
RRXineramaExtensionInit(void);
#endif
-/* mirrcrtc.c */
-Bool
-miRRSetScreenConfig(ScreenPtr screen,
- RRScreenConfigPtr screen_config);
-
-Bool
-miRRSetCrtcConfig(RRCrtcConfigPtr crtc_config);
-
-Bool
-miRRDisableCrtc(RRCrtcPtr crtc);
-
-Bool
-miRRCheckDisableCrtc(RRScreenConfigPtr new_screen_config,
- RRCrtcConfigPtr old_crtc_config);
-
-Bool
-miRRSetCrtcConfigs(ScreenPtr screen,
- RRScreenConfigPtr screen_config,
- RRCrtcConfigPtr crtc_configs,
- int num_configs);
-
#endif /* _RANDRSTR_H_ */
/*
diff --git a/xorg-server/randr/rrcrtc.c b/xorg-server/randr/rrcrtc.c index 524fcd266..4194cb6c2 100644 --- a/xorg-server/randr/rrcrtc.c +++ b/xorg-server/randr/rrcrtc.c @@ -37,7 +37,7 @@ RRCrtcChanged (RRCrtcPtr crtc, Bool layoutChanged) if (pScreen)
{
rrScrPriv(pScreen);
-
+
pScrPriv->changed = TRUE;
/*
* Send ConfigureNotify on any layout change
@@ -59,19 +59,19 @@ RRCrtcCreate (ScreenPtr pScreen, void *devPrivate) if (!RRInit())
return NULL;
-
+
pScrPriv = rrGetScrPriv(pScreen);
/* make space for the crtc pointer */
if (pScrPriv->numCrtcs)
- crtcs = realloc(pScrPriv->crtcs,
+ crtcs = realloc(pScrPriv->crtcs,
(pScrPriv->numCrtcs + 1) * sizeof (RRCrtcPtr));
else
crtcs = malloc(sizeof (RRCrtcPtr));
if (!crtcs)
return FALSE;
pScrPriv->crtcs = crtcs;
-
+
crtc = calloc(1, sizeof (RRCrtcRec));
if (!crtc)
return NULL;
@@ -90,13 +90,9 @@ RRCrtcCreate (ScreenPtr pScreen, void *devPrivate) crtc->devPrivate = devPrivate;
RRTransformInit (&crtc->client_pending_transform);
RRTransformInit (&crtc->client_current_transform);
- pixman_transform_init_identity (&crtc->client_sprite_position_transform);
- pixman_transform_init_identity (&crtc->client_sprite_image_transform);
pixman_transform_init_identity (&crtc->transform);
pixman_f_transform_init_identity (&crtc->f_transform);
pixman_f_transform_init_identity (&crtc->f_inverse);
- pixman_f_transform_init_identity (&crtc->f_sprite_position);
- pixman_f_transform_init_identity (&crtc->f_sprite_image_inverse);
if (!AddResource (crtc->id, RRCrtcType, (pointer) crtc))
return NULL;
@@ -104,7 +100,7 @@ RRCrtcCreate (ScreenPtr pScreen, void *devPrivate) /* attach the screen and crtc together */
crtc->pScreen = pScreen;
pScrPriv->crtcs[pScrPriv->numCrtcs++] = crtc;
-
+
return crtc;
}
@@ -138,11 +134,10 @@ RRCrtcNotify (RRCrtcPtr crtc, Rotation rotation,
RRTransformPtr transform,
int numOutputs,
- RROutputPtr *outputs,
- PixmapPtr scanoutPixmap)
+ RROutputPtr *outputs)
{
int i, j;
-
+
/*
* Check to see if any of the new outputs were
* not in the old list and mark them as changed
@@ -182,7 +177,7 @@ RRCrtcNotify (RRCrtcPtr crtc, if (numOutputs != crtc->numOutputs)
{
RROutputPtr *newoutputs;
-
+
if (numOutputs)
{
if (crtc->numOutputs)
@@ -236,30 +231,15 @@ RRCrtcNotify (RRCrtcPtr crtc, RRTransformCopy (&crtc->client_current_transform, transform);
RRCrtcChanged (crtc, TRUE);
}
-
- if (scanoutPixmap != crtc->scanoutPixmap)
- {
- if (scanoutPixmap)
- ++scanoutPixmap->refcnt;
- if (crtc->scanoutPixmap)
- (*crtc->scanoutPixmap->drawable.pScreen->DestroyPixmap) (crtc->scanoutPixmap);
- crtc->scanoutPixmap = scanoutPixmap;
- }
-
if (crtc->changed && mode)
{
RRTransformCompute (x, y,
mode->mode.width, mode->mode.height,
rotation,
&crtc->client_current_transform,
- &crtc->client_sprite_f_position_transform,
- &crtc->client_sprite_f_image_transform,
&crtc->transform, &crtc->f_transform,
- &crtc->f_inverse, &crtc->f_sprite_position,
- &crtc->f_sprite_image_inverse,
- NULL);
+ &crtc->f_inverse);
}
-
return TRUE;
}
@@ -270,7 +250,7 @@ RRDeliverCrtcEvent (ClientPtr client, WindowPtr pWin, RRCrtcPtr crtc) rrScrPriv (pScreen);
xRRCrtcChangeNotifyEvent ce;
RRModePtr mode = crtc->mode;
-
+
ce.type = RRNotify + RREventBase;
ce.subCode = RRNotify_CrtcChange;
ce.timestamp = pScrPriv->lastSetTime.milliseconds;
@@ -322,8 +302,7 @@ RRCrtcSet (RRCrtcPtr crtc, int y,
Rotation rotation,
int numOutputs,
- RROutputPtr *outputs,
- PixmapPtr scanout_pixmap)
+ RROutputPtr *outputs)
{
ScreenPtr pScreen = crtc->pScreen;
Bool ret = FALSE;
@@ -337,8 +316,7 @@ RRCrtcSet (RRCrtcPtr crtc, crtc->numOutputs == numOutputs &&
!memcmp (crtc->outputs, outputs, numOutputs * sizeof (RROutputPtr)) &&
!RRCrtcPendingProperties (crtc) &&
- !RRCrtcPendingTransform (crtc) &&
- crtc->scanoutPixmap == scanout_pixmap)
+ !RRCrtcPendingTransform (crtc))
{
ret = TRUE;
}
@@ -347,8 +325,8 @@ RRCrtcSet (RRCrtcPtr crtc, #if RANDR_12_INTERFACE
if (pScrPriv->rrCrtcSet)
{
- ret = (*pScrPriv->rrCrtcSet) (pScreen, crtc, mode, x, y,
- rotation, numOutputs, outputs, scanout_pixmap);
+ ret = (*pScrPriv->rrCrtcSet) (pScreen, crtc, mode, x, y,
+ rotation, numOutputs, outputs);
}
else
#endif
@@ -361,7 +339,7 @@ RRCrtcSet (RRCrtcPtr crtc, if (!mode)
{
- RRCrtcNotify (crtc, NULL, x, y, rotation, NULL, 0, NULL, scanout_pixmap);
+ RRCrtcNotify (crtc, NULL, x, y, rotation, NULL, 0, NULL);
ret = TRUE;
}
else
@@ -387,7 +365,7 @@ RRCrtcSet (RRCrtcPtr crtc, */
if (ret)
{
- RRCrtcNotify (crtc, mode, x, y, rotation, NULL, 1, outputs, scanout_pixmap);
+ RRCrtcNotify (crtc, mode, x, y, rotation, NULL, 1, outputs);
RRScreenSizeNotify (pScreen);
}
}
@@ -406,60 +384,6 @@ RRCrtcSet (RRCrtcPtr crtc, return ret;
}
-void
-RRFreeCrtcConfigs(RRCrtcConfigPtr configs, int num_configs)
-{
- int i;
-
- for (i = 0; i < num_configs; i++)
- free(configs[i].outputs);
- free(configs);
-}
-
-Bool
-RRCrtcCurrentConfig(RRCrtcPtr crtc,
- RRCrtcConfigPtr crtc_config)
-{
- crtc_config->crtc = crtc;
- crtc_config->x = crtc->x;
- crtc_config->y = crtc->y;
- crtc_config->mode = crtc->mode;
- crtc_config->rotation = crtc->rotation;
- crtc_config->numOutputs = crtc->numOutputs;
- crtc_config->outputs = calloc(crtc->numOutputs, sizeof (RROutputPtr));
- if (!crtc_config->outputs)
- return FALSE;
- memcpy(crtc_config->outputs, crtc->outputs, crtc->numOutputs * sizeof (RROutputPtr));
- crtc_config->sprite_position_transform = crtc->client_sprite_position_transform;
- crtc_config->sprite_image_transform = crtc->client_sprite_image_transform;
- crtc_config->sprite_position_f_transform = crtc->client_sprite_f_position_transform;
- crtc_config->sprite_image_f_transform = crtc->client_sprite_f_image_transform;
-
- crtc_config->pixmap = crtc->scanoutPixmap;
- crtc_config->pixmap_x = crtc->x;
- crtc_config->pixmap_y = crtc->y;
- return TRUE;
-}
-
-
-/*
- * Request that a set of crtcs be configured at the same
- * time on a single screen
- */
-
-Bool
-RRSetCrtcConfigs(ScreenPtr screen,
- RRScreenConfigPtr screen_config,
- RRCrtcConfigPtr crtc_configs,
- int num_configs)
-{
- rrScrPrivPtr scr_priv = rrGetScrPriv(screen);
-
- if (!scr_priv)
- return FALSE;
- return (*scr_priv->rrSetCrtcConfigs)(screen, screen_config, crtc_configs, num_configs);
-}
-
/*
* Return crtc transform
*/
@@ -503,7 +427,7 @@ RRCrtcDestroyResource (pointer value, XID pid) {
rrScrPriv(pScreen);
int i;
-
+
for (i = 0; i < pScrPriv->numCrtcs; i++)
{
if (pScrPriv->crtcs[i] == crtc)
@@ -536,7 +460,7 @@ RRCrtcGammaSet (RRCrtcPtr crtc, #if RANDR_12_INTERFACE
ScreenPtr pScreen = crtc->pScreen;
#endif
-
+
memcpy (crtc->gammaRed, red, crtc->gammaSize * sizeof (CARD16));
memcpy (crtc->gammaGreen, green, crtc->gammaSize * sizeof (CARD16));
memcpy (crtc->gammaBlue, blue, crtc->gammaSize * sizeof (CARD16));
@@ -586,11 +510,8 @@ RRCrtcGammaNotify (RRCrtcPtr crtc) return TRUE; /* not much going on here */
}
-/*
- * Compute overall scanout buffer requirements for the specified mode
- */
-void
-RRModeGetScanoutSize (RRModePtr mode, struct pixman_f_transform *transform,
+static void
+RRModeGetScanoutSize (RRModePtr mode, PictTransformPtr transform,
int *width, int *height)
{
BoxRec box;
@@ -606,7 +527,7 @@ RRModeGetScanoutSize (RRModePtr mode, struct pixman_f_transform *transform, box.x2 = mode->mode.width;
box.y2 = mode->mode.height;
- pixman_f_transform_bounds (transform, &box);
+ pixman_transform_bounds (transform, &box);
*width = box.x2 - box.x1;
*height = box.y2 - box.y1;
}
@@ -617,7 +538,7 @@ RRModeGetScanoutSize (RRModePtr mode, struct pixman_f_transform *transform, void
RRCrtcGetScanoutSize(RRCrtcPtr crtc, int *width, int *height)
{
- RRModeGetScanoutSize (crtc->mode, &crtc->f_transform, width, height);
+ RRModeGetScanoutSize (crtc->mode, &crtc->transform, width, height);
}
/*
@@ -702,44 +623,6 @@ RRCrtcTransformSet (RRCrtcPtr crtc, }
/*
- * Figure out whether the specific crtc_config can fit
- * within the screen_config
- */
-Bool
-RRScreenCoversCrtc(RRScreenConfigPtr screen_config,
- RRCrtcConfigPtr crtc_config,
- RRTransformPtr client_transform,
- XID *errorValue)
-{
- int source_width;
- int source_height;
- struct pixman_f_transform f_transform;
-
- RRTransformCompute (crtc_config->x, crtc_config->y,
- crtc_config->mode->mode.width, crtc_config->mode->mode.height,
- crtc_config->rotation,
- client_transform,
- &crtc_config->sprite_position_f_transform,
- &crtc_config->sprite_image_f_transform,
- NULL, &f_transform, NULL, NULL, NULL, NULL);
-
- RRModeGetScanoutSize (crtc_config->mode, &f_transform,
- &source_width, &source_height);
- if (crtc_config->x + source_width > screen_config->screen_pixmap_width) {
- if (errorValue)
- *errorValue = crtc_config->x;
- return FALSE;
- }
-
- if (crtc_config->y + source_height > screen_config->screen_pixmap_height) {
- if (errorValue)
- *errorValue = crtc_config->y;
- return FALSE;
- }
- return TRUE;
-}
-
-/*
* Initialize crtc type
*/
Bool
@@ -748,7 +631,7 @@ RRCrtcInit (void) RRCrtcType = CreateNewResourceType (RRCrtcDestroyResource, "CRTC");
if (!RRCrtcType)
return FALSE;
-
+
return TRUE;
}
@@ -777,7 +660,7 @@ ProcRRGetCrtcInfo (ClientPtr client) int i, j, k, n;
int width, height;
BoxRec panned_area;
-
+
REQUEST_SIZE_MATCH(xRRGetCrtcInfoReq);
VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess);
@@ -788,7 +671,7 @@ ProcRRGetCrtcInfo (ClientPtr client) pScrPriv = rrGetScrPriv(pScreen);
mode = crtc->mode;
-
+
rep.type = X_Reply;
rep.status = RRSetConfigSuccess;
rep.sequenceNumber = client->sequence;
@@ -821,7 +704,7 @@ ProcRRGetCrtcInfo (ClientPtr client) if (pScrPriv->outputs[i]->crtcs[j] == crtc)
k++;
rep.nPossibleOutput = k;
-
+
rep.length = rep.nOutput + rep.nPossibleOutput;
extraLen = rep.length << 2;
@@ -836,7 +719,7 @@ ProcRRGetCrtcInfo (ClientPtr client) outputs = (RROutput *) extra;
possible = (RROutput *) (outputs + rep.nOutput);
-
+
for (i = 0; i < crtc->numOutputs; i++)
{
outputs[i] = crtc->outputs[i]->id;
@@ -853,7 +736,7 @@ ProcRRGetCrtcInfo (ClientPtr client) swapl (&possible[k], n);
k++;
}
-
+
if (client->swapped) {
swaps(&rep.sequenceNumber, n);
swapl(&rep.length, n);
@@ -874,7 +757,7 @@ ProcRRGetCrtcInfo (ClientPtr client) WriteToClient (client, extraLen, (char *) extra);
free(extra);
}
-
+
return Success;
}
@@ -894,10 +777,10 @@ ProcRRSetCrtcConfig (ClientPtr client) TimeStamp time;
Rotation rotation;
int rc, i, j;
-
+
REQUEST_AT_LEAST_SIZE(xRRSetCrtcConfigReq);
numOutputs = (stuff->length - bytes_to_int32(SIZEOF (xRRSetCrtcConfigReq)));
-
+
VERIFY_RR_CRTC(stuff->crtc, crtc, DixSetAttrAccess);
if (stuff->mode == None)
@@ -920,7 +803,7 @@ ProcRRSetCrtcConfig (ClientPtr client) }
else
outputs = NULL;
-
+
outputIds = (RROutput *) (stuff + 1);
for (i = 0; i < numOutputs; i++)
{
@@ -943,7 +826,7 @@ ProcRRSetCrtcConfig (ClientPtr client) /* validate mode for this output */
for (j = 0; j < outputs[i]->numModes + outputs[i]->numUserModes; j++)
{
- RRModePtr m = (j < outputs[i]->numModes ?
+ RRModePtr m = (j < outputs[i]->numModes ?
outputs[i]->modes[j] :
outputs[i]->userModes[j - outputs[i]->numModes]);
if (m == mode)
@@ -978,17 +861,17 @@ ProcRRSetCrtcConfig (ClientPtr client) pScreen = crtc->pScreen;
pScrPriv = rrGetScrPriv(pScreen);
-
+
time = ClientTimeToServerTime(stuff->timestamp);
configTime = ClientTimeToServerTime(stuff->configTimestamp);
-
+
if (!pScrPriv)
{
time = currentTime;
rep.status = RRSetConfigFailed;
goto sendReply;
}
-
+
/*
* Validate requested rotation
*/
@@ -1021,7 +904,7 @@ ProcRRSetCrtcConfig (ClientPtr client) free(outputs);
return BadMatch;
}
-
+
#ifdef RANDR_12_INTERFACE
/*
* Check screen size bounds if the DDX provides a 1.2 interface
@@ -1041,19 +924,16 @@ ProcRRSetCrtcConfig (ClientPtr client) mode->mode.width, mode->mode.height,
rotation,
&crtc->client_pending_transform,
- &crtc->client_sprite_f_position_transform,
- &crtc->client_sprite_f_image_transform,
- &transform, &f_transform, &f_inverse, NULL, NULL, NULL);
+ &transform, &f_transform, &f_inverse);
- RRModeGetScanoutSize (mode, &f_transform,
- &source_width, &source_height);
+ RRModeGetScanoutSize (mode, &transform, &source_width, &source_height);
if (stuff->x + source_width > pScreen->width)
{
client->errorValue = stuff->x;
free(outputs);
return BadValue;
}
-
+
if (stuff->y + source_height > pScreen->height)
{
client->errorValue = stuff->y;
@@ -1063,26 +943,26 @@ ProcRRSetCrtcConfig (ClientPtr client) }
#endif
}
-
+
if (!RRCrtcSet (crtc, mode, stuff->x, stuff->y,
- rotation, numOutputs, outputs, NULL))
+ rotation, numOutputs, outputs))
{
rep.status = RRSetConfigFailed;
goto sendReply;
}
rep.status = RRSetConfigSuccess;
pScrPriv->lastSetTime = time;
-
+
sendReply:
free(outputs);
-
+
rep.type = X_Reply;
/* rep.status has already been filled in */
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.newTimestamp = pScrPriv->lastSetTime.milliseconds;
- if (client->swapped)
+ if (client->swapped)
{
int n;
swaps(&rep.sequenceNumber, n);
@@ -1090,7 +970,7 @@ sendReply: swapl(&rep.newTimestamp, n);
}
WriteToClient(client, sizeof(xRRSetCrtcConfigReply), (char *)&rep);
-
+
return Success;
}
@@ -1106,7 +986,7 @@ ProcRRGetPanning (ClientPtr client) BoxRec tracking;
INT16 border[4];
int n;
-
+
REQUEST_SIZE_MATCH(xRRGetPanningReq);
VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess);
@@ -1176,7 +1056,7 @@ ProcRRSetPanning (ClientPtr client) BoxRec tracking;
INT16 border[4];
int n;
-
+
REQUEST_SIZE_MATCH(xRRSetPanningReq);
VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess);
@@ -1191,9 +1071,9 @@ ProcRRSetPanning (ClientPtr client) rep.status = RRSetConfigFailed;
goto sendReply;
}
-
+
time = ClientTimeToServerTime(stuff->timestamp);
-
+
if (!pScrPriv->rrGetPanning)
return RRErrorBase + BadRRCrtc;
@@ -1269,7 +1149,7 @@ ProcRRGetCrtcGamma (ClientPtr client) int n;
unsigned long len;
char *extra = NULL;
-
+
REQUEST_SIZE_MATCH(xRRGetCrtcGammaReq);
VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess);
@@ -1278,7 +1158,7 @@ ProcRRGetCrtcGamma (ClientPtr client) return RRErrorBase + BadRRCrtc;
len = crtc->gammaSize * 3 * 2;
-
+
if (crtc->gammaSize) {
extra = malloc(len);
if (!extra)
@@ -1312,21 +1192,21 @@ ProcRRSetCrtcGamma (ClientPtr client) RRCrtcPtr crtc;
unsigned long len;
CARD16 *red, *green, *blue;
-
+
REQUEST_AT_LEAST_SIZE(xRRSetCrtcGammaReq);
VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess);
-
+
len = client->req_len - bytes_to_int32(sizeof (xRRSetCrtcGammaReq));
if (len < (stuff->size * 3 + 1) >> 1)
return BadLength;
if (stuff->size != crtc->gammaSize)
return BadMatch;
-
+
red = (CARD16 *) (stuff + 1);
green = red + crtc->gammaSize;
blue = green + crtc->gammaSize;
-
+
RRCrtcGammaSet (crtc, red, green, blue);
return Success;
@@ -1367,7 +1247,7 @@ ProcRRSetCrtcTransform (ClientPtr client) #define CrtcTransformExtra (SIZEOF(xRRGetCrtcTransformReply) - 32)
-
+
static int
transform_filter_length (RRTransformPtr transform)
{
@@ -1469,331 +1349,3 @@ ProcRRGetCrtcTransform (ClientPtr client) free(reply);
return Success;
}
-
-static int
-RRConvertCrtcConfig(ClientPtr client, ScreenPtr screen,
- RRScreenConfigPtr screen_config,
- RRCrtcConfigPtr config, xRRCrtcConfig *x,
- RROutput *outputIds)
-{
- RRCrtcPtr crtc;
- RROutputPtr *outputs;
- rrScrPrivPtr scr_priv;
- RRModePtr mode;
- PixmapPtr pixmap;
- int rc, i, j;
- Rotation rotation;
-
- VERIFY_RR_CRTC(x->crtc, crtc, DixSetAttrAccess);
-
- if (x->mode == None)
- {
- mode = NULL;
- if (x->nOutput > 0)
- return BadMatch;
- }
- else
- {
- VERIFY_RR_MODE(x->mode, mode, DixSetAttrAccess);
- if (x->nOutput == 0)
- return BadMatch;
- }
- if (x->nOutput)
- {
- outputs = malloc(x->nOutput * sizeof (RROutputPtr));
- if (!outputs)
- return BadAlloc;
- }
- else
- outputs = NULL;
-
- if (x->pixmap == None)
- pixmap = NULL;
- else if (x->pixmap == RR_CurrentScanoutPixmap)
- pixmap = crtc->scanoutPixmap;
- else
- {
- rc = dixLookupResourceByType((pointer *) &pixmap, x->pixmap,
- RT_PIXMAP, client, DixWriteAccess);
- if (rc != Success) {
- free(outputs);
- return rc;
- }
- /* XXX check to make sure this is a scanout pixmap */
- }
-
- for (i = 0; i < x->nOutput; i++)
- {
- rc = dixLookupResourceByType((pointer *)(outputs + i), outputIds[i],
- RROutputType, client, DixSetAttrAccess);
- if (rc != Success)
- {
- free(outputs);
- return rc;
- }
- /* validate crtc for this output */
- for (j = 0; j < outputs[i]->numCrtcs; j++)
- if (outputs[i]->crtcs[j] == crtc)
- break;
- if (j == outputs[i]->numCrtcs)
- {
- free(outputs);
- return BadMatch;
- }
- /* validate mode for this output */
- for (j = 0; j < outputs[i]->numModes + outputs[i]->numUserModes; j++)
- {
- RRModePtr m = (j < outputs[i]->numModes ?
- outputs[i]->modes[j] :
- outputs[i]->userModes[j - outputs[i]->numModes]);
- if (m == mode)
- break;
- }
- if (j == outputs[i]->numModes + outputs[i]->numUserModes)
- {
- free(outputs);
- return BadMatch;
- }
- }
- /* validate clones */
- for (i = 0; i < x->nOutput; i++)
- {
- for (j = 0; j < x->nOutput; j++)
- {
- int k;
- if (i == j)
- continue;
- for (k = 0; k < outputs[i]->numClones; k++)
- {
- if (outputs[i]->clones[k] == outputs[j])
- break;
- }
- if (k == outputs[i]->numClones)
- {
- free(outputs);
- return BadMatch;
- }
- }
- }
-
- if (crtc->pScreen != screen)
- return BadMatch;
-
- scr_priv = rrGetScrPriv(screen);
-
- config->crtc = crtc;
- config->x = x->x;
- config->y = x->y;
- config->mode = mode;
- config->rotation = x->rotation;
- config->numOutputs = x->nOutput;
- config->outputs = outputs;
- PictTransform_from_xRenderTransform(&config->sprite_position_transform,
- &x->spritePositionTransform);
- PictTransform_from_xRenderTransform(&config->sprite_image_transform,
- &x->spriteImageTransform);
- pixman_f_transform_from_pixman_transform(&config->sprite_position_f_transform,
- &config->sprite_position_transform);
- pixman_f_transform_from_pixman_transform(&config->sprite_image_f_transform,
- &config->sprite_image_transform);
- config->pixmap = pixmap;
- config->pixmap_x = x->xPixmap;
- config->pixmap_y = x->yPixmap;
-
- /*
- * Validate requested rotation
- */
- rotation = (Rotation) x->rotation;
-
- /* test the rotation bits only! */
- switch (rotation & 0xf) {
- case RR_Rotate_0:
- case RR_Rotate_90:
- case RR_Rotate_180:
- case RR_Rotate_270:
- break;
- default:
- /*
- * Invalid rotation
- */
- client->errorValue = x->rotation;
- free(outputs);
- return BadValue;
- }
-
- if (mode)
- {
- if ((~crtc->rotations) & rotation)
- {
- /*
- * requested rotation or reflection not supported by screen
- */
- client->errorValue = x->rotation;
- free(outputs);
- return BadMatch;
- }
-
- /*
- * If scanning out from another pixmap, make sure the mode
- * fits
- */
- if (pixmap)
- {
- if (x->xPixmap + mode->mode.width > pixmap->drawable.width) {
- client->errorValue = x->xPixmap;
- free(outputs);
- return BadValue;
- }
- if (x->yPixmap + mode->mode.height > pixmap->drawable.height) {
- client->errorValue = x->yPixmap;
- free(outputs);
- return BadValue;
- }
- }
- /*
- * Check screen size bounds if the DDX provides a 1.2 interface
- * for setting screen size. Else, assume the CrtcSet sets
- * the size along with the mode. If the driver supports transforms,
- * then it must allow crtcs to display a subset of the screen, so
- * only do this check for drivers without transform support.
- */
- else if (scr_priv->rrScreenSetSize && !crtc->transforms)
- {
- if (!RRScreenCoversCrtc(screen_config, config,
- &crtc->client_pending_transform,
- &client->errorValue))
- {
- free(outputs);
- return BadValue;
- }
- }
- }
-
- return Success;
-}
-
-int
-ProcRRSetCrtcConfigs (ClientPtr client)
-{
- REQUEST(xRRSetCrtcConfigsReq);
- xRRSetCrtcConfigsReply rep;
- DrawablePtr drawable;
- ScreenPtr screen;
- rrScrPrivPtr scr_priv;
- xRRCrtcConfig *x_configs;
- RRScreenConfigRec screen_config;
- RRCrtcConfigPtr configs = NULL;
- RROutput *output_ids;
- int num_configs = 0;
- int rc, i;
- int extra_len;
- int num_output_ids;
-
- REQUEST_AT_LEAST_SIZE(xRRSetCrtcConfigsReq);
-
- extra_len = client->req_len - bytes_to_int32(sizeof(xRRSetCrtcConfigsReq));
-
- num_configs = stuff->nConfigs;
-
- /* Check request length against number of configs specified */
- if (num_configs * (sizeof (xRRCrtcConfig) >> 2) > extra_len)
- return BadLength;
-
- extra_len -= num_configs * (sizeof (xRRCrtcConfig) >> 2);
- x_configs = (xRRCrtcConfig *) (stuff + 1);
-
- /* Check remaining request length against number of outputs */
- num_output_ids = 0;
- for (i = 0; i < num_configs; i++)
- num_output_ids += x_configs[i].nOutput;
-
- if (extra_len != num_output_ids)
- return BadLength;
-
- rc = dixLookupDrawable(&drawable, stuff->drawable, client, 0, DixGetAttrAccess);
- if (rc != Success)
- return rc;
-
- screen = drawable->pScreen;
-
- scr_priv = rrGetScrPriv(screen);
-
- if (!scr_priv)
- {
- rep.status = RRSetConfigFailed;
- goto sendReply;
- }
-
- if (stuff->widthInMillimeters == 0 || stuff->heightInMillimeters == 0)
- {
- client->errorValue = 0;
- return BadValue;
- }
-
- if (stuff->screenPixmapWidth < scr_priv->minWidth ||
- scr_priv->maxWidth < stuff->screenPixmapWidth)
- {
- client->errorValue = stuff->screenPixmapWidth;
- return BadValue;
- }
- if (stuff->screenPixmapHeight < scr_priv->minHeight ||
- scr_priv->maxHeight < stuff->screenPixmapHeight)
- {
- client->errorValue = stuff->screenPixmapHeight;
- return BadValue;
- }
-
- screen_config.screen_pixmap_width = stuff->screenPixmapWidth;
- screen_config.screen_pixmap_height = stuff->screenPixmapHeight;
- screen_config.screen_width = stuff->screenWidth;
- screen_config.screen_height = stuff->screenHeight;
- screen_config.mm_width = stuff->widthInMillimeters;
- screen_config.mm_height = stuff->heightInMillimeters;
-
- output_ids = (RROutput *) (x_configs + num_configs);
-
- /*
- * Convert protocol crtc configurations into
- * server crtc configurations
- */
- configs = calloc(num_configs, sizeof (RRCrtcConfigRec));
- if (num_configs > 0 && configs == NULL)
- return BadAlloc;
- for (i = 0; i < num_configs; i++) {
- rc = RRConvertCrtcConfig(client, screen, &screen_config,
- &configs[i],
- &x_configs[i], output_ids);
- if (rc != Success) {
- rep.status = RRSetConfigFailed;
- goto sendReply;
- }
- output_ids += x_configs[i].nOutput;
- }
-
- if (num_configs &&
- !RRSetCrtcConfigs (screen, &screen_config, configs, num_configs))
- {
- rep.status = RRSetConfigFailed;
- goto sendReply;
- }
- rep.status = RRSetConfigSuccess;
- scr_priv->lastSetTime = currentTime;
-
-sendReply:
- RRFreeCrtcConfigs(configs, num_configs);
-
- rep.type = X_Reply;
- /* rep.status has already been filled in */
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-
- if (client->swapped)
- {
- int n;
- swaps(&rep.sequenceNumber, n);
- swapl(&rep.length, n);
- }
- WriteToClient(client, sizeof(xRRSetCrtcConfigsReply), (char *)&rep);
-
- return Success;
-}
diff --git a/xorg-server/randr/rrdispatch.c b/xorg-server/randr/rrdispatch.c index b9cbb5858..a4927bd14 100644 --- a/xorg-server/randr/rrdispatch.c +++ b/xorg-server/randr/rrdispatch.c @@ -224,11 +224,5 @@ int (*ProcRandrVector[RRNumberRequests])(ClientPtr) = { ProcRRSetPanning, /* 29 */
ProcRRSetOutputPrimary, /* 30 */
ProcRRGetOutputPrimary, /* 31 */
-/* V1.4 additions */
- ProcRRQueryScanoutPixmaps, /* 32 */
- ProcRRCreateScanoutPixmap, /* 33 */
- ProcRRSetCrtcSpriteTransform,/* 34 */
- ProcRRGetCrtcSpriteTransform,/* 35 */
- ProcRRSetCrtcConfigs, /* 36 */
};
diff --git a/xorg-server/randr/rrinfo.c b/xorg-server/randr/rrinfo.c index faac15afb..04c1a6c98 100644 --- a/xorg-server/randr/rrinfo.c +++ b/xorg-server/randr/rrinfo.c @@ -168,7 +168,7 @@ RRScanOldConfig (ScreenPtr pScreen, Rotation rotations) /* notice current mode */
if (newMode)
RRCrtcNotify (crtc, newMode, 0, 0, pScrPriv->rotation,
- NULL, 1, &output, NULL);
+ NULL, 1, &output);
}
#endif
diff --git a/xorg-server/randr/rroutput.c b/xorg-server/randr/rroutput.c index 41d282f66..8f661a383 100644 --- a/xorg-server/randr/rroutput.c +++ b/xorg-server/randr/rroutput.c @@ -23,11 +23,6 @@ #include "randrstr.h"
-/* From render.h */
-#ifndef SubPixelUnknown
-#define SubPixelUnknown 0
-#endif
-
RESTYPE RROutputType;
/*
diff --git a/xorg-server/randr/rrpixmap.c b/xorg-server/randr/rrpixmap.c deleted file mode 100644 index 5949309c9..000000000 --- a/xorg-server/randr/rrpixmap.c +++ /dev/null @@ -1,154 +0,0 @@ -/*
- * Copyright © 2010 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that copyright
- * notice and this permission notice appear in supporting documentation, and
- * that the name of the copyright holders not be used in advertising or
- * publicity pertaining to distribution of the software without specific,
- * written prior permission. The copyright holders make no representations
- * about the suitability of this software for any purpose. It is provided "as
- * is" without express or implied warranty.
- *
- * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-#include "randrstr.h"
-#include "xace.h"
-
-int
-ProcRRQueryScanoutPixmaps (ClientPtr client)
-{
- REQUEST(xRRQueryScanoutPixmapsReq);
- xRRQueryScanoutPixmapsReply rep;
- RRScanoutPixmapInfo *info;
- xRRScanoutPixmapInfo *x_info;
- int n_info;
- int rc;
- DrawablePtr drawable;
- ScreenPtr screen;
- rrScrPrivPtr screen_priv;
- int n, s;
-
- REQUEST_SIZE_MATCH(xRRQueryScanoutPixmapsReq);
- rc = dixLookupDrawable(&drawable, stuff->drawable, client, 0, DixGetAttrAccess);
- if (rc != Success) {
- client->errorValue = stuff->drawable;
- return rc;
- }
-
- screen = drawable->pScreen;
- screen_priv = rrGetScrPriv(screen);
-
- rep.type = X_Reply;
- /* rep.status has already been filled in */
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-
- info = RRQueryScanoutPixmapInfo(screen, &n_info);
- x_info = calloc(n_info, sizeof (xRRScanoutPixmapInfo));
- if (n_info && !x_info)
- return BadAlloc;
- rep.length += (n_info * sizeof (xRRScanoutPixmapInfo)) >> 2;
- if (client->swapped) {
- swaps(&rep.sequenceNumber, n);
- swapl(&rep.length, n);
- }
-
- for (s = 0; s < n_info; s++) {
- x_info[s].format = info[s].format->id;
- x_info[s].maxWidth = info[s].maxWidth;
- x_info[s].maxHeight = info[s].maxHeight;
- x_info[s].rotations = info[s].rotations;
- if (client->swapped) {
- swapl(&x_info[s].format, n);
- swaps(&x_info[s].maxWidth, n);
- swaps(&x_info[s].maxHeight, n);
- swaps(&x_info[s].rotations, n);
- }
- }
-
- WriteToClient(client, sizeof(rep), (char *)&rep);
- if (n_info)
- WriteToClient(client, n_info * sizeof (xRRScanoutPixmapInfo),
- (char *) x_info);
- return Success;
-}
-
-int
-ProcRRCreateScanoutPixmap (ClientPtr client)
-{
- REQUEST(xRRCreateScanoutPixmapReq);
- int rc;
- DrawablePtr drawable;
- ScreenPtr screen;
- rrScrPrivPtr screen_priv;
- PixmapPtr pixmap;
- int n_info;
- RRScanoutPixmapInfo *info;
- int s;
-
- REQUEST_SIZE_MATCH(xRRCreateScanoutPixmapReq);
- client->errorValue = stuff->pid;
- LEGAL_NEW_RESOURCE(stuff->pid, client);
-
- rc = dixLookupDrawable(&drawable, stuff->drawable, client, 0, DixGetAttrAccess);
- if (rc != Success) {
- client->errorValue = stuff->drawable;
- return rc;
- }
- screen = drawable->pScreen;
- screen_priv = rrGetScrPriv(screen);
- if (!screen_priv)
- return BadValue;
-
- info = RRQueryScanoutPixmapInfo(screen, &n_info);
- for (s = 0; s < n_info; s++) {
- if (info[s].format->id == stuff->format)
- break;
- }
- if (s == n_info || !screen_priv->rrCreateScanoutPixmap) {
- client->errorValue = stuff->format;
- return BadValue;
- }
- info = &info[s];
- if (!stuff->width || stuff->width > info->maxWidth) {
- client->errorValue = stuff->width;
- return BadValue;
- }
- if (!stuff->height || stuff->height > info->maxHeight) {
- client->errorValue = stuff->height;
- return BadValue;
- }
- if ((stuff->rotations & info->rotations) != stuff->rotations) {
- client->errorValue = stuff->rotations;
- return BadValue;
- }
-
- pixmap = screen_priv->rrCreateScanoutPixmap (screen,
- stuff->width, stuff->height,
- info->depth,
- stuff->rotations,
- info->format);
- if (!pixmap)
- return BadAlloc;
-
- pixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
- pixmap->drawable.id = stuff->pid;
- rc = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, RT_PIXMAP,
- pixmap, RT_NONE, NULL, DixCreateAccess);
- if (rc != Success) {
- screen->DestroyPixmap(pixmap);
- return rc;
- }
- if (!AddResource(stuff->pid, RT_PIXMAP, pixmap))
- return BadAlloc;
- return Success;
-}
diff --git a/xorg-server/randr/rrscreen.c b/xorg-server/randr/rrscreen.c index 973991e20..7877aec11 100644 --- a/xorg-server/randr/rrscreen.c +++ b/xorg-server/randr/rrscreen.c @@ -1,1042 +1,1013 @@ -/* - * Copyright © 2006 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that copyright - * notice and this permission notice appear in supporting documentation, and - * that the name of the copyright holders not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. The copyright holders make no representations - * about the suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - * - * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#include "randrstr.h" - -static const int padlength[4] = {0, 3, 2, 1}; -/* From render.h */ -#ifndef SubPixelUnknown -#define SubPixelUnknown 0 -#endif - - -static CARD16 -RR10CurrentSizeID (ScreenPtr pScreen); - -/* - * Edit connection information block so that new clients - * see the current screen size on connect - */ -static void -RREditConnectionInfo (ScreenPtr pScreen) -{ - xConnSetup *connSetup; - char *vendor; - xPixmapFormat *formats; - xWindowRoot *root; - xDepth *depth; - xVisualType *visual; - int screen = 0; - int d; - - connSetup = (xConnSetup *) ConnectionInfo; - vendor = (char *) connSetup + sizeof (xConnSetup); - formats = (xPixmapFormat *) ((char *) vendor + - connSetup->nbytesVendor + - padlength[connSetup->nbytesVendor & 3]); - root = (xWindowRoot *) ((char *) formats + - sizeof (xPixmapFormat) * screenInfo.numPixmapFormats); - while (screen != pScreen->myNum) - { - depth = (xDepth *) ((char *) root + - sizeof (xWindowRoot)); - for (d = 0; d < root->nDepths; d++) - { - visual = (xVisualType *) ((char *) depth + - sizeof (xDepth)); - depth = (xDepth *) ((char *) visual + - depth->nVisuals * sizeof (xVisualType)); - } - root = (xWindowRoot *) ((char *) depth); - screen++; - } - root->pixWidth = pScreen->width; - root->pixHeight = pScreen->height; - root->mmWidth = pScreen->mmWidth; - root->mmHeight = pScreen->mmHeight; -} - -void -RRSendConfigNotify (ScreenPtr pScreen) -{ - WindowPtr pWin = pScreen->root; - xEvent event; - - event.u.u.type = ConfigureNotify; - event.u.configureNotify.window = pWin->drawable.id; - event.u.configureNotify.aboveSibling = None; - event.u.configureNotify.x = 0; - event.u.configureNotify.y = 0; - - /* XXX xinerama stuff ? */ - - event.u.configureNotify.width = pWin->drawable.width; - event.u.configureNotify.height = pWin->drawable.height; - event.u.configureNotify.borderWidth = wBorderWidth (pWin); - event.u.configureNotify.override = pWin->overrideRedirect; - DeliverEvents(pWin, &event, 1, NullWindow); -} - -void -RRDeliverScreenEvent (ClientPtr client, WindowPtr pWin, ScreenPtr pScreen) -{ - rrScrPriv (pScreen); - xRRScreenChangeNotifyEvent se; - RRCrtcPtr crtc = pScrPriv->numCrtcs ? pScrPriv->crtcs[0] : NULL; - WindowPtr pRoot = pScreen->root; - - se.type = RRScreenChangeNotify + RREventBase; - se.rotation = (CARD8) (crtc ? crtc->rotation : RR_Rotate_0); - se.timestamp = pScrPriv->lastSetTime.milliseconds; - se.configTimestamp = pScrPriv->lastConfigTime.milliseconds; - se.root = pRoot->drawable.id; - se.window = pWin->drawable.id; - se.subpixelOrder = PictureGetSubpixelOrder (pScreen); - - se.sizeID = RR10CurrentSizeID (pScreen); - - if (se.rotation & (RR_Rotate_90 | RR_Rotate_270)) { - se.widthInPixels = pScreen->height; - se.heightInPixels = pScreen->width; - se.widthInMillimeters = pScreen->mmHeight; - se.heightInMillimeters = pScreen->mmWidth; - } else { - se.widthInPixels = pScreen->width; - se.heightInPixels = pScreen->height; - se.widthInMillimeters = pScreen->mmWidth; - se.heightInMillimeters = pScreen->mmHeight; - } - - WriteEventsToClient (client, 1, (xEvent *) &se); -} - -/* - * Notify the extension that the screen size has been changed. - * The driver is responsible for calling this whenever it has changed - * the size of the screen - */ -void -RRScreenSizeNotify (ScreenPtr pScreen) -{ - rrScrPriv(pScreen); - /* - * Deliver ConfigureNotify events when root changes - * pixel size - */ - if (pScrPriv->width == pScreen->width && - pScrPriv->height == pScreen->height && - pScrPriv->mmWidth == pScreen->mmWidth && - pScrPriv->mmHeight == pScreen->mmHeight) - return; - - pScrPriv->width = pScreen->width; - pScrPriv->height = pScreen->height; - pScrPriv->mmWidth = pScreen->mmWidth; - pScrPriv->mmHeight = pScreen->mmHeight; - pScrPriv->changed = TRUE; -/* pScrPriv->sizeChanged = TRUE; */ - - RRTellChanged (pScreen); - RRSendConfigNotify (pScreen); - RREditConnectionInfo (pScreen); - - RRPointerScreenConfigured (pScreen); - /* - * Fix pointer bounds and location - */ - ScreenRestructured (pScreen); -} - -/* - * Request that the screen be resized - */ -Bool -RRScreenSizeSet (ScreenPtr pScreen, - CARD16 width, - CARD16 height, - CARD16 pixWidth, - CARD16 pixHeight, - CARD32 mmWidth, - CARD32 mmHeight) -{ - rrScrPriv(pScreen); - -#if RANDR_12_INTERFACE - if (pScrPriv->rrScreenSetSize) - { - return (*pScrPriv->rrScreenSetSize) (pScreen, - width, height, - pixWidth, pixHeight, - mmWidth, mmHeight); - } -#endif -#if RANDR_10_INTERFACE - if (pScrPriv->rrSetConfig) - { - return TRUE; /* can't set size separately */ - } -#endif - return FALSE; -} - -/* - * Compute an RRScreenConfig from the current screen information - */ -void -RRScreenCurrentConfig(ScreenPtr screen, - RRScreenConfigPtr screen_config) -{ - PixmapPtr screen_pixmap = screen->GetScreenPixmap(screen); - WindowPtr root = screen->root; - - screen_config->screen_pixmap_width = screen_pixmap->drawable.width; - screen_config->screen_pixmap_height = screen_pixmap->drawable.height; - screen_config->screen_width = root->drawable.width; - screen_config->screen_height = root->drawable.height; - screen_config->mm_width = screen->mmWidth; - screen_config->mm_height = screen->mmHeight; -} - -/* - * Retrieve valid screen size range - */ -int -ProcRRGetScreenSizeRange (ClientPtr client) -{ - REQUEST(xRRGetScreenSizeRangeReq); - xRRGetScreenSizeRangeReply rep; - WindowPtr pWin; - ScreenPtr pScreen; - rrScrPrivPtr pScrPriv; - int rc; - - REQUEST_SIZE_MATCH(xRRGetScreenInfoReq); - rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); - if (rc != Success) - return rc; - - pScreen = pWin->drawable.pScreen; - pScrPriv = rrGetScrPriv(pScreen); - - rep.type = X_Reply; - rep.pad = 0; - rep.sequenceNumber = client->sequence; - rep.length = 0; - - if (pScrPriv) - { - if (!RRGetInfo (pScreen, FALSE)) - return BadAlloc; - rep.minWidth = pScrPriv->minWidth; - rep.minHeight = pScrPriv->minHeight; - rep.maxWidth = pScrPriv->maxWidth; - rep.maxHeight = pScrPriv->maxHeight; - } - else - { - rep.maxWidth = rep.minWidth = pScreen->width; - rep.maxHeight = rep.minHeight = pScreen->height; - } - if (client->swapped) - { - int n; - - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - swaps(&rep.minWidth, n); - swaps(&rep.minHeight, n); - swaps(&rep.maxWidth, n); - swaps(&rep.maxHeight, n); - } - WriteToClient(client, sizeof(xRRGetScreenSizeRangeReply), (char *)&rep); - return Success; -} - -int -ProcRRSetScreenSize (ClientPtr client) -{ - REQUEST(xRRSetScreenSizeReq); - WindowPtr pWin; - ScreenPtr pScreen; - rrScrPrivPtr pScrPriv; - int i, rc; - - REQUEST_SIZE_MATCH(xRRSetScreenSizeReq); - rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); - if (rc != Success) - return rc; - - pScreen = pWin->drawable.pScreen; - pScrPriv = rrGetScrPriv(pScreen); - if (stuff->width < pScrPriv->minWidth || pScrPriv->maxWidth < stuff->width) - { - client->errorValue = stuff->width; - return BadValue; - } - if (stuff->height < pScrPriv->minHeight || - pScrPriv->maxHeight < stuff->height) - { - client->errorValue = stuff->height; - return BadValue; - } - for (i = 0; i < pScrPriv->numCrtcs; i++) - { - RRCrtcPtr crtc = pScrPriv->crtcs[i]; - RRModePtr mode = crtc->mode; - if (mode) - { - int source_width = mode->mode.width; - int source_height = mode->mode.height; - Rotation rotation = crtc->rotation; - - if (rotation == RR_Rotate_90 || rotation == RR_Rotate_270) - { - source_width = mode->mode.height; - source_height = mode->mode.width; - } - - if (crtc->x + source_width > stuff->width || - crtc->y + source_height > stuff->height) - return BadMatch; - } - } - if (stuff->widthInMillimeters == 0 || stuff->heightInMillimeters == 0) - { - client->errorValue = 0; - return BadValue; - } - if (!RRScreenSizeSet (pScreen, - stuff->width, stuff->height, - stuff->width, stuff->height, - stuff->widthInMillimeters, - stuff->heightInMillimeters)) - { - return BadMatch; - } - return Success; -} - -static int -rrGetScreenResources(ClientPtr client, Bool query) -{ - REQUEST(xRRGetScreenResourcesReq); - xRRGetScreenResourcesReply rep; - WindowPtr pWin; - ScreenPtr pScreen; - rrScrPrivPtr pScrPriv; - CARD8 *extra; - unsigned long extraLen; - int i, n, rc, has_primary = 0; - RRCrtc *crtcs; - RROutput *outputs; - xRRModeInfo *modeinfos; - CARD8 *names; - - REQUEST_SIZE_MATCH(xRRGetScreenResourcesReq); - rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); - if (rc != Success) - return rc; - - pScreen = pWin->drawable.pScreen; - pScrPriv = rrGetScrPriv(pScreen); - rep.pad = 0; - - if (query && pScrPriv) - if (!RRGetInfo (pScreen, query)) - return BadAlloc; - - if (!pScrPriv) - { - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.timestamp = currentTime.milliseconds; - rep.configTimestamp = currentTime.milliseconds; - rep.nCrtcs = 0; - rep.nOutputs = 0; - rep.nModes = 0; - rep.nbytesNames = 0; - extra = NULL; - extraLen = 0; - } - else - { - RRModePtr *modes; - int num_modes; - - modes = RRModesForScreen (pScreen, &num_modes); - if (!modes) - return BadAlloc; - - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.timestamp = pScrPriv->lastSetTime.milliseconds; - rep.configTimestamp = pScrPriv->lastConfigTime.milliseconds; - rep.nCrtcs = pScrPriv->numCrtcs; - rep.nOutputs = pScrPriv->numOutputs; - rep.nModes = num_modes; - rep.nbytesNames = 0; - - for (i = 0; i < num_modes; i++) - rep.nbytesNames += modes[i]->mode.nameLength; - - rep.length = (pScrPriv->numCrtcs + - pScrPriv->numOutputs + - num_modes * bytes_to_int32(SIZEOF(xRRModeInfo)) + - bytes_to_int32(rep.nbytesNames)); - - extraLen = rep.length << 2; - if (extraLen) - { - extra = malloc(extraLen); - if (!extra) - { - free(modes); - return BadAlloc; - } - } - else - extra = NULL; - - crtcs = (RRCrtc *) extra; - outputs = (RROutput *) (crtcs + pScrPriv->numCrtcs); - modeinfos = (xRRModeInfo *) (outputs + pScrPriv->numOutputs); - names = (CARD8 *) (modeinfos + num_modes); - - if (pScrPriv->primaryOutput && pScrPriv->primaryOutput->crtc) - { - has_primary = 1; - crtcs[0] = pScrPriv->primaryOutput->crtc->id; - if (client->swapped) - swapl (&crtcs[0], n); - } - - for (i = 0; i < pScrPriv->numCrtcs; i++) - { - if (has_primary && - pScrPriv->primaryOutput->crtc == pScrPriv->crtcs[i]) - { - has_primary = 0; - continue; - } - crtcs[i + has_primary] = pScrPriv->crtcs[i]->id; - if (client->swapped) - swapl (&crtcs[i + has_primary], n); - } - - for (i = 0; i < pScrPriv->numOutputs; i++) - { - outputs[i] = pScrPriv->outputs[i]->id; - if (client->swapped) - swapl (&outputs[i], n); - } - - for (i = 0; i < num_modes; i++) - { - RRModePtr mode = modes[i]; - modeinfos[i] = mode->mode; - if (client->swapped) - { - swapl (&modeinfos[i].id, n); - swaps (&modeinfos[i].width, n); - swaps (&modeinfos[i].height, n); - swapl (&modeinfos[i].dotClock, n); - swaps (&modeinfos[i].hSyncStart, n); - swaps (&modeinfos[i].hSyncEnd, n); - swaps (&modeinfos[i].hTotal, n); - swaps (&modeinfos[i].hSkew, n); - swaps (&modeinfos[i].vSyncStart, n); - swaps (&modeinfos[i].vSyncEnd, n); - swaps (&modeinfos[i].vTotal, n); - swaps (&modeinfos[i].nameLength, n); - swapl (&modeinfos[i].modeFlags, n); - } - memcpy (names, mode->name, - mode->mode.nameLength); - names += mode->mode.nameLength; - } - free(modes); - assert (bytes_to_int32((char *) names - (char *) extra) == rep.length); - } - - if (client->swapped) { - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - swapl(&rep.timestamp, n); - swapl(&rep.configTimestamp, n); - swaps(&rep.nCrtcs, n); - swaps(&rep.nOutputs, n); - swaps(&rep.nModes, n); - swaps(&rep.nbytesNames, n); - } - WriteToClient(client, sizeof(xRRGetScreenResourcesReply), (char *)&rep); - if (extraLen) - { - WriteToClient (client, extraLen, (char *) extra); - free(extra); - } - return Success; -} - -int -ProcRRGetScreenResources (ClientPtr client) -{ - return rrGetScreenResources(client, TRUE); -} - -int -ProcRRGetScreenResourcesCurrent (ClientPtr client) -{ - return rrGetScreenResources(client, FALSE); -} - -typedef struct _RR10Data { - RRScreenSizePtr sizes; - int nsize; - int nrefresh; - int size; - CARD16 refresh; -} RR10DataRec, *RR10DataPtr; - -/* - * Convert 1.2 monitor data into 1.0 screen data - */ -static RR10DataPtr -RR10GetData (ScreenPtr pScreen, RROutputPtr output) -{ - RR10DataPtr data; - RRScreenSizePtr size; - int nmode = output->numModes + output->numUserModes; - int o, os, l, r; - RRScreenRatePtr refresh; - CARD16 vRefresh; - RRModePtr mode; - Bool *used; - - /* Make sure there is plenty of space for any combination */ - data = malloc (sizeof (RR10DataRec) + - sizeof (RRScreenSize) * nmode + - sizeof (RRScreenRate) * nmode + - sizeof (Bool) * nmode); - if (!data) - return NULL; - size = (RRScreenSizePtr) (data + 1); - refresh = (RRScreenRatePtr) (size + nmode); - used = (Bool *) (refresh + nmode); - memset (used, '\0', sizeof (Bool) * nmode); - data->sizes = size; - data->nsize = 0; - data->nrefresh = 0; - data->size = 0; - data->refresh = 0; - - /* - * find modes not yet listed - */ - for (o = 0; o < output->numModes + output->numUserModes; o++) - { - if (used[o]) continue; - - if (o < output->numModes) - mode = output->modes[o]; - else - mode = output->userModes[o - output->numModes]; - - l = data->nsize; - size[l].id = data->nsize; - size[l].width = mode->mode.width; - size[l].height = mode->mode.height; - if (output->mmWidth && output->mmHeight) { - size[l].mmWidth = output->mmWidth; - size[l].mmHeight = output->mmHeight; - } else { - size[l].mmWidth = pScreen->mmWidth; - size[l].mmHeight = pScreen->mmHeight; - } - size[l].nRates = 0; - size[l].pRates = &refresh[data->nrefresh]; - data->nsize++; - - /* - * Find all modes with matching size - */ - for (os = o; os < output->numModes + output->numUserModes; os++) - { - if (os < output->numModes) - mode = output->modes[os]; - else - mode = output->userModes[os - output->numModes]; - if (mode->mode.width == size[l].width && - mode->mode.height == size[l].height) - { - vRefresh = RRVerticalRefresh (&mode->mode); - used[os] = TRUE; - - for (r = 0; r < size[l].nRates; r++) - if (vRefresh == size[l].pRates[r].rate) - break; - if (r == size[l].nRates) - { - size[l].pRates[r].rate = vRefresh; - size[l].pRates[r].mode = mode; - size[l].nRates++; - data->nrefresh++; - } - if (mode == output->crtc->mode) - { - data->size = l; - data->refresh = vRefresh; - } - } - } - } - return data; -} - -int -ProcRRGetScreenInfo (ClientPtr client) -{ - REQUEST(xRRGetScreenInfoReq); - xRRGetScreenInfoReply rep; - WindowPtr pWin; - int n, rc; - ScreenPtr pScreen; - rrScrPrivPtr pScrPriv; - CARD8 *extra; - unsigned long extraLen; - RROutputPtr output; - - REQUEST_SIZE_MATCH(xRRGetScreenInfoReq); - rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); - if (rc != Success) - return rc; - - pScreen = pWin->drawable.pScreen; - pScrPriv = rrGetScrPriv(pScreen); - rep.pad = 0; - - if (pScrPriv) - if (!RRGetInfo (pScreen, TRUE)) - return BadAlloc; - - output = RRFirstOutput (pScreen); - - if (!pScrPriv || !output) - { - rep.type = X_Reply; - rep.setOfRotations = RR_Rotate_0; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.root = pWin->drawable.pScreen->root->drawable.id; - rep.timestamp = currentTime.milliseconds; - rep.configTimestamp = currentTime.milliseconds; - rep.nSizes = 0; - rep.sizeID = 0; - rep.rotation = RR_Rotate_0; - rep.rate = 0; - rep.nrateEnts = 0; - extra = 0; - extraLen = 0; - } - else - { - int i, j; - xScreenSizes *size; - CARD16 *rates; - CARD8 *data8; - Bool has_rate = RRClientKnowsRates (client); - RR10DataPtr pData; - RRScreenSizePtr pSize; - - pData = RR10GetData (pScreen, output); - if (!pData) - return BadAlloc; - - rep.type = X_Reply; - rep.setOfRotations = output->crtc->rotations; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.root = pWin->drawable.pScreen->root->drawable.id; - rep.timestamp = pScrPriv->lastSetTime.milliseconds; - rep.configTimestamp = pScrPriv->lastConfigTime.milliseconds; - rep.rotation = output->crtc->rotation; - rep.nSizes = pData->nsize; - rep.nrateEnts = pData->nrefresh + pData->nsize; - rep.sizeID = pData->size; - rep.rate = pData->refresh; - - extraLen = rep.nSizes * sizeof (xScreenSizes); - if (has_rate) - extraLen += rep.nrateEnts * sizeof (CARD16); - - if (extraLen) - { - extra = (CARD8 *) malloc(extraLen); - if (!extra) - { - free(pData); - return BadAlloc; - } - } - else - extra = NULL; - - /* - * First comes the size information - */ - size = (xScreenSizes *) extra; - rates = (CARD16 *) (size + rep.nSizes); - for (i = 0; i < pData->nsize; i++) - { - pSize = &pData->sizes[i]; - size->widthInPixels = pSize->width; - size->heightInPixels = pSize->height; - size->widthInMillimeters = pSize->mmWidth; - size->heightInMillimeters = pSize->mmHeight; - if (client->swapped) - { - swaps (&size->widthInPixels, n); - swaps (&size->heightInPixels, n); - swaps (&size->widthInMillimeters, n); - swaps (&size->heightInMillimeters, n); - } - size++; - if (has_rate) - { - *rates = pSize->nRates; - if (client->swapped) - { - swaps (rates, n); - } - rates++; - for (j = 0; j < pSize->nRates; j++) - { - *rates = pSize->pRates[j].rate; - if (client->swapped) - { - swaps (rates, n); - } - rates++; - } - } - } - free(pData); - - data8 = (CARD8 *) rates; - - if (data8 - (CARD8 *) extra != extraLen) - FatalError ("RRGetScreenInfo bad extra len %ld != %ld\n", - (unsigned long)(data8 - (CARD8 *) extra), extraLen); - rep.length = bytes_to_int32(extraLen); - } - if (client->swapped) { - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - swapl(&rep.timestamp, n); - swaps(&rep.rotation, n); - swaps(&rep.nSizes, n); - swaps(&rep.sizeID, n); - swaps(&rep.rate, n); - swaps(&rep.nrateEnts, n); - } - WriteToClient(client, sizeof(xRRGetScreenInfoReply), (char *)&rep); - if (extraLen) - { - WriteToClient (client, extraLen, (char *) extra); - free(extra); - } - return Success; -} - -int -ProcRRSetScreenConfig (ClientPtr client) -{ - REQUEST(xRRSetScreenConfigReq); - xRRSetScreenConfigReply rep; - DrawablePtr pDraw; - int n, rc; - ScreenPtr pScreen; - rrScrPrivPtr pScrPriv; - TimeStamp time; - int i; - Rotation rotation; - int rate; - Bool has_rate; - RROutputPtr output; - RRCrtcPtr crtc; - RRModePtr mode; - RR10DataPtr pData = NULL; - RRScreenSizePtr pSize; - int width, height; - - UpdateCurrentTime (); - - if (RRClientKnowsRates (client)) - { - REQUEST_SIZE_MATCH (xRRSetScreenConfigReq); - has_rate = TRUE; - } - else - { - REQUEST_SIZE_MATCH (xRR1_0SetScreenConfigReq); - has_rate = FALSE; - } - - rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, DixWriteAccess); - if (rc != Success) { - client->errorValue = stuff->drawable; - return rc; - } - - pScreen = pDraw->pScreen; - - pScrPriv = rrGetScrPriv(pScreen); - - time = ClientTimeToServerTime(stuff->timestamp); - - if (!pScrPriv) - { - time = currentTime; - rep.status = RRSetConfigFailed; - goto sendReply; - } - if (!RRGetInfo (pScreen, FALSE)) - return BadAlloc; - - output = RRFirstOutput (pScreen); - if (!output) - { - time = currentTime; - rep.status = RRSetConfigFailed; - goto sendReply; - } - - crtc = output->crtc; - - /* - * If the client's config timestamp is not the same as the last config - * timestamp, then the config information isn't up-to-date and - * can't even be validated. - * - * Note that the client only knows about the milliseconds part of the - * timestamp, so using CompareTimeStamps here would cause randr to suddenly - * stop working after several hours have passed (freedesktop bug #6502). - */ - if (stuff->configTimestamp != pScrPriv->lastConfigTime.milliseconds) - { - rep.status = RRSetConfigInvalidConfigTime; - goto sendReply; - } - - pData = RR10GetData (pScreen, output); - if (!pData) - return BadAlloc; - - if (stuff->sizeID >= pData->nsize) - { - /* - * Invalid size ID - */ - client->errorValue = stuff->sizeID; - free(pData); - return BadValue; - } - pSize = &pData->sizes[stuff->sizeID]; - - /* - * Validate requested rotation - */ - rotation = (Rotation) stuff->rotation; - - /* test the rotation bits only! */ - switch (rotation & 0xf) { - case RR_Rotate_0: - case RR_Rotate_90: - case RR_Rotate_180: - case RR_Rotate_270: - break; - default: - /* - * Invalid rotation - */ - client->errorValue = stuff->rotation; - free(pData); - return BadValue; - } - - if ((~crtc->rotations) & rotation) - { - /* - * requested rotation or reflection not supported by screen - */ - client->errorValue = stuff->rotation; - free(pData); - return BadMatch; - } - - /* - * Validate requested refresh - */ - if (has_rate) - rate = (int) stuff->rate; - else - rate = 0; - - if (rate) - { - for (i = 0; i < pSize->nRates; i++) - { - if (pSize->pRates[i].rate == rate) - break; - } - if (i == pSize->nRates) - { - /* - * Invalid rate - */ - client->errorValue = rate; - free(pData); - return BadValue; - } - mode = pSize->pRates[i].mode; - } - else - mode = pSize->pRates[0].mode; - - /* - * Make sure the requested set-time is not older than - * the last set-time - */ - if (CompareTimeStamps (time, pScrPriv->lastSetTime) < 0) - { - rep.status = RRSetConfigInvalidTime; - goto sendReply; - } - - /* - * If the screen size is changing, adjust all of the other outputs - * to fit the new size, mirroring as much as possible - */ - width = mode->mode.width; - height = mode->mode.height; - if (rotation & (RR_Rotate_90|RR_Rotate_270)) - { - width = mode->mode.height; - height = mode->mode.width; - } - - if (width < pScrPriv->minWidth || pScrPriv->maxWidth < width) { - client->errorValue = width; - free(pData); - return BadValue; - } - if (height < pScrPriv->minHeight || pScrPriv->maxHeight < height) { - client->errorValue = height; - free(pData); - return BadValue; - } - - if (width != pScreen->width || height != pScreen->height) - { - int c; - - for (c = 0; c < pScrPriv->numCrtcs; c++) - { - if (!RRCrtcSet (pScrPriv->crtcs[c], NULL, 0, 0, RR_Rotate_0, - 0, NULL, NULL)) - { - rep.status = RRSetConfigFailed; - /* XXX recover from failure */ - goto sendReply; - } - } - if (!RRScreenSizeSet (pScreen, width, height, width, height, - pScreen->mmWidth, pScreen->mmHeight)) - { - rep.status = RRSetConfigFailed; - /* XXX recover from failure */ - goto sendReply; - } - } - - if (!RRCrtcSet (crtc, mode, 0, 0, stuff->rotation, 1, &output, NULL)) - rep.status = RRSetConfigFailed; - else { - pScrPriv->lastSetTime = time; - rep.status = RRSetConfigSuccess; - } - - /* - * XXX Configure other crtcs to mirror as much as possible - */ - -sendReply: - - free(pData); - - rep.type = X_Reply; - /* rep.status has already been filled in */ - rep.length = 0; - rep.sequenceNumber = client->sequence; - - rep.newTimestamp = pScrPriv->lastSetTime.milliseconds; - rep.newConfigTimestamp = pScrPriv->lastConfigTime.milliseconds; - rep.root = pDraw->pScreen->root->drawable.id; - - if (client->swapped) - { - swaps(&rep.sequenceNumber, n); - swapl(&rep.length, n); - swapl(&rep.newTimestamp, n); - swapl(&rep.newConfigTimestamp, n); - swapl(&rep.root, n); - } - WriteToClient(client, sizeof(xRRSetScreenConfigReply), (char *)&rep); - - return Success; -} - -static CARD16 -RR10CurrentSizeID (ScreenPtr pScreen) -{ - CARD16 sizeID = 0xffff; - RROutputPtr output = RRFirstOutput (pScreen); - - if (output) - { - RR10DataPtr data = RR10GetData (pScreen, output); - if (data) - { - int i; - for (i = 0; i < data->nsize; i++) - if (data->sizes[i].width == pScreen->width && - data->sizes[i].height == pScreen->height) - { - sizeID = (CARD16) i; - break; - } - free(data); - } - } - return sizeID; -} +/*
+ * Copyright © 2006 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no representations
+ * about the suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include "randrstr.h"
+
+static const int padlength[4] = {0, 3, 2, 1};
+
+static CARD16
+RR10CurrentSizeID (ScreenPtr pScreen);
+
+/*
+ * Edit connection information block so that new clients
+ * see the current screen size on connect
+ */
+static void
+RREditConnectionInfo (ScreenPtr pScreen)
+{
+ xConnSetup *connSetup;
+ char *vendor;
+ xPixmapFormat *formats;
+ xWindowRoot *root;
+ xDepth *depth;
+ xVisualType *visual;
+ int screen = 0;
+ int d;
+
+ connSetup = (xConnSetup *) ConnectionInfo;
+ vendor = (char *) connSetup + sizeof (xConnSetup);
+ formats = (xPixmapFormat *) ((char *) vendor +
+ connSetup->nbytesVendor +
+ padlength[connSetup->nbytesVendor & 3]);
+ root = (xWindowRoot *) ((char *) formats +
+ sizeof (xPixmapFormat) * screenInfo.numPixmapFormats);
+ while (screen != pScreen->myNum)
+ {
+ depth = (xDepth *) ((char *) root +
+ sizeof (xWindowRoot));
+ for (d = 0; d < root->nDepths; d++)
+ {
+ visual = (xVisualType *) ((char *) depth +
+ sizeof (xDepth));
+ depth = (xDepth *) ((char *) visual +
+ depth->nVisuals * sizeof (xVisualType));
+ }
+ root = (xWindowRoot *) ((char *) depth);
+ screen++;
+ }
+ root->pixWidth = pScreen->width;
+ root->pixHeight = pScreen->height;
+ root->mmWidth = pScreen->mmWidth;
+ root->mmHeight = pScreen->mmHeight;
+}
+
+void
+RRSendConfigNotify (ScreenPtr pScreen)
+{
+ WindowPtr pWin = pScreen->root;
+ xEvent event;
+
+ event.u.u.type = ConfigureNotify;
+ event.u.configureNotify.window = pWin->drawable.id;
+ event.u.configureNotify.aboveSibling = None;
+ event.u.configureNotify.x = 0;
+ event.u.configureNotify.y = 0;
+
+ /* XXX xinerama stuff ? */
+
+ event.u.configureNotify.width = pWin->drawable.width;
+ event.u.configureNotify.height = pWin->drawable.height;
+ event.u.configureNotify.borderWidth = wBorderWidth (pWin);
+ event.u.configureNotify.override = pWin->overrideRedirect;
+ DeliverEvents(pWin, &event, 1, NullWindow);
+}
+
+void
+RRDeliverScreenEvent (ClientPtr client, WindowPtr pWin, ScreenPtr pScreen)
+{
+ rrScrPriv (pScreen);
+ xRRScreenChangeNotifyEvent se;
+ RRCrtcPtr crtc = pScrPriv->numCrtcs ? pScrPriv->crtcs[0] : NULL;
+ WindowPtr pRoot = pScreen->root;
+
+ se.type = RRScreenChangeNotify + RREventBase;
+ se.rotation = (CARD8) (crtc ? crtc->rotation : RR_Rotate_0);
+ se.timestamp = pScrPriv->lastSetTime.milliseconds;
+ se.configTimestamp = pScrPriv->lastConfigTime.milliseconds;
+ se.root = pRoot->drawable.id;
+ se.window = pWin->drawable.id;
+ se.subpixelOrder = PictureGetSubpixelOrder (pScreen);
+
+ se.sizeID = RR10CurrentSizeID (pScreen);
+
+ if (se.rotation & (RR_Rotate_90 | RR_Rotate_270)) {
+ se.widthInPixels = pScreen->height;
+ se.heightInPixels = pScreen->width;
+ se.widthInMillimeters = pScreen->mmHeight;
+ se.heightInMillimeters = pScreen->mmWidth;
+ } else {
+ se.widthInPixels = pScreen->width;
+ se.heightInPixels = pScreen->height;
+ se.widthInMillimeters = pScreen->mmWidth;
+ se.heightInMillimeters = pScreen->mmHeight;
+ }
+
+ WriteEventsToClient (client, 1, (xEvent *) &se);
+}
+
+/*
+ * Notify the extension that the screen size has been changed.
+ * The driver is responsible for calling this whenever it has changed
+ * the size of the screen
+ */
+void
+RRScreenSizeNotify (ScreenPtr pScreen)
+{
+ rrScrPriv(pScreen);
+ /*
+ * Deliver ConfigureNotify events when root changes
+ * pixel size
+ */
+ if (pScrPriv->width == pScreen->width &&
+ pScrPriv->height == pScreen->height &&
+ pScrPriv->mmWidth == pScreen->mmWidth &&
+ pScrPriv->mmHeight == pScreen->mmHeight)
+ return;
+
+ pScrPriv->width = pScreen->width;
+ pScrPriv->height = pScreen->height;
+ pScrPriv->mmWidth = pScreen->mmWidth;
+ pScrPriv->mmHeight = pScreen->mmHeight;
+ pScrPriv->changed = TRUE;
+/* pScrPriv->sizeChanged = TRUE; */
+
+ RRTellChanged (pScreen);
+ RRSendConfigNotify (pScreen);
+ RREditConnectionInfo (pScreen);
+
+ RRPointerScreenConfigured (pScreen);
+ /*
+ * Fix pointer bounds and location
+ */
+ ScreenRestructured (pScreen);
+}
+
+/*
+ * Request that the screen be resized
+ */
+Bool
+RRScreenSizeSet (ScreenPtr pScreen,
+ CARD16 width,
+ CARD16 height,
+ CARD32 mmWidth,
+ CARD32 mmHeight)
+{
+ rrScrPriv(pScreen);
+
+#if RANDR_12_INTERFACE
+ if (pScrPriv->rrScreenSetSize)
+ {
+ return (*pScrPriv->rrScreenSetSize) (pScreen,
+ width, height,
+ mmWidth, mmHeight);
+ }
+#endif
+#if RANDR_10_INTERFACE
+ if (pScrPriv->rrSetConfig)
+ {
+ return TRUE; /* can't set size separately */
+ }
+#endif
+ return FALSE;
+}
+
+/*
+ * Retrieve valid screen size range
+ */
+int
+ProcRRGetScreenSizeRange (ClientPtr client)
+{
+ REQUEST(xRRGetScreenSizeRangeReq);
+ xRRGetScreenSizeRangeReply rep;
+ WindowPtr pWin;
+ ScreenPtr pScreen;
+ rrScrPrivPtr pScrPriv;
+ int rc;
+
+ REQUEST_SIZE_MATCH(xRRGetScreenInfoReq);
+ rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
+ if (rc != Success)
+ return rc;
+
+ pScreen = pWin->drawable.pScreen;
+ pScrPriv = rrGetScrPriv(pScreen);
+
+ rep.type = X_Reply;
+ rep.pad = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+
+ if (pScrPriv)
+ {
+ if (!RRGetInfo (pScreen, FALSE))
+ return BadAlloc;
+ rep.minWidth = pScrPriv->minWidth;
+ rep.minHeight = pScrPriv->minHeight;
+ rep.maxWidth = pScrPriv->maxWidth;
+ rep.maxHeight = pScrPriv->maxHeight;
+ }
+ else
+ {
+ rep.maxWidth = rep.minWidth = pScreen->width;
+ rep.maxHeight = rep.minHeight = pScreen->height;
+ }
+ if (client->swapped)
+ {
+ int n;
+
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swaps(&rep.minWidth, n);
+ swaps(&rep.minHeight, n);
+ swaps(&rep.maxWidth, n);
+ swaps(&rep.maxHeight, n);
+ }
+ WriteToClient(client, sizeof(xRRGetScreenSizeRangeReply), (char *)&rep);
+ return Success;
+}
+
+int
+ProcRRSetScreenSize (ClientPtr client)
+{
+ REQUEST(xRRSetScreenSizeReq);
+ WindowPtr pWin;
+ ScreenPtr pScreen;
+ rrScrPrivPtr pScrPriv;
+ int i, rc;
+
+ REQUEST_SIZE_MATCH(xRRSetScreenSizeReq);
+ rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
+ if (rc != Success)
+ return rc;
+
+ pScreen = pWin->drawable.pScreen;
+ pScrPriv = rrGetScrPriv(pScreen);
+ if (stuff->width < pScrPriv->minWidth || pScrPriv->maxWidth < stuff->width)
+ {
+ client->errorValue = stuff->width;
+ return BadValue;
+ }
+ if (stuff->height < pScrPriv->minHeight ||
+ pScrPriv->maxHeight < stuff->height)
+ {
+ client->errorValue = stuff->height;
+ return BadValue;
+ }
+ for (i = 0; i < pScrPriv->numCrtcs; i++)
+ {
+ RRCrtcPtr crtc = pScrPriv->crtcs[i];
+ RRModePtr mode = crtc->mode;
+ if (mode)
+ {
+ int source_width = mode->mode.width;
+ int source_height = mode->mode.height;
+ Rotation rotation = crtc->rotation;
+
+ if (rotation == RR_Rotate_90 || rotation == RR_Rotate_270)
+ {
+ source_width = mode->mode.height;
+ source_height = mode->mode.width;
+ }
+
+ if (crtc->x + source_width > stuff->width ||
+ crtc->y + source_height > stuff->height)
+ return BadMatch;
+ }
+ }
+ if (stuff->widthInMillimeters == 0 || stuff->heightInMillimeters == 0)
+ {
+ client->errorValue = 0;
+ return BadValue;
+ }
+ if (!RRScreenSizeSet (pScreen,
+ stuff->width, stuff->height,
+ stuff->widthInMillimeters,
+ stuff->heightInMillimeters))
+ {
+ return BadMatch;
+ }
+ return Success;
+}
+
+static int
+rrGetScreenResources(ClientPtr client, Bool query)
+{
+ REQUEST(xRRGetScreenResourcesReq);
+ xRRGetScreenResourcesReply rep;
+ WindowPtr pWin;
+ ScreenPtr pScreen;
+ rrScrPrivPtr pScrPriv;
+ CARD8 *extra;
+ unsigned long extraLen;
+ int i, n, rc, has_primary = 0;
+ RRCrtc *crtcs;
+ RROutput *outputs;
+ xRRModeInfo *modeinfos;
+ CARD8 *names;
+
+ REQUEST_SIZE_MATCH(xRRGetScreenResourcesReq);
+ rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
+ if (rc != Success)
+ return rc;
+
+ pScreen = pWin->drawable.pScreen;
+ pScrPriv = rrGetScrPriv(pScreen);
+ rep.pad = 0;
+
+ if (query && pScrPriv)
+ if (!RRGetInfo (pScreen, query))
+ return BadAlloc;
+
+ if (!pScrPriv)
+ {
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.timestamp = currentTime.milliseconds;
+ rep.configTimestamp = currentTime.milliseconds;
+ rep.nCrtcs = 0;
+ rep.nOutputs = 0;
+ rep.nModes = 0;
+ rep.nbytesNames = 0;
+ extra = NULL;
+ extraLen = 0;
+ }
+ else
+ {
+ RRModePtr *modes;
+ int num_modes;
+
+ modes = RRModesForScreen (pScreen, &num_modes);
+ if (!modes)
+ return BadAlloc;
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.timestamp = pScrPriv->lastSetTime.milliseconds;
+ rep.configTimestamp = pScrPriv->lastConfigTime.milliseconds;
+ rep.nCrtcs = pScrPriv->numCrtcs;
+ rep.nOutputs = pScrPriv->numOutputs;
+ rep.nModes = num_modes;
+ rep.nbytesNames = 0;
+
+ for (i = 0; i < num_modes; i++)
+ rep.nbytesNames += modes[i]->mode.nameLength;
+
+ rep.length = (pScrPriv->numCrtcs +
+ pScrPriv->numOutputs +
+ num_modes * bytes_to_int32(SIZEOF(xRRModeInfo)) +
+ bytes_to_int32(rep.nbytesNames));
+
+ extraLen = rep.length << 2;
+ if (extraLen)
+ {
+ extra = malloc(extraLen);
+ if (!extra)
+ {
+ free(modes);
+ return BadAlloc;
+ }
+ }
+ else
+ extra = NULL;
+
+ crtcs = (RRCrtc *) extra;
+ outputs = (RROutput *) (crtcs + pScrPriv->numCrtcs);
+ modeinfos = (xRRModeInfo *) (outputs + pScrPriv->numOutputs);
+ names = (CARD8 *) (modeinfos + num_modes);
+
+ if (pScrPriv->primaryOutput && pScrPriv->primaryOutput->crtc)
+ {
+ has_primary = 1;
+ crtcs[0] = pScrPriv->primaryOutput->crtc->id;
+ if (client->swapped)
+ swapl (&crtcs[0], n);
+ }
+
+ for (i = 0; i < pScrPriv->numCrtcs; i++)
+ {
+ if (has_primary &&
+ pScrPriv->primaryOutput->crtc == pScrPriv->crtcs[i])
+ {
+ has_primary = 0;
+ continue;
+ }
+ crtcs[i + has_primary] = pScrPriv->crtcs[i]->id;
+ if (client->swapped)
+ swapl (&crtcs[i + has_primary], n);
+ }
+
+ for (i = 0; i < pScrPriv->numOutputs; i++)
+ {
+ outputs[i] = pScrPriv->outputs[i]->id;
+ if (client->swapped)
+ swapl (&outputs[i], n);
+ }
+
+ for (i = 0; i < num_modes; i++)
+ {
+ RRModePtr mode = modes[i];
+ modeinfos[i] = mode->mode;
+ if (client->swapped)
+ {
+ swapl (&modeinfos[i].id, n);
+ swaps (&modeinfos[i].width, n);
+ swaps (&modeinfos[i].height, n);
+ swapl (&modeinfos[i].dotClock, n);
+ swaps (&modeinfos[i].hSyncStart, n);
+ swaps (&modeinfos[i].hSyncEnd, n);
+ swaps (&modeinfos[i].hTotal, n);
+ swaps (&modeinfos[i].hSkew, n);
+ swaps (&modeinfos[i].vSyncStart, n);
+ swaps (&modeinfos[i].vSyncEnd, n);
+ swaps (&modeinfos[i].vTotal, n);
+ swaps (&modeinfos[i].nameLength, n);
+ swapl (&modeinfos[i].modeFlags, n);
+ }
+ memcpy (names, mode->name,
+ mode->mode.nameLength);
+ names += mode->mode.nameLength;
+ }
+ free(modes);
+ assert (bytes_to_int32((char *) names - (char *) extra) == rep.length);
+ }
+
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.timestamp, n);
+ swapl(&rep.configTimestamp, n);
+ swaps(&rep.nCrtcs, n);
+ swaps(&rep.nOutputs, n);
+ swaps(&rep.nModes, n);
+ swaps(&rep.nbytesNames, n);
+ }
+ WriteToClient(client, sizeof(xRRGetScreenResourcesReply), (char *)&rep);
+ if (extraLen)
+ {
+ WriteToClient (client, extraLen, (char *) extra);
+ free(extra);
+ }
+ return Success;
+}
+
+int
+ProcRRGetScreenResources (ClientPtr client)
+{
+ return rrGetScreenResources(client, TRUE);
+}
+
+int
+ProcRRGetScreenResourcesCurrent (ClientPtr client)
+{
+ return rrGetScreenResources(client, FALSE);
+}
+
+typedef struct _RR10Data {
+ RRScreenSizePtr sizes;
+ int nsize;
+ int nrefresh;
+ int size;
+ CARD16 refresh;
+} RR10DataRec, *RR10DataPtr;
+
+/*
+ * Convert 1.2 monitor data into 1.0 screen data
+ */
+static RR10DataPtr
+RR10GetData (ScreenPtr pScreen, RROutputPtr output)
+{
+ RR10DataPtr data;
+ RRScreenSizePtr size;
+ int nmode = output->numModes + output->numUserModes;
+ int o, os, l, r;
+ RRScreenRatePtr refresh;
+ CARD16 vRefresh;
+ RRModePtr mode;
+ Bool *used;
+
+ /* Make sure there is plenty of space for any combination */
+ data = malloc (sizeof (RR10DataRec) +
+ sizeof (RRScreenSize) * nmode +
+ sizeof (RRScreenRate) * nmode +
+ sizeof (Bool) * nmode);
+ if (!data)
+ return NULL;
+ size = (RRScreenSizePtr) (data + 1);
+ refresh = (RRScreenRatePtr) (size + nmode);
+ used = (Bool *) (refresh + nmode);
+ memset (used, '\0', sizeof (Bool) * nmode);
+ data->sizes = size;
+ data->nsize = 0;
+ data->nrefresh = 0;
+ data->size = 0;
+ data->refresh = 0;
+
+ /*
+ * find modes not yet listed
+ */
+ for (o = 0; o < output->numModes + output->numUserModes; o++)
+ {
+ if (used[o]) continue;
+
+ if (o < output->numModes)
+ mode = output->modes[o];
+ else
+ mode = output->userModes[o - output->numModes];
+
+ l = data->nsize;
+ size[l].id = data->nsize;
+ size[l].width = mode->mode.width;
+ size[l].height = mode->mode.height;
+ if (output->mmWidth && output->mmHeight) {
+ size[l].mmWidth = output->mmWidth;
+ size[l].mmHeight = output->mmHeight;
+ } else {
+ size[l].mmWidth = pScreen->mmWidth;
+ size[l].mmHeight = pScreen->mmHeight;
+ }
+ size[l].nRates = 0;
+ size[l].pRates = &refresh[data->nrefresh];
+ data->nsize++;
+
+ /*
+ * Find all modes with matching size
+ */
+ for (os = o; os < output->numModes + output->numUserModes; os++)
+ {
+ if (os < output->numModes)
+ mode = output->modes[os];
+ else
+ mode = output->userModes[os - output->numModes];
+ if (mode->mode.width == size[l].width &&
+ mode->mode.height == size[l].height)
+ {
+ vRefresh = RRVerticalRefresh (&mode->mode);
+ used[os] = TRUE;
+
+ for (r = 0; r < size[l].nRates; r++)
+ if (vRefresh == size[l].pRates[r].rate)
+ break;
+ if (r == size[l].nRates)
+ {
+ size[l].pRates[r].rate = vRefresh;
+ size[l].pRates[r].mode = mode;
+ size[l].nRates++;
+ data->nrefresh++;
+ }
+ if (mode == output->crtc->mode)
+ {
+ data->size = l;
+ data->refresh = vRefresh;
+ }
+ }
+ }
+ }
+ return data;
+}
+
+int
+ProcRRGetScreenInfo (ClientPtr client)
+{
+ REQUEST(xRRGetScreenInfoReq);
+ xRRGetScreenInfoReply rep;
+ WindowPtr pWin;
+ int n, rc;
+ ScreenPtr pScreen;
+ rrScrPrivPtr pScrPriv;
+ CARD8 *extra;
+ unsigned long extraLen;
+ RROutputPtr output;
+
+ REQUEST_SIZE_MATCH(xRRGetScreenInfoReq);
+ rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
+ if (rc != Success)
+ return rc;
+
+ pScreen = pWin->drawable.pScreen;
+ pScrPriv = rrGetScrPriv(pScreen);
+ rep.pad = 0;
+
+ if (pScrPriv)
+ if (!RRGetInfo (pScreen, TRUE))
+ return BadAlloc;
+
+ output = RRFirstOutput (pScreen);
+
+ if (!pScrPriv || !output)
+ {
+ rep.type = X_Reply;
+ rep.setOfRotations = RR_Rotate_0;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.root = pWin->drawable.pScreen->root->drawable.id;
+ rep.timestamp = currentTime.milliseconds;
+ rep.configTimestamp = currentTime.milliseconds;
+ rep.nSizes = 0;
+ rep.sizeID = 0;
+ rep.rotation = RR_Rotate_0;
+ rep.rate = 0;
+ rep.nrateEnts = 0;
+ extra = 0;
+ extraLen = 0;
+ }
+ else
+ {
+ int i, j;
+ xScreenSizes *size;
+ CARD16 *rates;
+ CARD8 *data8;
+ Bool has_rate = RRClientKnowsRates (client);
+ RR10DataPtr pData;
+ RRScreenSizePtr pSize;
+
+ pData = RR10GetData (pScreen, output);
+ if (!pData)
+ return BadAlloc;
+
+ rep.type = X_Reply;
+ rep.setOfRotations = output->crtc->rotations;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.root = pWin->drawable.pScreen->root->drawable.id;
+ rep.timestamp = pScrPriv->lastSetTime.milliseconds;
+ rep.configTimestamp = pScrPriv->lastConfigTime.milliseconds;
+ rep.rotation = output->crtc->rotation;
+ rep.nSizes = pData->nsize;
+ rep.nrateEnts = pData->nrefresh + pData->nsize;
+ rep.sizeID = pData->size;
+ rep.rate = pData->refresh;
+
+ extraLen = rep.nSizes * sizeof (xScreenSizes);
+ if (has_rate)
+ extraLen += rep.nrateEnts * sizeof (CARD16);
+
+ if (extraLen)
+ {
+ extra = (CARD8 *) malloc(extraLen);
+ if (!extra)
+ {
+ free(pData);
+ return BadAlloc;
+ }
+ }
+ else
+ extra = NULL;
+
+ /*
+ * First comes the size information
+ */
+ size = (xScreenSizes *) extra;
+ rates = (CARD16 *) (size + rep.nSizes);
+ for (i = 0; i < pData->nsize; i++)
+ {
+ pSize = &pData->sizes[i];
+ size->widthInPixels = pSize->width;
+ size->heightInPixels = pSize->height;
+ size->widthInMillimeters = pSize->mmWidth;
+ size->heightInMillimeters = pSize->mmHeight;
+ if (client->swapped)
+ {
+ swaps (&size->widthInPixels, n);
+ swaps (&size->heightInPixels, n);
+ swaps (&size->widthInMillimeters, n);
+ swaps (&size->heightInMillimeters, n);
+ }
+ size++;
+ if (has_rate)
+ {
+ *rates = pSize->nRates;
+ if (client->swapped)
+ {
+ swaps (rates, n);
+ }
+ rates++;
+ for (j = 0; j < pSize->nRates; j++)
+ {
+ *rates = pSize->pRates[j].rate;
+ if (client->swapped)
+ {
+ swaps (rates, n);
+ }
+ rates++;
+ }
+ }
+ }
+ free(pData);
+
+ data8 = (CARD8 *) rates;
+
+ if (data8 - (CARD8 *) extra != extraLen)
+ FatalError ("RRGetScreenInfo bad extra len %ld != %ld\n",
+ (unsigned long)(data8 - (CARD8 *) extra), extraLen);
+ rep.length = bytes_to_int32(extraLen);
+ }
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.timestamp, n);
+ swaps(&rep.rotation, n);
+ swaps(&rep.nSizes, n);
+ swaps(&rep.sizeID, n);
+ swaps(&rep.rate, n);
+ swaps(&rep.nrateEnts, n);
+ }
+ WriteToClient(client, sizeof(xRRGetScreenInfoReply), (char *)&rep);
+ if (extraLen)
+ {
+ WriteToClient (client, extraLen, (char *) extra);
+ free(extra);
+ }
+ return Success;
+}
+
+int
+ProcRRSetScreenConfig (ClientPtr client)
+{
+ REQUEST(xRRSetScreenConfigReq);
+ xRRSetScreenConfigReply rep;
+ DrawablePtr pDraw;
+ int n, rc;
+ ScreenPtr pScreen;
+ rrScrPrivPtr pScrPriv;
+ TimeStamp time;
+ int i;
+ Rotation rotation;
+ int rate;
+ Bool has_rate;
+ RROutputPtr output;
+ RRCrtcPtr crtc;
+ RRModePtr mode;
+ RR10DataPtr pData = NULL;
+ RRScreenSizePtr pSize;
+ int width, height;
+
+ UpdateCurrentTime ();
+
+ if (RRClientKnowsRates (client))
+ {
+ REQUEST_SIZE_MATCH (xRRSetScreenConfigReq);
+ has_rate = TRUE;
+ }
+ else
+ {
+ REQUEST_SIZE_MATCH (xRR1_0SetScreenConfigReq);
+ has_rate = FALSE;
+ }
+
+ rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, DixWriteAccess);
+ if (rc != Success)
+ return rc;
+
+ pScreen = pDraw->pScreen;
+
+ pScrPriv = rrGetScrPriv(pScreen);
+
+ time = ClientTimeToServerTime(stuff->timestamp);
+
+ if (!pScrPriv)
+ {
+ time = currentTime;
+ rep.status = RRSetConfigFailed;
+ goto sendReply;
+ }
+ if (!RRGetInfo (pScreen, FALSE))
+ return BadAlloc;
+
+ output = RRFirstOutput (pScreen);
+ if (!output)
+ {
+ time = currentTime;
+ rep.status = RRSetConfigFailed;
+ goto sendReply;
+ }
+
+ crtc = output->crtc;
+
+ /*
+ * If the client's config timestamp is not the same as the last config
+ * timestamp, then the config information isn't up-to-date and
+ * can't even be validated.
+ *
+ * Note that the client only knows about the milliseconds part of the
+ * timestamp, so using CompareTimeStamps here would cause randr to suddenly
+ * stop working after several hours have passed (freedesktop bug #6502).
+ */
+ if (stuff->configTimestamp != pScrPriv->lastConfigTime.milliseconds)
+ {
+ rep.status = RRSetConfigInvalidConfigTime;
+ goto sendReply;
+ }
+
+ pData = RR10GetData (pScreen, output);
+ if (!pData)
+ return BadAlloc;
+
+ if (stuff->sizeID >= pData->nsize)
+ {
+ /*
+ * Invalid size ID
+ */
+ client->errorValue = stuff->sizeID;
+ free(pData);
+ return BadValue;
+ }
+ pSize = &pData->sizes[stuff->sizeID];
+
+ /*
+ * Validate requested rotation
+ */
+ rotation = (Rotation) stuff->rotation;
+
+ /* test the rotation bits only! */
+ switch (rotation & 0xf) {
+ case RR_Rotate_0:
+ case RR_Rotate_90:
+ case RR_Rotate_180:
+ case RR_Rotate_270:
+ break;
+ default:
+ /*
+ * Invalid rotation
+ */
+ client->errorValue = stuff->rotation;
+ free(pData);
+ return BadValue;
+ }
+
+ if ((~crtc->rotations) & rotation)
+ {
+ /*
+ * requested rotation or reflection not supported by screen
+ */
+ client->errorValue = stuff->rotation;
+ free(pData);
+ return BadMatch;
+ }
+
+ /*
+ * Validate requested refresh
+ */
+ if (has_rate)
+ rate = (int) stuff->rate;
+ else
+ rate = 0;
+
+ if (rate)
+ {
+ for (i = 0; i < pSize->nRates; i++)
+ {
+ if (pSize->pRates[i].rate == rate)
+ break;
+ }
+ if (i == pSize->nRates)
+ {
+ /*
+ * Invalid rate
+ */
+ client->errorValue = rate;
+ free(pData);
+ return BadValue;
+ }
+ mode = pSize->pRates[i].mode;
+ }
+ else
+ mode = pSize->pRates[0].mode;
+
+ /*
+ * Make sure the requested set-time is not older than
+ * the last set-time
+ */
+ if (CompareTimeStamps (time, pScrPriv->lastSetTime) < 0)
+ {
+ rep.status = RRSetConfigInvalidTime;
+ goto sendReply;
+ }
+
+ /*
+ * If the screen size is changing, adjust all of the other outputs
+ * to fit the new size, mirroring as much as possible
+ */
+ width = mode->mode.width;
+ height = mode->mode.height;
+ if (rotation & (RR_Rotate_90|RR_Rotate_270))
+ {
+ width = mode->mode.height;
+ height = mode->mode.width;
+ }
+
+ if (width < pScrPriv->minWidth || pScrPriv->maxWidth < width) {
+ client->errorValue = width;
+ free(pData);
+ return BadValue;
+ }
+ if (height < pScrPriv->minHeight || pScrPriv->maxHeight < height) {
+ client->errorValue = height;
+ free(pData);
+ return BadValue;
+ }
+
+ if (width != pScreen->width || height != pScreen->height)
+ {
+ int c;
+
+ for (c = 0; c < pScrPriv->numCrtcs; c++)
+ {
+ if (!RRCrtcSet (pScrPriv->crtcs[c], NULL, 0, 0, RR_Rotate_0,
+ 0, NULL))
+ {
+ rep.status = RRSetConfigFailed;
+ /* XXX recover from failure */
+ goto sendReply;
+ }
+ }
+ if (!RRScreenSizeSet (pScreen, width, height,
+ pScreen->mmWidth, pScreen->mmHeight))
+ {
+ rep.status = RRSetConfigFailed;
+ /* XXX recover from failure */
+ goto sendReply;
+ }
+ }
+
+ if (!RRCrtcSet (crtc, mode, 0, 0, stuff->rotation, 1, &output))
+ rep.status = RRSetConfigFailed;
+ else {
+ pScrPriv->lastSetTime = time;
+ rep.status = RRSetConfigSuccess;
+ }
+
+ /*
+ * XXX Configure other crtcs to mirror as much as possible
+ */
+
+sendReply:
+
+ free(pData);
+
+ rep.type = X_Reply;
+ /* rep.status has already been filled in */
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ rep.newTimestamp = pScrPriv->lastSetTime.milliseconds;
+ rep.newConfigTimestamp = pScrPriv->lastConfigTime.milliseconds;
+ rep.root = pDraw->pScreen->root->drawable.id;
+
+ if (client->swapped)
+ {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.newTimestamp, n);
+ swapl(&rep.newConfigTimestamp, n);
+ swapl(&rep.root, n);
+ }
+ WriteToClient(client, sizeof(xRRSetScreenConfigReply), (char *)&rep);
+
+ return Success;
+}
+
+static CARD16
+RR10CurrentSizeID (ScreenPtr pScreen)
+{
+ CARD16 sizeID = 0xffff;
+ RROutputPtr output = RRFirstOutput (pScreen);
+
+ if (output)
+ {
+ RR10DataPtr data = RR10GetData (pScreen, output);
+ if (data)
+ {
+ int i;
+ for (i = 0; i < data->nsize; i++)
+ if (data->sizes[i].width == pScreen->width &&
+ data->sizes[i].height == pScreen->height)
+ {
+ sizeID = (CARD16) i;
+ break;
+ }
+ free(data);
+ }
+ }
+ return sizeID;
+}
diff --git a/xorg-server/randr/rrsdispatch.c b/xorg-server/randr/rrsdispatch.c index 5c6978aa1..0a9207bac 100644 --- a/xorg-server/randr/rrsdispatch.c +++ b/xorg-server/randr/rrsdispatch.c @@ -461,132 +461,6 @@ SProcRRGetOutputPrimary (ClientPtr client) return ProcRandrVector[stuff->randrReqType](client);
}
-static int
-SProcRRQueryScanoutPixmaps (ClientPtr client)
-{
- int n;
- REQUEST(xRRQueryScanoutPixmapsReq);
-
- REQUEST_SIZE_MATCH(xRRQueryScanoutPixmapsReq);
- swaps(&stuff->length, n);
- swapl(&stuff->drawable, n);
- return ProcRandrVector[stuff->randrReqType](client);
-}
-
-static int
-SProcRRCreateScanoutPixmap (ClientPtr client)
-{
- int n;
- REQUEST(xRRCreateScanoutPixmapReq);
-
- REQUEST_SIZE_MATCH(xRRCreateScanoutPixmapReq);
- swaps(&stuff->length, n);
- swapl(&stuff->pid, n);
- swapl(&stuff->drawable, n);
- swaps(&stuff->width, n);
- swaps(&stuff->height, n);
- swapl(&stuff->format, n);
- swaps(&stuff->rotations, n);
- return ProcRandrVector[stuff->randrReqType](client);
-}
-
-static void
-swap_transform(xRenderTransform *t)
-{
- int n;
- swapl(&t->matrix11, n);
- swapl(&t->matrix12, n);
- swapl(&t->matrix13, n);
- swapl(&t->matrix21, n);
- swapl(&t->matrix22, n);
- swapl(&t->matrix23, n);
- swapl(&t->matrix31, n);
- swapl(&t->matrix32, n);
- swapl(&t->matrix33, n);
-}
-
-static int
-SProcRRSetCrtcSpriteTransform (ClientPtr client)
-{
- int n;
- REQUEST(xRRSetCrtcSpriteTransformReq);
-
- REQUEST_SIZE_MATCH(xRRSetCrtcSpriteTransformReq);
- swaps(&stuff->length, n);
- swapl(&stuff->crtc, n);
- swap_transform(&stuff->positionTransform);
- swap_transform(&stuff->imageTransform);
- return ProcRandrVector[stuff->randrReqType](client);
-}
-
-static int
-SProcRRGetCrtcSpriteTransform (ClientPtr client)
-{
- int n;
- REQUEST(xRRGetCrtcSpriteTransformReq);
-
- REQUEST_SIZE_MATCH(xRRGetCrtcSpriteTransformReq);
- swaps(&stuff->length, n);
- swapl(&stuff->crtc, n);
- return ProcRandrVector[stuff->randrReqType](client);
-}
-
-static int
-SProcRRSetCrtcConfigs (ClientPtr client)
-{
- int n;
- REQUEST(xRRSetCrtcConfigsReq);
- int c;
- int extra_len;
- int num_configs;
- int num_output_ids;
- xRRCrtcConfig *x_configs;
-
- REQUEST_AT_LEAST_SIZE(xRRSetCrtcConfigsReq);
- swaps(&stuff->length, n);
- swapl(&stuff->drawable, n);
- swaps(&stuff->screenPixmapWidth, n);
- swaps(&stuff->screenPixmapHeight, n);
- swaps(&stuff->screenWidth, n);
- swaps(&stuff->screenHeight, n);
- swapl(&stuff->widthInMillimeters, n);
- swapl(&stuff->heightInMillimeters, n);
- swaps(&stuff->nConfigs, n);
-
- extra_len = client->req_len - bytes_to_int32(sizeof(xRRSetCrtcConfigsReq));
-
- num_configs = stuff->nConfigs;
-
- /* Check request length against number of configs specified */
- if (num_configs * (sizeof (xRRCrtcConfig) >> 2) > extra_len)
- return BadLength;
-
- x_configs = (xRRCrtcConfig *) (stuff + 1);
- for (c = 0; c < num_configs; c++) {
- swapl(&x_configs->crtc, n);
- swaps(&x_configs->x, n);
- swaps(&x_configs->y, n);
- swapl(&x_configs->mode, n);
- swaps(&x_configs->rotation, n);
- swaps(&x_configs->nOutput, n);
- swap_transform(&x_configs->spritePositionTransform);
- swap_transform(&x_configs->spriteImageTransform);
- swapl(&x_configs->pixmap, n);
- swaps(&x_configs->xPixmap, n);
- swaps(&x_configs->yPixmap, n);
- x_configs++;
- }
-
- /* Let the other dispatch function deal with verifying that
- * the right number of output ids are present, just
- * swap whatever is here
- */
- num_output_ids = extra_len - (num_configs * (sizeof (xRRCrtcConfig)) >> 2);
- SwapLongs((CARD32 *) x_configs, num_output_ids);
-
- return ProcRandrVector[stuff->randrReqType](client);
-}
-
int (*SProcRandrVector[RRNumberRequests])(ClientPtr) = {
SProcRRQueryVersion, /* 0 */
/* we skip 1 to make old clients fail pretty immediately */
@@ -625,11 +499,5 @@ int (*SProcRandrVector[RRNumberRequests])(ClientPtr) = { SProcRRSetPanning, /* 29 */
SProcRRSetOutputPrimary, /* 30 */
SProcRRGetOutputPrimary, /* 31 */
-/* V1.4 additions */
- SProcRRQueryScanoutPixmaps, /* 32 */
- SProcRRCreateScanoutPixmap, /* 33 */
- SProcRRSetCrtcSpriteTransform,/* 34 */
- SProcRRGetCrtcSpriteTransform,/* 35 */
- SProcRRSetCrtcConfigs, /* 36 */
};
diff --git a/xorg-server/randr/rrsprite.c b/xorg-server/randr/rrsprite.c deleted file mode 100644 index c441e0396..000000000 --- a/xorg-server/randr/rrsprite.c +++ /dev/null @@ -1,104 +0,0 @@ -/*
- * Copyright © 2010 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that copyright
- * notice and this permission notice appear in supporting documentation, and
- * that the name of the copyright holders not be used in advertising or
- * publicity pertaining to distribution of the software without specific,
- * written prior permission. The copyright holders make no representations
- * about the suitability of this software for any purpose. It is provided "as
- * is" without express or implied warranty.
- *
- * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-#include "randrstr.h"
-#include "swaprep.h"
-
-void
-RRCrtcSpriteTransformSet(RRCrtcPtr crtc,
- PictTransform *position_transform,
- PictTransform *image_transform,
- struct pict_f_transform *f_position_transform,
- struct pict_f_transform *f_image_transform)
-{
- ScreenPtr pScreen;
- rrScrPrivPtr pScrPriv;
-
- pScreen = crtc->pScreen;
- pScrPriv = rrGetScrPriv(pScreen);
- crtc->client_sprite_position_transform = *position_transform;
- crtc->client_sprite_image_transform = *image_transform;
- crtc->client_sprite_f_position_transform = *f_position_transform;
- crtc->client_sprite_f_image_transform = *f_image_transform;
- if (pScrPriv->rrSetCrtcSpriteTransform)
- (*pScrPriv->rrSetCrtcSpriteTransform) (pScreen, crtc,
- &crtc->client_sprite_f_position_transform,
- &crtc->client_sprite_f_image_transform);
-}
-
-int
-ProcRRSetCrtcSpriteTransform (ClientPtr client)
-{
- REQUEST(xRRSetCrtcSpriteTransformReq);
- RRCrtcPtr crtc;
- PictTransform position_transform, image_transform;
- struct pixman_f_transform f_position_transform, f_image_transform;
-
- REQUEST_AT_LEAST_SIZE(xRRSetCrtcSpriteTransformReq);
- VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess);
-
- PictTransform_from_xRenderTransform (&position_transform, &stuff->positionTransform);
- PictTransform_from_xRenderTransform (&image_transform, &stuff->imageTransform);
- pixman_f_transform_from_pixman_transform (&f_position_transform, &position_transform);
- pixman_f_transform_from_pixman_transform (&f_image_transform, &image_transform);
-
- RRCrtcSpriteTransformSet (crtc, &position_transform, &image_transform,
- &f_position_transform, &f_image_transform);
- return Success;
-}
-
-#define CrtcSpriteTransformExtra (SIZEOF(xRRGetCrtcSpriteTransformReply) - 32)
-
-int
-ProcRRGetCrtcSpriteTransform (ClientPtr client)
-{
- REQUEST(xRRGetCrtcSpriteTransformReq);
- xRRGetCrtcSpriteTransformReply *reply;
- RRCrtcPtr crtc;
- int n;
- char *extra;
-
- REQUEST_SIZE_MATCH (xRRGetCrtcSpriteTransformReq);
- VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess);
-
- reply = malloc(sizeof (xRRGetCrtcSpriteTransformReply));
- if (!reply)
- return BadAlloc;
-
- extra = (char *) (reply + 1);
- reply->type = X_Reply;
- reply->sequenceNumber = client->sequence;
- reply->length = bytes_to_int32(CrtcSpriteTransformExtra);
-
- xRenderTransform_from_PictTransform(&reply->positionTransform, &crtc->client_sprite_position_transform);
- xRenderTransform_from_PictTransform(&reply->imageTransform, &crtc->client_sprite_image_transform);
-
- if (client->swapped) {
- swaps (&reply->sequenceNumber, n);
- swapl (&reply->length, n);
- SwapLongs((CARD32 *) &reply->positionTransform, bytes_to_int32(sizeof(xRenderTransform)));
- SwapLongs((CARD32 *) &reply->imageTransform, bytes_to_int32(sizeof(xRenderTransform)));
- }
- WriteToClient (client, sizeof (xRRGetCrtcSpriteTransformReply), (char *) reply);
- free(reply);
- return Success;
-}
diff --git a/xorg-server/randr/rrtransform.c b/xorg-server/randr/rrtransform.c index f78d5f913..102a0f48e 100644 --- a/xorg-server/randr/rrtransform.c +++ b/xorg-server/randr/rrtransform.c @@ -134,24 +134,6 @@ RRTransformRescale(struct pixman_f_transform *f_transform, double limit) f_transform->m[j][i] *= scale;
}
-#define EPSILON (1e-20)
-#define IS_F_SAME(a,b) (fabs((a)-(b)) < EPSILON)
-#define IS_F_ZERO(a) (fabs(a) < EPSILON)
-
-static Bool
-pict_f_transform_is_identity (const struct pixman_f_transform *t)
-{
- return (IS_F_SAME (t->m[0][0], t->m[1][1]) &&
- IS_F_SAME (t->m[0][0], t->m[2][2]) &&
- !IS_F_ZERO (t->m[0][0]) &&
- IS_F_ZERO (t->m[0][1]) &&
- IS_F_ZERO (t->m[0][2]) &&
- IS_F_ZERO (t->m[1][0]) &&
- IS_F_ZERO (t->m[1][2]) &&
- IS_F_ZERO (t->m[2][0]) &&
- IS_F_ZERO (t->m[2][1]));
-}
-
/*
* Compute the complete transformation matrix including
* client-specified transform, rotation/reflection values and the crtc
@@ -166,39 +148,23 @@ RRTransformCompute (int x, int height,
Rotation rotation,
RRTransformPtr rr_transform,
- struct pixman_f_transform *sprite_position_transform,
- struct pixman_f_transform *sprite_image_transform,
PictTransformPtr transform,
struct pixman_f_transform *f_transform,
- struct pixman_f_transform *f_inverse,
- struct pixman_f_transform *f_fb_to_sprite,
- struct pixman_f_transform *f_sprite_to_image,
- Bool *sprite_transform_in_use)
+ struct pixman_f_transform *f_inverse)
{
PictTransform t_transform, inverse;
struct pixman_f_transform tf_transform, tf_inverse;
- struct pixman_f_transform sf_position_transform, sf_image_transform;
- struct pixman_f_transform f_image_to_sprite;
Bool overflow = FALSE;
- Bool ret = TRUE;
if (!transform) transform = &t_transform;
if (!f_transform) f_transform = &tf_transform;
if (!f_inverse) f_inverse = &tf_inverse;
- if (!f_fb_to_sprite) f_fb_to_sprite = &sf_position_transform;
- if (!f_sprite_to_image) f_sprite_to_image = &sf_image_transform;
-
- /* invert the sprite image transform to have it go from dest to source */
- if (!pixman_f_transform_invert (&f_image_to_sprite, f_sprite_to_image))
- pixman_f_transform_init_identity(&f_image_to_sprite);
pixman_transform_init_identity (transform);
pixman_transform_init_identity (&inverse);
pixman_f_transform_init_identity (f_transform);
pixman_f_transform_init_identity (f_inverse);
- pixman_f_transform_init_identity (f_fb_to_sprite);
- pixman_f_transform_init_identity (f_sprite_to_image);
if (rotation != RR_Rotate_0)
{
double f_rot_cos, f_rot_sin, f_rot_dx, f_rot_dy;
@@ -280,14 +246,7 @@ RRTransformCompute (int x, pixman_f_transform_translate (f_transform, f_inverse, f_scale_dx, f_scale_dy);
}
- /*
- * Sprite position is affected by the transform matrix,
- * but the image is not
- */
- pixman_f_transform_multiply(f_sprite_to_image,
- f_transform,
- &f_image_to_sprite);
-
+#ifdef RANDR_12_INTERFACE
if (rr_transform)
{
if (!pixman_transform_multiply (transform, &rr_transform->transform, transform))
@@ -295,7 +254,7 @@ RRTransformCompute (int x, pixman_f_transform_multiply (f_transform, &rr_transform->f_transform, f_transform);
pixman_f_transform_multiply (f_inverse, f_inverse, &rr_transform->f_inverse);
}
-
+#endif
/*
* Compute the class of the resulting transform
*/
@@ -305,7 +264,7 @@ RRTransformCompute (int x, pixman_f_transform_init_translate (f_transform, x, y);
pixman_f_transform_init_translate (f_inverse, -x, -y);
- ret = FALSE;
+ return FALSE;
}
else
{
@@ -319,19 +278,6 @@ RRTransformCompute (int x, RRTransformRescale(&f_scaled, 16384.0);
pixman_transform_from_pixman_f_transform(transform, &f_scaled);
}
- ret = TRUE;
+ return TRUE;
}
-
- /*
- * Sprite position is affected by the transform matrix,
- * but the image is not
- */
- pixman_f_transform_multiply(f_fb_to_sprite,
- f_inverse,
- sprite_position_transform);
- if (sprite_transform_in_use)
- *sprite_transform_in_use = ret || !pict_f_transform_is_identity(f_fb_to_sprite);
- return ret;
}
-
-
diff --git a/xorg-server/randr/rrtransform.h b/xorg-server/randr/rrtransform.h index eaced0d3e..b09a84ca1 100644 --- a/xorg-server/randr/rrtransform.h +++ b/xorg-server/randr/rrtransform.h @@ -59,13 +59,6 @@ RRTransformSetFilter (RRTransformPtr dst, extern _X_EXPORT Bool
RRTransformCopy (RRTransformPtr dst, RRTransformPtr src);
-/*
- * Compute the complete transformation matrix including
- * client-specified transform, rotation/reflection values and the crtc
- * offset.
- *
- * Return TRUE if the resulting transform is not a simple translation.
- */
extern _X_EXPORT Bool
RRTransformCompute (int x,
int y,
@@ -73,14 +66,10 @@ RRTransformCompute (int x, int height,
Rotation rotation,
RRTransformPtr rr_transform,
- struct pict_f_transform *sprite_position_transform,
- struct pict_f_transform *sprite_image_transform,
PictTransformPtr transform,
struct pict_f_transform *f_transform,
- struct pict_f_transform *f_inverse,
- struct pict_f_transform *f_fb_to_sprite,
- struct pict_f_transform *f_sprite_to_image,
- Bool *sprite_transform_in_use);
+ struct pict_f_transform *f_inverse);
+
#endif /* _RRTRANSFORM_H_ */
|