[Spice-devel] [PATCH v4 00/19] Better encapsulation of image encoding stuff

Frediano Ziglio fziglio at redhat.com
Tue Jun 14 09:32:52 UTC 2016


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.

Future 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;
- Glz code is still messy although more encapsulated;
- ImageEncoders is quite huge, could be optimized;
- dcc-encoders.[ch] should be renamed to image-encoders.[ch];
- implements lazy allocation for encoders to reduce memory
  footprint.

Changes from v3:
- renamed ImageEncoderGlobals to ImageEncoderSharedData
  (and globals variables to shared_data);
- split a rename patch;
- added small optimization for ImageEncoders.

Changes from v2:
- minor comment fixes;
- added a structure to store global data. This allowed to
  store the old "glz_drawable_count". Also this reduce
  the number or parameters to pass to
  image_encoders_compress_XX functions.

Changes from v1:
- EncodersData structure renamed to ImageEncoders;
- all encoders function have the image_encoders_ prefix;
- split patches that move encoder fields from part that prepare
  dcc_compress_XX to be moved;
- merged some not strictly related patches.

Frediano Ziglio (19):
  Add a structure to hold ImageEncoders shared data
  Move some glz fields to ImageEncoders
  Change dcc_encoders_init to take ImageEncoders instead of
    DisplayChannelClient
  Move others glz fields to dcc-encoders
  Make dcc_compress_image_glz independent to DisplayChannelClient
  Move image_encoders_compress_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 image_encoders_compress_glz call
  Better encoders encapsulation
  Change RedGlzDrawable::drawable from pointer to boolean
  Use Ring instead of accessing Drawable internals
  Do not access ImageEncoders internal to lock/unlock glz encoding
  Make GlzSharedDictionary structure private in dcc-encoders.c
  Remove dependency from dcc-encoders to Drawable
  Reduce header dependency
  Remove message_buf from EncoderData

 server/dcc-encoders.c    | 573 +++++++++++++++++++++++++++++++++++++----------
 server/dcc-encoders.h    | 123 +++++-----
 server/dcc-send.c        |   8 +-
 server/dcc.c             | 218 +++---------------
 server/dcc.h             |   9 -
 server/display-channel.c | 112 ++-------
 server/display-channel.h |  16 +-
 server/red-worker.c      |   4 +-
 8 files changed, 565 insertions(+), 498 deletions(-)

-- 
2.7.4



More information about the Spice-devel mailing list