Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

[core] Return source and layer ownership - #7014

Merged
boundsj merged 5 commits into
masterfrom
boundsj-return-source-layer-ownership
Nov 11, 2016
Merged

boundsj merged 5 commits into
masterfrom
boundsj-return-source-layer-ownership

Conversation

@boundsj

@boundsj boundsj commented Nov 10, 2016 •

Copy link
Copy Markdown
Contributor

When a source or layer is removed transfer ownership back to the caller so it can (optionally) take it.

ref #6959

cc @jfirebaugh

When a source or layer is removed transfer ownership back to the
caller so it can (optionally) take it.
@boundsj boundsj added Core The cross-platform C++ core, aka mbgl runtime styling labels Nov 10, 2016
@boundsj boundsj added this to the ios-v3.4.0 milestone Nov 10, 2016
@boundsj boundsj self-assigned this Nov 10, 2016
@mention-bot

Copy link
Copy Markdown

@boundsj, thanks for your PR! By analyzing the history of the files in this pull request, we identified @jfirebaugh, @brunoabinader and @kkaefer to be potential reviewers.

@boundsj

boundsj commented Nov 10, 2016

Copy link
Copy Markdown
Contributor Author

Once this is ready, I'd like to merge it to master and then cherry-pick to the iOS (and maybe Android) release branches where the returned objects can actually be used in the platform source and layer wrappers.

@boundsj boundsj mentioned this pull request Nov 11, 2016
4 tasks done
Comment thread src/mbgl/map/map.cpp Outdated
if (impl->style) {
impl->styleMutated = true;
impl->style->removeSource(sourceID);
return impl->style->removeSource(sourceID);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 8584922

Comment thread src/mbgl/map/map.cpp
auto removedLayer = impl->style->removeLayer(id);
impl->onUpdate(Update::Classes);

impl->backend.deactivate();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will need to add special logic for CustomLayer. Currently, ~CustomLayer calls the CustomLayerDeinitializeFunction, which may make OpenGL calls. This is the reason that we call impl->backend.activate()/deactivate() -- the context needs to be active when initialization/deinitialization happens.

I think we need to preserve the behavior that removing a CustomLayer triggers deinitialization, even when returning ownership. Let's do this in Style::removeLayer, making it parallel Style::addLayer, which does initialization.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


void CustomLayer::Impl::deinitialize() {
assert(deinitializeFn);
deinitializeFn(context);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also need to remove deinitialization from CustomLayer::Impl::~Impl. And from the looks of that method, it's possible that deinitializeFn may be optional? I don't remember but we should probably keep the guard.

@boundsj

boundsj commented Nov 11, 2016

Copy link
Copy Markdown
Contributor Author

@jfirebaugh can you please double check that 554abe9 looks ok to you?

@jfirebaugh

Copy link
Copy Markdown
Contributor

👍

@boundsj
boundsj merged commit edf40bb into master Nov 11, 2016
@boundsj
boundsj deleted the boundsj-return-source-layer-ownership branch November 11, 2016 22:40
boundsj added a commit that referenced this pull request Nov 14, 2016
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.
ivovandongen pushed a commit that referenced this pull request Nov 14, 2016
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.
@ivovandongen ivovandongen mentioned this pull request Nov 14, 2016
ivovandongen pushed a commit that referenced this pull request Nov 14, 2016
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.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Core The cross-platform C++ core, aka mbgl runtime styling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants