[Spice-devel] [PATCH] RFC Avoid multiple typedef in headers
Frediano Ziglio
fziglio at redhat.com
Tue May 24 15:46:56 UTC 2016
This after typedef discussions
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
server/dcc-encoders.h | 33 ++++++++++++++++++---------------
server/dcc.h | 20 +++++++++++---------
server/display-channel.h | 2 ++
server/image-cache.h | 6 ++----
server/stream.h | 41 +++++++++++++++++++++--------------------
5 files changed, 54 insertions(+), 48 deletions(-)
diff --git a/server/dcc-encoders.h b/server/dcc-encoders.h
index 84f9f93..1627a9c 100644
--- a/server/dcc-encoders.h
+++ b/server/dcc-encoders.h
@@ -32,21 +32,24 @@
#endif
#include "zlib-encoder.h"
+struct Drawable;
+struct DisplayChannelClient;
+
typedef struct RedCompressBuf RedCompressBuf;
typedef struct GlzDrawableInstanceItem GlzDrawableInstanceItem;
typedef struct RedGlzDrawable RedGlzDrawable;
-void dcc_encoders_init (DisplayChannelClient *dcc);
-void dcc_encoders_free (DisplayChannelClient *dcc);
-void dcc_free_glz_drawable_instance (DisplayChannelClient *dcc,
+void dcc_encoders_init (struct DisplayChannelClient *dcc);
+void dcc_encoders_free (struct DisplayChannelClient *dcc);
+void dcc_free_glz_drawable_instance (struct DisplayChannelClient *dcc,
GlzDrawableInstanceItem *item);
-void dcc_free_glz_drawable (DisplayChannelClient *dcc,
+void dcc_free_glz_drawable (struct DisplayChannelClient *dcc,
RedGlzDrawable *drawable);
-int dcc_free_some_independent_glz_drawables (DisplayChannelClient *dcc);
-void dcc_free_glz_drawables (DisplayChannelClient *dcc);
-void dcc_free_glz_drawables_to_free (DisplayChannelClient* dcc);
-void dcc_freeze_glz (DisplayChannelClient *dcc);
-void dcc_release_glz (DisplayChannelClient *dcc);
+int dcc_free_some_independent_glz_drawables (struct DisplayChannelClient *dcc);
+void dcc_free_glz_drawables (struct DisplayChannelClient *dcc);
+void dcc_free_glz_drawables_to_free (struct DisplayChannelClient* dcc);
+void dcc_freeze_glz (struct DisplayChannelClient *dcc);
+void dcc_release_glz (struct DisplayChannelClient *dcc);
void marshaller_add_compressed (SpiceMarshaller *m,
RedCompressBuf *comp_buf,
@@ -75,14 +78,14 @@ typedef struct GlzSharedDictionary {
RedClient *client; // channel clients of the same client share the dict
} GlzSharedDictionary;
-GlzSharedDictionary* dcc_get_glz_dictionary (DisplayChannelClient *dcc,
+GlzSharedDictionary* dcc_get_glz_dictionary (struct DisplayChannelClient *dcc,
uint8_t id, int window_size);
-GlzSharedDictionary* dcc_restore_glz_dictionary (DisplayChannelClient *dcc,
+GlzSharedDictionary* dcc_restore_glz_dictionary (struct DisplayChannelClient *dcc,
uint8_t id,
GlzEncDictRestoreData *restore_data);
typedef struct {
- DisplayChannelClient *dcc;
+ struct DisplayChannelClient *dcc;
RedCompressBuf *bufs_head;
RedCompressBuf *bufs_tail;
jmp_buf jmp_env;
@@ -101,7 +104,7 @@ typedef struct {
char message_buf[512];
} EncoderData;
-void encoder_data_init(EncoderData *data, DisplayChannelClient *dcc);
+void encoder_data_init(EncoderData *data, struct DisplayChannelClient *dcc);
void encoder_data_reset(EncoderData *data);
typedef struct {
@@ -156,11 +159,11 @@ struct RedGlzDrawable {
RingItem link; // ordered by the time it was encoded
RingItem drawable_link;
RedDrawable *red_drawable;
- Drawable *drawable;
+ struct Drawable *drawable;
GlzDrawableInstanceItem instances_pool[MAX_GLZ_DRAWABLE_INSTANCES];
Ring instances;
uint8_t instances_count;
- DisplayChannelClient *dcc;
+ struct DisplayChannelClient *dcc;
};
#define RED_RELEASE_BUNCH_SIZE 64
diff --git a/server/dcc.h b/server/dcc.h
index a11d25a..81aaf07 100644
--- a/server/dcc.h
+++ b/server/dcc.h
@@ -42,6 +42,8 @@
#define MAX_PIPE_SIZE 50
+struct Drawable;
+
typedef struct WaitForChannels {
SpiceMsgWaitForChannels header;
SpiceWaitForChannel buf[MAX_CACHE_CLIENTS];
@@ -54,7 +56,7 @@ typedef struct FreeList {
WaitForChannels wait;
} FreeList;
-struct DisplayChannelClient {
+typedef struct DisplayChannelClient {
CommonGraphicsChannelClient common;
uint32_t id;
SpiceImageCompression image_compression;
@@ -113,7 +115,7 @@ struct DisplayChannelClient {
uint32_t streams_max_latency;
uint64_t streams_max_bit_rate;
bool gl_draw_ongoing;
-};
+} DisplayChannelClient;
#define DCC_TO_WORKER(dcc) \
(SPICE_CONTAINEROF((dcc)->common.base.channel, CommonGraphicsChannel, base)->worker)
@@ -152,11 +154,11 @@ typedef struct RedImageItem {
typedef struct RedDrawablePipeItem {
RingItem base; /* link for a list of pipe items held by Drawable */
RedPipeItem dpi_pipe_item; /* link for the client's pipe itself */
- Drawable *drawable;
+ struct Drawable *drawable;
DisplayChannelClient *dcc;
} RedDrawablePipeItem;
-DisplayChannelClient* dcc_new (DisplayChannel *display,
+DisplayChannelClient* dcc_new (struct DisplayChannel *display,
RedClient *client,
RedsStream *stream,
int mig_target,
@@ -197,11 +199,11 @@ void dcc_palette_cache_palette (DisplayCha
int dcc_pixmap_cache_unlocked_add (DisplayChannelClient *dcc,
uint64_t id, uint32_t size, int lossy);
void dcc_prepend_drawable (DisplayChannelClient *dcc,
- Drawable *drawable);
+ struct Drawable *drawable);
void dcc_append_drawable (DisplayChannelClient *dcc,
- Drawable *drawable);
+ struct Drawable *drawable);
void dcc_add_drawable_after (DisplayChannelClient *dcc,
- Drawable *drawable,
+ struct Drawable *drawable,
RedPipeItem *pos);
void dcc_send_item (RedChannelClient *dcc,
RedPipeItem *item);
@@ -209,7 +211,7 @@ int dcc_clear_surface_drawables_from_pipe (DisplayCha
int surface_id,
int wait_if_used);
int dcc_drawable_is_in_pipe (DisplayChannelClient *dcc,
- Drawable *drawable);
+ struct Drawable *drawable);
RedPipeItem * dcc_gl_scanout_item_new (RedChannelClient *rcc,
void *data, int num);
RedPipeItem * dcc_gl_draw_item_new (RedChannelClient *rcc,
@@ -223,7 +225,7 @@ typedef struct compress_send_data_t {
} compress_send_data_t;
int dcc_compress_image (DisplayChannelClient *dcc,
- SpiceImage *dest, SpiceBitmap *src, Drawable *drawable,
+ SpiceImage *dest, SpiceBitmap *src, struct Drawable *drawable,
int can_lossy,
compress_send_data_t* o_comp_data);
diff --git a/server/display-channel.h b/server/display-channel.h
index 4eb78c5..f3270ad 100644
--- a/server/display-channel.h
+++ b/server/display-channel.h
@@ -46,6 +46,8 @@
#include "dcc.h"
#include "display-limits.h"
+typedef struct Drawable Drawable;
+typedef struct DisplayChannel DisplayChannel;
typedef struct DependItem {
Drawable *drawable;
diff --git a/server/image-cache.h b/server/image-cache.h
index 38a318e..af1aef3 100644
--- a/server/image-cache.h
+++ b/server/image-cache.h
@@ -23,9 +23,7 @@
#include <common/canvas_base.h>
#include <common/ring.h>
-/* FIXME: move back to display-channel.h (once structs are private) */
-typedef struct Drawable Drawable;
-typedef struct DisplayChannelClient DisplayChannelClient;
+struct Drawable;
typedef struct ImageCacheItem {
RingItem lru_link;
@@ -55,7 +53,7 @@ void image_cache_init (ImageCache *cache);
void image_cache_reset (ImageCache *cache);
void image_cache_aging (ImageCache *cache);
void image_cache_localize (ImageCache *cache, SpiceImage **image_ptr,
- SpiceImage *image_store, Drawable *drawable);
+ SpiceImage *image_store, struct Drawable *drawable);
void image_cache_localize_brush (ImageCache *cache, SpiceBrush *brush,
SpiceImage *image_store);
void image_cache_localize_mask (ImageCache *cache, SpiceQMask *mask,
diff --git a/server/stream.h b/server/stream.h
index 715f920..5f58325 100644
--- a/server/stream.h
+++ b/server/stream.h
@@ -42,8 +42,9 @@
#define RED_STREAM_DEFAULT_LOW_START_BIT_RATE (2.5 * 1024 * 1024) // 2.5Mbps
#define MAX_FPS 30
-/* move back to display_channel once struct private */
-typedef struct DisplayChannel DisplayChannel;
+struct Drawable;
+struct DisplayChannel;
+struct DisplayChannelClient;
typedef struct Stream Stream;
@@ -85,7 +86,7 @@ typedef struct StreamAgent {
Stream *stream;
uint64_t last_send_time;
VideoEncoder *video_encoder;
- DisplayChannelClient *dcc;
+ struct DisplayChannelClient *dcc;
int frames;
int drops;
@@ -125,7 +126,7 @@ typedef struct ItemTrace {
struct Stream {
uint8_t refs;
- Drawable *current;
+ struct Drawable *current;
red_time_t last_time;
int width;
int height;
@@ -139,28 +140,28 @@ struct Stream {
uint32_t input_fps;
};
-void display_channel_init_streams (DisplayChannel *display);
-void stream_stop (DisplayChannel *display,
+void display_channel_init_streams (struct DisplayChannel *display);
+void stream_stop (struct DisplayChannel *display,
Stream *stream);
-void stream_unref (DisplayChannel *display,
+void stream_unref (struct DisplayChannel *display,
Stream *stream);
-void stream_trace_update (DisplayChannel *display,
- Drawable *drawable);
-void stream_maintenance (DisplayChannel *display,
- Drawable *candidate,
- Drawable *prev);
-void stream_timeout (DisplayChannel *display);
-void stream_detach_and_stop (DisplayChannel *display);
-void stream_trace_add_drawable (DisplayChannel *display,
- Drawable *item);
-void stream_detach_behind (DisplayChannel *display,
+void stream_trace_update (struct DisplayChannel *display,
+ struct Drawable *drawable);
+void stream_maintenance (struct DisplayChannel *display,
+ struct Drawable *candidate,
+ struct Drawable *prev);
+void stream_timeout (struct DisplayChannel *display);
+void stream_detach_and_stop (struct DisplayChannel *display);
+void stream_trace_add_drawable (struct DisplayChannel *display,
+ struct Drawable *item);
+void stream_detach_behind (struct DisplayChannel *display,
QRegion *region,
- Drawable *drawable);
+ struct Drawable *drawable);
-void stream_agent_unref (DisplayChannel *display,
+void stream_agent_unref (struct DisplayChannel *display,
StreamAgent *agent);
void stream_agent_stop (StreamAgent *agent);
-void detach_stream(DisplayChannel *display, Stream *stream, int detach_sized);
+void detach_stream(struct DisplayChannel *display, Stream *stream, int detach_sized);
#endif /* STREAM_H */
--
2.7.4
More information about the Spice-devel
mailing list