ephyr: Refactor XV adaptor feature detection.

This obviously wanted a helper function beforehand, but even more so
now that we have XCB.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Julien Cristau <jcristau@debian.org>
This commit is contained in:
Eric Anholt 2013-08-18 20:08:32 +02:00
parent 7a9c311add
commit fad79d2e3e
3 changed files with 17 additions and 110 deletions

View File

@ -137,74 +137,6 @@ ephyrHostXVAdaptorGetVideoFormats (const xcb_xv_adaptor_info_t *a_this,
return formats;
}
Bool
ephyrHostXVAdaptorHasPutVideo (const xcb_xv_adaptor_info_t *a_this,
Bool *a_result)
{
EPHYR_RETURN_VAL_IF_FAIL(a_this && a_result, FALSE);
if ((a_this->type & (XCB_XV_TYPE_VIDEO_MASK | XCB_XV_TYPE_INPUT_MASK)) ==
(XCB_XV_TYPE_VIDEO_MASK | XCB_XV_TYPE_INPUT_MASK))
*a_result = TRUE;
else
*a_result = FALSE;
return TRUE;
}
Bool
ephyrHostXVAdaptorHasGetVideo(const xcb_xv_adaptor_info_t *a_this,
Bool *a_result)
{
if ((a_this->type & (XCB_XV_TYPE_VIDEO_MASK | XCB_XV_TYPE_OUTPUT_MASK)) ==
(XCB_XV_TYPE_VIDEO_MASK | XCB_XV_TYPE_OUTPUT_MASK))
*a_result = TRUE;
else
*a_result = FALSE;
return TRUE;
}
Bool
ephyrHostXVAdaptorHasPutStill(const xcb_xv_adaptor_info_t *a_this,
Bool *a_result)
{
EPHYR_RETURN_VAL_IF_FAIL(a_this && a_result, FALSE);
if ((a_this->type & (XCB_XV_TYPE_STILL_MASK | XCB_XV_TYPE_INPUT_MASK)) ==
(XCB_XV_TYPE_STILL_MASK | XCB_XV_TYPE_INPUT_MASK))
*a_result = TRUE;
else
*a_result = FALSE;
return TRUE;
}
Bool
ephyrHostXVAdaptorHasGetStill(const xcb_xv_adaptor_info_t *a_this,
Bool *a_result)
{
EPHYR_RETURN_VAL_IF_FAIL(a_this && a_result, FALSE);
if ((a_this->type & (XCB_XV_TYPE_STILL_MASK | XCB_XV_TYPE_OUTPUT_MASK)) ==
(XCB_XV_TYPE_STILL_MASK | XCB_XV_TYPE_OUTPUT_MASK))
*a_result = TRUE;
else
*a_result = FALSE;
return TRUE;
}
Bool
ephyrHostXVAdaptorHasPutImage(const xcb_xv_adaptor_info_t *a_this,
Bool *a_result)
{
EPHYR_RETURN_VAL_IF_FAIL(a_this && a_result, FALSE);
if ((a_this->type & (XCB_XV_TYPE_IMAGE_MASK | XCB_XV_TYPE_INPUT_MASK)) ==
(XCB_XV_TYPE_IMAGE_MASK | XCB_XV_TYPE_INPUT_MASK))
*a_result = TRUE;
else
*a_result = FALSE;
return TRUE;
}
Bool
ephyrHostXVQueryEncodings(int a_port_id,
EphyrHostEncoding ** a_encodings,

View File

@ -98,17 +98,6 @@ char* ephyrHostXVAdaptorGetName(const xcb_xv_adaptor_info_t *a_this);
EphyrHostVideoFormat *ephyrHostXVAdaptorGetVideoFormats
(const xcb_xv_adaptor_info_t *a_this, int *a_nb_formats);
Bool ephyrHostXVAdaptorHasPutVideo(const xcb_xv_adaptor_info_t *a_this,
Bool *a_result);
Bool ephyrHostXVAdaptorHasGetVideo(const xcb_xv_adaptor_info_t *a_this,
Bool *a_result);
Bool ephyrHostXVAdaptorHasPutStill(const xcb_xv_adaptor_info_t *a_this,
Bool *a_result);
Bool ephyrHostXVAdaptorHasGetStill(const xcb_xv_adaptor_info_t *a_this,
Bool *a_result);
Bool ephyrHostXVAdaptorHasPutImage(const xcb_xv_adaptor_info_t *a_this,
Bool *a_result);
/*
* encoding
*/

View File

@ -169,6 +169,12 @@ static int s_base_port_id;
* <helpers>
* ************/
static Bool
adaptor_has_flags(const xcb_xv_adaptor_info_t *adaptor, uint32_t flags)
{
return (adaptor->type & flags) == flags;
}
static Bool
DoSimpleClip(BoxPtr a_dst_box, BoxPtr a_clipper, BoxPtr a_result)
{
@ -508,7 +514,6 @@ static Bool
ephyrXVPrivSetAdaptorsHooks(EphyrXVPriv * a_this)
{
int i = 0;
Bool has_it = FALSE;
xcb_xv_adaptor_info_t *cur_host_adaptor = NULL;
EPHYR_RETURN_VAL_IF_FAIL(a_this, FALSE);
@ -528,45 +533,26 @@ ephyrXVPrivSetAdaptorsHooks(EphyrXVPriv * a_this)
EPHYR_LOG_ERROR("failed to get host adaptor at index %d\n", i);
continue;
}
has_it = FALSE;
if (!ephyrHostXVAdaptorHasPutImage(cur_host_adaptor, &has_it)) {
EPHYR_LOG_ERROR("error\n");
}
if (has_it) {
if (adaptor_has_flags(cur_host_adaptor,
XCB_XV_TYPE_IMAGE_MASK | XCB_XV_TYPE_INPUT_MASK))
a_this->adaptors[i].PutImage = ephyrPutImage;
}
has_it = FALSE;
if (!ephyrHostXVAdaptorHasPutVideo(cur_host_adaptor, &has_it)) {
EPHYR_LOG_ERROR("error\n");
}
if (has_it) {
if (adaptor_has_flags(cur_host_adaptor,
XCB_XV_TYPE_VIDEO_MASK | XCB_XV_TYPE_INPUT_MASK))
a_this->adaptors[i].PutVideo = ephyrPutVideo;
}
has_it = FALSE;
if (!ephyrHostXVAdaptorHasGetVideo(cur_host_adaptor, &has_it)) {
EPHYR_LOG_ERROR("error\n");
}
if (has_it) {
if (adaptor_has_flags(cur_host_adaptor,
XCB_XV_TYPE_VIDEO_MASK | XCB_XV_TYPE_OUTPUT_MASK))
a_this->adaptors[i].GetVideo = ephyrGetVideo;
}
has_it = FALSE;
if (!ephyrHostXVAdaptorHasPutStill(cur_host_adaptor, &has_it)) {
EPHYR_LOG_ERROR("error\n");
}
if (has_it) {
if (adaptor_has_flags(cur_host_adaptor,
XCB_XV_TYPE_STILL_MASK | XCB_XV_TYPE_INPUT_MASK))
a_this->adaptors[i].PutStill = ephyrPutStill;
}
has_it = FALSE;
if (!ephyrHostXVAdaptorHasGetStill(cur_host_adaptor, &has_it)) {
EPHYR_LOG_ERROR("error\n");
}
if (has_it) {
if (adaptor_has_flags(cur_host_adaptor,
XCB_XV_TYPE_STILL_MASK | XCB_XV_TYPE_OUTPUT_MASK))
a_this->adaptors[i].GetStill = ephyrGetStill;
}
}
EPHYR_LOG("leave\n");
return TRUE;