diff options
author | Marc-André Lureau <marcandre.lureau@gmail.com> | 2013-09-30 15:00:01 +0200 |
---|---|---|
committer | Fabiano Fidêncio <fidencio@redhat.com> | 2015-02-23 23:00:40 +0100 |
commit | 286a570895c04c3624c403120c20dd54b627fb58 (patch) | |
tree | 57adc8d905f3e7b4ea55a61c3286cd5ac4611c1f | |
parent | c261e99df0257014c9ec16c76245bffa0fc73ca8 (diff) | |
download | spice-286a570895c04c3624c403120c20dd54b627fb58.tar.gz spice-286a570895c04c3624c403120c20dd54b627fb58.tar.xz spice-286a570895c04c3624c403120c20dd54b627fb58.zip |
server: rename files
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | server/Makefile.am | 96 | ||||
-rw-r--r-- | server/cache-item.c.template (renamed from server/cache_item.c.template) | 0 | ||||
-rw-r--r-- | server/cache-item.h (renamed from server/cache_item.h) | 0 | ||||
-rw-r--r-- | server/canvas.c | 7 | ||||
-rw-r--r-- | server/canvas.h | 10 | ||||
-rw-r--r-- | server/char-device.c (renamed from server/char_device.c) | 2 | ||||
-rw-r--r-- | server/char-device.h (renamed from server/char_device.h) | 2 | ||||
-rw-r--r-- | server/common.h | 17 | ||||
-rw-r--r-- | server/cursor-channel.c (renamed from server/cursor_channel.c) | 4 | ||||
-rw-r--r-- | server/cursor-channel.h (renamed from server/cursor_channel.h) | 2 | ||||
-rw-r--r-- | server/dcc-encoders.c (renamed from server/dcc_encoders.c) | 4 | ||||
-rw-r--r-- | server/dcc-encoders.h (renamed from server/dcc_encoders.h) | 9 | ||||
-rw-r--r-- | server/dcc-send.c (renamed from server/dcc_send.c) | 2 | ||||
-rw-r--r-- | server/dcc.c | 4 | ||||
-rw-r--r-- | server/dcc.h | 6 | ||||
-rw-r--r-- | server/dispatcher.h | 3 | ||||
-rw-r--r-- | server/display-channel.c (renamed from server/display_channel.c) | 2 | ||||
-rw-r--r-- | server/display-channel.h (renamed from server/display_channel.h) | 25 | ||||
-rw-r--r-- | server/glz-encode-match.c.template (renamed from server/glz_encode_match.c.template) | 0 | ||||
-rw-r--r-- | server/glz-encode.c.template (renamed from server/glz_encode.c.template) | 0 | ||||
-rw-r--r-- | server/glz-encoder-dict.c (renamed from server/glz_encoder_dictionary.c) | 5 | ||||
-rw-r--r-- | server/glz-encoder-dict.h (renamed from server/glz_encoder_dictionary.h) | 4 | ||||
-rw-r--r-- | server/glz-encoder-priv.h (renamed from server/glz_encoder_dictionary_protected.h) | 21 | ||||
-rw-r--r-- | server/glz-encoder.c (renamed from server/glz_encoder.c) | 18 | ||||
-rw-r--r-- | server/glz-encoder.h (renamed from server/glz_encoder.h) | 25 | ||||
-rw-r--r-- | server/glz_encoder_config.h | 59 | ||||
-rw-r--r-- | server/image-cache.c (renamed from server/spice_image_cache.c) | 4 | ||||
-rw-r--r-- | server/image-cache.h (renamed from server/spice_image_cache.h) | 2 | ||||
-rw-r--r-- | server/inputs-channel.c (renamed from server/inputs_channel.c) | 6 | ||||
-rw-r--r-- | server/inputs-channel.h (renamed from server/inputs_channel.h) | 0 | ||||
-rw-r--r-- | server/jpeg-encoder.c (renamed from server/jpeg_encoder.c) | 3 | ||||
-rw-r--r-- | server/jpeg-encoder.h (renamed from server/jpeg_encoder.h) | 0 | ||||
-rw-r--r-- | server/main-channel.c (renamed from server/main_channel.c) | 6 | ||||
-rw-r--r-- | server/main-channel.h (renamed from server/main_channel.h) | 0 | ||||
-rw-r--r-- | server/main-dispatcher.c (renamed from server/main_dispatcher.c) | 2 | ||||
-rw-r--r-- | server/main-dispatcher.h (renamed from server/main_dispatcher.h) | 0 | ||||
-rwxr-xr-x | server/make_recorder.sh | 13 | ||||
-rw-r--r-- | server/memslot.c (renamed from server/red_memslots.c) | 33 | ||||
-rw-r--r-- | server/memslot.h (renamed from server/red_memslots.h) | 39 | ||||
-rw-r--r-- | server/migration-protocol.h (renamed from server/migration_protocol.h) | 2 | ||||
-rw-r--r-- | server/mjpeg-encoder.c (renamed from server/mjpeg_encoder.c) | 2 | ||||
-rw-r--r-- | server/mjpeg-encoder.h (renamed from server/mjpeg_encoder.h) | 0 | ||||
-rw-r--r-- | server/pixmap-cache.c (renamed from server/pixmap_cache.c) | 2 | ||||
-rw-r--r-- | server/pixmap-cache.h (renamed from server/pixmap_cache.h) | 1 | ||||
-rw-r--r-- | server/red_bitmap_utils.c | 99 | ||||
-rw-r--r-- | server/red_channel.c | 2 | ||||
-rw-r--r-- | server/red_dispatcher.c | 3 | ||||
-rw-r--r-- | server/red_dispatcher.h | 1 | ||||
-rw-r--r-- | server/red_parse_qxl.c | 62 | ||||
-rw-r--r-- | server/red_parse_qxl.h | 2 | ||||
-rw-r--r-- | server/red_record_qxl.c | 62 | ||||
-rw-r--r-- | server/red_record_qxl.h | 2 | ||||
-rw-r--r-- | server/red_replay_qxl.c | 2 | ||||
-rw-r--r-- | server/red_worker.c | 20 | ||||
-rw-r--r-- | server/red_worker.h | 6 | ||||
-rw-r--r-- | server/reds.c | 12 | ||||
-rw-r--r-- | server/reds.h | 5 | ||||
-rw-r--r-- | server/reds_stream.c | 2 | ||||
-rw-r--r-- | server/reds_sw_canvas.c | 26 | ||||
-rw-r--r-- | server/reds_sw_canvas.h | 24 | ||||
-rw-r--r-- | server/smartcard.c | 4 | ||||
-rw-r--r-- | server/sound.c (renamed from server/snd_worker.c) | 6 | ||||
-rw-r--r-- | server/sound.h (renamed from server/snd_worker.h) | 0 | ||||
-rw-r--r-- | server/spice-bitmap-utils.c (renamed from server/spice_bitmap_utils.c) | 101 | ||||
-rw-r--r-- | server/spice-bitmap-utils.c.template (renamed from server/red_bitmap_utils.c.template) | 0 | ||||
-rw-r--r-- | server/spice-bitmap-utils.h (renamed from server/red_bitmap_utils.h) | 18 | ||||
-rw-r--r-- | server/spice_bitmap_utils.h | 11 | ||||
-rw-r--r-- | server/spice_server_utils.h | 8 | ||||
-rw-r--r-- | server/spicevmc.c | 4 | ||||
-rw-r--r-- | server/stream.c | 2 | ||||
-rw-r--r-- | server/stream.h | 4 | ||||
-rw-r--r-- | server/tree.c (renamed from server/tree_item.c) | 4 | ||||
-rw-r--r-- | server/tree.h (renamed from server/tree_item.h) | 8 | ||||
-rw-r--r-- | server/utils.h | 7 | ||||
-rw-r--r-- | server/zlib-encoder.c (renamed from server/zlib_encoder.c) | 2 | ||||
-rw-r--r-- | server/zlib-encoder.h (renamed from server/zlib_encoder.h) | 0 |
77 files changed, 431 insertions, 522 deletions
@@ -87,7 +87,7 @@ Major changes in 0.11.3: SPICE_MAIN_CAP_AGENT_CONNECTED_TOKENS SPICE_MAIN_CAP_SEAMLESS_MIGRATE * Misc: - * char_device.c: Introducing shared flow control code for char devices + * char-device.c: Introducing shared flow control code for char devices * Enable build without client, cegui and slirp. Major changes in 0.11.0: diff --git a/server/Makefile.am b/server/Makefile.am index dea1ce14..bc0979cf 100644 --- a/server/Makefile.am +++ b/server/Makefile.am @@ -4,6 +4,7 @@ SUBDIRS = . tests AM_CPPFLAGS = \ -DSPICE_SERVER_INTERNAL \ -DRED_STATISTICS \ + $(CELT051_CFLAGS) \ $(COMMON_CFLAGS) \ $(GLIB2_CFLAGS) \ $(LZ4_CFLAGS) \ @@ -64,26 +65,25 @@ libspice_server_la_SOURCES = \ $(libspice_serverinclude_HEADERS) \ agent-msg-filter.c \ agent-msg-filter.h \ - cache_item.h \ - char_device.c \ - char_device.h \ + cache-item.h \ + char-device.c \ + char-device.h \ demarshallers.h \ - glz_encoder.c \ - glz_encoder.h \ - glz_encoder_config.h \ - glz_encoder_dictionary.c \ - glz_encoder_dictionary.h \ - glz_encoder_dictionary_protected.h \ - inputs_channel.c \ - inputs_channel.h \ - jpeg_encoder.c \ - jpeg_encoder.h \ + glz-encoder.c \ + glz-encoder.h \ + glz-encoder-dict.c \ + glz-encoder-dict.h \ + glz-encoder-priv.h \ + inputs-channel.c \ + inputs-channel.h \ + jpeg-encoder.c \ + jpeg-encoder.h \ lz4_encoder.c \ lz4_encoder.h \ - main_channel.c \ - main_channel.h \ - mjpeg_encoder.c \ - mjpeg_encoder.h \ + main-channel.c \ + main-channel.h \ + mjpeg-encoder.c \ + mjpeg-encoder.h \ red_channel.c \ red_channel.h \ common.h \ @@ -91,11 +91,11 @@ libspice_server_la_SOURCES = \ dispatcher.h \ red_dispatcher.c \ red_dispatcher.h \ - main_dispatcher.c \ - main_dispatcher.h \ - migration_protocol.h \ - red_memslots.c \ - red_memslots.h \ + main-dispatcher.c \ + main-dispatcher.h \ + migration-protocol.h \ + memslot.c \ + memslot.h \ red_parse_qxl.c \ red_record_qxl.c \ red_replay_qxl.c \ @@ -103,43 +103,43 @@ libspice_server_la_SOURCES = \ red_time.h \ red_worker.c \ red_worker.h \ - display_channel.c \ - display_channel.h \ - cursor_channel.c \ - cursor_channel.h \ + display-channel.c \ + display-channel.h \ + cursor-channel.c \ + cursor-channel.h \ reds.c \ reds.h \ reds-private.h \ reds_stream.c \ reds_stream.h \ - reds_sw_canvas.c \ - reds_sw_canvas.h \ - snd_worker.c \ - snd_worker.h \ + sound.c \ + sound.h \ + spice-experimental.h \ + spice.h \ stat.h \ spicevmc.c \ - zlib_encoder.c \ - zlib_encoder.h \ - spice_bitmap_utils.h \ - spice_bitmap_utils.c \ + zlib-encoder.c \ + zlib-encoder.h \ + spice-bitmap-utils.h \ + spice-bitmap-utils.c \ spice_server_utils.h \ - spice_image_cache.h \ - spice_image_cache.c \ - pixmap_cache.h \ - pixmap_cache.c \ - tree_item.h \ - tree_item.c \ - red_bitmap_utils.h \ - red_bitmap_utils.c \ + image-cache.h \ + image-cache.c \ + pixmap-cache.h \ + pixmap-cache.c \ + tree.h \ + tree.c \ utils.c \ utils.h \ stream.c \ stream.h \ dcc.c \ - dcc_send.c \ + dcc-send.c \ dcc.h \ - dcc_encoders.c \ - dcc_encoders.h \ + dcc-encoders.c \ + dcc-encoders.h \ + canvas.c \ + canvas.h \ $(NULL) if SUPPORT_SMARTCARD @@ -151,9 +151,9 @@ endif EXTRA_DIST = \ red_bitmap_utils.c.template \ - cache_item.c.template \ - glz_encode_match.c.template \ - glz_encode.c.template \ + cache-item.c.template \ + glz-encode-match.c.template \ + glz-encode.c.template \ spice-server.syms \ $(NULL) diff --git a/server/cache_item.c.template b/server/cache-item.c.template index e5770cf6..e5770cf6 100644 --- a/server/cache_item.c.template +++ b/server/cache-item.c.template diff --git a/server/cache_item.h b/server/cache-item.h index 34a570b0..34a570b0 100644 --- a/server/cache_item.h +++ b/server/cache-item.h diff --git a/server/canvas.c b/server/canvas.c new file mode 100644 index 00000000..6e6d9ae4 --- /dev/null +++ b/server/canvas.c @@ -0,0 +1,7 @@ +#include "canvas.h" + +#define SPICE_CANVAS_INTERNAL +#define SW_CANVAS_IMAGE_CACHE +#include "common/sw_canvas.c" +#undef SW_CANVAS_IMAGE_CACHE +#undef SPICE_CANVAS_INTERNAL diff --git a/server/canvas.h b/server/canvas.h new file mode 100644 index 00000000..8470d444 --- /dev/null +++ b/server/canvas.h @@ -0,0 +1,10 @@ +#ifndef CANVAS_H_ +#define CANVAS_H_ + +#define SPICE_CANVAS_INTERNAL +#define SW_CANVAS_IMAGE_CACHE +#include "common/sw_canvas.h" +#undef SW_CANVAS_IMAGE_CACHE +#undef SPICE_CANVAS_INTERNAL + +#endif /* CANVAS_H_ */ diff --git a/server/char_device.c b/server/char-device.c index c6dc45b9..4e62bdb4 100644 --- a/server/char_device.c +++ b/server/char-device.c @@ -21,7 +21,7 @@ #include <config.h> -#include "char_device.h" +#include "char-device.h" #include "red_channel.h" #include "reds.h" diff --git a/server/char_device.h b/server/char-device.h index c17a40d4..58a3ea8e 100644 --- a/server/char_device.h +++ b/server/char-device.h @@ -3,7 +3,7 @@ #include "spice.h" #include "red_channel.h" -#include "migration_protocol.h" +#include "migration-protocol.h" /* * Shared code for char devices, mainly for flow control. diff --git a/server/common.h b/server/common.h index b0b7eddc..1edb098b 100644 --- a/server/common.h +++ b/server/common.h @@ -18,15 +18,26 @@ #ifndef _H_COMMON #define _H_COMMON -#include <spice/macros.h> +#include <glib.h> + +#include <errno.h> +#include <stdbool.h> +#include <stdint.h> #include <string.h> +#include <unistd.h> +#include <spice/macros.h> +#include "common/log.h" +#include "common/lz_common.h" +#include "common/marshaller.h" #include "common/mem.h" -#include "common/spice_common.h" #include "common/messages.h" -#include "common/lz_common.h" +#include "common/ring.h" +#include "common/spice_common.h" +#include "common/draw.h" #include "spice.h" +#include "utils.h" #define SPICE_GNUC_VISIBLE __attribute__ ((visibility ("default"))) diff --git a/server/cursor_channel.c b/server/cursor-channel.c index 609e7639..cd6513d5 100644 --- a/server/cursor_channel.c +++ b/server/cursor-channel.c @@ -1,5 +1,5 @@ #include "common/generated_server_marshallers.h" -#include "cursor_channel.h" +#include "cursor-channel.h" #define CLIENT_CURSOR_CACHE_SIZE 256 @@ -64,7 +64,7 @@ struct _CursorChannelClient { #define RCC_TO_CCC(rcc) SPICE_CONTAINEROF((rcc), CursorChannelClient, common.base) #define CLIENT_CURSOR_CACHE -#include "cache_item.c.template" +#include "cache-item.c.template" #undef CLIENT_CURSOR_CACHE static CursorItem *cursor_item_new(QXLInstance *qxl, RedCursorCmd *cmd, uint32_t group_id) diff --git a/server/cursor_channel.h b/server/cursor-channel.h index 478a785d..5e834d77 100644 --- a/server/cursor_channel.h +++ b/server/cursor-channel.h @@ -5,7 +5,7 @@ #include "reds.h" #include "red_worker.h" #include "red_parse_qxl.h" -#include "cache_item.h" +#include "cache-item.h" #include "stat.h" typedef struct _CursorChannel CursorChannel; diff --git a/server/dcc_encoders.c b/server/dcc-encoders.c index 695bfd60..65fbb037 100644 --- a/server/dcc_encoders.c +++ b/server/dcc-encoders.c @@ -1,7 +1,7 @@ #include <glib.h> -#include "dcc_encoders.h" -#include "display_channel.h" +#include "dcc-encoders.h" +#include "display-channel.h" #define ZLIB_DEFAULT_COMPRESSION_LEVEL 3 diff --git a/server/dcc_encoders.h b/server/dcc-encoders.h index 1e8aff86..a08460c4 100644 --- a/server/dcc_encoders.h +++ b/server/dcc-encoders.h @@ -6,14 +6,13 @@ #include "common/quic.h" #include "red_channel.h" #include "red_parse_qxl.h" -#include "spice_image_cache.h" -#include "glz_encoder_dictionary.h" -#include "glz_encoder.h" -#include "jpeg_encoder.h" +#include "image-cache.h" +#include "glz-encoder.h" +#include "jpeg-encoder.h" #ifdef USE_LZ4 #include "lz4_encoder.h" #endif -#include "zlib_encoder.h" +#include "zlib-encoder.h" typedef struct RedCompressBuf RedCompressBuf; typedef struct _GlzDrawableInstanceItem GlzDrawableInstanceItem; diff --git a/server/dcc_send.c b/server/dcc-send.c index c11ec052..d5d2df2f 100644 --- a/server/dcc_send.c +++ b/server/dcc-send.c @@ -1,5 +1,5 @@ #include "dcc.h" -#include "display_channel.h" +#include "display-channel.h" #include "common/marshaller.h" #include "common/generated_server_marshallers.h" diff --git a/server/dcc.c b/server/dcc.c index 0e1619b4..a7104900 100644 --- a/server/dcc.c +++ b/server/dcc.c @@ -1,5 +1,5 @@ #include "dcc.h" -#include "display_channel.h" +#include "display-channel.h" #define DISPLAY_CLIENT_SHORT_TIMEOUT 15000000000ULL //nano @@ -1156,7 +1156,7 @@ int dcc_compress_image(DisplayChannelClient *dcc, } #define CLIENT_PALETTE_CACHE -#include "cache_item.c.template" +#include "cache-item.c.template" #undef CLIENT_PALETTE_CACHE void dcc_palette_cache_palette(DisplayChannelClient *dcc, SpicePalette *palette, diff --git a/server/dcc.h b/server/dcc.h index 4575c47e..0adc2795 100644 --- a/server/dcc.h +++ b/server/dcc.h @@ -2,9 +2,9 @@ # define DCC_H_ #include "red_worker.h" -#include "pixmap_cache.h" -#include "cache_item.h" -#include "dcc_encoders.h" +#include "pixmap-cache.h" +#include "cache-item.h" +#include "dcc-encoders.h" #include "stream.h" #define PALETTE_CACHE_HASH_SHIFT 8 diff --git a/server/dispatcher.h b/server/dispatcher.h index 818eb8b9..5a439080 100644 --- a/server/dispatcher.h +++ b/server/dispatcher.h @@ -1,8 +1,7 @@ #ifndef DISPATCHER_H #define DISPATCHER_H -#include <spice.h> -#include "utils.h" +#include "common.h" typedef struct Dispatcher Dispatcher; diff --git a/server/display_channel.c b/server/display-channel.c index 5a69e608..93d21e95 100644 --- a/server/display_channel.c +++ b/server/display-channel.c @@ -1,4 +1,4 @@ -#include "display_channel.h" +#include "display-channel.h" uint32_t generate_uid(DisplayChannel *display) { diff --git a/server/display_channel.h b/server/display-channel.h index c9efb6ee..5d5e5727 100644 --- a/server/display_channel.h +++ b/server/display-channel.h @@ -6,28 +6,27 @@ #include "common/rect.h" #include "red_worker.h" #include "reds_stream.h" -#include "cache_item.h" -#include "pixmap_cache.h" -#include "reds_sw_canvas.h" +#include "cache-item.h" +#include "pixmap-cache.h" +#include "canvas.h" #include "stat.h" #include "reds.h" -#include "mjpeg_encoder.h" -#include "red_memslots.h" +#include "mjpeg-encoder.h" +#include "memslot.h" #include "red_parse_qxl.h" #include "red_record_qxl.h" #include "demarshallers.h" #include "red_channel.h" #include "red_dispatcher.h" #include "dispatcher.h" -#include "main_channel.h" -#include "migration_protocol.h" -#include "main_dispatcher.h" -#include "spice_server_utils.h" -#include "spice_bitmap_utils.h" -#include "spice_image_cache.h" -#include "pixmap_cache.h" +#include "main-channel.h" +#include "migration-protocol.h" +#include "main-dispatcher.h" +#include "spice-bitmap-utils.h" +#include "image-cache.h" +#include "pixmap-cache.h" #include "utils.h" -#include "tree_item.h" +#include "tree.h" #include "stream.h" #include "dcc.h" diff --git a/server/glz_encode_match.c.template b/server/glz-encode-match.c.template index 1fd251ee..1fd251ee 100644 --- a/server/glz_encode_match.c.template +++ b/server/glz-encode-match.c.template diff --git a/server/glz_encode.c.template b/server/glz-encode.c.template index 89092a97..89092a97 100644 --- a/server/glz_encode.c.template +++ b/server/glz-encode.c.template diff --git a/server/glz_encoder_dictionary.c b/server/glz-encoder-dict.c index ba6065f6..b17daafe 100644 --- a/server/glz_encoder_dictionary.c +++ b/server/glz-encoder-dict.c @@ -22,8 +22,9 @@ #include <string.h> #include <stdio.h> -#include "glz_encoder_dictionary.h" -#include "glz_encoder_dictionary_protected.h" +#include "glz-encoder.h" +#include "glz-encoder-dict.h" +#include "glz-encoder-priv.h" /* turning all used images to free ones. If they are alive, calling the free_image callback for each one */ diff --git a/server/glz_encoder_dictionary.h b/server/glz-encoder-dict.h index eb57aa54..0a58b4b6 100644 --- a/server/glz_encoder_dictionary.h +++ b/server/glz-encoder-dict.h @@ -19,7 +19,6 @@ #define _H_GLZ_ENCODER_DICTIONARY #include <stdint.h> -#include "glz_encoder_config.h" /* Interface for maintaining lz dictionary that is shared among several encoders. @@ -30,6 +29,9 @@ typedef void GlzEncDictContext; typedef void GlzEncDictImageContext; +typedef void GlzUsrImageContext; +typedef struct GlzEncoderUsrContext GlzEncoderUsrContext; + /* NOTE: DISPLAY_MIGRATE_DATA_VERSION should change in case GlzEncDictRestoreData changes*/ typedef struct GlzEncDictRestoreData { uint32_t size; diff --git a/server/glz_encoder_dictionary_protected.h b/server/glz-encoder-priv.h index ee1f8d8e..b0ac7f4c 100644 --- a/server/glz_encoder_dictionary_protected.h +++ b/server/glz-encoder-priv.h @@ -15,8 +15,10 @@ License along with this library; if not, see <http://www.gnu.org/licenses/>. */ -#ifndef _H_GLZ_ENCODER_DICTIONARY_PROTECTED -#define _H_GLZ_ENCODER_DICTIONARY_PROTECTED +#ifndef _H_GLZ_ENCODER_PRIV +#define _H_GLZ_ENCODER_PRIV + +#include "common.h" /* Interface for using the dictionary for encoding. Data structures are exposed for the encoder for efficiency @@ -183,4 +185,17 @@ void glz_dictionary_post_encode(uint32_t encoder_id, GlzEncoderUsrContext *usr, (dict)->window.encoders_heads[enc_id]].pixels_so_far <= \ ref_seg->pixels_so_far))) -#endif // _H_GLZ_ENCODER_DICTIONARY_PROTECTED +#ifdef DEBUG + +#define GLZ_ASSERT(usr, x) \ + if (!(x)) (usr)->error(usr, "%s: ASSERT %s failed\n", __FUNCTION__, #x); + +#else + +#define GLZ_ASSERT(usr, x) + +#endif + + + +#endif // _H_GLZ_ENCODER_PRIV diff --git a/server/glz_encoder.c b/server/glz-encoder.c index b0c1cfd8..a11bfb63 100644 --- a/server/glz_encoder.c +++ b/server/glz-encoder.c @@ -20,8 +20,8 @@ #include <pthread.h> #include <stdio.h> -#include "glz_encoder.h" -#include "glz_encoder_dictionary_protected.h" +#include "glz-encoder.h" +#include "glz-encoder-priv.h" /* Holds a specific data for one encoder, and data that is relevant for the current image encoded */ @@ -202,24 +202,24 @@ typedef uint16_t rgb16_pixel_t; #define GLZ_ENCODE_SIZE -#include "glz_encode_match.c.template" +#include "glz-encode-match.c.template" #define GLZ_ENCODE_MATCH -#include "glz_encode_match.c.template" +#include "glz-encode-match.c.template" #define LZ_PLT -#include "glz_encode.c.template" +#include "glz-encode.c.template" #define LZ_RGB16 -#include "glz_encode.c.template" +#include "glz-encode.c.template" #define LZ_RGB24 -#include "glz_encode.c.template" +#include "glz-encode.c.template" #define LZ_RGB32 -#include "glz_encode.c.template" +#include "glz-encode.c.template" #define LZ_RGB_ALPHA -#include "glz_encode.c.template" +#include "glz-encode.c.template" int glz_encode(GlzEncoderContext *opaque_encoder, diff --git a/server/glz_encoder.h b/server/glz-encoder.h index 34c363a3..56818ec0 100644 --- a/server/glz_encoder.h +++ b/server/glz-encoder.h @@ -20,10 +20,29 @@ /* Manging the lz encoding using a dictionary that is shared among encoders */ -#include <stdint.h> +#include "common.h" #include "common/lz_common.h" -#include "glz_encoder_dictionary.h" -#include "glz_encoder_config.h" +#include "glz-encoder-dict.h" + +struct GlzEncoderUsrContext { + SPICE_GNUC_PRINTF(2, 3) void (*error)(GlzEncoderUsrContext *usr, const char *fmt, ...); + SPICE_GNUC_PRINTF(2, 3) void (*warn)(GlzEncoderUsrContext *usr, const char *fmt, ...); + SPICE_GNUC_PRINTF(2, 3) void (*info)(GlzEncoderUsrContext *usr, const char *fmt, ...); + void *(*malloc)(GlzEncoderUsrContext *usr, int size); + void (*free)(GlzEncoderUsrContext *usr, void *ptr); + + // get the next chunk of the image which is entered to the dictionary. If the image is down to + // top, return it from the last line to the first one (stride should always be positive) + int (*more_lines)(GlzEncoderUsrContext *usr, uint8_t **lines); + + // get the next chunk of the compressed buffer.return number of bytes in the chunk. + int (*more_space)(GlzEncoderUsrContext *usr, uint8_t **io_ptr); + + // called when an image is removed from the dictionary, due to the window size limit + void (*free_image)(GlzEncoderUsrContext *usr, GlzUsrImageContext *image); + +}; + typedef void GlzEncoderContext; diff --git a/server/glz_encoder_config.h b/server/glz_encoder_config.h deleted file mode 100644 index 6472668d..00000000 --- a/server/glz_encoder_config.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - Copyright (C) 2009 Red Hat, Inc. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see <http://www.gnu.org/licenses/>. -*/ - -#ifndef _H_GLZ_ENCODER_CONFIG -#define _H_GLZ_ENCODER_CONFIG - -#include <spice/macros.h> -#include "common/lz_common.h" - -typedef void GlzUsrImageContext; -typedef struct GlzEncoderUsrContext GlzEncoderUsrContext; - -struct GlzEncoderUsrContext { - SPICE_GNUC_PRINTF(2, 3) void (*error)(GlzEncoderUsrContext *usr, const char *fmt, ...); - SPICE_GNUC_PRINTF(2, 3) void (*warn)(GlzEncoderUsrContext *usr, const char *fmt, ...); - SPICE_GNUC_PRINTF(2, 3) void (*info)(GlzEncoderUsrContext *usr, const char *fmt, ...); - void *(*malloc)(GlzEncoderUsrContext *usr, int size); - void (*free)(GlzEncoderUsrContext *usr, void *ptr); - - // get the next chunk of the image which is entered to the dictionary. If the image is down to - // top, return it from the last line to the first one (stride should always be positive) - int (*more_lines)(GlzEncoderUsrContext *usr, uint8_t **lines); - - // get the next chunk of the compressed buffer.return number of bytes in the chunk. - int (*more_space)(GlzEncoderUsrContext *usr, uint8_t **io_ptr); - - // called when an image is removed from the dictionary, due to the window size limit - void (*free_image)(GlzEncoderUsrContext *usr, GlzUsrImageContext *image); - -}; - - -#ifdef DEBUG - -#define GLZ_ASSERT(usr, x) \ - if (!(x)) (usr)->error(usr, "%s: ASSERT %s failed\n", __FUNCTION__, #x); - -#else - -#define GLZ_ASSERT(usr, x) - -#endif - - -#endif diff --git a/server/spice_image_cache.c b/server/image-cache.c index 5fbf24dd..387b5f25 100644 --- a/server/spice_image_cache.c +++ b/server/image-cache.c @@ -1,6 +1,6 @@ -#include "spice_image_cache.h" +#include "image-cache.h" #include "red_parse_qxl.h" -#include "display_channel.h" +#include "display-channel.h" static ImageCacheItem *image_cache_find(ImageCache *cache, uint64_t id) { diff --git a/server/spice_image_cache.h b/server/image-cache.h index 1ce69c3d..6c03a6e8 100644 --- a/server/spice_image_cache.h +++ b/server/image-cache.h @@ -7,7 +7,7 @@ #include "common/canvas_base.h" #include "common/ring.h" -/* FIXME: move back to display_channel.h (once structs are private) */ +/* FIXME: move back to display-channel.h (once structs are private) */ typedef struct Drawable Drawable; typedef struct _DisplayChannelClient DisplayChannelClient; diff --git a/server/inputs_channel.c b/server/inputs-channel.c index 5986a5c7..14f1b124 100644 --- a/server/inputs_channel.c +++ b/server/inputs-channel.c @@ -39,9 +39,9 @@ #include "reds.h" #include "reds_stream.h" #include "red_channel.h" -#include "main_channel.h" -#include "inputs_channel.h" -#include "migration_protocol.h" +#include "main-channel.h" +#include "inputs-channel.h" +#include "migration-protocol.h" // TODO: RECEIVE_BUF_SIZE used to be the same for inputs_channel and main_channel // since it was defined once in reds.c which contained both. diff --git a/server/inputs_channel.h b/server/inputs-channel.h index 672ca83a..672ca83a 100644 --- a/server/inputs_channel.h +++ b/server/inputs-channel.h diff --git a/server/jpeg_encoder.c b/server/jpeg-encoder.c index a0c0c9ef..673a1449 100644 --- a/server/jpeg_encoder.c +++ b/server/jpeg-encoder.c @@ -19,7 +19,8 @@ #endif #include "common.h" -#include "jpeg_encoder.h" +#include "jpeg-encoder.h" + #include <jpeglib.h> typedef struct JpegEncoder { diff --git a/server/jpeg_encoder.h b/server/jpeg-encoder.h index 690a0296..690a0296 100644 --- a/server/jpeg_encoder.h +++ b/server/jpeg-encoder.h diff --git a/server/main_channel.c b/server/main-channel.c index f056c0b6..81682353 100644 --- a/server/main_channel.c +++ b/server/main-channel.c @@ -41,12 +41,12 @@ #include "common/ring.h" #include "demarshallers.h" -#include "main_channel.h" +#include "main-channel.h" #include "red_channel.h" #include "common.h" #include "reds.h" -#include "migration_protocol.h" -#include "main_dispatcher.h" +#include "migration-protocol.h" +#include "main-dispatcher.h" #define ZERO_BUF_SIZE 4096 diff --git a/server/main_channel.h b/server/main-channel.h index c8e9ade2..c8e9ade2 100644 --- a/server/main_channel.h +++ b/server/main-channel.h diff --git a/server/main_dispatcher.c b/server/main-dispatcher.c index 504cc122..d58afb7b 100644 --- a/server/main_dispatcher.c +++ b/server/main-dispatcher.c @@ -6,7 +6,7 @@ #include "common.h" #include "dispatcher.h" -#include "main_dispatcher.h" +#include "main-dispatcher.h" #include "red_channel.h" #include "reds.h" diff --git a/server/main_dispatcher.h b/server/main-dispatcher.h index 522c7f91..522c7f91 100644 --- a/server/main_dispatcher.h +++ b/server/main-dispatcher.h diff --git a/server/make_recorder.sh b/server/make_recorder.sh deleted file mode 100755 index e7a92341..00000000 --- a/server/make_recorder.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -if [ ! -e red_parse_qxl.c ]; then - echo run in server subdir - exit 1 -fi -if [ -e red_record_qxl.c ]; then - echo not overwriting red_record_qxl.c - exit 1 -fi -cp red_parse_qxl.c red_record_qxl.c.base -sed -e 's/\(static.*\)red_get\([a-z_]*(\)/\1red_record\2int fd, /' -e 's/^void red_get_\(.*\)(/void red_record_\1(int fd, /' < red_record_qxl.c.base > red_record_qxl.1.c -sed -e 's/red_get\(.*\)(/red_record\1(fd, /' < red_record_qxl.1.c > red_record_qxl.c -diff -u red_parse_qxl.c red_record_qxl.c diff --git a/server/red_memslots.c b/server/memslot.c index 6ec1dd6c..6b5bb8db 100644 --- a/server/red_memslots.c +++ b/server/memslot.c @@ -21,8 +21,7 @@ #include <inttypes.h> -#include "common.h" -#include "red_memslots.h" +#include "memslot.h" static unsigned long __get_clean_virt(RedMemSlotInfo *info, QXLPHYSICAL addr) { @@ -49,7 +48,7 @@ static void print_memslots(RedMemSlotInfo *info) } /* return 1 if validation successfull, 0 otherwise */ -int validate_virt(RedMemSlotInfo *info, unsigned long virt, int slot_id, +int memslot_validate_virt(RedMemSlotInfo *info, unsigned long virt, int slot_id, uint32_t add_size, uint32_t group_id) { MemSlot *slot; @@ -76,7 +75,7 @@ int validate_virt(RedMemSlotInfo *info, unsigned long virt, int slot_id, * return virtual address if successful, which may be 0. * returns 0 and sets error to 1 if an error condition occurs. */ -unsigned long get_virt(RedMemSlotInfo *info, QXLPHYSICAL addr, uint32_t add_size, +unsigned long memslot_get_virt(RedMemSlotInfo *info, QXLPHYSICAL addr, uint32_t add_size, int group_id, int *error) { int slot_id; @@ -92,7 +91,7 @@ unsigned long get_virt(RedMemSlotInfo *info, QXLPHYSICAL addr, uint32_t add_size return 0; } - slot_id = get_memslot_id(info, addr); + slot_id = memslot_get_id(info, addr); if (slot_id > info->num_memslots) { print_memslots(info); spice_critical("slot_id %d too big, addr=%" PRIx64, slot_id, addr); @@ -102,7 +101,7 @@ unsigned long get_virt(RedMemSlotInfo *info, QXLPHYSICAL addr, uint32_t add_size slot = &info->mem_slots[group_id][slot_id]; - generation = get_generation(info, addr); + generation = memslot_get_generation(info, addr); if (generation != slot->generation) { print_memslots(info); spice_critical("address generation is not valid, group_id %d, slot_id %d, gen %d, slot_gen %d\n", @@ -114,7 +113,7 @@ unsigned long get_virt(RedMemSlotInfo *info, QXLPHYSICAL addr, uint32_t add_size h_virt = __get_clean_virt(info, addr); h_virt += slot->address_delta; - if (!validate_virt(info, h_virt, slot_id, add_size, group_id)) { + if (!memslot_validate_virt(info, h_virt, slot_id, add_size, group_id)) { *error = 1; return 0; } @@ -122,7 +121,7 @@ unsigned long get_virt(RedMemSlotInfo *info, QXLPHYSICAL addr, uint32_t add_size return h_virt; } -void red_memslot_info_init(RedMemSlotInfo *info, +void memslot_info_init(RedMemSlotInfo *info, uint32_t num_groups, uint32_t num_slots, uint8_t generation_bits, uint8_t id_bits, @@ -130,8 +129,8 @@ void red_memslot_info_init(RedMemSlotInfo *info, { uint32_t i; - spice_assert(num_slots > 0); - spice_assert(num_groups > 0); + spice_return_if_fail(num_slots > 0); + spice_return_if_fail(num_groups > 0); info->num_memslots_groups = num_groups; info->num_memslots = num_slots; @@ -153,12 +152,12 @@ void red_memslot_info_init(RedMemSlotInfo *info, (info->mem_slot_bits + info->generation_bits)); } -void red_memslot_info_add_slot(RedMemSlotInfo *info, uint32_t slot_group_id, uint32_t slot_id, +void memslot_info_add_slot(RedMemSlotInfo *info, uint32_t slot_group_id, uint32_t slot_id, uint64_t addr_delta, unsigned long virt_start, unsigned long virt_end, uint32_t generation) { - spice_assert(info->num_memslots_groups > slot_group_id); - spice_assert(info->num_memslots > slot_id); + spice_return_if_fail(info->num_memslots_groups > slot_group_id); + spice_return_if_fail(info->num_memslots > slot_id); info->mem_slots[slot_group_id][slot_id].address_delta = addr_delta; info->mem_slots[slot_group_id][slot_id].virt_start_addr = virt_start; @@ -166,16 +165,16 @@ void red_memslot_info_add_slot(RedMemSlotInfo *info, uint32_t slot_group_id, uin info->mem_slots[slot_group_id][slot_id].generation = generation; } -void red_memslot_info_del_slot(RedMemSlotInfo *info, uint32_t slot_group_id, uint32_t slot_id) +void memslot_info_del_slot(RedMemSlotInfo *info, uint32_t slot_group_id, uint32_t slot_id) { - spice_assert(info->num_memslots_groups > slot_group_id); - spice_assert(info->num_memslots > slot_id); + spice_return_if_fail(info->num_memslots_groups > slot_group_id); + spice_return_if_fail(info->num_memslots > slot_id); info->mem_slots[slot_group_id][slot_id].virt_start_addr = 0; info->mem_slots[slot_group_id][slot_id].virt_end_addr = 0; } -void red_memslot_info_reset(RedMemSlotInfo *info) +void memslot_info_reset(RedMemSlotInfo *info) { uint32_t i; for (i = 0; i < info->num_memslots_groups; ++i) { diff --git a/server/red_memslots.h b/server/memslot.h index dabd404a..57e2b31f 100644 --- a/server/red_memslots.h +++ b/server/memslot.h @@ -16,8 +16,8 @@ License along with this library; if not, see <http://www.gnu.org/licenses/>. */ -#ifndef _H_REDMEMSLOTS -#define _H_REDMEMSLOTS +#ifndef _H_MEMSLOT +#define _H_MEMSLOT #include "common.h" @@ -43,30 +43,29 @@ typedef struct RedMemSlotInfo { unsigned long memslot_clean_virt_mask; } RedMemSlotInfo; -static inline int get_memslot_id(RedMemSlotInfo *info, uint64_t addr) +static inline int memslot_get_id (RedMemSlotInfo *info, uint64_t addr) { return addr >> info->memslot_id_shift; } -static inline int get_generation(RedMemSlotInfo *info, uint64_t addr) +static inline int memslot_get_generation (RedMemSlotInfo *info, uint64_t addr) { return (addr >> info->memslot_gen_shift) & info->memslot_gen_mask; } -int validate_virt(RedMemSlotInfo *info, unsigned long virt, int slot_id, - uint32_t add_size, uint32_t group_id); -unsigned long get_virt(RedMemSlotInfo *info, QXLPHYSICAL addr, uint32_t add_size, - int group_id, int *error); +int memslot_validate_virt (RedMemSlotInfo *info, unsigned long virt, int slot_id, + uint32_t add_size, uint32_t group_id); +unsigned long memslot_get_virt (RedMemSlotInfo *info, QXLPHYSICAL addr, uint32_t add_size, + int group_id, int *error); +void memslot_info_init (RedMemSlotInfo *info, + uint32_t num_groups, uint32_t num_slots, + uint8_t generation_bits, + uint8_t id_bits, + uint8_t internal_groupslot_id); +void memslot_info_add_slot (RedMemSlotInfo *info, uint32_t slot_group_id, uint32_t slot_id, + uint64_t addr_delta, unsigned long virt_start, unsigned long virt_end, + uint32_t generation); +void memslot_info_del_slot (RedMemSlotInfo *info, uint32_t slot_group_id, uint32_t slot_id); +void memslot_info_reset (RedMemSlotInfo *info); -void red_memslot_info_init(RedMemSlotInfo *info, - uint32_t num_groups, uint32_t num_slots, - uint8_t generation_bits, - uint8_t id_bits, - uint8_t internal_groupslot_id); -void red_memslot_info_add_slot(RedMemSlotInfo *info, uint32_t slot_group_id, uint32_t slot_id, - uint64_t addr_delta, unsigned long virt_start, unsigned long virt_end, - uint32_t generation); -void red_memslot_info_del_slot(RedMemSlotInfo *info, uint32_t slot_group_id, uint32_t slot_id); -void red_memslot_info_reset(RedMemSlotInfo *info); - -#endif +#endif /* MEMSLOT_H_ */ diff --git a/server/migration_protocol.h b/server/migration-protocol.h index fa17c7c4..4c92e881 100644 --- a/server/migration_protocol.h +++ b/server/migration-protocol.h @@ -19,7 +19,7 @@ #define _H_MIGRATION_PROTOCOL #include <spice/vd_agent.h> -#include "glz_encoder_dictionary.h" +#include "glz-encoder-dict.h" /* ************************************************ * src-server to dst-server migration data messages diff --git a/server/mjpeg_encoder.c b/server/mjpeg-encoder.c index 65689a68..8c7c1451 100644 --- a/server/mjpeg_encoder.c +++ b/server/mjpeg-encoder.c @@ -20,7 +20,7 @@ #endif #include "common.h" -#include "mjpeg_encoder.h" +#include "mjpeg-encoder.h" #include <jerror.h> #include <jpeglib.h> #include <inttypes.h> diff --git a/server/mjpeg_encoder.h b/server/mjpeg-encoder.h index 0e13ba16..0e13ba16 100644 --- a/server/mjpeg_encoder.h +++ b/server/mjpeg-encoder.h diff --git a/server/pixmap_cache.c b/server/pixmap-cache.c index 5d1b985e..3b89e132 100644 --- a/server/pixmap_cache.c +++ b/server/pixmap-cache.c @@ -1,4 +1,4 @@ -#include "pixmap_cache.h" +#include "pixmap-cache.h" int pixmap_cache_set_lossy(PixmapCache *cache, uint64_t id, int lossy) { diff --git a/server/pixmap_cache.h b/server/pixmap-cache.h index 3992b029..72afc54d 100644 --- a/server/pixmap_cache.h +++ b/server/pixmap-cache.h @@ -2,7 +2,6 @@ # define _PIXMAP_CACHE_H #include "red_channel.h" -#include "spice_server_utils.h" #define MAX_CACHE_CLIENTS 4 diff --git a/server/red_bitmap_utils.c b/server/red_bitmap_utils.c deleted file mode 100644 index 33886dcf..00000000 --- a/server/red_bitmap_utils.c +++ /dev/null @@ -1,99 +0,0 @@ -#include "red_bitmap_utils.h" - -#define RED_BITMAP_UTILS_RGB16 -#include "red_bitmap_utils.c.template" -#define RED_BITMAP_UTILS_RGB24 -#include "red_bitmap_utils.c.template" -#define RED_BITMAP_UTILS_RGB32 -#include "red_bitmap_utils.c.template" - -#define GRADUAL_HIGH_RGB24_TH -0.03 -#define GRADUAL_HIGH_RGB16_TH 0 - -// setting a more permissive threshold for stream identification in order -// not to miss streams that were artificially scaled on the guest (e.g., full screen view -// in window media player 12). see red_stream_add_frame -#define GRADUAL_MEDIUM_SCORE_TH 0.002 - -// assumes that stride doesn't overflow -BitmapGradualType bitmap_get_graduality_level(SpiceBitmap *bitmap) -{ - double score = 0.0; - int num_samples = 0; - int num_lines; - double chunk_score = 0.0; - int chunk_num_samples = 0; - uint32_t x, i; - SpiceChunk *chunk; - - chunk = bitmap->data->chunk; - for (i = 0; i < bitmap->data->num_chunks; i++) { - num_lines = chunk[i].len / bitmap->stride; - x = bitmap->x; - switch (bitmap->format) { - case SPICE_BITMAP_FMT_16BIT: - compute_lines_gradual_score_rgb16((rgb16_pixel_t *)chunk[i].data, x, num_lines, - &chunk_score, &chunk_num_samples); - break; - case SPICE_BITMAP_FMT_24BIT: - compute_lines_gradual_score_rgb24((rgb24_pixel_t *)chunk[i].data, x, num_lines, - &chunk_score, &chunk_num_samples); - break; - case SPICE_BITMAP_FMT_32BIT: - case SPICE_BITMAP_FMT_RGBA: - compute_lines_gradual_score_rgb32((rgb32_pixel_t *)chunk[i].data, x, num_lines, - &chunk_score, &chunk_num_samples); - break; - default: - spice_error("invalid bitmap format (not RGB) %u", bitmap->format); - } - score += chunk_score; - num_samples += chunk_num_samples; - } - - spice_assert(num_samples); - score /= num_samples; - - if (bitmap->format == SPICE_BITMAP_FMT_16BIT) { - if (score < GRADUAL_HIGH_RGB16_TH) { - return BITMAP_GRADUAL_HIGH; - } - } else { - if (score < GRADUAL_HIGH_RGB24_TH) { - return BITMAP_GRADUAL_HIGH; - } - } - - if (score < GRADUAL_MEDIUM_SCORE_TH) { - return BITMAP_GRADUAL_MEDIUM; - } else { - return BITMAP_GRADUAL_LOW; - } -} - -int bitmap_has_extra_stride(SpiceBitmap *bitmap) -{ - spice_assert(bitmap); - if (bitmap_fmt_is_rgb(bitmap->format)) { - return ((bitmap->x * bitmap_fmt_get_bytes_per_pixel(bitmap->format)) < bitmap->stride); - } else { - switch (bitmap->format) { - case SPICE_BITMAP_FMT_8BIT: - return (bitmap->x < bitmap->stride); - case SPICE_BITMAP_FMT_4BIT_BE: - case SPICE_BITMAP_FMT_4BIT_LE: { - int bytes_width = SPICE_ALIGN(bitmap->x, 2) >> 1; - return bytes_width < bitmap->stride; - } - case SPICE_BITMAP_FMT_1BIT_BE: - case SPICE_BITMAP_FMT_1BIT_LE: { - int bytes_width = SPICE_ALIGN(bitmap->x, 8) >> 3; - return bytes_width < bitmap->stride; - } - default: - spice_error("invalid image type %u", bitmap->format); - return 0; - } - } - return 0; -} diff --git a/server/red_channel.c b/server/red_channel.c index 808f0311..b11f5bc5 100644 --- a/server/red_channel.c +++ b/server/red_channel.c @@ -41,7 +41,7 @@ #include "red_channel.h" #include "reds.h" #include "reds_stream.h" -#include "main_dispatcher.h" +#include "main-dispatcher.h" #include "utils.h" typedef struct EmptyMsgPipeItem { diff --git a/server/red_dispatcher.c b/server/red_dispatcher.c index 0648c3aa..a44a22f8 100644 --- a/server/red_dispatcher.c +++ b/server/red_dispatcher.c @@ -33,11 +33,10 @@ #include "spice.h" #include "red_worker.h" -#include "reds_sw_canvas.h" +#include "canvas.h" #include "reds.h" #include "dispatcher.h" #include "red_parse_qxl.h" -#include "spice_server_utils.h" #include "stream.h" #include "red_dispatcher.h" diff --git a/server/red_dispatcher.h b/server/red_dispatcher.h index 1ca41011..0d33b673 100644 --- a/server/red_dispatcher.h +++ b/server/red_dispatcher.h @@ -18,7 +18,6 @@ #ifndef _H_RED_DISPATCHER #define _H_RED_DISPATCHER -#include "spice_server_utils.h" #include "red_channel.h" typedef struct RedDispatcher RedDispatcher; diff --git a/server/red_parse_qxl.c b/server/red_parse_qxl.c index 4aa8def0..a59e9d32 100644 --- a/server/red_parse_qxl.c +++ b/server/red_parse_qxl.c @@ -22,10 +22,10 @@ #include <stdbool.h> #include <inttypes.h> #include "common/lz_common.h" -#include "red_bitmap_utils.h" #include "common.h" -#include "red_memslots.h" +#include "memslot.h" #include "red_parse_qxl.h" +#include "spice-bitmap-utils.h" #if 0 static void hexdump_qxl(RedMemSlotInfo *slots, int group_id, @@ -95,7 +95,7 @@ static size_t red_get_data_chunks_ptr(RedMemSlotInfo *slots, int group_id, red->data_size = qxl->data_size; data_size += red->data_size; - if (!validate_virt(slots, (intptr_t)qxl->data, memslot_id, red->data_size, group_id)) { + if (!memslot_validate_virt(slots, (intptr_t)qxl->data, memslot_id, red->data_size, group_id)) { return 0; } red->data = qxl->data; @@ -104,15 +104,15 @@ static size_t red_get_data_chunks_ptr(RedMemSlotInfo *slots, int group_id, while (qxl->next_chunk) { red_prev = red; red = spice_new(RedDataChunk, 1); - memslot_id = get_memslot_id(slots, qxl->next_chunk); - qxl = (QXLDataChunk *)get_virt(slots, qxl->next_chunk, sizeof(*qxl), group_id, + memslot_id = memslot_get_id(slots, qxl->next_chunk); + qxl = (QXLDataChunk *)memslot_get_virt(slots, qxl->next_chunk, sizeof(*qxl), group_id, &error); if (error) { return 0; } red->data_size = qxl->data_size; data_size += red->data_size; - if (!validate_virt(slots, (intptr_t)qxl->data, memslot_id, red->data_size, group_id)) { + if (!memslot_validate_virt(slots, (intptr_t)qxl->data, memslot_id, red->data_size, group_id)) { return 0; } red->data = qxl->data; @@ -129,9 +129,9 @@ static size_t red_get_data_chunks(RedMemSlotInfo *slots, int group_id, { QXLDataChunk *qxl; int error; - int memslot_id = get_memslot_id(slots, addr); + int memslot_id = memslot_get_id(slots, addr); - qxl = (QXLDataChunk *)get_virt(slots, addr, sizeof(*qxl), group_id, &error); + qxl = (QXLDataChunk *)memslot_get_virt(slots, addr, sizeof(*qxl), group_id, &error); if (error) { return 0; } @@ -186,12 +186,12 @@ static SpicePath *red_get_path(RedMemSlotInfo *slots, int group_id, uint32_t count; int error; - qxl = (QXLPath *)get_virt(slots, addr, sizeof(*qxl), group_id, &error); + qxl = (QXLPath *)memslot_get_virt(slots, addr, sizeof(*qxl), group_id, &error); if (error) { return NULL; } size = red_get_data_chunks_ptr(slots, group_id, - get_memslot_id(slots, addr), + memslot_get_id(slots, addr), &chunks, &qxl->chunk); data = red_linearize_chunk(&chunks, size, &free_data); red_put_data_chunks(&chunks); @@ -264,12 +264,12 @@ static SpiceClipRects *red_get_clip_rects(RedMemSlotInfo *slots, int group_id, int i; int error; - qxl = (QXLClipRects *)get_virt(slots, addr, sizeof(*qxl), group_id, &error); + qxl = (QXLClipRects *)memslot_get_virt(slots, addr, sizeof(*qxl), group_id, &error); if (error) { return NULL; } size = red_get_data_chunks_ptr(slots, group_id, - get_memslot_id(slots, addr), + memslot_get_id(slots, addr), &chunks, &qxl->chunk); data = red_linearize_chunk(&chunks, size, &free_data); red_put_data_chunks(&chunks); @@ -297,7 +297,7 @@ static SpiceChunks *red_get_image_data_flat(RedMemSlotInfo *slots, int group_id, data = spice_chunks_new(1); data->data_size = size; - data->chunk[0].data = (void*)get_virt(slots, addr, size, group_id, &error); + data->chunk[0].data = (void*)memslot_get_virt(slots, addr, size, group_id, &error); if (error) { return 0; } @@ -382,7 +382,7 @@ static SpiceImage *red_get_image(RedMemSlotInfo *slots, int group_id, return NULL; } - qxl = (QXLImage *)get_virt(slots, addr, sizeof(*qxl), group_id, &error); + qxl = (QXLImage *)memslot_get_virt(slots, addr, sizeof(*qxl), group_id, &error); if (error) { return NULL; } @@ -424,14 +424,14 @@ static SpiceImage *red_get_image(RedMemSlotInfo *slots, int group_id, if (qxl->bitmap.palette) { QXLPalette *qp; int i, num_ents; - qp = (QXLPalette *)get_virt(slots, qxl->bitmap.palette, + qp = (QXLPalette *)memslot_get_virt(slots, qxl->bitmap.palette, sizeof(*qp), group_id, &error); if (error) { goto error; } num_ents = qp->num_ents; - if (!validate_virt(slots, (intptr_t)qp->ents, - get_memslot_id(slots, qxl->bitmap.palette), + if (!memslot_validate_virt(slots, (intptr_t)qp->ents, + memslot_get_id(slots, qxl->bitmap.palette), num_ents * sizeof(qp->ents[0]), group_id)) { goto error; } @@ -476,7 +476,7 @@ static SpiceImage *red_get_image(RedMemSlotInfo *slots, int group_id, case SPICE_IMAGE_TYPE_QUIC: red->u.quic.data_size = qxl->quic.data_size; size = red_get_data_chunks_ptr(slots, group_id, - get_memslot_id(slots, addr), + memslot_get_id(slots, addr), &chunks, (QXLDataChunk *)qxl->quic.data); spice_assert(size == red->u.quic.data_size); if (size != red->u.quic.data_size) { @@ -672,7 +672,7 @@ static bool get_transform(RedMemSlotInfo *slots, if (qxl_transform == 0) return FALSE; - t = (uint32_t *)get_virt(slots, qxl_transform, sizeof(*dst_transform), group_id, &error); + t = (uint32_t *)memslot_get_virt(slots, qxl_transform, sizeof(*dst_transform), group_id, &error); if (!t || error) return FALSE; @@ -747,7 +747,7 @@ static int red_get_stroke_ptr(RedMemSlotInfo *slots, int group_id, red->attr.style = spice_malloc_n(style_nseg, sizeof(SPICE_FIXED28_4)); red->attr.style_nseg = style_nseg; spice_assert(qxl->attr.style); - buf = (uint8_t *)get_virt(slots, qxl->attr.style, + buf = (uint8_t *)memslot_get_virt(slots, qxl->attr.style, style_nseg * sizeof(QXLFIXED), group_id, &error); if (error) { return error; @@ -786,12 +786,12 @@ static SpiceString *red_get_string(RedMemSlotInfo *slots, int group_id, int glyphs, bpp = 0, i; int error; - qxl = (QXLString *)get_virt(slots, addr, sizeof(*qxl), group_id, &error); + qxl = (QXLString *)memslot_get_virt(slots, addr, sizeof(*qxl), group_id, &error); if (error) { return NULL; } chunk_size = red_get_data_chunks_ptr(slots, group_id, - get_memslot_id(slots, addr), + memslot_get_id(slots, addr), &chunks, &qxl->chunk); if (!chunk_size) { /* XXX could be a zero sized string.. */ @@ -933,7 +933,7 @@ static int red_get_native_drawable(RedMemSlotInfo *slots, int group_id, int i; int error = 0; - qxl = (QXLDrawable *)get_virt(slots, addr, sizeof(*qxl), group_id, &error); + qxl = (QXLDrawable *)memslot_get_virt(slots, addr, sizeof(*qxl), group_id, &error); if (error) { return error; } @@ -1016,7 +1016,7 @@ static int red_get_compat_drawable(RedMemSlotInfo *slots, int group_id, QXLCompatDrawable *qxl; int error; - qxl = (QXLCompatDrawable *)get_virt(slots, addr, sizeof(*qxl), group_id, &error); + qxl = (QXLCompatDrawable *)memslot_get_virt(slots, addr, sizeof(*qxl), group_id, &error); if (error) { return error; } @@ -1164,7 +1164,7 @@ int red_get_update_cmd(RedMemSlotInfo *slots, int group_id, QXLUpdateCmd *qxl; int error; - qxl = (QXLUpdateCmd *)get_virt(slots, addr, sizeof(*qxl), group_id, &error); + qxl = (QXLUpdateCmd *)memslot_get_virt(slots, addr, sizeof(*qxl), group_id, &error); if (error) { return 1; } @@ -1193,7 +1193,7 @@ int red_get_message(RedMemSlotInfo *slots, int group_id, * luckily this is for debug logging only, * so we can just ignore it by default. */ - qxl = (QXLMessage *)get_virt(slots, addr, sizeof(*qxl), group_id, &error); + qxl = (QXLMessage *)memslot_get_virt(slots, addr, sizeof(*qxl), group_id, &error); if (error) { return 1; } @@ -1214,7 +1214,7 @@ int red_get_surface_cmd(RedMemSlotInfo *slots, int group_id, size_t size; int error; - qxl = (QXLSurfaceCmd *)get_virt(slots, addr, sizeof(*qxl), group_id, + qxl = (QXLSurfaceCmd *)memslot_get_virt(slots, addr, sizeof(*qxl), group_id, &error); if (error) { return 1; @@ -1233,7 +1233,7 @@ int red_get_surface_cmd(RedMemSlotInfo *slots, int group_id, red->u.surface_create.stride = qxl->u.surface_create.stride; size = red->u.surface_create.height * abs(red->u.surface_create.stride); red->u.surface_create.data = - (uint8_t*)get_virt(slots, qxl->u.surface_create.data, size, group_id, &error); + (uint8_t*)memslot_get_virt(slots, qxl->u.surface_create.data, size, group_id, &error); if (error) { return 1; } @@ -1257,7 +1257,7 @@ static int red_get_cursor(RedMemSlotInfo *slots, int group_id, bool free_data; int error; - qxl = (QXLCursor *)get_virt(slots, addr, sizeof(*qxl), group_id, &error); + qxl = (QXLCursor *)memslot_get_virt(slots, addr, sizeof(*qxl), group_id, &error); if (error) { return 1; } @@ -1272,7 +1272,7 @@ static int red_get_cursor(RedMemSlotInfo *slots, int group_id, red->flags = 0; red->data_size = qxl->data_size; size = red_get_data_chunks_ptr(slots, group_id, - get_memslot_id(slots, addr), + memslot_get_id(slots, addr), &chunks, &qxl->chunk); data = red_linearize_chunk(&chunks, size, &free_data); red_put_data_chunks(&chunks); @@ -1296,7 +1296,7 @@ int red_get_cursor_cmd(RedMemSlotInfo *slots, int group_id, QXLCursorCmd *qxl; int error; - qxl = (QXLCursorCmd *)get_virt(slots, addr, sizeof(*qxl), group_id, &error); + qxl = (QXLCursorCmd *)memslot_get_virt(slots, addr, sizeof(*qxl), group_id, &error); if (error) { return error; } diff --git a/server/red_parse_qxl.h b/server/red_parse_qxl.h index ff8a251a..2a974a3e 100644 --- a/server/red_parse_qxl.h +++ b/server/red_parse_qxl.h @@ -21,7 +21,7 @@ #include <spice/qxl_dev.h> #include "common.h" -#include "red_memslots.h" +#include "memslot.h" typedef struct RedDrawable { int refs; diff --git a/server/red_record_qxl.c b/server/red_record_qxl.c index ad5caf9a..2ef6a267 100644 --- a/server/red_record_qxl.c +++ b/server/red_record_qxl.c @@ -23,9 +23,9 @@ #include <inttypes.h> #include "red_worker.h" #include "common.h" -#include "red_memslots.h" +#include "memslot.h" #include "red_parse_qxl.h" -#include "zlib_encoder.h" +#include "zlib-encoder.h" #if 0 static void hexdump_qxl(RedMemSlotInfo *slots, int group_id, @@ -139,21 +139,21 @@ static size_t red_record_data_chunks_ptr(FILE *fd, const char *prefix, while (cur->next_chunk) { cur = - (QXLDataChunk*)get_virt(slots, cur->next_chunk, sizeof(*cur), group_id, + (QXLDataChunk*)memslot_get_virt(slots, cur->next_chunk, sizeof(*cur), group_id, &error); data_size += cur->data_size; count_chunks++; } fprintf(fd, "data_chunks %d %ld\n", count_chunks, data_size); - validate_virt(slots, (intptr_t)qxl->data, memslot_id, qxl->data_size, group_id); + memslot_validate_virt(slots, (intptr_t)qxl->data, memslot_id, qxl->data_size, group_id); write_binary(fd, prefix, qxl->data_size, qxl->data); while (qxl->next_chunk) { - memslot_id = get_memslot_id(slots, qxl->next_chunk); - qxl = (QXLDataChunk*)get_virt(slots, qxl->next_chunk, sizeof(*qxl), group_id, + memslot_id = memslot_get_id(slots, qxl->next_chunk); + qxl = (QXLDataChunk*)memslot_get_virt(slots, qxl->next_chunk, sizeof(*qxl), group_id, &error); - validate_virt(slots, (intptr_t)qxl->data, memslot_id, qxl->data_size, group_id); + memslot_validate_virt(slots, (intptr_t)qxl->data, memslot_id, qxl->data_size, group_id); write_binary(fd, prefix, qxl->data_size, qxl->data); } @@ -165,10 +165,10 @@ static size_t red_record_data_chunks(FILE *fd, const char *prefix, QXLPHYSICAL addr) { QXLDataChunk *qxl; - int memslot_id = get_memslot_id(slots, addr); + int memslot_id = memslot_get_id(slots, addr); int error; - qxl = (QXLDataChunk*)get_virt(slots, addr, sizeof(*qxl), group_id, + qxl = (QXLDataChunk*)memslot_get_virt(slots, addr, sizeof(*qxl), group_id, &error); return red_record_data_chunks_ptr(fd, prefix, slots, group_id, memslot_id, qxl); } @@ -195,10 +195,10 @@ static void red_record_path(FILE *fd, RedMemSlotInfo *slots, int group_id, QXLPath *qxl; int error; - qxl = (QXLPath *)get_virt(slots, addr, sizeof(*qxl), group_id, + qxl = (QXLPath *)memslot_get_virt(slots, addr, sizeof(*qxl), group_id, &error); red_record_data_chunks_ptr(fd, "path", slots, group_id, - get_memslot_id(slots, addr), + memslot_get_id(slots, addr), &qxl->chunk); } @@ -208,11 +208,11 @@ static void red_record_clip_rects(FILE *fd, RedMemSlotInfo *slots, int group_id, QXLClipRects *qxl; int error; - qxl = (QXLClipRects *)get_virt(slots, addr, sizeof(*qxl), group_id, + qxl = (QXLClipRects *)memslot_get_virt(slots, addr, sizeof(*qxl), group_id, &error); fprintf(fd, "num_rects %d\n", qxl->num_rects); red_record_data_chunks_ptr(fd, "clip_rects", slots, group_id, - get_memslot_id(slots, addr), + memslot_get_id(slots, addr), &qxl->chunk); } @@ -223,7 +223,7 @@ static void red_record_virt_data_flat(FILE *fd, const char *prefix, int error; write_binary(fd, prefix, - size, (uint8_t*)get_virt(slots, addr, size, group_id, + size, (uint8_t*)memslot_get_virt(slots, addr, size, group_id, &error)); } @@ -253,7 +253,7 @@ static void red_record_image(FILE *fd, RedMemSlotInfo *slots, int group_id, return; } - qxl = (QXLImage *)get_virt(slots, addr, sizeof(*qxl), group_id, + qxl = (QXLImage *)memslot_get_virt(slots, addr, sizeof(*qxl), group_id, &error); fprintf(fd, "descriptor.id %ld\n", qxl->descriptor.id); fprintf(fd, "descriptor.type %d\n", qxl->descriptor.type); @@ -273,12 +273,12 @@ static void red_record_image(FILE *fd, RedMemSlotInfo *slots, int group_id, if (qxl->bitmap.palette) { QXLPalette *qp; int i, num_ents; - qp = (QXLPalette *)get_virt(slots, qxl->bitmap.palette, + qp = (QXLPalette *)memslot_get_virt(slots, qxl->bitmap.palette, sizeof(*qp), group_id, &error); num_ents = qp->num_ents; fprintf(fd, "qp.num_ents %d\n", qp->num_ents); - validate_virt(slots, (intptr_t)qp->ents, - get_memslot_id(slots, qxl->bitmap.palette), + memslot_validate_virt(slots, (intptr_t)qp->ents, + memslot_get_id(slots, qxl->bitmap.palette), num_ents * sizeof(qp->ents[0]), group_id); fprintf(fd, "unique %ld\n", qp->unique); for (i = 0; i < num_ents; i++) { @@ -302,7 +302,7 @@ static void red_record_image(FILE *fd, RedMemSlotInfo *slots, int group_id, case SPICE_IMAGE_TYPE_QUIC: fprintf(fd, "quic.data_size %d\n", qxl->quic.data_size); size = red_record_data_chunks_ptr(fd, "quic.data", slots, group_id, - get_memslot_id(slots, addr), + memslot_get_id(slots, addr), (QXLDataChunk *)qxl->quic.data); spice_assert(size == qxl->quic.data_size); break; @@ -426,7 +426,7 @@ static void red_record_stroke_ptr(FILE *fd, RedMemSlotInfo *slots, int group_id, fprintf(fd, "attr.style_nseg %d\n", qxl->attr.style_nseg); spice_assert(qxl->attr.style); - buf = (uint8_t *)get_virt(slots, qxl->attr.style, + buf = (uint8_t *)memslot_get_virt(slots, qxl->attr.style, style_nseg * sizeof(QXLFIXED), group_id, &error); write_binary(fd, "style", style_nseg * sizeof(QXLFIXED), buf); @@ -443,13 +443,13 @@ static void red_record_string(FILE *fd, RedMemSlotInfo *slots, int group_id, size_t chunk_size; int error; - qxl = (QXLString *)get_virt(slots, addr, sizeof(*qxl), group_id, + qxl = (QXLString *)memslot_get_virt(slots, addr, sizeof(*qxl), group_id, &error); fprintf(fd, "data_size %d\n", qxl->data_size); fprintf(fd, "length %d\n", qxl->length); fprintf(fd, "flags %d\n", qxl->flags); chunk_size = red_record_data_chunks_ptr(fd, "string", slots, group_id, - get_memslot_id(slots, addr), + memslot_get_id(slots, addr), &qxl->chunk); spice_assert(chunk_size == qxl->data_size); } @@ -521,7 +521,7 @@ static void red_record_native_drawable(FILE *fd, RedMemSlotInfo *slots, int grou int i; int error; - qxl = (QXLDrawable *)get_virt(slots, addr, sizeof(*qxl), group_id, + qxl = (QXLDrawable *)memslot_get_virt(slots, addr, sizeof(*qxl), group_id, &error); red_record_rect_ptr(fd, "bbox", &qxl->bbox); @@ -597,7 +597,7 @@ static void red_record_compat_drawable(FILE *fd, RedMemSlotInfo *slots, int grou QXLCompatDrawable *qxl; int error; - qxl = (QXLCompatDrawable *)get_virt(slots, addr, sizeof(*qxl), group_id, + qxl = (QXLCompatDrawable *)memslot_get_virt(slots, addr, sizeof(*qxl), group_id, &error); red_record_rect_ptr(fd, "bbox", &qxl->bbox); @@ -676,7 +676,7 @@ void red_record_update_cmd(FILE *fd, RedMemSlotInfo *slots, int group_id, QXLUpdateCmd *qxl; int error; - qxl = (QXLUpdateCmd *)get_virt(slots, addr, sizeof(*qxl), group_id, + qxl = (QXLUpdateCmd *)memslot_get_virt(slots, addr, sizeof(*qxl), group_id, &error); fprintf(fd, "update\n"); @@ -697,7 +697,7 @@ void red_record_message(FILE *fd, RedMemSlotInfo *slots, int group_id, * luckily this is for debug logging only, * so we can just ignore it by default. */ - qxl = (QXLMessage *)get_virt(slots, addr, sizeof(*qxl), group_id, + qxl = (QXLMessage *)memslot_get_virt(slots, addr, sizeof(*qxl), group_id, &error); write_binary(fd, "message", strlen((char*)qxl->data), (uint8_t*)qxl->data); } @@ -709,7 +709,7 @@ void red_record_surface_cmd(FILE *fd, RedMemSlotInfo *slots, int group_id, size_t size; int error; - qxl = (QXLSurfaceCmd *)get_virt(slots, addr, sizeof(*qxl), group_id, + qxl = (QXLSurfaceCmd *)memslot_get_virt(slots, addr, sizeof(*qxl), group_id, &error); fprintf(fd, "surface_cmd\n"); @@ -726,7 +726,7 @@ void red_record_surface_cmd(FILE *fd, RedMemSlotInfo *slots, int group_id, size = qxl->u.surface_create.height * abs(qxl->u.surface_create.stride); if (qxl->flags && QXL_SURF_FLAG_KEEP_DATA) { write_binary(fd, "data", size, - (uint8_t*)get_virt(slots, qxl->u.surface_create.data, size, group_id, + (uint8_t*)memslot_get_virt(slots, qxl->u.surface_create.data, size, group_id, &error)); } break; @@ -739,7 +739,7 @@ static void red_record_cursor(FILE *fd, RedMemSlotInfo *slots, int group_id, QXLCursor *qxl; int error; - qxl = (QXLCursor *)get_virt(slots, addr, sizeof(*qxl), group_id, + qxl = (QXLCursor *)memslot_get_virt(slots, addr, sizeof(*qxl), group_id, &error); fprintf(fd, "header.unique %ld\n", qxl->header.unique); @@ -751,7 +751,7 @@ static void red_record_cursor(FILE *fd, RedMemSlotInfo *slots, int group_id, fprintf(fd, "data_size %d\n", qxl->data_size); red_record_data_chunks_ptr(fd, "cursor", slots, group_id, - get_memslot_id(slots, addr), + memslot_get_id(slots, addr), &qxl->chunk); } @@ -761,7 +761,7 @@ void red_record_cursor_cmd(FILE *fd, RedMemSlotInfo *slots, int group_id, QXLCursorCmd *qxl; int error; - qxl = (QXLCursorCmd *)get_virt(slots, addr, sizeof(*qxl), group_id, + qxl = (QXLCursorCmd *)memslot_get_virt(slots, addr, sizeof(*qxl), group_id, &error); fprintf(fd, "cursor_cmd\n"); diff --git a/server/red_record_qxl.h b/server/red_record_qxl.h index d42d29ec..47014b1b 100644 --- a/server/red_record_qxl.h +++ b/server/red_record_qxl.h @@ -21,7 +21,7 @@ #include <spice/qxl_dev.h> #include "common.h" -#include "red_memslots.h" +#include "memslot.h" void red_record_drawable(FILE *fd, RedMemSlotInfo *slots, int group_id, QXLPHYSICAL addr, uint32_t flags); diff --git a/server/red_replay_qxl.c b/server/red_replay_qxl.c index 454f626f..125512c6 100644 --- a/server/red_replay_qxl.c +++ b/server/red_replay_qxl.c @@ -25,7 +25,7 @@ #include "reds.h" #include "red_worker.h" #include "common.h" -#include "red_memslots.h" +#include "memslot.h" #include "red_parse_qxl.h" #include "red_replay_qxl.h" #include <glib.h> diff --git a/server/red_worker.c b/server/red_worker.c index 50fc8401..7d72c05e 100644 --- a/server/red_worker.c +++ b/server/red_worker.c @@ -44,13 +44,13 @@ #include "common/region.h" #include "common/ring.h" -#include "display_channel.h" +#include "display-channel.h" #include "stream.h" #include "spice.h" #include "red_worker.h" -#include "cursor_channel.h" -#include "tree_item.h" +#include "cursor-channel.h" +#include "tree.h" #include "utils.h" #define CMD_RING_POLL_TIMEOUT 10 //milli @@ -1224,7 +1224,7 @@ static void handle_dev_del_memslot(void *opaque, uint32_t message_type, void *pa uint32_t slot_id = msg->slot_id; uint32_t slot_group_id = msg->slot_group_id; - red_memslot_info_del_slot(&worker->mem_slots, slot_group_id, slot_id); + memslot_info_del_slot(&worker->mem_slots, slot_group_id, slot_id); } static void handle_dev_destroy_surface_wait(void *opaque, uint32_t message_type, void *payload) @@ -1296,7 +1296,7 @@ static void dev_create_primary_surface(RedWorker *worker, uint32_t surface_id, spice_warn_if(((uint64_t)abs(surface.stride) * (uint64_t)surface.height) != abs(surface.stride) * surface.height); - line_0 = (uint8_t*)get_virt(&worker->mem_slots, surface.mem, + line_0 = (uint8_t*)memslot_get_virt(&worker->mem_slots, surface.mem, surface.height * abs(surface.stride), surface.group_id, &error); if (error) { @@ -1567,7 +1567,7 @@ static void handle_dev_monitors_config_async(void *opaque, int min_size = sizeof(QXLMonitorsConfig) + sizeof(QXLHead); int error; QXLMonitorsConfig *dev_monitors_config = - (QXLMonitorsConfig*)get_virt(&worker->mem_slots, msg->monitors_config, + (QXLMonitorsConfig*)memslot_get_virt(&worker->mem_slots, msg->monitors_config, min_size, msg->group_id, &error); if (error) { @@ -1702,7 +1702,7 @@ static void handle_dev_set_mouse_mode(void *opaque, uint32_t message_type, void static void dev_add_memslot(RedWorker *worker, QXLDevMemSlot mem_slot) { - red_memslot_info_add_slot(&worker->mem_slots, mem_slot.slot_group_id, mem_slot.slot_id, + memslot_info_add_slot(&worker->mem_slots, mem_slot.slot_group_id, mem_slot.slot_id, mem_slot.addr_delta, mem_slot.virt_start, mem_slot.virt_end, mem_slot.generation); } @@ -1713,7 +1713,7 @@ static void handle_dev_add_memslot(void *opaque, uint32_t message_type, void *pa RedWorkerMessageAddMemslot *msg = payload; QXLDevMemSlot mem_slot = msg->mem_slot; - red_memslot_info_add_slot(&worker->mem_slots, mem_slot.slot_group_id, mem_slot.slot_id, + memslot_info_add_slot(&worker->mem_slots, mem_slot.slot_group_id, mem_slot.slot_id, mem_slot.addr_delta, mem_slot.virt_start, mem_slot.virt_end, mem_slot.generation); } @@ -1730,7 +1730,7 @@ static void handle_dev_reset_memslots(void *opaque, uint32_t message_type, void { RedWorker *worker = opaque; - red_memslot_info_reset(&worker->mem_slots); + memslot_info_reset(&worker->mem_slots); } static void handle_dev_driver_unload(void *opaque, uint32_t message_type, void *payload) @@ -2109,7 +2109,7 @@ RedWorker* red_worker_new(QXLInstance *qxl, RedDispatcher *red_dispatcher) g_source_attach(source, worker->main_context); g_source_unref(source); - red_memslot_info_init(&worker->mem_slots, + memslot_info_init(&worker->mem_slots, init_info.num_memslots_groups, init_info.num_memslots, init_info.memslot_gen_bits, diff --git a/server/red_worker.h b/server/red_worker.h index 4a549e62..679a9782 100644 --- a/server/red_worker.h +++ b/server/red_worker.h @@ -18,12 +18,6 @@ #ifndef _H_REDWORKER #define _H_REDWORKER -#include <unistd.h> -#include <errno.h> - -#include "common/marshaller.h" - -#include "utils.h" #include "common.h" #include "red_dispatcher.h" #include "red_parse_qxl.h" diff --git a/server/reds.c b/server/reds.c index d2fd5101..7e4bb5c4 100644 --- a/server/reds.c +++ b/server/reds.c @@ -57,15 +57,15 @@ #include "reds.h" #include "stream.h" #include "agent-msg-filter.h" -#include "inputs_channel.h" -#include "main_channel.h" +#include "inputs-channel.h" +#include "main-channel.h" #include "red_dispatcher.h" -#include "main_dispatcher.h" -#include "snd_worker.h" +#include "main-dispatcher.h" +#include "sound.h" #include "stat.h" #include "demarshallers.h" -#include "char_device.h" -#include "migration_protocol.h" +#include "char-device.h" +#include "migration-protocol.h" #ifdef USE_SMARTCARD #include "smartcard.h" #endif diff --git a/server/reds.h b/server/reds.h index 03c483e1..58b445b2 100644 --- a/server/reds.h +++ b/server/reds.h @@ -28,7 +28,10 @@ #include "common/messages.h" #include "spice.h" #include "red_channel.h" -#include "migration_protocol.h" +#include "migration-protocol.h" + +#define SPICE_GNUC_VISIBLE __attribute__ ((visibility ("default"))) + struct QXLState { QXLInterface *qif; diff --git a/server/reds_stream.c b/server/reds_stream.c index 7f17d1c4..68c37740 100644 --- a/server/reds_stream.c +++ b/server/reds_stream.c @@ -20,7 +20,7 @@ #endif #include "common.h" -#include "main_dispatcher.h" +#include "main-dispatcher.h" #include "reds_stream.h" #include "common/log.h" diff --git a/server/reds_sw_canvas.c b/server/reds_sw_canvas.c deleted file mode 100644 index 297df376..00000000 --- a/server/reds_sw_canvas.c +++ /dev/null @@ -1,26 +0,0 @@ -/* - Copyright (C) 2011 Red Hat, Inc. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see <http://www.gnu.org/licenses/>. -*/ -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "common/spice_common.h" - -#include "reds_sw_canvas.h" -#define SW_CANVAS_IMAGE_CACHE -#include "common/sw_canvas.c" -#undef SW_CANVAS_IMAGE_CACHE diff --git a/server/reds_sw_canvas.h b/server/reds_sw_canvas.h deleted file mode 100644 index 96a4c0ce..00000000 --- a/server/reds_sw_canvas.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - Copyright (C) 2011 Red Hat, Inc. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see <http://www.gnu.org/licenses/>. -*/ -#ifndef _H_REDS_SW_CANVAS -#define _H_REDS_SW_CANVAS - -#define SW_CANVAS_IMAGE_CACHE -#include "common/sw_canvas.h" -#undef SW_CANVAS_IMAGE_CACHE - -#endif diff --git a/server/smartcard.c b/server/smartcard.c index aad22aad..928e27b8 100644 --- a/server/smartcard.c +++ b/server/smartcard.c @@ -23,10 +23,10 @@ #include <vscard_common.h> #include "reds.h" -#include "char_device.h" +#include "char-device.h" #include "red_channel.h" #include "smartcard.h" -#include "migration_protocol.h" +#include "migration-protocol.h" /* * TODO: the code doesn't really support multiple readers. diff --git a/server/snd_worker.c b/server/sound.c index e519bd9b..1f3a4839 100644 --- a/server/snd_worker.c +++ b/server/sound.c @@ -28,14 +28,14 @@ #include "common/marshaller.h" #include "common/generated_server_marshallers.h" +#include "common/snd_codec.h" #include "spice.h" #include "common.h" -#include "main_channel.h" +#include "main-channel.h" #include "reds.h" #include "red_dispatcher.h" -#include "snd_worker.h" -#include "common/snd_codec.h" +#include "sound.h" #include "demarshallers.h" #ifndef IOV_MAX diff --git a/server/snd_worker.h b/server/sound.h index 8de746de..8de746de 100644 --- a/server/snd_worker.h +++ b/server/sound.h diff --git a/server/spice_bitmap_utils.c b/server/spice-bitmap-utils.c index 9ff87646..fc8dbe6b 100644 --- a/server/spice_bitmap_utils.c +++ b/server/spice-bitmap-utils.c @@ -1,9 +1,102 @@ -#include <stdio.h> +#include "spice-bitmap-utils.h" -#include "common/log.h" -#include "common/draw.h" +#define RED_BITMAP_UTILS_RGB16 +#include "spice-bitmap-utils.c.template" +#define RED_BITMAP_UTILS_RGB24 +#include "spice-bitmap-utils.c.template" +#define RED_BITMAP_UTILS_RGB32 +#include "spice-bitmap-utils.c.template" -#include "spice_bitmap_utils.h" +#define GRADUAL_HIGH_RGB24_TH -0.03 +#define GRADUAL_HIGH_RGB16_TH 0 + +// setting a more permissive threshold for stream identification in order +// not to miss streams that were artificially scaled on the guest (e.g., full screen view +// in window media player 12). see red_stream_add_frame +#define GRADUAL_MEDIUM_SCORE_TH 0.002 + +// assumes that stride doesn't overflow +BitmapGradualType bitmap_get_graduality_level(SpiceBitmap *bitmap) +{ + double score = 0.0; + int num_samples = 0; + int num_lines; + double chunk_score = 0.0; + int chunk_num_samples = 0; + uint32_t x, i; + SpiceChunk *chunk; + + chunk = bitmap->data->chunk; + for (i = 0; i < bitmap->data->num_chunks; i++) { + num_lines = chunk[i].len / bitmap->stride; + x = bitmap->x; + switch (bitmap->format) { + case SPICE_BITMAP_FMT_16BIT: + compute_lines_gradual_score_rgb16((rgb16_pixel_t *)chunk[i].data, x, num_lines, + &chunk_score, &chunk_num_samples); + break; + case SPICE_BITMAP_FMT_24BIT: + compute_lines_gradual_score_rgb24((rgb24_pixel_t *)chunk[i].data, x, num_lines, + &chunk_score, &chunk_num_samples); + break; + case SPICE_BITMAP_FMT_32BIT: + case SPICE_BITMAP_FMT_RGBA: + compute_lines_gradual_score_rgb32((rgb32_pixel_t *)chunk[i].data, x, num_lines, + &chunk_score, &chunk_num_samples); + break; + default: + spice_error("invalid bitmap format (not RGB) %u", bitmap->format); + } + score += chunk_score; + num_samples += chunk_num_samples; + } + + spice_assert(num_samples); + score /= num_samples; + + if (bitmap->format == SPICE_BITMAP_FMT_16BIT) { + if (score < GRADUAL_HIGH_RGB16_TH) { + return BITMAP_GRADUAL_HIGH; + } + } else { + if (score < GRADUAL_HIGH_RGB24_TH) { + return BITMAP_GRADUAL_HIGH; + } + } + + if (score < GRADUAL_MEDIUM_SCORE_TH) { + return BITMAP_GRADUAL_MEDIUM; + } else { + return BITMAP_GRADUAL_LOW; + } +} + +int bitmap_has_extra_stride(SpiceBitmap *bitmap) +{ + spice_assert(bitmap); + if (bitmap_fmt_is_rgb(bitmap->format)) { + return ((bitmap->x * bitmap_fmt_get_bytes_per_pixel(bitmap->format)) < bitmap->stride); + } else { + switch (bitmap->format) { + case SPICE_BITMAP_FMT_8BIT: + return (bitmap->x < bitmap->stride); + case SPICE_BITMAP_FMT_4BIT_BE: + case SPICE_BITMAP_FMT_4BIT_LE: { + int bytes_width = SPICE_ALIGN(bitmap->x, 2) >> 1; + return bytes_width < bitmap->stride; + } + case SPICE_BITMAP_FMT_1BIT_BE: + case SPICE_BITMAP_FMT_1BIT_LE: { + int bytes_width = SPICE_ALIGN(bitmap->x, 8) >> 3; + return bytes_width < bitmap->stride; + } + default: + spice_error("invalid image type %u", bitmap->format); + return 0; + } + } + return 0; +} int spice_bitmap_from_surface_type(uint32_t surface_format) { diff --git a/server/red_bitmap_utils.c.template b/server/spice-bitmap-utils.c.template index 6d508a7c..6d508a7c 100644 --- a/server/red_bitmap_utils.c.template +++ b/server/spice-bitmap-utils.c.template diff --git a/server/red_bitmap_utils.h b/server/spice-bitmap-utils.h index 6b0e69a0..b73d368e 100644 --- a/server/red_bitmap_utils.h +++ b/server/spice-bitmap-utils.h @@ -1,10 +1,7 @@ -#ifndef RED_BITMAP_UTILS_H_ -# define RED_BITMAP_UTILS_H_ +#ifndef H_SPICE_BITMAP_UTILS +#define H_SPICE_BITMAP_UTILS -#include <glib.h> -#include <stdint.h> -#include "common/draw.h" -#include "common/log.h" +#include "common.h" typedef enum { BITMAP_GRADUAL_INVALID, @@ -71,4 +68,11 @@ static inline int bitmap_fmt_has_graduality(uint8_t fmt) BitmapGradualType bitmap_get_graduality_level (SpiceBitmap *bitmap); int bitmap_has_extra_stride (SpiceBitmap *bitmap); -#endif /* RED_BITMAP_UTILS_H_ */ +void dump_bitmap(SpiceBitmap *bitmap); + +int spice_bitmap_from_surface_type(uint32_t surface_format); + +uint8_t *spice_bitmap_get_line(const SpiceBitmap *image, size_t *offset, + int *chunk_nr, int stride); + +#endif diff --git a/server/spice_bitmap_utils.h b/server/spice_bitmap_utils.h deleted file mode 100644 index 9d3a5aea..00000000 --- a/server/spice_bitmap_utils.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef H_SPICE_BITMAP_UTILS -#define H_SPICE_BITMAP_UTILS - -void dump_bitmap(SpiceBitmap *bitmap); - -int spice_bitmap_from_surface_type(uint32_t surface_format); - -uint8_t *spice_bitmap_get_line(const SpiceBitmap *image, size_t *offset, - int *chunk_nr, int stride); - -#endif diff --git a/server/spice_server_utils.h b/server/spice_server_utils.h deleted file mode 100644 index b493a122..00000000 --- a/server/spice_server_utils.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef H_SPICE_SERVER_UTIL -#define H_SPICE_SERVER_UTIL - -#include <unistd.h> -#include <errno.h> -#include <string.h> -#include <stdbool.h> -#endif diff --git a/server/spicevmc.c b/server/spicevmc.c index e10f1837..d07db1d1 100644 --- a/server/spicevmc.c +++ b/server/spicevmc.c @@ -30,10 +30,10 @@ #include "common/generated_server_marshallers.h" -#include "char_device.h" +#include "char-device.h" #include "red_channel.h" #include "reds.h" -#include "migration_protocol.h" +#include "migration-protocol.h" /* todo: add flow control. i.e., * (a) limit the tokens available for the client diff --git a/server/stream.c b/server/stream.c index 3cd359a6..52f26345 100644 --- a/server/stream.c +++ b/server/stream.c @@ -1,5 +1,5 @@ #include "stream.h" -#include "display_channel.h" +#include "display-channel.h" #define FPS_TEST_INTERVAL 1 #define FOREACH_STREAMS(display, item) \ diff --git a/server/stream.h b/server/stream.h index f4089543..ca168d5f 100644 --- a/server/stream.h +++ b/server/stream.h @@ -3,10 +3,10 @@ #include <glib.h> #include "utils.h" -#include "mjpeg_encoder.h" +#include "mjpeg-encoder.h" #include "common/region.h" #include "red_channel.h" -#include "spice_image_cache.h" +#include "image-cache.h" #define RED_STREAM_DETACTION_MAX_DELTA ((1000 * 1000 * 1000) / 5) // 1/5 sec #define RED_STREAM_CONTINUS_MAX_DELTA (1000 * 1000 * 1000) diff --git a/server/tree_item.c b/server/tree.c index bed90b22..bb150b9b 100644 --- a/server/tree_item.c +++ b/server/tree.c @@ -1,8 +1,8 @@ #include <spice/qxl_dev.h> #include "red_parse_qxl.h" -#include "display_channel.h" +#include "display-channel.h" -#include "tree_item.h" +#include "tree.h" static const char *draw_type_to_str(uint8_t type) { diff --git a/server/tree_item.h b/server/tree.h index 025c9977..8866160a 100644 --- a/server/tree_item.h +++ b/server/tree.h @@ -1,10 +1,10 @@ -#ifndef TREE_ITEM_H_ -# define TREE_ITEM_H_ +#ifndef TREE_H_ +# define TREE_H_ #include <stdint.h> #include "common/region.h" #include "common/ring.h" -#include "red_bitmap_utils.h" +#include "spice-bitmap-utils.h" enum { TREE_ITEM_TYPE_NONE, @@ -73,4 +73,4 @@ Container* container_new (DrawItem *item); void container_free (Container *container); void container_cleanup (Container *container); -#endif /* TREE_ITEM_H_ */ +#endif /* TREE_H_ */ diff --git a/server/utils.h b/server/utils.h index 998c1c4f..6a2a6e67 100644 --- a/server/utils.h +++ b/server/utils.h @@ -1,12 +1,9 @@ #ifndef UTILS_H_ # define UTILS_H_ -#include <glib.h> -#include <stdint.h> -#include <time.h> +#include "common.h" -#include "common/ring.h" -#include "common/log.h" +#define SPICE_GNUC_VISIBLE __attribute__ ((visibility ("default"))) static inline void set_bit(int index, uint32_t *addr) { diff --git a/server/zlib_encoder.c b/server/zlib-encoder.c index e6286c85..4d2517d1 100644 --- a/server/zlib_encoder.c +++ b/server/zlib-encoder.c @@ -20,7 +20,7 @@ #endif #include "common.h" -#include "zlib_encoder.h" +#include "zlib-encoder.h" #include <zlib.h> struct ZlibEncoder { diff --git a/server/zlib_encoder.h b/server/zlib-encoder.h index 0620fc7b..0620fc7b 100644 --- a/server/zlib_encoder.h +++ b/server/zlib-encoder.h |