summaryrefslogtreecommitdiff
path: root/common
AgeCommit message (Collapse)AuthorFilesLines
2018-05-31quic: Remove some too strict asserts in hot pathsFrediano Ziglio2-7/+17
Some assert in the code are doing some paranoid test and in code paths quite hot. The encoding time is reduced by 30-50% while the decoding time is reduced by a 20-30%. Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Victor Toso <victortoso@redhat.com>
2018-05-28quic: Remove 'no-inline' hackFrediano Ziglio1-21/+2
The quic code goes through a function pointer in two places in order to try to prevent the compiler from inlining code. Doing performance measurements this trick does not work anymore and just make code less readable. This patch and message was based on a previous work of Christophe Fergeau. Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Victor Toso <victortoso@redhat.com>
2018-05-25lz: Inline GET_{r,g,b} macrosFrediano Ziglio1-12/+1
With last changes are just used once and are straight forward. Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: jonathon Jongsma <jjongsma@redhat.com>
2018-05-25lz: Optimise SAME_PIXEL for RGB16Frediano Ziglio1-4/+4
Do not extract all components and compare one by one, can be easily compared together. Performance measurements on a set of 16 bit images shown an improve of about 10%. Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-05-24quic: Use channel->correlate_row in macrosChristophe Fergeau1-50/+48
This avoids the need for a local variable with the right name (which was decorrelate_drow in some cases in quic_tmpl.c...) Signed-off-by: Christophe Fergeau <cfergeau@redhat.com> Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-05-24quic: Remove unused argument in uncompress_row{0, }Christophe Fergeau1-8/+6
'correlation_row' is always set to channel->colleration_row, and we already pass 'channel' as an argument. Signed-off-by: Christophe Fergeau <cfergeau@redhat.com> Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-05-24quic: Add macros to make quic_tmpl.c much closer to quic_rgb_tmpl.cChristophe Fergeau1-77/+107
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com> Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-05-24quic: s/decorrelate_drow/correlate_rowChristophe Fergeau1-27/+27
The naming is odd as this is just an alias for channel->correlate_row. This will also help in subsequent commits to make things more consistent with quic_rgb_tmpl.c Signed-off-by: Christophe Fergeau <cfergeau@redhat.com> Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-05-24quic: Introduce CommonState *state variable in templatesChristophe Fergeau2-184/+200
Most functions in quic_tmpl.c/quic_rgb_tmpl.c have only superficial differences. One of them is using channel->state or encoder->rgb_state. This commit adds a local CommonState *state in all template methods which will be used instead of channel->state or encoder->rgb_state. This makes it easier to spot the common code between the 2 template files... Signed-off-by: Christophe Fergeau <cfergeau@redhat.com> Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-05-24quic: Factor common codeChristophe Fergeau1-82/+34
We don't need 2 different implementations when the only difference is the CommonState which is being used. Signed-off-by: Christophe Fergeau <cfergeau@redhat.com> Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-05-24quic: Get rid of RLE #defineChristophe Fergeau3-33/+0
It's always set, no need to have conditional compilation based on it. Signed-off-by: Christophe Fergeau <cfergeau@redhat.com> Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-05-24quic: Get rid of RLE_STAT #defineChristophe Fergeau2-63/+2
It's always set, no need to have conditional compilation based on it. Signed-off-by: Christophe Fergeau <cfergeau@redhat.com> Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-05-24quic: Get rid of QUIC_RGB #defineChristophe Fergeau2-163/+0
It's always set, no need to have conditional compilation based on it. Signed-off-by: Christophe Fergeau <cfergeau@redhat.com> Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-05-24quic: Remove configurable PREDChristophe Fergeau3-74/+0
It's hardcoded at compile-time, and I don't think it was changed in years... Signed-off-by: Christophe Fergeau <cfergeau@redhat.com> Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-05-24quic: Remove configurable RLE_PREDChristophe Fergeau3-97/+16
It's hardcoded at compile-time, and I don't think it was changed in years... Signed-off-by: Christophe Fergeau <cfergeau@redhat.com> Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-05-21marshaller: Remove initial underscore from static functionFrediano Ziglio1-2/+2
This is the only function starting with an underscore, looks out of style. Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2018-05-18Fix cast to spice_marshaller_item_free_func functionEduardo Lima (Etrunko)1-1/+6
Building with gcc 8.0.1 from Fedora 28 gives the following error: FAILED: common/common@@spice-common@sta/marshaller.c.o ../common/marshaller.c: In function 'spice_marshaller_reserve_space': ../common/marshaller.c:311:27: error: cast between incompatible function types from 'void (*)(void *)' to 'void (*)(uint8_t *, void *)' {aka 'void (*)(unsigned char *, void *)'} [-Werror=cast-function-type] item->free_data = (spice_marshaller_item_free_func)free; ^ cc1: all warnings being treated as errors Which can be easily fixed by creating a new function with the correct signature and calling free() from it. Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com> Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-05-17build: Remove FIXME_SERVER_SMARTCARD hackEduardo Lima (Etrunko)1-2/+0
This hack is now made obsolete by the previous commit. We can safely remove those defines and the code now builds fine for both spice server and spice-gtk. commit df4ec5c3186e796624e4bbf2dc4a269faf2823f6 Author: Frediano Ziglio <fziglio@redhat.com> Date: Fri May 11 16:59:46 2018 +0100 Fix generation of Smartcard channel Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com> Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-05-10lz: Move ENCODE_PIXEL for RGB24 and RGB32 to a common placeFrediano Ziglio1-2/+1
The macro for both depth is the same, reuse the definition. Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-05-10miLineArc(): initialize edge1, edge2Jonathon Jongsma1-1/+1
When compiling spice-common with meson/ninja under "release" mode, I get several compiler warnings about possibly-uninitialized members. For example: ../subprojects/spice-common/common/lines.c: In function ‘miLineArc’: ../subprojects/spice-common/common/lines.c:2167:17: error: ‘edge2.dx’ may be used uninitialized in this function [-Werror=maybe-uninitialized] edge->e += edge->dx; \ ^~ ../subprojects/spice-common/common/lines.c:2426:24: note: ‘edge2.dx’ was declared here PolyEdgeRec edge1, edge2; ^~~~~ Initializing these structures to zero silences the warnings. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-05-05messages: document limitation of id in StreamCreateVictor Toso1-1/+1
Note that the ID limitation always existed but now we have the limitation in the protocol itself with SPICE_MAX_NUM_STREAMS Signed-off-by: Victor Toso <victortoso@redhat.com> Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-03-19Add --enable-extra-checks optionFrediano Ziglio1-0/+6
Allow to enable code to do additional or expensive checks. The option should be used by higher level libraries. By default the option is disabled. Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2018-01-31canvas: Use SPICE_UNALIGNED_CAST to avoid -Wcast-align warningsFrediano Ziglio1-1/+1
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-25canvas: Fix some semi transparent drawingFrediano Ziglio1-2/+10
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-24canvas: Prevent some error compiling spice-gtkFrediano Ziglio1-3/+5
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-23Fix build with LibreSSLPaweł Pękala1-1/+1
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-18canvas: Remove unused include headerFrediano Ziglio2-7/+0
Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-01-18canvas: Unify __surface_create_stride and surface_create_strideFrediano Ziglio1-9/+3
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-18canvas: Remove dc fields from CanvasBase and LzDecodeUsrDataFrediano Ziglio3-43/+1
Now always NULL. Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-01-18canvas: Remove dc parameter from SwCanvas::put_imageFrediano Ziglio2-6/+0
Not used anymore. Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-01-18canvas: Remove unused dc parameter from surface_createFrediano Ziglio3-41/+7
Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-01-18canvas: Remove Windows bitmap allocationFrediano Ziglio1-105/+0
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-18canvas: Remove mutex field from PixmanDataFrediano Ziglio1-11/+0
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-18canvas: Move PixmanData to C fileFrediano Ziglio2-9/+9
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-18lz: Remove unused encode_level and only assigned io_startFrediano Ziglio1-7/+0
Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Uri Lublin <uril@redhat.com>
2018-01-18lz: Simplify codeFrediano Ziglio1-9/+4
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-18lz: Avoid temporary variableFrediano Ziglio1-7/+5
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-18canvas: Remove possible leak on LZ decompression failureFrediano Ziglio1-2/+4
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-18canvas: Simplify code using spice_memdupFrediano Ziglio1-4/+1
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-17Remove GDI canvasPavel Grunt4-1943/+0
Only spicec was using it - removed by spice server commit: 1876971442ef808b5dcdaa5dc12df617f2179cb5 Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-12-22canvas-base: Fix width computation for palette imagesFrediano Ziglio1-1/+1
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-11-07canvas_base: Allow to specify constant operationsFrediano Ziglio1-2/+2
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-07ring: Remove short living temporary variableFrediano Ziglio1-8/+2
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-07ring: Remove __ring_remove functionFrediano Ziglio1-8/+3
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-09-25Make the compiler work out better way to write unaligned memoryFrediano Ziglio1-16/+41
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-08-23quic: avoid crash on specific imagesFrediano Ziglio1-1/+1
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-09quic: turn back some commented out checks as compile timeFrediano Ziglio1-2/+2
Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-08-09quic: use 32 bit for bppmaskFrediano Ziglio1-2/+2
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-09quic: remove Channel::encoderFrediano Ziglio1-7/+4
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-09quic: remove only assigned CommonState::encoderFrediano Ziglio1-4/+0
Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Jonathon Jongsma <jjongsma@redhat.com>