Commit Graph

679 Commits

Author SHA1 Message Date
Frediano Ziglio
2eaef9c16d protocol: Add some documentation for inval_all_pixmaps message
This message is not straight forward to grasp.
Not clear by the name why we need to wait other channels messages
before resetting the image cache.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-03-18 09:14:29 +00:00
Frediano Ziglio
8096b1206b canvas: Use SPICE_UNALIGNED_CAST to avoid -Wcast-align warnings
This solves https://bugs.freedesktop.org/show_bug.cgi?id=104521.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2018-01-31 15:10:35 +00:00
Frediano Ziglio
fd0aba2750 canvas: Fix some semi transparent drawing
This is reproducible using desktop icons on Windows XP.

These drawing are sent for the icons on the desktop.
To get an extends.x1 >= 32 you have to move an icon out of the
screen on the left side. Set the icon size to 72 as the icon has
to be out of the screen quite a lot.
Disable the grid alignment on the desktop and move an icon out of
the screen. Select and unselect the icon.
Using "/ 32" the icon will have a white background instead of a
transparent one.
Using a "/ 8" the icon is rendered correctly.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe de Dinechin <cdupontd@redhat.com>
2018-01-25 22:27:34 +00:00
Frediano Ziglio
f3478aa4b6 canvas: Prevent some error compiling spice-gtk
Due to different warning setting some GCC reports:

In file included from ../spice-common/common/sw_canvas.c:27:0,
                 from client_sw_canvas.c:20:
../spice-common/common/canvas_base.c: In function ‘canvas_get_lz’:
../spice-common/common/canvas_base.c:768:13: error: ‘palette’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
             free(palette);
             ^~~~~~~~~~~~~
../spice-common/common/canvas_base.c:764:9: error: variable ‘free_palette’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered]
     int free_palette = FALSE;
         ^~~~~~~~~~~~
cc1: all warnings being treated as errors

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Snir Sheriber <ssheribe@redhat.com>
2018-01-24 10:41:02 +00:00
Paweł Pękala
122be3d1f7 Fix build with LibreSSL
Some FreeBSD configurations can use LibreSSL instead of OpenSSL.
The two libraries are really similar but need some minimal adjustment.

Signed-off-by: Paweł Pękala <pawelbsd@gmail.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-01-23 10:23:43 +00:00
Frediano Ziglio
41c7ea6611 canvas: Remove unused include header
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-01-18 14:34:26 +00:00
Frediano Ziglio
0dda6fbf55 canvas: Unify __surface_create_stride and surface_create_stride
They are now just the same function with same parameters,
just one calls the other.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-01-18 14:34:24 +00:00
Frediano Ziglio
3bf6e7b899 canvas: Remove dc fields from CanvasBase and LzDecodeUsrData
Now always NULL.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-01-18 14:34:22 +00:00
Frediano Ziglio
b0f1d31dd1 canvas: Remove dc parameter from SwCanvas::put_image
Not used anymore.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-01-18 14:34:19 +00:00
Frediano Ziglio
6ce1a61577 canvas: Remove unused dc parameter from surface_create
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-01-18 14:34:16 +00:00
Frediano Ziglio
00d1cda4ce canvas: Remove Windows bitmap allocation
There's no reason to use a DIB section if we are going to use just the
memory in it assigned to a pixman surface, use normal path and memory.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-01-18 14:34:14 +00:00
Frediano Ziglio
cd88d0294c canvas: Remove mutex field from PixmanData
The field is only assigned but never used.
This was used in the GDI canvas which has now been removed.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-01-18 14:34:12 +00:00
Frediano Ziglio
fea48544a8 canvas: Move PixmanData to C file
This structure is used only in canvas_utils.c

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-01-18 14:33:44 +00:00
Frediano Ziglio
27e32fa8a6 lz: Remove unused encode_level and only assigned io_start
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2018-01-18 10:08:46 +00:00
Frediano Ziglio
5fda05740f lz: Simplify code
Remove some conditional code always defining CAST_PLT_DISTANCE
macro.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2018-01-18 10:08:43 +00:00
Frediano Ziglio
552e842a16 lz: Avoid temporary variable
Use a break to exit the loop instead of using a variable.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2018-01-18 10:08:41 +00:00
Frediano Ziglio
29eff61cf8 canvas: Remove possible leak on LZ decompression failure
longjmp can happen in different places, even after the palette
is allocated so we need to free it if it got allocated.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2018-01-18 10:08:39 +00:00
Frediano Ziglio
d11df6b66b canvas: Simplify code using spice_memdup
Instead of using spice_malloc+memcpy use spice_memdup which is
doing the same.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2018-01-18 10:08:26 +00:00
Pavel Grunt
a3a2bb9ea7 Remove GDI canvas
Only spicec was using it - removed by spice server commit:
1876971442ef808b5dcdaa5dc12df617f2179cb5

Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-01-17 09:31:32 +00:00
Frediano Ziglio
637621a9b9 canvas-base: Fix width computation for palette images
Palette images have padding at the end of each line, so their stride
can't be inferred from their width as is currently done. This causes a
wrong calculation of stride_encoded value which causes a wrong stride
adjustment.

