Commit Graph

516 Commits

Author SHA1 Message Date
Frediano Ziglio
7a6980def8 quic: Make {UN, }COMPRESS_xx macros closer
Define COMPRESS_xx/UNCOMPRESS_xx macros in a more similar way between
quic_tmpl.c and quic_rgb_tmpl.c using channel suffixes. Instead of
having #define COMPRESS(channel) do_something(channel), we'll now have
 #define COMPRESS(channel) do_something(channel_##channel), and call it
with COMPRESS(a)

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2018-07-10 10:33:28 +01:00
Frediano Ziglio
1ca7e2d765 quic: Add SAME_PIXEL macro
This helps making the code in quic_tmpl.c and quic_rgb_tmpl.c more
similar.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2018-07-10 10:33:28 +01:00
Frediano Ziglio
499b10e494 quic: Rework PIXEL_A/PIXEL_B macros
This makes them identical to their counterparts in quic_rgb_tmpl.c

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2018-07-10 10:33:28 +01:00
Frediano Ziglio
946d3dda22 quic: Add UPDATE_MODEL_COMP macro to iterate over channels
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2018-07-10 10:33:28 +01:00
Christophe Fergeau
204ff1ae2e pixman: Use g_error() rather than g_abort()
g_abort() was only added in glib 2.50, which causes meson build failures
since this defines GLIB_VERSION_MIN_REQUIRED/GLIB_VERSION_MAX_ALLOWED

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-07-06 18:11:54 +02:00
Christophe Fergeau
b4e07c31cf build: Remove spice_common.h
Most users of spice_common.h don't need it, or only need log.h. It only
has a few users outside of spice-common. It's not very well defined
which headers it should contain. This commit removes spice_common.h in
favour of direct inclusion of the needed headers.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-07-06 06:46:15 +01:00
Christophe Fergeau
8069bf498d common: Remove spice_abort()
There are only 2 users in spice-common, and none in spice-gtk/spice

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-07-06 06:46:13 +01:00
Christophe Fergeau
31d4622687 log: Remove SPICE_DISABLE_ABORT
spice-gtk was the last user, and stopped using it on Jun 14th 2017
in 040090ccba34 "build-sys: remove -DSPICE_DISABLE_ABORT"

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-07-06 06:46:05 +01:00
Frediano Ziglio
bb8d75bf31 canvas_base: Avoid misaligned access decoding LZ4 data
Make code faster on platforms not supporting unaligned access by
default.
SPICE_UNALIGNED_CAST is just silencing possible alignment warning and,
if enabled, produces some logs, however in this case we know that the
pointer can be misaligned.
Use packed structures to tell compiler to generate best code possible.
For more details see comment on commit 74e50b57ae ("Make the
compiler work out better way to write unaligned memory").

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-07-05 09:38:30 +01:00
Frediano Ziglio
e98e08594c canvas_base: Fix minor indentation issues
This patch just changes some spaces fixing some possible misleading
indentation.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2018-07-05 09:23:14 +01:00
Christophe Fergeau
3def5a8448 swcanvas: Remove canvas_create()
Nothing calls it in spice-gtk or spice-server

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-07-04 10:04:02 +02:00
Frediano Ziglio
cd932df7a2 quic: Call encode from golomb_coding
golomb_coding is always followed by a encode call.
Simplify code calling directly it, no reason to pass back output
using pointers.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-07-03 19:37:39 +01:00
Frediano Ziglio
4b0c25823f log: Remove spice_printerr macro
All usages of this macro were removed.
A library should not log to standard error but use log facilities
so remove this macro to avoid possible future usage.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-06-29 19:02:21 +01:00
Frediano Ziglio
0385a67ef8 build: Reindent macros
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-06-28 13:34:14 +01:00
Christophe Fergeau
f90ab1f19b snd: Replace spice_printerr() use with g_warning
This allows users of the library to redirect where these messages go
through use of g_log_set_default_handler() rather than unconditionally
printing on stderr.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-06-28 13:39:52 +02:00
Frediano Ziglio
1378d5cfc4 canvas_base: Make sure top_down is a boolean
Should be a 0/1 but just in case make sure.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-06-27 21:44:17 +01:00
Frediano Ziglio
16deca6f1c marshaller: Fix a possible leak
The possible file descriptor associated to the message (currently
can be only the DRM descriptor from Virgl) is not freed in case
the marshaller is reset/destroyed.
This can happen connecting/disconnecting client.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-06-27 21:44:05 +01:00
Frediano Ziglio
0ac8e55ddf test-region: Create proper test for region from source code
region.c contained code to test the module.
Separate test code into a proper test.
Test is copied verbatim from the original code.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-06-27 13:17:41 +01:00
Frediano Ziglio
8e8476d932 ssl_verify: Fix build for newer LibreSSL
LibreSSL 2.7 defines ASN1_STRING_get0_data, like OpenSSL 1.1.
This fixes https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=229044.
Original patch from Piotr Kubaj.

Reported-by: Jack L. <xxjack12xx@gmail.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-06-26 18:30:58 +01:00
Frediano Ziglio
3f04e2649d Revert "ssl_verify: Fix build for newer LibreSSL"
This reverts commit 638c77f3e6.
Commit had a misleading comment.
2018-06-26 18:30:58 +01:00
Frediano Ziglio
638c77f3e6 ssl_verify: Fix build for newer LibreSSL
LibreSSL 2.7 does not define ASN1_STRING_get0_data, like OpenSSL 1.1.
This fixes https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=229044.
Original patch from Piotr Kubaj.

Reported-by: Jack L. <xxjack12xx@gmail.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-06-26 17:58:44 +01:00
Frediano Ziglio
818b820644 canvas_base: Rework DUMP_JPEG debugging
The DUMP_JPEG compile time flag is used to dump all jpeg images
to files.
The code was saving garbage instead of proper data.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Reported-by: 谢 昆明 <KunMing.Xie@hotmail.com>
Tested-by: 谢 昆明 <KunMing.Xie@hotmail.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-06-26 17:55:04 +01:00
Christophe de Dinechin
258123318d Add SPICE_ATTR_NORETURN on prototype of error functions
The error functions are supposed to not return.  Using the attribute
documents that in the interface, and is better for the compiler
because most noreturn-related optimizations and spurious warning
eliminations happen at the call site.

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-06-26 10:25:42 +01:00
Christophe Fergeau
82a5f19d99 log: Only install glib log handler if SPICE_DEBUG_LEVEL is set
Calling g_log_set_handler() is problematic as this means applications
using spice-server won't be able to use g_log_set_default_handler to
manage spice logging output themselves. Since this call is only needed
for backwards compatibility (so that calling g_log together with
SPICE_DEBUG_LEVEL set has the expected behaviour), we can install it
only when SPICE_DEBUG_LEVEL is set.
Then we should deprecate SPICE_DEBUG_LEVEL once and for all.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-06-20 17:35:43 +01:00
Frediano Ziglio
1dcdefa8b3 quic: Use __builtin_clz if available
Different processors has specific instructions to count leading
zero bits. This includes: x86. x64, arm, ppc.
For portability reason the behaviour of __builtin_clz is not
defined if the value is zero so test for it.
Currently the function is not called with the value or 0.
This increase performance decoding of about 4-5% on a x64 machine
(code size decreases a little too, but about 0.1%).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-06-05 14:58:02 +01:00
Christophe Fergeau
b208389334 build: Move client sources to libspice_common_client_la_SOURCES
These sources are only used by the client, so they do not belong in
libspice_common_la_SOURCES.

Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-06-05 14:10:29 +01:00
Christophe Fergeau
992ebac6b5 build: Remove bitops.h
Nothing uses it since the GL backend was removed in 384698a

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-06-05 14:10:22 +01:00
Frediano Ziglio
349a74d7c2 quic: Fix endianness encoding
The image is going to network and network protocol is little endian
so the numbers has to be little endian. Note that this is already done
during decoding.
Tested on a ppc64 machine.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-06-04 16:05:20 +01:00
Eduardo Lima (Etrunko)
55070333f6 Add support for building with meson/ninja
In a comparison with current autotools build system, meson/ninja
provides a huge improvement in build speed, while keeping the same
functionalities currently available and being considered more user
friendly.

The new system coexists within the same repository with the current one,
so we can do more extensive testing of its functionality before deciding
if the old system can be removed, or for some reason, has to stay for
good.

- Meson: https://mesonbuild.com

  This is the equivalent of autogen/configure step in autotools. It
  generates the files that will be used by ninja to actually build the
  source code.

  The project has received lots of traction recently, with many GNOME
  projects willing to move to this new build system. The following wiki
  page has more details of the status of the many projects being ported:

    https://wiki.gnome.org/Initiatives/GnomeGoals/MesonPorting

  Meson has a python-like syntax, easy to read, and the documentation
  on the project is very complete, with a dedicated page on how to port
  from autotools, explaining how most common use cases can be
  implemented using meson.

    http://mesonbuild.com/Porting-from-autotools.html

  Other important sources of information:

    http://mesonbuild.com/howtox.html
    http://mesonbuild.com/Syntax.html
    http://mesonbuild.com/Reference-manual.html

- Ninja: https://ninja-build.org

  Ninja is the equivalent of make in an autotools setup, which actually
  builds the source code. It has being used by large and complex
  projects such as Google Chrome, Android and LLVM. There is not much to
  say about ninja (other than it is much faster than make) because we
  won't interact directly with it as much, as meson does the middle man
  job here. The reasoning for creating ninja in the first place is
  explained on the following post:

    http://neugierig.org/software/chromium/notes/2011/02/ninja.html

  Also its manual provides more in-depth information about the design
  principles:

    https://ninja-build.org/manual.html

- Basic workflow:

  Meson package is available for most if not all distros, so, taking
  Fedora as an example, we only need to run:

    # dnf -y install meson ninja-build.

  With Meson, building in-tree is not possible at all, so we need to
  pass a directory as argument to meson where we want the build to be
  done. This has the advantage of creating builds with different options
  under the same parent directory, e.g.:

    $ meson ./build --prefix=/usr
    $ meson ./build-extra -Dextra-checks=true -Dalignment-checks=true

  After configuration is done, we call ninja to actually do the build.

    $ ninja -C ./build
    $ ninja -C ./build install

  Ninja defaults to parallel builds, and this can be changed with the -j
  flag.

    $ ninja -j 10 -C ./build

- Hacking:

  * meson.build: Mandatory for the project root and usually found under
                 each directory you want something to be built.

  * meson_options.txt: Options that can interfere with the result of the
                       build.

Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-06-01 21:27:04 +01:00
Frediano Ziglio
68c0f93889 quic: Remove some too strict asserts in hot paths
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-31 07:34:17 +01:00
Frediano Ziglio
160232f8f6 quic: Remove 'no-inline' hack
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-28 11:27:01 +01:00
Frediano Ziglio
5312ea3f35 lz: Inline GET_{r,g,b} macros
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-25 11:54:18 +01:00
Frediano Ziglio
70aa6d39b6 lz: Optimise SAME_PIXEL for RGB16
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-25 11:54:18 +01:00
Christophe Fergeau
a1f6f42a33 quic: Use channel->correlate_row in macros
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-24 17:20:38 +01:00
Christophe Fergeau
0e550416f1 quic: Remove unused argument in uncompress_row{0, }
'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-24 12:18:49 +01:00
Christophe Fergeau
8152238618 quic: Add macros to make quic_tmpl.c much closer to quic_rgb_tmpl.c
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-05-24 12:18:44 +01:00
Christophe Fergeau
423518768e quic: s/decorrelate_drow/correlate_row
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-24 12:18:40 +01:00
Christophe Fergeau
4690e7239d quic: Introduce CommonState *state variable in templates
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-24 12:18:37 +01:00
Christophe Fergeau
b9dd7ed8f1 quic: Factor common code
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-24 12:18:33 +01:00
Christophe Fergeau
d240af18a4 quic: Get rid of RLE #define
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-24 11:01:31 +01:00
Christophe Fergeau
fce119be44 quic: Get rid of RLE_STAT #define
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-24 11:01:28 +01:00
Christophe Fergeau
7b2c2e620e quic: Get rid of QUIC_RGB #define
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-24 11:01:25 +01:00
Christophe Fergeau
763735d636 quic: Remove configurable PRED
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-24 11:01:22 +01:00
Christophe Fergeau
0629153699 quic: Remove configurable RLE_PRED
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-24 11:01:15 +01:00
Frediano Ziglio
78a17ba00a marshaller: Remove initial underscore from static function
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-21 13:34:58 +01:00
Eduardo Lima (Etrunko)
8816d30e67 Fix cast to spice_marshaller_item_free_func function
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-18 00:07:08 -03:00
Eduardo Lima (Etrunko)
f97c9c3900 build: Remove FIXME_SERVER_SMARTCARD hack
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 df4ec5c318
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-17 15:11:37 +01:00
Frediano Ziglio
75d9842e7d lz: Move ENCODE_PIXEL for RGB24 and RGB32 to a common place
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-10 19:50:50 +01:00
Jonathon Jongsma
fc46379b37 miLineArc(): initialize edge1, edge2
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-10 10:05:41 -05:00
Victor Toso
5729664523 messages: document limitation of id in StreamCreate
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-05-05 13:00:56 +01:00