[core] Return source and layer ownership (#7014)

When a source or layer is removed transfer ownership back to the
caller so it can (optionally) take it. Preserve the behavior that 
removing a CustomLayer triggers deinitialization.  Deinitialize all 
custom layers when a style is destroyed in case those layers are not 
explicitly removed.
This commit is contained in:
Jesse Bounds
2016-11-11 14:40:04 -08:00
committed by GitHub
parent 39b0bc0a40
commit edf40bb6d9
6 changed files with 43 additions and 17 deletions

View File

@@ -23,11 +23,7 @@ CustomLayer::Impl::Impl(const CustomLayer::Impl& other)
// Don't copy anything else.
}
CustomLayer::Impl::~Impl() {
if (deinitializeFn) {
deinitializeFn(context);
}
}
CustomLayer::Impl::~Impl() = default;
std::unique_ptr<Layer> CustomLayer::Impl::clone() const {
return std::make_unique<CustomLayer>(*this);
@@ -43,6 +39,12 @@ void CustomLayer::Impl::initialize() {
initializeFn(context);
}
void CustomLayer::Impl::deinitialize() {
if (deinitializeFn) {
deinitializeFn(context);
}
}
void CustomLayer::Impl::render(const TransformState& state) const {
assert(renderFn);