Before commit 5603961ff "fix 16 bpp LZ image decompression", the output
stride was always computed as "stride = (n_comp_pixels / height) * 4"
that is assuming 4 bytes for pixel which was wrong for some output
however computing starting from width was wrong for palette images.

This commit was added to spice-gtk in v0.32~58, which nicely matches the
"client regression when upgrading from spice-gtk v0.31 to spice-gtk
v0.33".

This fix bug https://bugzilla.redhat.com/show_bug.cgi?id=1508847.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Tested-by: Philip J. Turmel <philip@turmel.org>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-12-22 18:19:54 +00:00
Frediano Ziglio
53f6d1269a protocol: Allow to specify a surface will be streamed
This flag will allow the client to perform some optimisations
on output and buffering processing.
Old clients will ignore this additional flag.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2017-12-01 15:48:56 +00:00
Frediano Ziglio
94898df6b4 proto: Add some documentation to stream_report message
Most of the documentation is extracted from notes in spice-server
code and comments.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-11-29 11:50:54 +00:00
Frediano Ziglio
45e2844845 canvas_base: Allow to specify constant operations
There's no need for the canvas operations to be changed.
This allows without casts to have the operation structures
constants in the code.
This potentially allows to reduce attack surface having some
more data constant instead or read/write.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe de Dinechin <dinechin@redhat.com>
2017-11-07 13:11:19 +00:00
Frediano Ziglio
72ae9b2971 ring: Remove short living temporary variable
Just a style change, the variable does not help readability.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe de Dinechin <dinechin@redhat.com>
2017-11-07 13:11:19 +00:00
Frediano Ziglio
c208ca85cd ring: Remove __ring_remove function
Is just used by ring_remove, no reason to have it.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe de Dinechin <dinechin@redhat.com>
2017-11-07 13:11:19 +00:00
Frediano Ziglio
c2f2096d90 test-marshallers: Test demarshalling
Generate demarshallers code and check it too.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-25 16:13:27 +01:00
Frediano Ziglio
c25c75b552 test-marshallers: Use unaligned structure
Allows to test for bad performance on some systems.
For instance on ARMv6/ARMv7 which does not support by default
64 bit unaligned read/write this can be checked on Linux
using /proc/cpu/alignment file.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-25 16:13:18 +01:00
Frediano Ziglio
74e50b57ae Make the compiler work out better way to write unaligned memory
Instead of assuming that the system can safely do unaligned access
to memory use packed structures to allow the compiler generate
best code possible.
A packed structure tells the compiler to not leave padding inside it
and that the structure can be unaligned so any field can be unaligned
having to generate proper access code based on architecture.
For instance ARM7 can use unaligned access but not for 64 bit
numbers (currently these accesses are emulated by Linux kernel
with obvious performance consequences).

This changes the current methods from:

#ifdef WORDS_BIGENDIAN
#define read_uint32(ptr) ((uint32_t)SPICE_BYTESWAP32(*((uint32_t *)(ptr))))
#define write_uint32(ptr, val) *(uint32_t *)(ptr) = SPICE_BYTESWAP32((uint32_t)val)
#else
#define read_uint32(ptr) (*((uint32_t *)(ptr)))
#define write_uint32(ptr, val) (*((uint32_t *)(ptr))) = val
#endif

to:

#include <spice/start-packed.h>
typedef struct SPICE_ATTR_PACKED {
    uint32_t v;
} uint32_unaligned_t;
#include <spice/end-packed.h>

#ifdef WORDS_BIGENDIAN
#define read_uint32(ptr) ((uint32_t)SPICE_BYTESWAP32(((uint32_unaligned_t *)(ptr))->v))
#define write_uint32(ptr, val) ((uint32_unaligned_t *)(ptr))->v = SPICE_BYTESWAP32((uint32_t)val)
#else
#define read_uint32(ptr) (((uint32_unaligned_t *)(ptr))->v)
#define write_uint32(ptr, val) (((uint32_unaligned_t *)(ptr))->v) = val
#endif

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-25 16:12:45 +01:00
Frediano Ziglio
70d4739ce2 quic: avoid crash on specific images
encodes_ones is called to encode a long sequence of 1 bits.
In some conditions (I manage to reproduce with a 85000x4 pixel
image fill with a single color) encodes_ones is called with a
"n" value >= 32.
This cause encode to be called with a "len" value of 32 which
trigger this assert:

   spice_assert(len > 0 && len < 32);

causing a crash. Instead of calling encode with a constant
"len" as 32 call encode_32 which is supposed to encode
exactly 32 bit.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-08-23 22:47:08 +01:00
Frediano Ziglio
429ad96537 quic: turn back some commented out checks as compile time
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-08-09 07:07:36 +01:00
Frediano Ziglio
a6d6e8435a quic: use 32 bit for bppmask
In most occurrences bppmask is converted to 32 bit anyway.
In the left one a possible more bigger precision is not needed.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-08-09 07:07:34 +01:00
Frediano Ziglio
6a882282f1 quic: remove Channel::encoder
This field is easily accessible from Encoder structure.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-08-09 07:07:32 +01:00
Frediano Ziglio
3306492247 quic: remove only assigned CommonState::encoder
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-08-09 07:07:29 +01:00
Frediano Ziglio
65ba949fb0 quic: remove only assigned num_channels field
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-08-09 07:07:13 +01:00
Frediano Ziglio
9f6a671294 quic: fix typo golomb_deoding -> golomb_decoding
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-08-03 13:33:00 +01:00
Frediano Ziglio
b64ee40a60 quic: fix typo corelate -> correlate
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-08-03 13:32:45 +01:00
Christophe Fergeau
c39f2da17e quic: Use i == 0 rather than !i
This helps to make quic_rgb_tmpl.c and quic_tmpl.c more consistent.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2017-08-01 15:53:59 +02:00
Christophe Fergeau
8dd7374a1d quic: Fix "corelate" typo
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2017-08-01 15:53:47 +02:00
Christophe Fergeau
9574246403 quic: Use SPICE_VERIFY for static check
DEFevol is known at compile-time, so we can use SPICE_VERIFY to check
its value.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2017-08-01 15:53:44 +02:00
Christophe Fergeau
5684ed10be quic: Use DEFwmimax constant rather than wmimax variable
We never change its value, so we basically have 2 constants for the
same thing, DEFwmimax and wmimax. This commit removes the latter.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2017-08-01 15:53:42 +02:00
Christophe Fergeau
f122d3dadc quic: Use DEFwminext constant rather than wminext variable
We never change its value, so we basically have 2 constants for the
same thing, DEFwminext and wminext. This commit removes the latter

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2017-08-01 15:53:38 +02:00
Christophe Fergeau
db5bff3728 quic: Use DEFevol constant rather than evol variable
We never change 'evol' value, and this is currently causing issues with
gcc 7.1.1: quic.c is checking at compile-time that 'evol' is 1, 3 or 5.
This is a constant, so a static check should be good, but the compiler (gcc
7.1.1) is unable to know 'evol' value at compile-time. Since the removal
of spice_static_assert in favour of SPICE_VERIFY, this causes a
compile-time failure.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2017-08-01 15:53:34 +02:00
Christophe Fergeau
a25ebbac56 canvas: Don't try to unref NULL pixman_image_t
pixman_image_unref() does not ignore NULL pointers, it tries to
dereference it which causes a crash. When trying to decode invalid QUIC
data, we could end up in a situation where 'surface' would still be
NULL when reaching the setjmp block.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-07-20 17:13:35 +02:00
Christophe Fergeau
fffe755d9c log: Define G_LOG_DOMAIN as early as possible
"log: Forbid the usage of obsolete SPICE_LOG_DOMAIN" introduced a small
regression, if G_LOG_DOMAIN is not set when glib.h is included, the
header will set it to a default value. Redefining it later in log.c is
going to cause a compile-time warning.
This commit adds the definition to SPICE_COMMON_CFLAGS so that it's
defined before any inclusion of glib.h is possible. This is similar to
what is done in spice/configure.ac.

This avoids this warning:
CC       log.lo
log.c:44:0: warning: "G_LOG_DOMAIN" redefined
 #define G_LOG_DOMAIN "Spice"

In file included from /usr/include/glib-2.0/glib.h:62:0,
                 from log.c:22:
/usr/include/glib-2.0/glib/gmessages.h:280:0: note: this is the location of the previous definition
 #define G_LOG_DOMAIN    ((gchar*) 0)

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-07-07 17:04:36 +02:00
Frediano Ziglio
eeab433539 log: Force format in log macro to be a string
Make sure format is a string and not a pointer.
This prevents usages like:

  spice_debug(NULL);

This forbids computed format strings, but on the other hand, forcing
the use of string constants allows the compiler to always check
argument types against the format string. Moreover, there is no
occurrences of computed format strings in the current codebase.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-07-05 09:53:10 +01:00
Frediano Ziglio
518c57db20 log: Forbid the usage of obsolete SPICE_LOG_DOMAIN
As we decided to not use multiple GLib domains, the SPICE_LOG_DOMAIN
macro is not really useful. This commit removes it.
Will be replaced by some different categorization.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-07-05 09:53:02 +01:00
Frediano Ziglio
14c595b609 quic: Fix typo in function names
reste -> reset

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-07-04 10:06:09 +01:00
Frediano Ziglio
dde1fe3533 log: remove spice_static_assert macro
The macro was misused and not doing static check.
Spice have other working static check macros to use.
The macro is used only by spice-common so removing it
does not cause issues to other depending projects.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2017-06-22 11:34:19 +01:00
Frediano Ziglio
2ff5c77fff quic: constantify some variable
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2017-06-22 11:34:19 +01:00
Frediano Ziglio
f80b229e07 canvas-base: Do not attempt useless cast on stride adjustment
memmove already deal with any alignment so there's no
reason to have row byte pointer cast to uint32_t.
This also remove the confusing "dest" terminology used. The image
is aligned in place so the image bits are used for both destination
and source.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-06-21 12:57:52 +01:00