[PATCH weston 6/8] compositor-drm: Make some functions take a weston_output directly

Pekka Paalanen ppaalanen at gmail.com
Tue Jan 31 13:30:09 UTC 2017


On Mon,  2 May 2016 22:40:15 +0100
Emmanuel Gil Peyrot <emmanuel.peyrot at collabora.com> wrote:

> Makes it clearer that they don’t use any field specific to drm_output,
> and reduce the amount of churn from the following commits.
> 
> Signed-off-by: Emmanuel Gil Peyrot <emmanuel.peyrot at collabora.com>
> ---
>  src/compositor-drm.c | 48 ++++++++++++++++++++++++------------------------
>  1 file changed, 24 insertions(+), 24 deletions(-)
> 
> diff --git a/src/compositor-drm.c b/src/compositor-drm.c
> index 5938d53..1edcaab 100644
> --- a/src/compositor-drm.c
> +++ b/src/compositor-drm.c
> @@ -232,7 +232,7 @@ static void
>  drm_output_set_cursor(struct drm_output *output);
>  
>  static void
> -drm_output_update_msc(struct drm_output *output, unsigned int seq);
> +drm_output_update_msc(struct weston_output *output_base, unsigned int seq);

Hi,

if you change the argument type, then you should also change the
function name. It would be odd for a function be named
drm_output_something() and not even take one as an argument.

Our convention for "object-oriented C" favours the naming scheme:
<class>_<method>(class *this, args...)

I think it's a nice convention in general, but there are cases where it
is awkward, like weston_view_from_global_float() I talked about with
Daniel recently.

Of course, it would be somewhat off to have a DRM-dpecific
weston_output_update_msc() in compositor-drm.c. In this particular case
I would just keep it as is.

> @@ -1367,17 +1367,17 @@ drm_output_destroy(struct weston_output *output_base)
>   * @returns Pointer to a mode from the output's mode list
>   */
>  static struct drm_mode *
> -choose_mode (struct drm_output *output, struct weston_mode *target_mode)
> +choose_mode (struct weston_output *output_base, struct weston_mode *target_mode)

This one does use drm-specific fields of struct drm_mode, and those are
only applicable with a drm_output kind of weston_output. It doesn't
change much code-wise, and I'd prefer to leave it as is, if not renamed
to drm_output_choose_mode().


Thanks,
pq
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 801 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20170131/efd1d91a/attachment.sig>


More information about the wayland-devel mailing list