From: Seunghun Lee Date: Thu, 26 Jul 2018 04:37:34 +0000 (+0900) Subject: virtual (client): Added implementation for setting available format. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7e7fcd357fbec8140bb607ba4f9417baef49f747;hp=0613d5ca5f9a733c596b7b61d02ebd08c19a87ed;p=platform%2Fcore%2Fuifw%2Flibtdm.git virtual (client): Added implementation for setting available format. Change-Id: I59a1716409d2b4d18b4ff66b65bf94cfcf76292a --- diff --git a/client/tdm_client.c b/client/tdm_client.c index b1af3f1..d3e8b47 100644 --- a/client/tdm_client.c +++ b/client/tdm_client.c @@ -96,6 +96,12 @@ typedef struct _tdm_private_client_voutput { struct { int count; + tbm_format *formats; + } available_formats; + + struct + { + int count; tdm_client_output_mode *modes; } available_modes; @@ -1743,6 +1749,9 @@ tdm_client_voutput_destroy(tdm_client_voutput *voutput) if (private_voutput->available_modes.modes) free(private_voutput->available_modes.modes); + if (private_voutput->available_formats.formats) + free(private_voutput->available_formats.formats); + wl_tdm_voutput_destroy(private_voutput->wl_voutput); free(private_voutput); @@ -1778,6 +1787,35 @@ tdm_client_voutput_set_available_modes(tdm_client_voutput *voutput, const tdm_cl } tdm_error +tdm_client_voutput_set_available_formats(tdm_client_voutput *voutput, const tbm_format *formats, const int count) +{ + tdm_private_client_voutput *private_voutput; + + TDM_RETURN_VAL_IF_FAIL(voutput != NULL, TDM_ERROR_INVALID_PARAMETER); + + if ((count > 0) && (formats == NULL)) + return TDM_ERROR_INVALID_PARAMETER; + + private_voutput = (tdm_private_client_voutput *)voutput; + + if (private_voutput->base.connection == TDM_OUTPUT_CONN_STATUS_CONNECTED) + return TDM_ERROR_BAD_REQUEST; + + if (private_voutput->available_formats.formats) + free(private_voutput->available_formats.formats); + + private_voutput->available_formats.count = count; + + if (count != 0) + { + private_voutput->available_formats.formats = calloc(count, sizeof(tbm_format)); + memcpy(private_voutput->available_formats.formats, formats, sizeof(tbm_format) * count); + } + + return TDM_ERROR_NONE; +} + +tdm_error tdm_client_voutput_set_physical_size(tdm_client_voutput *voutput, unsigned int mmWidth, unsigned int mmHeight) { tdm_private_client_voutput *private_voutput; @@ -1837,6 +1875,23 @@ tdm_client_output_set_mode(tdm_client_output *output, const tdm_client_output_mo return TDM_ERROR_NONE; } +void +_tdm_client_voutput_send_available_formats(tdm_private_client_voutput *private_voutput) +{ + tbm_format *format; + struct wl_array array; + int i, size; + + size = sizeof(tbm_format); + wl_array_init(&array); + for (i = 0; i < private_voutput->available_formats.count; i++) { + format = wl_array_add(&array, size); + *format = private_voutput->available_formats.formats[i]; + } + wl_tdm_voutput_set_available_formats(private_voutput->wl_voutput, &array); + wl_array_release(&array); +} + tdm_error tdm_client_output_connect(tdm_client_output *output) { @@ -1867,6 +1922,9 @@ tdm_client_output_connect(tdm_client_output *output) modes[i].flags, modes[i].type, modes[i].name); } + + _tdm_client_voutput_send_available_formats(private_voutput); + wl_tdm_voutput_set_physical_size(private_voutput->wl_voutput, private_voutput->mmwidth, private_voutput->mmheight); wl_tdm_voutput_connect(private_voutput->wl_voutput); diff --git a/client/tdm_client.h b/client/tdm_client.h index d0512cc..c0ffeb7 100644 --- a/client/tdm_client.h +++ b/client/tdm_client.h @@ -442,6 +442,9 @@ tdm_error tdm_client_voutput_set_available_modes(tdm_client_voutput *voutput, const tdm_client_output_mode *modes, int count); tdm_error +tdm_client_voutput_set_available_formats(tdm_client_voutput *voutput, const tbm_format *formats, const int count); + +tdm_error tdm_client_voutput_set_physical_size(tdm_client_voutput *voutput, unsigned int mmWidth, unsigned int mmHeight); tdm_error diff --git a/haltests/src/tc_tdm_client.cpp b/haltests/src/tc_tdm_client.cpp index 6be6821..1ee78c5 100644 --- a/haltests/src/tc_tdm_client.cpp +++ b/haltests/src/tc_tdm_client.cpp @@ -1413,6 +1413,7 @@ protected: static tdm_client *client; static tdm_client_voutput *voutput; const int MODE_COUNT = 2; + const int FORMAT_COUNT = 2; private: static pid_t server_pid; @@ -1540,6 +1541,7 @@ _tc_tdm_client_virutual_make_available_mode(tdm_client_output_mode *modes, int c } } + TEST_F(TDMVirtualOutput, SetAvailableModes) { tdm_error ret; @@ -1565,6 +1567,19 @@ TEST_F(TDMVirtualOutput, FailTestSetAvailableModes) ASSERT_EQ(ret, TDM_ERROR_INVALID_PARAMETER); } +TEST_F(TDMVirtualOutput, SetAvailableFormats) +{ + const int nformats = 2; + tdm_error ret; + tbm_format formats[nformats]; + + formats[0] = TBM_FORMAT_ARGB8888; + formats[1] = TBM_FORMAT_XRGB8888; + + ret = tdm_client_voutput_set_available_formats(this->voutput, formats, nformats); + ASSERT_EQ(ret, TDM_ERROR_NONE); +} + TEST_F(TDMVirtualOutput, SetPhysicalSize) { tdm_error ret; @@ -1595,10 +1610,12 @@ TEST_F(TDMVirtualOutput, GetClientOutput) TEST_F(TDMVirtualOutput, Connect) { + const int nformats = 2; tdm_error ret; tdm_client_output *output; unsigned int mmWidth = 300, mmHeight = 150; tdm_client_output_mode modes[this->MODE_COUNT]; + tbm_format formats[nformats]; int count = this->MODE_COUNT; output = tdm_client_voutput_get_client_output(this->voutput, &ret); @@ -1612,6 +1629,11 @@ TEST_F(TDMVirtualOutput, Connect) ret = tdm_client_voutput_set_available_modes(this->voutput, modes, count); ASSERT_EQ(ret, TDM_ERROR_NONE); + formats[0] = TBM_FORMAT_ARGB8888; + formats[1] = TBM_FORMAT_XRGB8888; + ret = tdm_client_voutput_set_available_formats(this->voutput, formats, nformats); + ASSERT_EQ(ret, TDM_ERROR_NONE); + ret = tdm_client_output_connect(output); ASSERT_EQ(ret, TDM_ERROR_NONE); diff --git a/protocol/tdm.xml b/protocol/tdm.xml index 3db00b1..4cc3aae 100644 --- a/protocol/tdm.xml +++ b/protocol/tdm.xml @@ -96,6 +96,10 @@ + + + + diff --git a/src/tdm_server.c b/src/tdm_server.c index 0b15154..b394618 100644 --- a/src/tdm_server.c +++ b/src/tdm_server.c @@ -79,6 +79,11 @@ typedef struct _tdm_server_voutput_info { int count; tdm_output_mode *modes; } available_modes; + struct + { + int count; + tbm_format *formats; + } available_formats; unsigned int mmwidth; unsigned int mmheight; @@ -790,6 +795,31 @@ _tdm_voutput_cb_set_available_modes(struct wl_client *client, } static void +_tdm_voutput_cb_set_available_formats(struct wl_client *client, + struct wl_resource *resource, + struct wl_array *formats) +{ + tdm_server_voutput_info *voutput_info; + tbm_format *f; + int count = 0, i = 0; + + voutput_info = wl_resource_get_user_data(resource); + + voutput_info->available_formats.count = 0; + if (voutput_info->available_formats.formats) + free(voutput_info->available_formats.formats); + + wl_array_for_each(f, formats) + count++; + + voutput_info->available_formats.formats = malloc(count * sizeof(tbm_format)); + voutput_info->available_formats.count = count; + + wl_array_for_each(f, formats) + voutput_info->available_formats.formats[i++] = *f; +} + +static void _tdm_voutput_cb_set_physical_size(struct wl_client *client, struct wl_resource *resource, unsigned int mmwidth, unsigned int mmheight) { @@ -835,6 +865,7 @@ _tdm_voutput_cb_disconnect(struct wl_client *client, struct wl_resource *resourc static const struct wl_tdm_voutput_interface tdm_voutput_implementation = { _tdm_voutput_cb_destroy, _tdm_voutput_cb_set_available_modes, + _tdm_voutput_cb_set_available_formats, _tdm_voutput_cb_set_physical_size, _tdm_voutput_cb_connect, _tdm_voutput_cb_disconnect