Hi, after the discussion and tests to reduce typedef mess I realized the code lack some proper encapsulation. In DisplayChannel there are multiple files to handle different stuff but all code needs to know all structures and basically include all stuff. Looking at code one stuff that could/should be separate is the image encoding. There is no high level reason why to compress an image a connection to a client is required. So I started moving encoding fields into a structure and encapsulating code reducing access and knowledge about image encoding. Results: - dcc-encoders.c does not include or use DisplayChannel stuff; - more structures are now defined in dcc-encoders.c; - dcc-encoders does not use Drawable but just a Ring to store internal data. Improvements (not strictly related to this patchset): - dcc_compress_image should be moved to dcc-encoders.c; - there is no reason dcc-encoders.h should use RedClient, this is just as the Glz dictionaries are bound to client; - define a structure to store global fields like all image statistics; - I'm not sure about the EncodersData name, possibly ImageEncoding would be better; - Glz code is still messy although more encapsulated; - EncodersData is quite huge, could be optimized. Frediano Frediano Ziglio (30): Do not release too much drawables Move dcc glz field initialization into dcc_new Add compress_buf_free function Move marshalling code from dcc-encoders to dcc-send Encapsulate quic information in a new EncodersData structure Move dcc_compress_image_quic to dcc-encoders.c Encapsulate lz information in EncodersData structure Move dcc_compress_image_lz to dcc-encoders.c Encapsulate jpeg information in EncodersData structure Move dcc_compress_image_jpeg to dcc-encoders.c Encapsulate lz4 information in EncodersData structure Move dcc_compress_image_lz4 to dcc-encoders.c Encapsulate zlib information in EncodersData structure More encapsulation for dcc_encoders_free Move some glz fields to EncodersData Move others glz fields to dcc-encoders Make dcc_compress_image_glz independent to DisplayChannelClient Move dcc_compress_image_glz to dcc-encoders.c Encapsulate some data in dcc-encoders Encapsulate code to save glz state Make some function static Encapsulate dcc_release_glz Better encapsulation for dcc_compress_image_glz call Better encoders encapsulation Change RedGlzDrawable::drawable from pointer to boolean Use Ring instead of accessing Drawable internals Do not access EncodersData internal to lock/unlock glz encoding Make GlzSharedDictionary structure private in dcc-encoders.c Remove dependency from dcc-encoders to Drawable Reduce header dependency server/dcc-encoders.c | 874 +++++++++++++++++++++++++++++++++++++++-------- server/dcc-encoders.h | 149 ++++---- server/dcc-send.c | 28 +- server/dcc.c | 539 ++--------------------------- server/dcc.h | 33 +- server/display-channel.c | 43 +-- server/display-channel.h | 7 - server/red-worker.c | 6 +- 8 files changed, 886 insertions(+), 793 deletions(-) -- 2.7.4 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel