[core] Replace createRender{Source,Layer} with Render{Source,Layer}::create

* Eliminates the need for EnableImmutableFromThis
* Eliminates the dependency of {Source,Layer}::Impl on corresponding Render class (circular dependency)
This commit is contained in:
John Firebaugh
2017-05-11 10:29:37 -07:00
parent afead4e749
commit 095dc7b167
43 changed files with 91 additions and 117 deletions

View File

@@ -1,9 +1,35 @@
#include <mbgl/renderer/render_source.hpp>
#include <mbgl/renderer/render_source_observer.hpp>
#include <mbgl/renderer/sources/render_geojson_source.hpp>
#include <mbgl/renderer/sources/render_raster_source.hpp>
#include <mbgl/renderer/sources/render_vector_source.hpp>
#include <mbgl/annotation/render_annotation_source.hpp>
#include <mbgl/tile/tile.hpp>
namespace mbgl {
using namespace style;
std::unique_ptr<RenderSource> RenderSource::create(Immutable<Source::Impl> impl) {
switch (impl->type) {
case SourceType::Vector:
return std::make_unique<RenderVectorSource>(staticImmutableCast<VectorSource::Impl>(impl));
case SourceType::Raster:
return std::make_unique<RenderRasterSource>(staticImmutableCast<RasterSource::Impl>(impl));
case SourceType::GeoJSON:
return std::make_unique<RenderGeoJSONSource>(staticImmutableCast<GeoJSONSource::Impl>(impl));
case SourceType::Video:
assert(false);
return nullptr;
case SourceType::Annotations:
return std::make_unique<RenderAnnotationSource>(staticImmutableCast<AnnotationSource::Impl>(impl));
}
// Not reachable, but placate GCC.
assert(false);
return nullptr;
}
static RenderSourceObserver nullObserver;
RenderSource::RenderSource(Immutable<style::Source::Impl> impl)