From: Marc-André Lureau <marcandre.lureau@xxxxxxxxx> --- NEWS | 2 +- server/Makefile.am | 62 +++---- server/{reds_sw_canvas.c => canvas.c} | 10 +- server/{reds_sw_canvas.h => canvas.h} | 9 +- server/{char_device.c => char-device.c} | 2 +- server/{char_device.h => char-device.h} | 2 +- server/dcc-encoders.h | 9 +- server/dispatcher.h | 3 +- server/display-channel.h | 16 +- ...glz_encoder_dictionary.c => glz-encoder-dict.c} | 5 +- ...glz_encoder_dictionary.h => glz-encoder-dict.h} | 4 +- ...r_dictionary_protected.h => glz-encoder-priv.h} | 21 ++- server/{glz_encoder.c => glz-encoder.c} | 4 +- server/{glz_encoder.h => glz-encoder.h} | 25 ++- server/glz_encoder_config.h | 59 ------- server/{spice_image_cache.c => image-cache.c} | 2 +- server/{spice_image_cache.h => image-cache.h} | 2 +- server/{inputs_channel.c => inputs-channel.c} | 6 +- server/{inputs_channel.h => inputs-channel.h} | 0 server/{jpeg_encoder.c => jpeg-encoder.c} | 3 +- server/{jpeg_encoder.h => jpeg-encoder.h} | 0 server/{main_channel.c => main-channel.c} | 6 +- server/{main_channel.h => main-channel.h} | 0 server/{main_dispatcher.c => main-dispatcher.c} | 2 +- server/{main_dispatcher.h => main-dispatcher.h} | 0 server/{red_memslots.c => memslot.c} | 33 ++-- server/{red_memslots.h => memslot.h} | 39 +++-- .../{migration_protocol.h => migration-protocol.h} | 2 +- server/{mjpeg_encoder.c => mjpeg-encoder.c} | 2 +- server/{mjpeg_encoder.h => mjpeg-encoder.h} | 0 server/red_channel.c | 2 +- server/red_common.h | 17 +- server/red_dispatcher.c | 2 +- server/red_dispatcher.h | 2 - server/red_parse_qxl.c | 62 +++---- server/red_parse_qxl.h | 2 +- server/red_record_qxl.c | 62 +++---- server/red_record_qxl.h | 2 +- server/red_replay_qxl.c | 2 +- server/red_worker.c | 16 +- server/red_worker.h | 3 - server/reds.c | 13 +- server/reds.h | 5 +- server/reds_stream.c | 2 +- server/smartcard.c | 4 +- server/{snd_worker.c => sound.c} | 6 +- server/{snd_worker.h => sound.h} | 0 server/spice-bitmap-utils.c | 162 ++++++++++++++++++ server/spice-bitmap-utils.h | 15 +- server/spice_bitmap_utils.c | 188 --------------------- server/spice_bitmap_utils.h | 8 - server/spicevmc.c | 4 +- server/stream.h | 4 +- server/utils.h | 6 +- server/{zlib_encoder.c => zlib-encoder.c} | 2 +- server/{zlib_encoder.h => zlib-encoder.h} | 0 56 files changed, 435 insertions(+), 486 deletions(-) rename server/{reds_sw_canvas.c => canvas.c} (84%) rename server/{reds_sw_canvas.h => canvas.h} (81%) rename server/{char_device.c => char-device.c} (99%) rename server/{char_device.h => char-device.h} (99%) rename server/{glz_encoder_dictionary.c => glz-encoder-dict.c} (99%) rename server/{glz_encoder_dictionary.h => glz-encoder-dict.h} (96%) rename server/{glz_encoder_dictionary_protected.h => glz-encoder-priv.h} (95%) rename server/{glz_encoder.c => glz-encoder.c} (99%) rename server/{glz_encoder.h => glz-encoder.h} (67%) delete mode 100644 server/glz_encoder_config.h rename server/{spice_image_cache.c => image-cache.c} (99%) rename server/{spice_image_cache.h => image-cache.h} (97%) rename server/{inputs_channel.c => inputs-channel.c} (99%) rename server/{inputs_channel.h => inputs-channel.h} (100%) rename server/{jpeg_encoder.c => jpeg-encoder.c} (99%) rename server/{jpeg_encoder.h => jpeg-encoder.h} (100%) rename server/{main_channel.c => main-channel.c} (99%) rename server/{main_channel.h => main-channel.h} (100%) rename server/{main_dispatcher.c => main-dispatcher.c} (99%) rename server/{main_dispatcher.h => main-dispatcher.h} (100%) rename server/{red_memslots.c => memslot.c} (84%) rename server/{red_memslots.h => memslot.h} (51%) rename server/{migration_protocol.h => migration-protocol.h} (99%) rename server/{mjpeg_encoder.c => mjpeg-encoder.c} (99%) rename server/{mjpeg_encoder.h => mjpeg-encoder.h} (100%) rename server/{snd_worker.c => sound.c} (99%) rename server/{snd_worker.h => sound.h} (100%) delete mode 100644 server/spice_bitmap_utils.c delete mode 100644 server/spice_bitmap_utils.h rename server/{zlib_encoder.c => zlib-encoder.c} (99%) rename server/{zlib_encoder.h => zlib-encoder.h} (100%) diff --git a/NEWS b/NEWS index a33f6cf..c05f62a 100644 --- a/NEWS +++ b/NEWS @@ -101,7 +101,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 6b45a42..7876e9c 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) \ @@ -66,25 +67,24 @@ libspice_server_la_SOURCES = \ agent-msg-filter.c \ agent-msg-filter.h \ cache-item.h \ - char_device.c \ - char_device.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 \ red_common.h \ @@ -92,11 +92,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_record_qxl.h \ @@ -114,20 +114,18 @@ libspice_server_la_SOURCES = \ 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 \ spice_timer_queue.c \ spice_timer_queue.h \ - zlib_encoder.c \ - zlib_encoder.h \ - spice_bitmap_utils.h \ - spice_bitmap_utils.c \ - spice_image_cache.h \ - spice_image_cache.c \ + zlib-encoder.c \ + zlib-encoder.h \ + image-cache.h \ + image-cache.c \ pixmap-cache.h \ pixmap-cache.c \ tree.h \ @@ -144,6 +142,8 @@ libspice_server_la_SOURCES = \ display-limits.h \ dcc-encoders.c \ dcc-encoders.h \ + canvas.c \ + canvas.h \ $(NULL) if HAVE_SMARTCARD diff --git a/server/reds_sw_canvas.c b/server/canvas.c similarity index 84% rename from server/reds_sw_canvas.c rename to server/canvas.c index 297df37..883fe25 100644 --- a/server/reds_sw_canvas.c +++ b/server/canvas.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* Copyright (C) 2011 Red Hat, Inc. @@ -14,13 +15,10 @@ 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 "canvas.h" -#include "common/spice_common.h" - -#include "reds_sw_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/reds_sw_canvas.h b/server/canvas.h similarity index 81% rename from server/reds_sw_canvas.h rename to server/canvas.h index 96a4c0c..d2835ec 100644 --- a/server/reds_sw_canvas.h +++ b/server/canvas.h @@ -1,3 +1,4 @@ +/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* Copyright (C) 2011 Red Hat, Inc. @@ -14,11 +15,13 @@ 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 +#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 +#endif /* CANVAS_H_ */ diff --git a/server/char_device.c b/server/char-device.c similarity index 99% rename from server/char_device.c rename to server/char-device.c index ae7cb98..3790fab 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 similarity index 99% rename from server/char_device.h rename to server/char-device.h index 55d1ee6..30b3d4a 100644 --- a/server/char_device.h +++ b/server/char-device.h @@ -20,7 +20,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/dcc-encoders.h b/server/dcc-encoders.h index 5de66f7..dc00ed1 100644 --- a/server/dcc-encoders.h +++ b/server/dcc-encoders.h @@ -23,14 +23,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/dispatcher.h b/server/dispatcher.h index 353744a..0d3175f 100644 --- a/server/dispatcher.h +++ b/server/dispatcher.h @@ -18,8 +18,7 @@ #ifndef DISPATCHER_H #define DISPATCHER_H -#include <spice.h> -#include "utils.h" +#include "red_common.h" typedef struct Dispatcher Dispatcher; diff --git a/server/display-channel.h b/server/display-channel.h index a990e09..6353493 100644 --- a/server/display-channel.h +++ b/server/display-channel.h @@ -25,22 +25,22 @@ #include "reds_stream.h" #include "cache-item.h" #include "pixmap-cache.h" -#include "reds_sw_canvas.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_bitmap_utils.h" -#include "spice_image_cache.h" +#include "main-channel.h" +#include "migration-protocol.h" +#include "main-dispatcher.h" +#include "spice-bitmap-utils.h" +#include "image-cache.h" #include "utils.h" #include "tree.h" #include "stream.h" diff --git a/server/glz_encoder_dictionary.c b/server/glz-encoder-dict.c similarity index 99% rename from server/glz_encoder_dictionary.c rename to server/glz-encoder-dict.c index 70226e1..af74736 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 similarity index 96% rename from server/glz_encoder_dictionary.h rename to server/glz-encoder-dict.h index eb57aa5..0a58b4b 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 similarity index 95% rename from server/glz_encoder_dictionary_protected.h rename to server/glz-encoder-priv.h index 098684f..a14ec74 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 "red_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 similarity index 99% rename from server/glz_encoder.c rename to server/glz-encoder.c index 65f4478..f761330 100644 --- a/server/glz_encoder.c +++ b/server/glz-encoder.c @@ -21,8 +21,8 @@ #include <glib.h> #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 */ diff --git a/server/glz_encoder.h b/server/glz-encoder.h similarity index 67% rename from server/glz_encoder.h rename to server/glz-encoder.h index e91f515..6de7513 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 "red_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 6472668..0000000 --- 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 similarity index 99% rename from server/spice_image_cache.c rename to server/image-cache.c index 1c5de24..f4d2ee9 100644 --- a/server/spice_image_cache.c +++ b/server/image-cache.c @@ -18,7 +18,7 @@ #ifdef HAVE_CONFIG_H #include <config.h> #endif -#include "spice_image_cache.h" +#include "image-cache.h" #include "red_parse_qxl.h" #include "display-channel.h" diff --git a/server/spice_image_cache.h b/server/image-cache.h similarity index 97% rename from server/spice_image_cache.h rename to server/image-cache.h index 6d6b32d..91ccc6d 100644 --- a/server/spice_image_cache.h +++ b/server/image-cache.h @@ -24,7 +24,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 similarity index 99% rename from server/inputs_channel.c rename to server/inputs-channel.c index 2934572..3e8fccd 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 similarity index 100% rename from server/inputs_channel.h rename to server/inputs-channel.h diff --git a/server/jpeg_encoder.c b/server/jpeg-encoder.c similarity index 99% rename from server/jpeg_encoder.c rename to server/jpeg-encoder.c index 0296e9b..428fd5b 100644 --- a/server/jpeg_encoder.c +++ b/server/jpeg-encoder.c @@ -19,7 +19,8 @@ #endif #include "red_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 similarity index 100% rename from server/jpeg_encoder.h rename to server/jpeg-encoder.h diff --git a/server/main_channel.c b/server/main-channel.c similarity index 99% rename from server/main_channel.c rename to server/main-channel.c index 1af6baa..5ca5bba 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 "red_common.h" #include "reds.h" -#include "migration_protocol.h" -#include "main_dispatcher.h" +#include "migration-protocol.h" +#include "main-dispatcher.h" #include "utils.h" #define ZERO_BUF_SIZE 4096 diff --git a/server/main_channel.h b/server/main-channel.h similarity index 100% rename from server/main_channel.h rename to server/main-channel.h diff --git a/server/main_dispatcher.c b/server/main-dispatcher.c similarity index 99% rename from server/main_dispatcher.c rename to server/main-dispatcher.c index 6ad9d89..eb7cee6 100644 --- a/server/main_dispatcher.c +++ b/server/main-dispatcher.c @@ -23,7 +23,7 @@ #include "red_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 similarity index 100% rename from server/main_dispatcher.h rename to server/main-dispatcher.h diff --git a/server/red_memslots.c b/server/memslot.c similarity index 84% rename from server/red_memslots.c rename to server/memslot.c index 1b3ec62..6b5bb8d 100644 --- a/server/red_memslots.c +++ b/server/memslot.c @@ -21,8 +21,7 @@ #include <inttypes.h> -#include "red_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 similarity index 51% rename from server/red_memslots.h rename to server/memslot.h index 27443a6..6f02f90 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 "red_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 similarity index 99% rename from server/migration_protocol.h rename to server/migration-protocol.h index 21d3ec8..c1d97ef 100644 --- a/server/migration_protocol.h +++ b/server/migration-protocol.h @@ -20,7 +20,7 @@ #include <spice/macros.h> #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 similarity index 99% rename from server/mjpeg_encoder.c rename to server/mjpeg-encoder.c index 9b331c1..04c95a6 100644 --- a/server/mjpeg_encoder.c +++ b/server/mjpeg-encoder.c @@ -20,7 +20,7 @@ #endif #include "red_common.h" -#include "mjpeg_encoder.h" +#include "mjpeg-encoder.h" #include "utils.h" #include <jerror.h> #include <jpeglib.h> diff --git a/server/mjpeg_encoder.h b/server/mjpeg-encoder.h similarity index 100% rename from server/mjpeg_encoder.h rename to server/mjpeg-encoder.h diff --git a/server/red_channel.c b/server/red_channel.c index 609c83f..948d354 100644 --- a/server/red_channel.c +++ b/server/red_channel.c @@ -42,7 +42,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_common.h b/server/red_common.h index 7f1677e..2d3977b 100644 --- a/server/red_common.h +++ b/server/red_common.h @@ -18,15 +18,26 @@ #ifndef _H_RED_COMMON #define _H_RED_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/red_dispatcher.c b/server/red_dispatcher.c index a7825f5..7baa197 100644 --- a/server/red_dispatcher.c +++ b/server/red_dispatcher.c @@ -32,7 +32,7 @@ #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" diff --git a/server/red_dispatcher.h b/server/red_dispatcher.h index 9f3474f..13c0cee 100644 --- a/server/red_dispatcher.h +++ b/server/red_dispatcher.h @@ -18,8 +18,6 @@ #ifndef _H_RED_DISPATCHER #define _H_RED_DISPATCHER -#include <unistd.h> -#include <errno.h> #include "red_channel.h" typedef struct RedDispatcher RedDispatcher; diff --git a/server/red_parse_qxl.c b/server/red_parse_qxl.c index 2cfd5ea..9464c7a 100644 --- a/server/red_parse_qxl.c +++ b/server/red_parse_qxl.c @@ -25,7 +25,7 @@ #include "common/lz_common.h" #include "spice-bitmap-utils.h" #include "red_common.h" -#include "red_memslots.h" +#include "memslot.h" #include "red_parse_qxl.h" /* Max size in bytes for any data field used in a QXL command. @@ -52,7 +52,7 @@ static void hexdump_qxl(RedMemSlotInfo *slots, int group_id, uint8_t *hex; int i; - hex = (uint8_t*)get_virt(slots, addr, bytes, group_id); + hex = (uint8_t*)memslot_get_virt(slots, addr, bytes, group_id); for (i = 0; i < bytes; i++) { if (0 == i % 16) { fprintf(stderr, "%lx: ", addr+i); @@ -118,7 +118,7 @@ static size_t red_get_data_chunks_ptr(RedMemSlotInfo *slots, int group_id, data_size += red->data_size; red->data = qxl->data; red->prev_chunk = red->next_chunk = NULL; - if (!validate_virt(slots, (intptr_t)red->data, memslot_id, red->data_size, group_id)) { + if (!memslot_validate_virt(slots, (intptr_t)red->data, memslot_id, red->data_size, group_id)) { red->data = NULL; return 0; } @@ -132,8 +132,8 @@ static size_t red_get_data_chunks_ptr(RedMemSlotInfo *slots, int group_id, goto error; } - memslot_id = get_memslot_id(slots, next_chunk); - qxl = (QXLDataChunk *)get_virt(slots, next_chunk, sizeof(*qxl), + memslot_id = memslot_get_id(slots, next_chunk); + qxl = (QXLDataChunk *)memslot_get_virt(slots, next_chunk, sizeof(*qxl), group_id, &error); if (error) goto error; @@ -161,7 +161,7 @@ static size_t red_get_data_chunks_ptr(RedMemSlotInfo *slots, int group_id, spice_warning("too much data inside chunks, avoiding DoS\n"); goto error; } - if (!validate_virt(slots, (intptr_t)red->data, memslot_id, red->data_size, group_id)) + if (!memslot_validate_virt(slots, (intptr_t)red->data, memslot_id, red->data_size, group_id)) goto error; } @@ -185,9 +185,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; } @@ -242,12 +242,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); @@ -321,12 +321,12 @@ static SpiceClipRects *red_get_clip_rects(RedMemSlotInfo *slots, int group_id, int error; uint32_t num_rects; - 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); @@ -355,7 +355,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; } @@ -445,7 +445,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; } @@ -488,14 +488,14 @@ static SpiceImage *red_get_image(RedMemSlotInfo *slots, int group_id, if (palette) { QXLPalette *qp; int i, num_ents; - qp = (QXLPalette *)get_virt(slots, palette, + qp = (QXLPalette *)memslot_get_virt(slots, 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, palette), + if (!memslot_validate_virt(slots, (intptr_t)qp->ents, + memslot_get_id(slots, palette), num_ents * sizeof(qp->ents[0]), group_id)) { goto error; } @@ -544,7 +544,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) { @@ -741,7 +741,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; @@ -816,7 +816,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; @@ -858,12 +858,12 @@ static SpiceString *red_get_string(RedMemSlotInfo *slots, int group_id, int error; uint16_t qxl_flags, qxl_length; - 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.. */ @@ -1013,7 +1013,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; } @@ -1096,7 +1096,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; } @@ -1244,7 +1244,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; } @@ -1273,7 +1273,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; } @@ -1312,7 +1312,7 @@ int red_get_surface_cmd(RedMemSlotInfo *slots, int group_id, int error; unsigned int bpp; - 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; @@ -1350,7 +1350,7 @@ int red_get_surface_cmd(RedMemSlotInfo *slots, int group_id, return 1; } 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; } @@ -1374,7 +1374,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; } @@ -1389,7 +1389,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); red->data_size = MIN(red->data_size, size); data = red_linearize_chunk(&chunks, size, &free_data); @@ -1414,7 +1414,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 b3b28e1..09059f5 100644 --- a/server/red_parse_qxl.h +++ b/server/red_parse_qxl.h @@ -21,7 +21,7 @@ #include <spice/qxl_dev.h> #include "red_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 b35b462..0a29432 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 "red_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 @@ static 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 @@ static 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 @@ static 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 @@ static 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) != 0) { 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 b737db8..6fcbec9 100644 --- a/server/red_record_qxl.h +++ b/server/red_record_qxl.h @@ -21,7 +21,7 @@ #include <spice/qxl_dev.h> #include "red_common.h" -#include "red_memslots.h" +#include "memslot.h" void red_record_dev_input_primary_surface_create( FILE *fd, QXLDevSurfaceCreate *surface, uint8_t *line_0); diff --git a/server/red_replay_qxl.c b/server/red_replay_qxl.c index ad1a8fd..6e32588 100644 --- a/server/red_replay_qxl.c +++ b/server/red_replay_qxl.c @@ -26,7 +26,7 @@ #include "reds.h" #include "red_worker.h" #include "red_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 56c00c6..3f1f24b 100644 --- a/server/red_worker.c +++ b/server/red_worker.c @@ -796,7 +796,7 @@ static void handle_dev_del_memslot(void *opaque, void *payload) 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, void *payload) @@ -869,7 +869,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) { @@ -1138,7 +1138,7 @@ static void handle_dev_monitors_config_async(void *opaque, void *payload) int error; uint16_t count, max_allowed; QXLMonitorsConfig *dev_monitors_config = - (QXLMonitorsConfig*)get_virt(&worker->mem_slots, msg->monitors_config, + (QXLMonitorsConfig*)memslot_get_virt(&worker->mem_slots, msg->monitors_config, qxl_monitors_config_size(1), msg->group_id, &error); @@ -1162,7 +1162,7 @@ static void handle_dev_monitors_config_async(void *opaque, void *payload) } /* get pointer again to check virtual size */ dev_monitors_config = - (QXLMonitorsConfig*)get_virt(&worker->mem_slots, msg->monitors_config, + (QXLMonitorsConfig*)memslot_get_virt(&worker->mem_slots, msg->monitors_config, qxl_monitors_config_size(count), msg->group_id, &error); if (error) { @@ -1266,7 +1266,7 @@ static void handle_dev_set_mouse_mode(void *opaque, void *payload) 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); } @@ -1277,7 +1277,7 @@ static void handle_dev_add_memslot(void *opaque, void *payload) 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); } @@ -1294,7 +1294,7 @@ static void handle_dev_reset_memslots(void *opaque, void *payload) { RedWorker *worker = opaque; - red_memslot_info_reset(&worker->mem_slots); + memslot_info_reset(&worker->mem_slots); } static void handle_dev_driver_unload(void *opaque, void *payload) @@ -1606,7 +1606,7 @@ RedWorker* red_worker_new(QXLInstance *qxl, RedDispatcher *red_dispatcher) worker->watches[0].watch_func = handle_dev_input; worker->watches[0].watch_func_opaque = worker; - 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 a76c805..1e2c550 100644 --- a/server/red_worker.h +++ b/server/red_worker.h @@ -18,9 +18,6 @@ #ifndef _H_REDWORKER #define _H_REDWORKER -#include <unistd.h> -#include <errno.h> -#include "utils.h" #include "red_common.h" #include "red_dispatcher.h" #include "red_parse_qxl.h" diff --git a/server/reds.c b/server/reds.c index 8b3c3cb..509c346 100644 --- a/server/reds.c +++ b/server/reds.c @@ -56,16 +56,15 @@ #include "spice.h" #include "reds.h" #include "agent-msg-filter.h" -#include "inputs_channel.h" -#include "main_channel.h" -#include "red_common.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 fcdc5eb..b0168db 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 3b47391..6f5c43f 100644 --- a/server/reds_stream.c +++ b/server/reds_stream.c @@ -19,7 +19,7 @@ #include <config.h> #endif -#include "main_dispatcher.h" +#include "main-dispatcher.h" #include "red_common.h" #include "reds_stream.h" #include "common/log.h" diff --git a/server/smartcard.c b/server/smartcard.c index aad22aa..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 similarity index 99% rename from server/snd_worker.c rename to server/sound.c index b039939..4b1ec7a 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 "red_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 similarity index 100% rename from server/snd_worker.h rename to server/sound.h diff --git a/server/spice-bitmap-utils.c b/server/spice-bitmap-utils.c index 03d7694..8d6e7c6 100644 --- a/server/spice-bitmap-utils.c +++ b/server/spice-bitmap-utils.c @@ -117,3 +117,165 @@ int bitmap_has_extra_stride(SpiceBitmap *bitmap) } return 0; } + +int spice_bitmap_from_surface_type(uint32_t surface_format) +{ + switch (surface_format) { + case SPICE_SURFACE_FMT_16_555: + return SPICE_BITMAP_FMT_16BIT; + case SPICE_SURFACE_FMT_32_xRGB: + return SPICE_BITMAP_FMT_32BIT; + case SPICE_SURFACE_FMT_32_ARGB: + return SPICE_BITMAP_FMT_RGBA; + case SPICE_SURFACE_FMT_8_A: + return SPICE_BITMAP_FMT_8BIT_A; + default: + spice_critical("Unsupported surface format"); + } + return 0; +} + +#define RAM_PATH "/tmp/tmpfs" + +static void dump_palette(FILE *f, SpicePalette* plt) +{ + int i; + for (i = 0; i < plt->num_ents; i++) { + fwrite(plt->ents + i, sizeof(uint32_t), 1, f); + } +} + +static void dump_line(FILE *f, uint8_t* line, uint16_t n_pixel_bits, int width, int row_size) +{ + int i; + int copy_bytes_size = SPICE_ALIGN(n_pixel_bits * width, 8) / 8; + + fwrite(line, 1, copy_bytes_size, f); + if (row_size > copy_bytes_size) { + // each line should be 4 bytes aligned + for (i = copy_bytes_size; i < row_size; i++) { + fprintf(f, "%c", 0); + } + } +} +void dump_bitmap(SpiceBitmap *bitmap) +{ + static uint32_t file_id = 0; + + char file_str[200]; + int rgb = TRUE; + uint16_t n_pixel_bits; + SpicePalette *plt = NULL; + uint32_t id; + int row_size; + uint32_t file_size; + int alpha = 0; + uint32_t header_size = 14 + 40; + uint32_t bitmap_data_offset; + uint32_t tmp_u32; + int32_t tmp_32; + uint16_t tmp_u16; + FILE *f; + int i, j; + + switch (bitmap->format) { + case SPICE_BITMAP_FMT_1BIT_BE: + case SPICE_BITMAP_FMT_1BIT_LE: + rgb = FALSE; + n_pixel_bits = 1; + break; + case SPICE_BITMAP_FMT_4BIT_BE: + case SPICE_BITMAP_FMT_4BIT_LE: + rgb = FALSE; + n_pixel_bits = 4; + break; + case SPICE_BITMAP_FMT_8BIT: + rgb = FALSE; + n_pixel_bits = 8; + break; + case SPICE_BITMAP_FMT_16BIT: + n_pixel_bits = 16; + break; + case SPICE_BITMAP_FMT_24BIT: + n_pixel_bits = 24; + break; + case SPICE_BITMAP_FMT_32BIT: + n_pixel_bits = 32; + break; + case SPICE_BITMAP_FMT_RGBA: + n_pixel_bits = 32; + alpha = 1; + break; + default: + spice_error("invalid bitmap format %u", bitmap->format); + return; + } + + if (!rgb) { + if (!bitmap->palette) { + return; // dont dump masks. + } + plt = bitmap->palette; + } + row_size = (((bitmap->x * n_pixel_bits) + 31) / 32) * 4; + bitmap_data_offset = header_size; + + if (plt) { + bitmap_data_offset += plt->num_ents * 4; + } + file_size = bitmap_data_offset + (bitmap->y * row_size); + + id = ++file_id; + sprintf(file_str, "%s/%u.bmp", RAM_PATH, id); + + f = fopen(file_str, "wb"); + if (!f) { + spice_error("Error creating bmp"); + return; + } + + /* writing the bmp v3 header */ + fprintf(f, "BM"); + fwrite(&file_size, sizeof(file_size), 1, f); + tmp_u16 = alpha ? 1 : 0; + fwrite(&tmp_u16, sizeof(tmp_u16), 1, f); // reserved for application + tmp_u16 = 0; + fwrite(&tmp_u16, sizeof(tmp_u16), 1, f); + fwrite(&bitmap_data_offset, sizeof(bitmap_data_offset), 1, f); + tmp_u32 = header_size - 14; + fwrite(&tmp_u32, sizeof(tmp_u32), 1, f); // sub header size + tmp_32 = bitmap->x; + fwrite(&tmp_32, sizeof(tmp_32), 1, f); + tmp_32 = bitmap->y; + fwrite(&tmp_32, sizeof(tmp_32), 1, f); + + tmp_u16 = 1; + fwrite(&tmp_u16, sizeof(tmp_u16), 1, f); // color plane + fwrite(&n_pixel_bits, sizeof(n_pixel_bits), 1, f); // pixel depth + + tmp_u32 = 0; + fwrite(&tmp_u32, sizeof(tmp_u32), 1, f); // compression method + + tmp_u32 = 0; //file_size - bitmap_data_offset; + fwrite(&tmp_u32, sizeof(tmp_u32), 1, f); // image size + tmp_32 = 0; + fwrite(&tmp_32, sizeof(tmp_32), 1, f); + fwrite(&tmp_32, sizeof(tmp_32), 1, f); + tmp_u32 = (!plt) ? 0 : plt->num_ents; // plt entries + fwrite(&tmp_u32, sizeof(tmp_u32), 1, f); + tmp_u32 = 0; + fwrite(&tmp_u32, sizeof(tmp_u32), 1, f); + + if (plt) { + dump_palette(f, plt); + } + /* writing the data */ + for (i = 0; i < bitmap->data->num_chunks; i++) { + SpiceChunk *chunk = &bitmap->data->chunk[i]; + int num_lines = chunk->len / bitmap->stride; + for (j = 0; j < num_lines; j++) { + dump_line(f, chunk->data + (j * bitmap->stride), n_pixel_bits, bitmap->x, row_size); + } + } + fclose(f); +} diff --git a/server/spice-bitmap-utils.h b/server/spice-bitmap-utils.h index 38cb88a..beaa96f 100644 --- a/server/spice-bitmap-utils.h +++ b/server/spice-bitmap-utils.h @@ -15,13 +15,10 @@ 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 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 "red_common.h" typedef enum { BITMAP_GRADUAL_INVALID, @@ -88,4 +85,8 @@ 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); + +#endif diff --git a/server/spice_bitmap_utils.c b/server/spice_bitmap_utils.c deleted file mode 100644 index ae3fc8b..0000000 --- a/server/spice_bitmap_utils.c +++ /dev/null @@ -1,188 +0,0 @@ -/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -/* - Copyright (C) 2009-2015 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 <stdio.h> - -#include "common/log.h" -#include "common/draw.h" - -#include "spice_bitmap_utils.h" - -int spice_bitmap_from_surface_type(uint32_t surface_format) -{ - switch (surface_format) { - case SPICE_SURFACE_FMT_16_555: - return SPICE_BITMAP_FMT_16BIT; - case SPICE_SURFACE_FMT_32_xRGB: - return SPICE_BITMAP_FMT_32BIT; - case SPICE_SURFACE_FMT_32_ARGB: - return SPICE_BITMAP_FMT_RGBA; - case SPICE_SURFACE_FMT_8_A: - return SPICE_BITMAP_FMT_8BIT_A; - default: - spice_critical("Unsupported surface format"); - } - return 0; -} - -#define RAM_PATH "/tmp/tmpfs" - -static void dump_palette(FILE *f, SpicePalette* plt) -{ - int i; - for (i = 0; i < plt->num_ents; i++) { - fwrite(plt->ents + i, sizeof(uint32_t), 1, f); - } -} - -static void dump_line(FILE *f, uint8_t* line, uint16_t n_pixel_bits, int width, int row_size) -{ - int i; - int copy_bytes_size = SPICE_ALIGN(n_pixel_bits * width, 8) / 8; - - fwrite(line, 1, copy_bytes_size, f); - if (row_size > copy_bytes_size) { - // each line should be 4 bytes aligned - for (i = copy_bytes_size; i < row_size; i++) { - fprintf(f, "%c", 0); - } - } -} -void dump_bitmap(SpiceBitmap *bitmap) -{ - static uint32_t file_id = 0; - - char file_str[200]; - int rgb = TRUE; - uint16_t n_pixel_bits; - SpicePalette *plt = NULL; - uint32_t id; - int row_size; - uint32_t file_size; - int alpha = 0; - uint32_t header_size = 14 + 40; - uint32_t bitmap_data_offset; - uint32_t tmp_u32; - int32_t tmp_32; - uint16_t tmp_u16; - FILE *f; - int i, j; - - switch (bitmap->format) { - case SPICE_BITMAP_FMT_1BIT_BE: - case SPICE_BITMAP_FMT_1BIT_LE: - rgb = FALSE; - n_pixel_bits = 1; - break; - case SPICE_BITMAP_FMT_4BIT_BE: - case SPICE_BITMAP_FMT_4BIT_LE: - rgb = FALSE; - n_pixel_bits = 4; - break; - case SPICE_BITMAP_FMT_8BIT: - rgb = FALSE; - n_pixel_bits = 8; - break; - case SPICE_BITMAP_FMT_16BIT: - n_pixel_bits = 16; - break; - case SPICE_BITMAP_FMT_24BIT: - n_pixel_bits = 24; - break; - case SPICE_BITMAP_FMT_32BIT: - n_pixel_bits = 32; - break; - case SPICE_BITMAP_FMT_RGBA: - n_pixel_bits = 32; - alpha = 1; - break; - default: - spice_error("invalid bitmap format %u", bitmap->format); - return; - } - - if (!rgb) { - if (!bitmap->palette) { - return; // dont dump masks. - } - plt = bitmap->palette; - } - row_size = (((bitmap->x * n_pixel_bits) + 31) / 32) * 4; - bitmap_data_offset = header_size; - - if (plt) { - bitmap_data_offset += plt->num_ents * 4; - } - file_size = bitmap_data_offset + (bitmap->y * row_size); - - id = ++file_id; - sprintf(file_str, "%s/%u.bmp", RAM_PATH, id); - - f = fopen(file_str, "wb"); - if (!f) { - spice_error("Error creating bmp"); - return; - } - - /* writing the bmp v3 header */ - fprintf(f, "BM"); - fwrite(&file_size, sizeof(file_size), 1, f); - tmp_u16 = alpha ? 1 : 0; - fwrite(&tmp_u16, sizeof(tmp_u16), 1, f); // reserved for application - tmp_u16 = 0; - fwrite(&tmp_u16, sizeof(tmp_u16), 1, f); - fwrite(&bitmap_data_offset, sizeof(bitmap_data_offset), 1, f); - tmp_u32 = header_size - 14; - fwrite(&tmp_u32, sizeof(tmp_u32), 1, f); // sub header size - tmp_32 = bitmap->x; - fwrite(&tmp_32, sizeof(tmp_32), 1, f); - tmp_32 = bitmap->y; - fwrite(&tmp_32, sizeof(tmp_32), 1, f); - - tmp_u16 = 1; - fwrite(&tmp_u16, sizeof(tmp_u16), 1, f); // color plane - fwrite(&n_pixel_bits, sizeof(n_pixel_bits), 1, f); // pixel depth - - tmp_u32 = 0; - fwrite(&tmp_u32, sizeof(tmp_u32), 1, f); // compression method - - tmp_u32 = 0; //file_size - bitmap_data_offset; - fwrite(&tmp_u32, sizeof(tmp_u32), 1, f); // image size - tmp_32 = 0; - fwrite(&tmp_32, sizeof(tmp_32), 1, f); - fwrite(&tmp_32, sizeof(tmp_32), 1, f); - tmp_u32 = (!plt) ? 0 : plt->num_ents; // plt entries - fwrite(&tmp_u32, sizeof(tmp_u32), 1, f); - tmp_u32 = 0; - fwrite(&tmp_u32, sizeof(tmp_u32), 1, f); - - if (plt) { - dump_palette(f, plt); - } - /* writing the data */ - for (i = 0; i < bitmap->data->num_chunks; i++) { - SpiceChunk *chunk = &bitmap->data->chunk[i]; - int num_lines = chunk->len / bitmap->stride; - for (j = 0; j < num_lines; j++) { - dump_line(f, chunk->data + (j * bitmap->stride), n_pixel_bits, bitmap->x, row_size); - } - } - fclose(f); -} diff --git a/server/spice_bitmap_utils.h b/server/spice_bitmap_utils.h deleted file mode 100644 index 69860e5..0000000 --- a/server/spice_bitmap_utils.h +++ /dev/null @@ -1,8 +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); - -#endif diff --git a/server/spicevmc.c b/server/spicevmc.c index d37b1ec..52a29a4 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.h b/server/stream.h index 214d1df..cb2b844 100644 --- a/server/stream.h +++ b/server/stream.h @@ -20,10 +20,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/utils.h b/server/utils.h index aba85f9..20ebe00 100644 --- a/server/utils.h +++ b/server/utils.h @@ -18,11 +18,9 @@ #ifndef UTILS_H_ # define UTILS_H_ -#include <glib.h> -#include <time.h> +#include "red_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 similarity index 99% rename from server/zlib_encoder.c rename to server/zlib-encoder.c index a3d2aa6..069a448 100644 --- a/server/zlib_encoder.c +++ b/server/zlib-encoder.c @@ -20,7 +20,7 @@ #endif #include "red_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 similarity index 100% rename from server/zlib_encoder.h rename to server/zlib-encoder.h -- 2.4.3 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/spice-devel