422b94e002e2187dd3e313768ab8906be9ed1f9c |
20-Jan-2018 |
Chia-I Wu <olv@google.com> |
graphics: make allocator passthrough library header-only android.hardware.graphics.allocator@2.0-passthrough should be a header-only library to be fully reusable by vendor HALs. This also allows us to switch from virtual inheritance to templates, which is more straightforward. This changes nothing to the users and we still have these relations - AllocatorHal is an abstract class to be implemented by vendors or the default implementations - Gralloc[01]Hal are our default implementations - Allocator implements HIDL IAllocator interface on top of AllocatorHal What we do not like about virtual inheritance is that, given // abstract class B and D class B { virtual void foo() = 0; virtual void bar() = 0; }; class D : public virtual B { // foo is superceded by fooEnhanced in D void foo() { fooEnhanced(); } virtual void fooEnhanced() = 0; }; // an implementation of B class BImpl : public virtual B { void foo() {} void bar() {} }; // an implementation of D on top of BImpl class DImpl : public virtual D, public virtual BImpl { void fooEnhanced() {} }; we get "no unique final overrider" becase both D and BImpl implement foo. With non-virtual inheritance, on the other hand, we get "DImpl is abstract" because foo is still pure virtual implemented in DImpl. Templates solve the issue by allowing namespace detail{ template<typename T> class BImpl : public T { ... }; template<typename T> class DImpl : public BImpl<T> { ... }; } // namespace detail using BImpl = detail::BImpl<B>; using DImpl = detail::DImpl<D>; Test: boots Change-Id: Iccb513e4fc751e9a687a1ed2d9fb2192c8324a50
nclude/allocator-hal/2.0/Allocator.h
|
d6daa8ddf9ad758a9eaddd624dec57f543d51b44 |
08-Jan-2018 |
Chia-I Wu <olv@google.com> |
graphics: add allocator HAL support library Add a header-only library android.hardware.graphics.allocator@2.0-hal that can be used by implementations. An imlpementation can class VendorHal : public AllocatorHal { ... }; auto allocator = std::make_unique<Allocator>(); allocator->init(std::make_unique<VendorHal>(...)); Or, if vendor extensions are to be added to the IAllocator, class AlocatorHalExt : public AllocatorHal { ... }; class VendorHal : public AllocatorHalExt { ... }; class AllocatorExt : public AllocatorImpl<IAllocatorExt, AllocatorHalExt> { ... }; auto allocator = std::make_unique<AllocatorExt>(); allocator->init(std::make_unique<VendorHal>(...)); Test: builds Change-Id: I7cb7a4888316b871e5c49d96524b1642fc708f2d
ndroid.bp
nclude/allocator-hal/2.0/Allocator.h
nclude/allocator-hal/2.0/AllocatorHal.h
|