[core] Added GLContextMode to MapData
Adding new mbgl::GLContextMode enum to mbgl::Map ctor, which gets stored in MapData. In shared GL context environments, we cannot assume that the GL state that has been left since the last draw is the same, so we reset the GL configurations to their default values.
This commit is contained in:
@@ -44,7 +44,8 @@ class Map : private util::noncopyable {
|
||||
|
||||
public:
|
||||
explicit Map(View&, FileSource&,
|
||||
MapMode mode = MapMode::Continuous);
|
||||
MapMode mapMode = MapMode::Continuous,
|
||||
GLContextMode contextMode = GLContextMode::Unique);
|
||||
~Map();
|
||||
|
||||
// Pauses the render thread. The render thread will stop running but will not be terminated and will not lose state until resumed.
|
||||
|
||||
@@ -10,6 +10,11 @@ enum class MapMode : uint8_t {
|
||||
Still, // a once-off still image
|
||||
};
|
||||
|
||||
}
|
||||
enum class GLContextMode : uint8_t {
|
||||
Unique,
|
||||
Shared,
|
||||
};
|
||||
|
||||
#endif
|
||||
} // namespace mbgl
|
||||
|
||||
#endif // MBGL_MAP_MODE
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
Map::Map(View& view_, FileSource& fileSource, MapMode mode)
|
||||
Map::Map(View& view_, FileSource& fileSource, MapMode mapMode, GLContextMode contextMode)
|
||||
: view(view_),
|
||||
transform(std::make_unique<Transform>(view)),
|
||||
data(std::make_unique<MapData>(mode, view.getPixelRatio())),
|
||||
data(std::make_unique<MapData>(mapMode, contextMode, view.getPixelRatio())),
|
||||
context(std::make_unique<util::Thread<MapContext>>(util::ThreadContext{"Map", util::ThreadType::Map, util::ThreadPriority::Regular}, view, fileSource, *data))
|
||||
{
|
||||
view.initialize(this);
|
||||
|
||||
@@ -20,8 +20,9 @@ class MapData {
|
||||
using Lock = std::lock_guard<std::mutex>;
|
||||
|
||||
public:
|
||||
inline MapData(MapMode mode_, const float pixelRatio_)
|
||||
inline MapData(MapMode mode_, GLContextMode contextMode_, const float pixelRatio_)
|
||||
: mode(mode_)
|
||||
, contextMode(contextMode_)
|
||||
, pixelRatio(pixelRatio_)
|
||||
, animationTime(Duration::zero())
|
||||
, defaultFadeDuration(mode_ == MapMode::Continuous ? std::chrono::milliseconds(300) : Duration::zero())
|
||||
@@ -125,6 +126,7 @@ public:
|
||||
|
||||
public:
|
||||
const MapMode mode;
|
||||
const GLContextMode contextMode;
|
||||
const float pixelRatio;
|
||||
|
||||
private:
|
||||
|
||||
@@ -13,7 +13,7 @@ TEST(MapContext, DoubleStyleLoad) {
|
||||
std::shared_ptr<HeadlessDisplay> display = std::make_shared<HeadlessDisplay>();
|
||||
HeadlessView view(display, 1, 512, 512);
|
||||
DefaultFileSource fileSource(nullptr);
|
||||
MapData data(MapMode::Continuous, view.getPixelRatio());
|
||||
MapData data(MapMode::Continuous, GLContextMode::Unique, view.getPixelRatio());
|
||||
|
||||
util::Thread<MapContext> context({"Map", util::ThreadType::Map, util::ThreadPriority::Regular}, view, fileSource, data);
|
||||
|
||||
|
||||
@@ -39,9 +39,10 @@ TEST_P(StyleParserTest, ParseStyle) {
|
||||
Log::setObserver(std::unique_ptr<Log::Observer>(observer));
|
||||
|
||||
MapMode mapMode = MapMode::Continuous;
|
||||
GLContextMode contextMode = GLContextMode::Unique;
|
||||
const float pixelRatio = 1.0f;
|
||||
|
||||
MapData data(mapMode, pixelRatio);
|
||||
MapData data(mapMode, contextMode, pixelRatio);
|
||||
StyleParser parser(data);
|
||||
parser.parse(styleDoc);
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
MockMapContext(View& view,
|
||||
FileSource& fileSource,
|
||||
const std::function<void(std::exception_ptr error)>& callback)
|
||||
: data_(MapMode::Still, view.getPixelRatio()),
|
||||
: data_(MapMode::Still, GLContextMode::Unique, view.getPixelRatio()),
|
||||
transform_(view),
|
||||
callback_(callback) {
|
||||
util::ThreadContext::setFileSource(&fileSource);
|
||||
|
||||
Reference in New Issue
Block a user