This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[core] Split layer type specific code in mbgl::Programs
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).
- Loading branch information
1 parent
c621b81
commit 2743ef0
Showing
23 changed files
with
257 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#include <mbgl/programs/programs.hpp> | ||
|
||
#include <mbgl/programs/background_program.hpp> | ||
#include <mbgl/programs/circle_program.hpp> | ||
#include <mbgl/programs/heatmap_program.hpp> | ||
#include <mbgl/programs/hillshade_program.hpp> | ||
#include <mbgl/programs/fill_extrusion_program.hpp> | ||
#include <mbgl/programs/fill_program.hpp> | ||
#include <mbgl/programs/line_program.hpp> | ||
#include <mbgl/programs/raster_program.hpp> | ||
#include <mbgl/programs/symbol_program.hpp> | ||
|
||
namespace mbgl { | ||
|
||
Programs::Programs(gl::Context& context_, const ProgramParameters& programParameters_) | ||
: debug(context_, programParameters_), | ||
clippingMask(context_, programParameters_), | ||
context(context_), | ||
programParameters(std::move(programParameters_)) { | ||
} | ||
|
||
Programs::~Programs() = default; | ||
|
||
BackgroundLayerPrograms& Programs::getBackgroundLayerPrograms() noexcept { | ||
if (!backgroundPrograms) { | ||
backgroundPrograms = std::make_unique<BackgroundLayerPrograms>(context, programParameters); | ||
} | ||
return static_cast<BackgroundLayerPrograms&>(*backgroundPrograms); | ||
} | ||
|
||
RasterLayerPrograms& Programs::getRasterLayerPrograms() noexcept { | ||
if (!rasterPrograms) { | ||
rasterPrograms = std::make_unique<RasterLayerPrograms>(context, programParameters); | ||
} | ||
return static_cast<RasterLayerPrograms&>(*rasterPrograms); | ||
} | ||
|
||
HeatmapLayerPrograms& Programs::getHeatmapLayerPrograms() noexcept { | ||
if (!heatmapPrograms) { | ||
heatmapPrograms = std::make_unique<HeatmapLayerPrograms>(context, programParameters); | ||
} | ||
return static_cast<HeatmapLayerPrograms&>(*heatmapPrograms); | ||
} | ||
|
||
HillshadeLayerPrograms& Programs::getHillshadeLayerPrograms() noexcept { | ||
if (!hillshadePrograms) { | ||
hillshadePrograms = std::make_unique<HillshadeLayerPrograms>(context, programParameters); | ||
} | ||
return static_cast<HillshadeLayerPrograms&>(*hillshadePrograms); | ||
} | ||
|
||
FillLayerPrograms& Programs::getFillLayerPrograms() noexcept { | ||
if (!fillPrograms) { | ||
fillPrograms = std::make_unique<FillLayerPrograms>(context, programParameters); | ||
} | ||
return static_cast<FillLayerPrograms&>(*fillPrograms); | ||
} | ||
|
||
FillExtrusionLayerPrograms& Programs::getFillExtrusionLayerPrograms() noexcept { | ||
if (!fillExtrusionPrograms) { | ||
fillExtrusionPrograms = std::make_unique<FillExtrusionLayerPrograms>(context, programParameters); | ||
} | ||
return static_cast<FillExtrusionLayerPrograms&>(*fillExtrusionPrograms); | ||
} | ||
|
||
CircleLayerPrograms& Programs::getCircleLayerPrograms() noexcept { | ||
if (!circlePrograms) { | ||
circlePrograms = std::make_unique<CircleLayerPrograms>(context, programParameters); | ||
} | ||
return static_cast<CircleLayerPrograms&>(*circlePrograms); | ||
} | ||
|
||
LineLayerPrograms& Programs::getLineLayerPrograms() noexcept { | ||
if (!linePrograms) { | ||
linePrograms = std::make_unique<LineLayerPrograms>(context, programParameters); | ||
} | ||
return static_cast<LineLayerPrograms&>(*linePrograms); | ||
} | ||
|
||
SymbolLayerPrograms& Programs::getSymbolLayerPrograms() noexcept { | ||
if (!symbolPrograms) { | ||
symbolPrograms = std::make_unique<SymbolLayerPrograms>(context, programParameters); | ||
} | ||
return static_cast<SymbolLayerPrograms&>(*symbolPrograms); | ||
} | ||
|
||
} // namespace mbgl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,54 @@ | ||
#pragma once | ||
|
||
#include <mbgl/programs/background_program.hpp> | ||
#include <mbgl/programs/circle_program.hpp> | ||
#include <mbgl/programs/clipping_mask_program.hpp> | ||
#include <mbgl/programs/extrusion_texture_program.hpp> | ||
#include <mbgl/programs/fill_program.hpp> | ||
#include <mbgl/programs/fill_extrusion_program.hpp> | ||
#include <mbgl/programs/heatmap_program.hpp> | ||
#include <mbgl/programs/heatmap_texture_program.hpp> | ||
#include <mbgl/programs/hillshade_program.hpp> | ||
#include <mbgl/programs/hillshade_prepare_program.hpp> | ||
#include <mbgl/programs/line_program.hpp> | ||
#include <mbgl/programs/raster_program.hpp> | ||
#include <mbgl/programs/symbol_program.hpp> | ||
#include <mbgl/programs/debug_program.hpp> | ||
#include <mbgl/programs/collision_box_program.hpp> | ||
#include <mbgl/programs/program_parameters.hpp> | ||
#include <memory> | ||
|
||
namespace mbgl { | ||
|
||
class BackgroundLayerPrograms; | ||
|
||
class CircleLayerPrograms; | ||
class RasterLayerPrograms; | ||
class HeatmapLayerPrograms; | ||
class HillshadeLayerPrograms; | ||
class FillLayerPrograms; | ||
class FillExtrusionLayerPrograms; | ||
class LineLayerPrograms; | ||
class SymbolLayerPrograms; | ||
|
||
class Programs { | ||
public: | ||
Programs(gl::Context& context, const ProgramParameters& programParameters) | ||
: background(context, programParameters), | ||
backgroundPattern(context, programParameters), | ||
circle(context, programParameters), | ||
extrusionTexture(context, programParameters), | ||
fill(context, programParameters), | ||
fillExtrusion(context, programParameters), | ||
fillExtrusionPattern(context, programParameters), | ||
fillPattern(context, programParameters), | ||
fillOutline(context, programParameters), | ||
fillOutlinePattern(context, programParameters), | ||
heatmap(context, programParameters), | ||
heatmapTexture(context, programParameters), | ||
hillshade(context, programParameters), | ||
hillshadePrepare(context, programParameters), | ||
line(context, programParameters), | ||
lineGradient(context, programParameters), | ||
lineSDF(context, programParameters), | ||
linePattern(context, programParameters), | ||
raster(context, programParameters), | ||
symbolIcon(context, programParameters), | ||
symbolIconSDF(context, programParameters), | ||
symbolGlyph(context, programParameters), | ||
debug(context, programParameters), | ||
collisionBox(context, programParameters), | ||
collisionCircle(context, programParameters), | ||
clippingMask(context, programParameters) { | ||
} | ||
Programs(gl::Context&, const ProgramParameters&); | ||
~Programs(); | ||
|
||
BackgroundProgram background; | ||
BackgroundPatternProgram backgroundPattern; | ||
ProgramMap<CircleProgram> circle; | ||
ExtrusionTextureProgram extrusionTexture; | ||
ProgramMap<FillProgram> fill; | ||
ProgramMap<FillExtrusionProgram> fillExtrusion; | ||
ProgramMap<FillExtrusionPatternProgram> fillExtrusionPattern; | ||
ProgramMap<FillPatternProgram> fillPattern; | ||
ProgramMap<FillOutlineProgram> fillOutline; | ||
ProgramMap<FillOutlinePatternProgram> fillOutlinePattern; | ||
ProgramMap<HeatmapProgram> heatmap; | ||
HeatmapTextureProgram heatmapTexture; | ||
HillshadeProgram hillshade; | ||
HillshadePrepareProgram hillshadePrepare; | ||
ProgramMap<LineProgram> line; | ||
ProgramMap<LineGradientProgram> lineGradient; | ||
ProgramMap<LineSDFProgram> lineSDF; | ||
ProgramMap<LinePatternProgram> linePattern; | ||
RasterProgram raster; | ||
ProgramMap<SymbolIconProgram> symbolIcon; | ||
ProgramMap<SymbolSDFIconProgram> symbolIconSDF; | ||
ProgramMap<SymbolSDFTextProgram> symbolGlyph; | ||
BackgroundLayerPrograms& getBackgroundLayerPrograms() noexcept; | ||
RasterLayerPrograms& getRasterLayerPrograms() noexcept; | ||
HeatmapLayerPrograms& getHeatmapLayerPrograms() noexcept; | ||
CircleLayerPrograms& getCircleLayerPrograms() noexcept; | ||
HillshadeLayerPrograms& getHillshadeLayerPrograms() noexcept; | ||
FillLayerPrograms& getFillLayerPrograms() noexcept; | ||
FillExtrusionLayerPrograms& getFillExtrusionLayerPrograms() noexcept; | ||
LineLayerPrograms& getLineLayerPrograms() noexcept; | ||
SymbolLayerPrograms& getSymbolLayerPrograms() noexcept; | ||
|
||
DebugProgram debug; | ||
CollisionBoxProgram collisionBox; | ||
CollisionCircleProgram collisionCircle; | ||
ClippingMaskProgram clippingMask; | ||
|
||
private: | ||
std::unique_ptr<LayerTypePrograms> backgroundPrograms; | ||
std::unique_ptr<LayerTypePrograms> circlePrograms; | ||
std::unique_ptr<LayerTypePrograms> rasterPrograms; | ||
std::unique_ptr<LayerTypePrograms> heatmapPrograms; | ||
std::unique_ptr<LayerTypePrograms> hillshadePrograms; | ||
std::unique_ptr<LayerTypePrograms> fillPrograms; | ||
std::unique_ptr<LayerTypePrograms> fillExtrusionPrograms; | ||
std::unique_ptr<LayerTypePrograms> linePrograms; | ||
std::unique_ptr<LayerTypePrograms> symbolPrograms; | ||
|
||
gl::Context& context; | ||
ProgramParameters programParameters; | ||
}; | ||
|
||
} // namespace mbgl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.