[cairo] absract_surface -> cairo_surface_t* vs void*
Enrico Weigelt, metux IT consult
enrico.weigelt at gr13.net
Sat Dec 12 08:22:46 PST 2015
On 11.12.2015 18:06, Uli Schlachter wrote:
> What deeper inheritance? Can surface inherit from each other at all?
See DRM backend.
Actually, it's not true inheritance like in C++, but more container
>> into cairo_surface_t, so we can check individual
>> instances for correct class
>> * add some macros for the typecasting and type check
>> * make the whole thing (compile-time) optional
> Don't the existing ->type and ->backend values serve this goal? I guess we could
> add some macros for this, but ->backend == my_backend is quite obvious, I think.
As long as no inheritance is involved, that's correct.
But w/ inheritance (like done in the DRM backend) it's getting a bit
more complex. For example, the drm-i915 backend uses some generic
functions of the drm-intel backend, which in turn uses some from the
more generic drm backend. In that case these inherited functions are
called directly, so they dont know that they're actually running for
a different backend, so the check would fail.
An alternative would be having all derived backends defining all
backend ops functions own their own, which then explicitly call the
inherited functions - leading to more core (and a little bit of
runtime overhead). These functions would first cast to the parent
class and then casting to their real one - having the type id of
the derived class in a separate field.
mit freundlichen Grüßen
metux IT consulting
More information about the cairo