[Spice-devel] [PATCH] server: Consider the surface id when identifying video streams, and draw the stream on the proper surface, #28088

Yonit Halperin yhalperi at redhat.com
Sun Jul 25 23:18:20 PDT 2010


---
 server/red_worker.c |   21 +++++++++++++++++----
 1 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/server/red_worker.c b/server/red_worker.c
index cbfe405..1c32a26 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -427,6 +427,7 @@ struct Stream {
     int width;
     int height;
     SpiceRect dest_area;
+    int dest_surface_id;
 #endif
     MJpegEncoder *mjpeg_encoder;
     int top_down;
@@ -858,6 +859,7 @@ typedef struct ItemTrace {
     int width;
     int height;
     SpiceRect dest_area;
+    int dest_surface_id;
 } ItemTrace;
 
 #define TRACE_ITEMS_SHIFT 3
@@ -1687,6 +1689,7 @@ static inline void red_add_item_trace(RedWorker *worker, Drawable *item)
     trace->width = src_area->right - src_area->left;
     trace->height = src_area->bottom - src_area->top;
     trace->dest_area = item->red_drawable->bbox;
+    trace->dest_surface_id = item->surface_id;
 }
 
 #endif
@@ -2716,6 +2719,7 @@ static void red_create_stream(RedWorker *worker, Drawable *drawable)
     stream->height = src_rect->bottom - src_rect->top;
     stream->dest_area = drawable->red_drawable->bbox;
 #endif
+    stream->dest_surface_id = drawable->surface_id;
     stream->refs = 1;
     stream->bit_rate = get_bit_rate(stream_width, stream_height);
     SpiceBitmap *bitmap = &drawable->red_drawable->u.copy.src_bitmap->u.bitmap;
@@ -2781,6 +2785,7 @@ static inline int __red_is_next_stream_frame(RedWorker *worker,
                                              const int other_src_width,
                                              const int other_src_height,
                                              const SpiceRect *other_dest,
+                                             int other_dest_surface_id,
                                              const red_time_t other_time,
                                              const Stream *stream)
 {
@@ -2791,6 +2796,10 @@ static inline int __red_is_next_stream_frame(RedWorker *worker,
         return FALSE;
     }
 
+    if (candidate->surface_id != other_dest_surface_id) {
+        return FALSE;
+    }
+
     red_drawable = candidate->red_drawable;
 
     if (!rect_is_equal(&red_drawable->bbox, other_dest)) {
@@ -2822,7 +2831,9 @@ static inline int red_is_next_stream_frame(RedWorker *worker, const Drawable *ca
     SpiceRect* prev_src = &prev->red_drawable->u.copy.src_area;
     return __red_is_next_stream_frame(worker, candidate, prev_src->right - prev_src->left,
                                       prev_src->bottom - prev_src->top,
-                                      &prev->red_drawable->bbox, prev->creation_time,
+                                      &prev->red_drawable->bbox,
+                                      prev->surface_id,
+                                      prev->creation_time,
                                       prev->stream);
 }
 
@@ -3113,6 +3124,7 @@ static inline void red_use_stream_trace(RedWorker *worker, Drawable *drawable)
                                                            stream->width,
                                                            stream->height,
                                                            &stream->dest_area,
+                                                           stream->dest_surface_id,
                                                            stream->last_time,
                                                            stream)) {
             red_attach_stream(worker, drawable, stream);
@@ -3125,7 +3137,8 @@ static inline void red_use_stream_trace(RedWorker *worker, Drawable *drawable)
     trace_end = trace + NUM_TRACE_ITEMS;
     for (; trace < trace_end; trace++) {
         if (__red_is_next_stream_frame(worker, drawable, trace->width, trace->height,
-                                       &trace->dest_area, trace->time, NULL)) {
+                                       &trace->dest_area,
+                                       trace->dest_surface_id, trace->time, NULL)) {
             red_stream_add_frame(worker, drawable,
                                  trace->frames_count,
                                  trace->gradual_frames_count,
@@ -8408,7 +8421,7 @@ static void red_display_send_upgrade(DisplayChannel *display_channel, UpgradeIte
     ASSERT(red_drawable->u.copy.rop_descriptor == SPICE_ROPD_OP_PUT);
     ASSERT(red_drawable->u.copy.mask.bitmap == 0);
 
-    copy.base.surface_id = 0;
+    copy.base.surface_id = red_drawable->surface_id;
     copy.base.box = red_drawable->bbox;
     copy.base.clip.type = SPICE_CLIP_TYPE_RECTS;
     copy.base.clip.rects = item->rects;
@@ -8435,7 +8448,7 @@ static void red_display_send_stream_start(DisplayChannel *display_channel, Strea
     SpiceMsgDisplayStreamCreate stream_create;
     SpiceClipRects clip_rects;
 
-    stream_create.surface_id = 0;
+    stream_create.surface_id = stream->dest_surface_id;
     stream_create.id = agent - display_channel->stream_agents;
     stream_create.flags = stream->top_down ? SPICE_STREAM_FLAGS_TOP_DOWN : 0;
     stream_create.codec_type = SPICE_VIDEO_CODEC_TYPE_MJPEG;
-- 
1.7.1.1



More information about the Spice-devel mailing list