Re: [PATCH 12/14] Use a single class for every escape command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Sep 01, 2016 at 01:00:54PM +0100, Frediano Ziglio wrote:
> Do not use two classes one for XPDM and the other for WDDM.
> 
> Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
> ---
>  vdagent/display_configuration.cpp | 76 +++++++++++++++++----------------------
>  vdagent/display_configuration.h   | 17 +++++++++
>  2 files changed, 49 insertions(+), 44 deletions(-)
> 
> diff --git a/vdagent/display_configuration.cpp b/vdagent/display_configuration.cpp
> index 301e136..2387073 100644
> --- a/vdagent/display_configuration.cpp
> +++ b/vdagent/display_configuration.cpp
> @@ -204,48 +204,40 @@ struct D3DKMT_OPENADAPTERFROMGDIDISPLAYNAME {
>      UINT VidPnSourceId;
>  };
>  
> -struct QXLMonitorEscape {
> -    QXLMonitorEscape(DEVMODE* dev_mode)
> -    {
> -        ZeroMemory(&_head, sizeof(_head));
> -        _head.x = dev_mode->dmPosition.x;
> -        _head.y = dev_mode->dmPosition.y;
> -        _head.width = dev_mode->dmPelsWidth;
> -        _head.height = dev_mode->dmPelsHeight;
> -    }
> -    QXLHead _head;
> -};
> +template <typename Content>
> +static inline int ExtEscape(HDC hdc, EscapeData<Content>& data)
> +{
> +    return ExtEscape(hdc, data._ioctl, sizeof(data._data), (LPCSTR) &data._data, 0, NULL);
> +}
>  
> -struct QxlCustomEscapeObj : public QXLEscapeSetCustomDisplay {
> -    QxlCustomEscapeObj(uint32_t bitsPerPel, uint32_t width, uint32_t height)
> +struct QxlMonitorEscape: public EscapeData<QXLHead> {
> +    QxlMonitorEscape(const DEVMODE& dev_mode):
> +        EscapeData<QXLHead>(QXL_ESCAPE_MONITOR_CONFIG)
>      {
> -        xres = width;
> -        yres = height;
> -        bpp = bitsPerPel;
> +        _data.x = dev_mode.dmPosition.x;
> +        _data.y = dev_mode.dmPosition.y;
> +        _data.width = dev_mode.dmPelsWidth;
> +        _data.height = dev_mode.dmPelsHeight;
>      }
> -};
> -
> -struct WDDMCustomDisplayEscape {
> -    WDDMCustomDisplayEscape(DEVMODE* dev_mode)
> +    QxlMonitorEscape(const DisplayMode& mode):
> +        EscapeData<QXLHead>(QXL_ESCAPE_MONITOR_CONFIG)
>      {
> -        _ioctl = QXL_ESCAPE_SET_CUSTOM_DISPLAY;
> -        _custom.bpp = dev_mode->dmBitsPerPel;
> -        _custom.xres = dev_mode->dmPelsWidth;
> -        _custom.yres = dev_mode->dmPelsHeight;
> +        _data.x = mode.get_pos_x();
> +        _data.y = mode.get_pos_y();
> +        _data.width = mode.get_width();
> +        _data.height = mode.get_height();
>      }
>      uint32_t                    _ioctl;
>      QXLEscapeSetCustomDisplay   _custom;
>  };
>  
> -struct WDDMMonitorConfigEscape {
> -    WDDMMonitorConfigEscape(DisplayMode* mode)
> +struct QxlCustomEscape : public EscapeData<QXLEscapeSetCustomDisplay> {
> +    QxlCustomEscape(const DEVMODE& dev_mode):
> +        EscapeData<QXLEscapeSetCustomDisplay>(QXL_ESCAPE_SET_CUSTOM_DISPLAY)
>      {
> -        _ioctl = QXL_ESCAPE_MONITOR_CONFIG;
> -        _head.id = _head.surface_id = 0;
> -        _head.x = mode->get_pos_x();
> -        _head.y = mode->get_pos_y();
> -        _head.width = mode->get_width();
> -        _head.height = mode->get_height();
> +        _data.xres = dev_mode.dmPelsWidth;
> +        _data.yres = dev_mode.dmPelsHeight;
> +        _data.bpp = dev_mode.dmBitsPerPel;
>      }
>      uint32_t    _ioctl;
>      QXLHead     _head;
> @@ -331,11 +323,8 @@ bool XPDMInterface::custom_display_escape(LPCTSTR device_name, DEVMODE* dev_mode
>          }
>      }
>  
> -    QxlCustomEscapeObj custom_escape(dev_mode->dmBitsPerPel,
> -                                            dev_mode->dmPelsWidth, dev_mode->dmPelsHeight);
> -
> -    int err = ExtEscape(hdc, QXL_ESCAPE_SET_CUSTOM_DISPLAY,
> -              sizeof(QXLEscapeSetCustomDisplay), (LPCSTR) &custom_escape, 0, NULL);
> +    QxlCustomEscape custom_escape(*dev_mode);
> +    int err = ExtEscape(hdc, custom_escape);
>      if (err <= 0) {
>          vd_printf("%s: Can't set custom display, perhaps running with an older driver?",
>              __FUNCTION__);
> @@ -356,7 +345,7 @@ bool XPDMInterface::update_monitor_config(LPCTSTR device_name, DisplayMode* mode
>          return false;
>      }
>  
> -    QXLMonitorEscape monitor_config(dev_mode);
> +    QxlMonitorEscape monitor_config(*dev_mode);
>      HDC hdc(CreateDC(device_name, NULL, NULL, NULL));
>      int err(0);
>  
> @@ -364,8 +353,7 @@ bool XPDMInterface::update_monitor_config(LPCTSTR device_name, DisplayMode* mode
>          return false;
>      }
>  
> -    err = ExtEscape(hdc, QXL_ESCAPE_MONITOR_CONFIG, sizeof(QXLHead),
> -                    (LPCSTR) &monitor_config, 0, NULL);
> +    err = ExtEscape(hdc, monitor_config);
>      if (err < 0) {
>          vd_printf("%s: %S can't update monitor config, may have old, old driver",
>                   __FUNCTION__, device_name);

Looks similar to what you fixed in patch 4.

Christophe

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]