History log of /hardware/interfaces/graphics/allocator/2.0/utils/passthrough/include/allocator-passthrough/2.0/GrallocLoader.h
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
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
/hardware/interfaces/graphics/allocator/2.0/utils/passthrough/include/allocator-passthrough/2.0/GrallocLoader.h
699df2167a9749ae3f091b7f5ed2e343251afbcc 15-Dec-2017 Chia-I Wu <olv@google.com> graphics: use allocator HAL support library in default impl

Rename Gralloc0Allocator to Gralloc0Hal and make it inherit from
AllocatorHal. Do the same to Gralloc1Allocator. Add GrallocLoader
to load either of Gralloc[01]Hal and create a IAllocator instance.

Test: boots and VTS
Change-Id: I09ae680c0086ca9e73e412a34d7cd2f3665d3bc2
/hardware/interfaces/graphics/allocator/2.0/utils/passthrough/include/allocator-passthrough/2.0/GrallocLoader.h