[Spice-commits] 4 commits - src/decode-glz.c src/spice-channel.c src/spicy-screenshot.c
Pavel Grunt
pgrunt at kemper.freedesktop.org
Mon Dec 21 09:37:04 PST 2015
src/decode-glz.c | 2 -
src/spice-channel.c | 81 ++++++++++++++++++++++++++++---------------------
src/spicy-screenshot.c | 6 +++
3 files changed, 54 insertions(+), 35 deletions(-)
New commits:
commit f1e504f02baea94b223e3cde90da0c2a5e2f7403
Author: Lukas Venhoda <lvenhoda at redhat.com>
Date: Thu Dec 17 16:50:19 2015 +0100
ppc: Fix spicy-screenshot colors on BE machines
Save screenshot in proper endianess
xRGB on LE machine and BGRx on BE machine
Acked-by: Pavel Grunt <pgrunt at redhat.com>
diff --git a/src/spicy-screenshot.c b/src/spicy-screenshot.c
index d90d4e8..63666d6 100644
--- a/src/spicy-screenshot.c
+++ b/src/spicy-screenshot.c
@@ -63,9 +63,15 @@ static int write_ppm_32(void)
n = d_width * d_height;
p = d_data;
while (n > 0) {
+#ifdef WORDS_BIGENDIAN
+ fputc(p[1], fp);
+ fputc(p[2], fp);
+ fputc(p[3], fp);
+#else
fputc(p[2], fp);
fputc(p[1], fp);
fputc(p[0], fp);
+#endif
p += 4;
n--;
}
commit 756f756c8aae1814fd8f36e08df44b85ffb63574
Author: Lukas Venhoda <lvenhoda at redhat.com>
Date: Thu Dec 17 16:50:18 2015 +0100
ppc: Fix colors on ppc when using GLZ
Fixes color order on PowerPC when using GLZ image compression.
Acked-by: Pavel Grunt <pgrunt at redhat.com>
diff --git a/src/decode-glz.c b/src/decode-glz.c
index 34a7185..a5fb6c1 100644
--- a/src/decode-glz.c
+++ b/src/decode-glz.c
@@ -55,7 +55,7 @@ static struct glz_image *glz_image_new(struct glz_image_hdr *hdr,
img = g_new0(struct glz_image, 1);
img->hdr = *hdr;
img->surface = alloc_lz_image_surface
- (opaque, type == LZ_IMAGE_TYPE_RGBA ? PIXMAN_a8r8g8b8 : PIXMAN_x8r8g8b8,
+ (opaque, type == LZ_IMAGE_TYPE_RGBA ? PIXMAN_LE_a8r8g8b8 : PIXMAN_LE_x8r8g8b8,
img->hdr.width, img->hdr.height, img->hdr.gross_pixels, img->hdr.top_down);
pixman_image_ref(img->surface);
img->data = (uint8_t *)pixman_image_get_data(img->surface);
commit 4395cb797db92a4c03a1a0bdc5a23bf3ae9873c9
Author: Fabiano FidĂȘncio <fidencio at redhat.com>
Date: Thu Dec 17 16:50:17 2015 +0100
ppc: Fix message endianess
diff --git a/src/spice-channel.c b/src/spice-channel.c
index 26b5c38..41c94d0 100644
--- a/src/spice-channel.c
+++ b/src/spice-channel.c
@@ -1178,35 +1178,39 @@ static void spice_channel_send_link(SpiceChannel *channel)
return;
}
- c->link_msg.connection_id = spice_session_get_connection_id(c->session);
+ c->link_hdr.major_version = GUINT32_TO_LE(c->link_hdr.major_version);
+ c->link_hdr.minor_version = GUINT32_TO_LE(c->link_hdr.minor_version);
+
+ c->link_msg.connection_id = GUINT32_TO_LE(spice_session_get_connection_id(c->session));
c->link_msg.channel_type = c->channel_type;
c->link_msg.channel_id = c->channel_id;
- c->link_msg.caps_offset = sizeof(c->link_msg);
+ c->link_msg.caps_offset = GUINT32_TO_LE(sizeof(c->link_msg));
- c->link_msg.num_common_caps = c->common_caps->len;
- c->link_msg.num_channel_caps = c->caps->len;
- c->link_hdr.size += (c->link_msg.num_common_caps +
- c->link_msg.num_channel_caps) * sizeof(uint32_t);
+ c->link_msg.num_common_caps = GUINT32_TO_LE(c->common_caps->len);
+ c->link_msg.num_channel_caps = GUINT32_TO_LE(c->caps->len);
+ c->link_hdr.size += (c->common_caps->len + c->caps->len) * sizeof(uint32_t);
buffer = g_malloc0(sizeof(c->link_hdr) + c->link_hdr.size);
p = buffer;
+ c->link_hdr.size = GUINT32_TO_LE(c->link_hdr.size);
+
memcpy(p, &c->link_hdr, sizeof(c->link_hdr)); p += sizeof(c->link_hdr);
memcpy(p, &c->link_msg, sizeof(c->link_msg)); p += sizeof(c->link_msg);
for (i = 0; i < c->common_caps->len; i++) {
- *(uint32_t *)p = g_array_index(c->common_caps, uint32_t, i);
+ *(uint32_t *)p = GUINT32_TO_LE(g_array_index(c->common_caps, uint32_t, i));
p += sizeof(uint32_t);
}
for (i = 0; i < c->caps->len; i++) {
- *(uint32_t *)p = g_array_index(c->caps, uint32_t, i);
+ *(uint32_t *)p = GUINT32_TO_LE(g_array_index(c->caps, uint32_t, i));
p += sizeof(uint32_t);
}
CHANNEL_DEBUG(channel, "channel type %d id %d num common caps %d num caps %d",
- c->link_msg.channel_type,
- c->link_msg.channel_id,
- c->link_msg.num_common_caps,
- c->link_msg.num_channel_caps);
+ c->channel_type,
+ c->channel_id,
+ c->common_caps->len,
+ c->caps->len);
spice_channel_write(channel, buffer, p - buffer);
g_free(buffer);
}
@@ -1228,13 +1232,19 @@ static gboolean spice_channel_recv_link_hdr(SpiceChannel *channel)
goto error;
}
- CHANNEL_DEBUG(channel, "Peer version: %d:%d", c->peer_hdr.major_version, c->peer_hdr.minor_version);
+ CHANNEL_DEBUG(channel, "Peer version: %d:%d",
+ GUINT32_FROM_LE(c->peer_hdr.major_version),
+ GUINT32_FROM_LE(c->peer_hdr.minor_version));
if (c->peer_hdr.major_version != c->link_hdr.major_version) {
g_warning("major mismatch (got %d, expected %d)",
c->peer_hdr.major_version, c->link_hdr.major_version);
goto error;
}
+ c->peer_hdr.major_version = GUINT32_FROM_LE(c->peer_hdr.major_version);
+ c->peer_hdr.minor_version = GUINT32_FROM_LE(c->peer_hdr.minor_version);
+ c->peer_hdr.size = GUINT32_FROM_LE(c->peer_hdr.size);
+
c->peer_msg = g_malloc0(c->peer_hdr.size);
if (c->peer_msg == NULL) {
g_warning("invalid peer header size: %u", c->peer_hdr.size);
@@ -1723,7 +1733,7 @@ static gboolean spice_channel_recv_link_msg(SpiceChannel *channel)
{
SpiceChannelPrivate *c;
int rc, num_caps, i;
- uint32_t *caps;
+ uint32_t *caps, num_channel_caps, num_common_caps;
SpiceChannelEvent event = SPICE_CHANNEL_ERROR_LINK;
g_return_val_if_fail(channel != NULL, FALSE);
@@ -1754,24 +1764,27 @@ static gboolean spice_channel_recv_link_msg(SpiceChannel *channel)
goto error;
}
- num_caps = c->peer_msg->num_channel_caps + c->peer_msg->num_common_caps;
+ num_channel_caps = GUINT32_FROM_LE(c->peer_msg->num_channel_caps);
+ num_common_caps = GUINT32_FROM_LE(c->peer_msg->num_common_caps);
+
+ num_caps = num_channel_caps + num_common_caps;
CHANNEL_DEBUG(channel, "%s: %d caps", __FUNCTION__, num_caps);
/* see original spice/client code: */
/* g_return_if_fail(c->peer_msg + c->peer_msg->caps_offset * sizeof(uint32_t) > c->peer_msg + c->peer_hdr.size); */
- caps = (uint32_t *)((uint8_t *)c->peer_msg + c->peer_msg->caps_offset);
+ caps = (uint32_t *)((uint8_t *)c->peer_msg + GUINT32_FROM_LE(c->peer_msg->caps_offset));
- g_array_set_size(c->remote_common_caps, c->peer_msg->num_common_caps);
- for (i = 0; i < c->peer_msg->num_common_caps; i++, caps++) {
- g_array_index(c->remote_common_caps, uint32_t, i) = *caps;
- CHANNEL_DEBUG(channel, "got common caps %u:0x%X", i, *caps);
+ g_array_set_size(c->remote_common_caps, num_common_caps);
+ for (i = 0; i < num_common_caps; i++, caps++) {
+ g_array_index(c->remote_common_caps, uint32_t, i) = GUINT32_FROM_LE(*caps);
+ CHANNEL_DEBUG(channel, "got common caps %u:0x%X", i, GUINT32_FROM_LE(*caps));
}
- g_array_set_size(c->remote_caps, c->peer_msg->num_channel_caps);
- for (i = 0; i < c->peer_msg->num_channel_caps; i++, caps++) {
- g_array_index(c->remote_caps, uint32_t, i) = *caps;
- CHANNEL_DEBUG(channel, "got channel caps %u:0x%X", i, *caps);
+ g_array_set_size(c->remote_caps, num_channel_caps);
+ for (i = 0; i < num_channel_caps; i++, caps++) {
+ g_array_index(c->remote_caps, uint32_t, i) = GUINT32_FROM_LE(*caps);
+ CHANNEL_DEBUG(channel, "got channel caps %u:0x%X", i, GUINT32_FROM_LE(*caps));
}
if (!spice_channel_test_common_capability(channel,
commit a22bfaf2385928fb70b5f949ce3bd0d8b7f5170d
Author: Fabiano FidĂȘncio <fidencio at redhat.com>
Date: Thu Dec 17 16:50:16 2015 +0100
ppc: Fix header endianess
diff --git a/src/spice-channel.c b/src/spice-channel.c
index a2a6cb9..26b5c38 100644
--- a/src/spice-channel.c
+++ b/src/spice-channel.c
@@ -373,9 +373,9 @@ static inline void spice_header_set_msg_type(uint8_t *header, gboolean is_mini_h
uint16_t type)
{
if (is_mini_header) {
- ((SpiceMiniDataHeader *)header)->type = type;
+ ((SpiceMiniDataHeader *)header)->type = GUINT16_TO_LE(type);
} else {
- ((SpiceDataHeader *)header)->type = type;
+ ((SpiceDataHeader *)header)->type = GUINT16_TO_LE(type);
}
}
@@ -383,9 +383,9 @@ static inline void spice_header_set_msg_size(uint8_t *header, gboolean is_mini_h
uint32_t size)
{
if (is_mini_header) {
- ((SpiceMiniDataHeader *)header)->size = size;
+ ((SpiceMiniDataHeader *)header)->size = GUINT32_TO_LE(size);
} else {
- ((SpiceDataHeader *)header)->size = size;
+ ((SpiceDataHeader *)header)->size = GUINT32_TO_LE(size);
}
}
@@ -393,9 +393,9 @@ G_GNUC_INTERNAL
uint16_t spice_header_get_msg_type(uint8_t *header, gboolean is_mini_header)
{
if (is_mini_header) {
- return ((SpiceMiniDataHeader *)header)->type;
+ return GUINT16_FROM_LE(((SpiceMiniDataHeader *)header)->type);
} else {
- return ((SpiceDataHeader *)header)->type;
+ return GUINT16_FROM_LE(((SpiceDataHeader *)header)->type);
}
}
@@ -403,9 +403,9 @@ G_GNUC_INTERNAL
uint32_t spice_header_get_msg_size(uint8_t *header, gboolean is_mini_header)
{
if (is_mini_header) {
- return ((SpiceMiniDataHeader *)header)->size;
+ return GUINT32_FROM_LE(((SpiceMiniDataHeader *)header)->size);
} else {
- return ((SpiceDataHeader *)header)->size;
+ return GUINT32_FROM_LE(((SpiceDataHeader *)header)->size);
}
}
@@ -418,7 +418,7 @@ static inline void spice_header_set_msg_serial(uint8_t *header, gboolean is_mini
uint64_t serial)
{
if (!is_mini_header) {
- ((SpiceDataHeader *)header)->serial = serial;
+ ((SpiceDataHeader *)header)->serial = GUINT64_TO_LE(serial);
}
}
@@ -457,7 +457,7 @@ static inline uint32_t spice_header_get_msg_sub_list(uint8_t *header, gboolean i
if (is_mini_header) {
return 0;
} else {
- return ((SpiceDataHeader *)header)->sub_list;
+ return GUINT32_FROM_LE(((SpiceDataHeader *)header)->sub_list);
}
}
More information about the Spice-commits
mailing list