[Spice-commits] 2 commits - server/dispatcher.h server/display-channel.h server/glz-encoder.h server/glz-encoder-priv.h server/Makefile.am server/memslot.c server/red-common.h server/red-dispatcher.h server/reds.c server/red-worker.h server/spice_bitmap_utils.c server/spice-bitmap-utils.c server/spice_bitmap_utils.h server/spice-bitmap-utils.h server/sw-canvas.c server/utils.h
Frediano Ziglio
fziglio at kemper.freedesktop.org
Wed Dec 9 14:19:46 PST 2015
server/Makefile.am | 4
server/dispatcher.h | 3
server/display-channel.h | 2
server/glz-encoder-priv.h | 2
server/glz-encoder.h | 2
server/memslot.c | 1
server/red-common.h | 19 +++-
server/red-dispatcher.h | 2
server/red-worker.h | 3
server/reds.c | 1
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/sw-canvas.c | 3
server/utils.h | 6 -
16 files changed, 193 insertions(+), 228 deletions(-)
New commits:
commit febaed3529c6b9a0799f8e677e1c80f5eab7182e
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Thu Dec 3 13:55:23 2015 -0600
server: misc header cleanups
Signed-off-by: Marc-André Lureau <marcandre.lureau at gmail.com>
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Signed-off-by: Jonathon Jongsma <jjongsma at redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
diff --git a/server/Makefile.am b/server/Makefile.am
index 32ab8eb..d4fc972 100644
--- a/server/Makefile.am
+++ b/server/Makefile.am
@@ -117,6 +117,8 @@ libspice_server_la_SOURCES = \
sw-canvas.h \
sound.c \
sound.h \
+ spice-experimental.h \
+ spice.h \
stat.h \
spicevmc.c \
spice_timer_queue.c \
diff --git a/server/dispatcher.h b/server/dispatcher.h
index 353744a..78ef663 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/glz-encoder-priv.h b/server/glz-encoder-priv.h
index 3f22508..919c439 100644
--- a/server/glz-encoder-priv.h
+++ b/server/glz-encoder-priv.h
@@ -18,6 +18,8 @@
#ifndef GLZ_ENCODER_PRIV_H_
#define GLZ_ENCODER_PRIV_H_
+#include "red-common.h"
+
/* Interface for using the dictionary for encoding.
Data structures are exposed for the encoder for efficiency
purposes. */
diff --git a/server/glz-encoder.h b/server/glz-encoder.h
index dc08830..0493b83 100644
--- a/server/glz-encoder.h
+++ b/server/glz-encoder.h
@@ -20,7 +20,7 @@
/* 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-dict.h"
diff --git a/server/memslot.c b/server/memslot.c
index 47e431b..768762b 100644
--- a/server/memslot.c
+++ b/server/memslot.c
@@ -21,7 +21,6 @@
#include <inttypes.h>
-#include "red-common.h"
#include "memslot.h"
static unsigned long __get_clean_virt(RedMemSlotInfo *info, QXLPHYSICAL addr)
diff --git a/server/red-common.h b/server/red-common.h
index 7f1677e..f6098f6 100644
--- a/server/red-common.h
+++ b/server/red-common.h
@@ -18,16 +18,25 @@
#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"
-
-#define SPICE_GNUC_VISIBLE __attribute__ ((visibility ("default")))
+#include "utils.h"
#endif
diff --git a/server/red-dispatcher.h b/server/red-dispatcher.h
index d9ee0ec..d99695d 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-worker.h b/server/red-worker.h
index 710b54c..44f35f7 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 f698042..d890616 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -58,7 +58,6 @@
#include "agent-msg-filter.h"
#include "inputs-channel.h"
#include "main-channel.h"
-#include "red-common.h"
#include "red-dispatcher.h"
#include "main-dispatcher.h"
#include "sound.h"
diff --git a/server/spice-bitmap-utils.h b/server/spice-bitmap-utils.h
index 2b43d4b..ffb6c74 100644
--- a/server/spice-bitmap-utils.h
+++ b/server/spice-bitmap-utils.h
@@ -18,7 +18,6 @@
#ifndef SPICE_BITMAP_UTILS_H_
#define SPICE_BITMAP_UTILS_H_
-#include <glib.h>
#include "red-common.h"
typedef enum {
diff --git a/server/sw-canvas.c b/server/sw-canvas.c
index 0ef050e..29d89db 100644
--- a/server/sw-canvas.c
+++ b/server/sw-canvas.c
@@ -17,9 +17,6 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-
-#include "common/spice_common.h"
-
#include "sw-canvas.h"
#define SW_CANVAS_IMAGE_CACHE
#include "common/sw_canvas.c"
diff --git a/server/utils.h b/server/utils.h
index aba85f9..d7b9e40 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)
{
commit 24da6bcd379d0d25b32c3bbdeb01073d29710dce
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Thu Dec 3 11:26:38 2015 +0000
server: merge spice-bitmap-utils and spice_bitmap_utils
Signed-off-by: Marc-André Lureau <marcandre.lureau at gmail.com>
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
diff --git a/server/Makefile.am b/server/Makefile.am
index 3db81db..32ab8eb 100644
--- a/server/Makefile.am
+++ b/server/Makefile.am
@@ -123,8 +123,6 @@ libspice_server_la_SOURCES = \
spice_timer_queue.h \
zlib-encoder.c \
zlib-encoder.h \
- spice_bitmap_utils.h \
- spice_bitmap_utils.c \
image-cache.h \
image-cache.c \
pixmap-cache.h \
diff --git a/server/display-channel.h b/server/display-channel.h
index e698788..3d414c2 100644
--- a/server/display-channel.h
+++ b/server/display-channel.h
@@ -39,7 +39,7 @@
#include "main-channel.h"
#include "migration-protocol.h"
#include "main-dispatcher.h"
-#include "spice_bitmap_utils.h"
+#include "spice-bitmap-utils.h"
#include "image-cache.h"
#include "utils.h"
#include "tree.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..2b43d4b 100644
--- a/server/spice-bitmap-utils.h
+++ b/server/spice-bitmap-utils.h
@@ -15,13 +15,11 @@
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 SPICE_BITMAP_UTILS_H_
+#define SPICE_BITMAP_UTILS_H_
#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 +86,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 /* SPICE_BITMAP_UTILS_H_ */
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
More information about the Spice-commits
mailing list