-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[core] Split layer type specific code in mbgl::Programs #13577
Conversation
a292949
to
d51b9c2
Compare
e976ba6
to
25ea831
Compare
src/mbgl/programs/programs.cpp
Outdated
property = std::make_unique<ProgramsType>(context, programParameters); \ | ||
} \ | ||
return static_cast<ProgramsType&>(*property); \ | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We try to use as little macros as possible. While the macro is a bit shorter, writing out all functions verbatim doesn't look like it'd be too much code either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, will remove it
std::unique_ptr<LayerTypePrograms> fillPrograms; | ||
std::unique_ptr<LayerTypePrograms> fillExtrusionPrograms; | ||
std::unique_ptr<LayerTypePrograms> linePrograms; | ||
std::unique_ptr<LayerTypePrograms> symbolPrograms; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need an abstract base class here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unique_ptr
requires a destructor defined, so pointers to the concrete classes would prevent from LTO removing them from the binaries.
25ea831
to
2743ef0
Compare
@kkaefer thanks for your comments! addressed in the latest patch |
@alexshalamov @tmpsantos Could you also take a look? |
Progams code for a certain layer type is encapsulted within a dedicated `<layer type>Programs` class, inherited from the generic base `LayerTypePrograms` class. `mbgl::Programs::get<layer type>Programs()` lazily initializes the layer type-specific programs code using pointer to the base class, which allows LTO to remove this code from binaries (if the corresponding `get<layer type>Programs()` method can never be invoked).
2743ef0
to
33a98b9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. @kkaefer what do you think?
Programs code for a certain layer type is encapsulated within
a dedicated
<layer type>Programs
class, inherited fromthe generic base
LayerTypePrograms
class.mbgl::Programs::get<layer type>Programs()
lazily initializes thelayer type-specific programs code using pointer to the base class,
which allows LTO to remove this code from binaries (if the corresponding
get<layer type>Programs()
method can never be invoked).Tagging #13276