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
Refactor GL context creation and headless rendering #6596
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#pragma once | ||
|
||
#if defined(__QT__) | ||
#define MBGL_USE_QT 1 | ||
#elif defined(__APPLE__) | ||
#include <TargetConditionals.h> | ||
#if TARGET_OS_IOS | ||
#define MBGL_USE_EAGL 1 | ||
#else | ||
#define MBGL_USE_CGL 1 | ||
#endif | ||
#else | ||
#define MBGL_USE_GLX 1 | ||
#endif |
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,45 @@ | ||
#pragma once | ||
|
||
#include <mbgl/map/change.hpp> | ||
|
||
#include <memory> | ||
|
||
namespace mbgl { | ||
|
||
namespace gl { | ||
class Context; | ||
} // namespace gl | ||
|
||
class Backend { | ||
public: | ||
Backend(); | ||
virtual ~Backend(); | ||
|
||
// Returns the backend's context which manages OpenGL state. | ||
gl::Context& getContext(); | ||
|
||
// Called when the backend's GL context needs to be made active or inactive. These are called, | ||
// as a matched pair, in four situations: | ||
// | ||
// 1. When releasing GL resources during Map destruction | ||
// 2. When calling a CustomLayerInitializeFunction, during Map::addLayer | ||
// 3. When calling a CustomLayerDeinitializeFunction, during Map::removeLayer | ||
// 4. When rendering for Map::renderStill | ||
// | ||
// They are *not* called for Map::render; it is assumed that the correct context is already | ||
// activated prior to calling Map::render. | ||
virtual void activate() = 0; | ||
virtual void deactivate() = 0; | ||
|
||
// Called when the map needs to be rendered; the backend should call Map::render() at some point | ||
// in the near future. (Not called for Map::renderStill() mode.) | ||
virtual void invalidate() = 0; | ||
|
||
// Notifies a watcher of map x/y/scale/rotation changes. | ||
virtual void notifyMapChange(MapChange change); | ||
|
||
private: | ||
const std::unique_ptr<gl::Context> context; | ||
}; | ||
|
||
} // 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Would it make sense as a followup to rename Headless ⇢ Offscreen for consistency?
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.
I didn't rename this to have a difference in naming: Offscreen rendering doesn't necessarily imply headless rendering (and vice versa): We can use Offscreen views/texturs in regular rendering as well.