Skip to content
  • Emmanuele Bassi's avatar
    Remove Units from the public API · d6d208da
    Emmanuele Bassi authored
    With the recent change to internal floating point values, ClutterUnit
    has become a redundant type, defined to be a float. All integer entry
    points are being internally converted to floating point values to be
    passed to the GL pipeline with the least amount of conversion.
    
    ClutterUnit is thus exposed as just a "pixel with fractionary bits",
    and not -- as users might think -- as generic, resolution and device
    independent units. not that it was the case, but a definitive amount
    of people was convinced it did provide this "feature", and was flummoxed
    about the mere existence of this type.
    
    So, having ClutterUnit exposed in the public API doubles the entry
    points and has the following disadvantages:
    
      - we have to maintain twice the amount of entry points in ClutterActor
      - we still do an integer-to-float implicit conversion
      - we introduce a weird impedance between pixels and "pixels with
        fractionary bits"
      - language bindings will have to choose what to bind, and resort
        to manually overriding the API
        + *except* for language bindings based on GObject-Introspection, as
          they cannot do manual overrides, thus will replicate the entire
          set of entry points
    
    For these reason, we should coalesces every Actor entry point for
    pixels and for ClutterUnit into a single entry point taking a float,
    like:
    
      void clutter_actor_set_x (ClutterActor *self,
                                gfloat        x);
      void clutter_actor_get_size (ClutterActor *self,
                                   gfloat       *width,
                                   gfloat       *height);
      gfloat clutter_actor_get_height (ClutterActor *self);
    
    etc.
    
    The issues I have identified are:
    
      - we'll have a two cases of compiler warnings:
        - printf() format of the return values from %d to %f
        - clutter_actor_get_size() taking floats instead of unsigned ints
      - we'll have a problem with varargs when passing an integer instead
        of a floating point value, except on 64bit platforms where the
        size of a float is the same as the size of an int
    
    To be clear: the *intent* of the API should not change -- we still use
    pixels everywhere -- but:
    
      - we remove ambiguity in the API with regard to pixels and units
      - we remove entry points we get to maintain for the whole 1.0
        version of the API
      - we make things simpler to bind for both manual language bindings
        and automatic (gobject-introspection based) ones
      - we have the simplest API possible while still exposing the
        capabilities of the underlying GL implementation
    d6d208da