Merge branch 'master' into perspective-without-y-flip
This commit is contained in:
@@ -334,7 +334,6 @@ bool MapContext::renderSync(const TransformState& state, const FrameData& frame)
|
||||
if (!painter) {
|
||||
painter = std::make_unique<Painter>(data);
|
||||
painter->setup();
|
||||
painter->updateRenderOrder(*style);
|
||||
}
|
||||
|
||||
painter->setDebug(data.getDebug());
|
||||
@@ -401,10 +400,6 @@ void MapContext::setSprite(const std::string& name, std::shared_ptr<const Sprite
|
||||
void MapContext::onTileDataChanged() {
|
||||
assert(util::ThreadContext::currentlyOn(util::ThreadType::Map));
|
||||
|
||||
if (painter) {
|
||||
painter->updateRenderOrder(*style);
|
||||
}
|
||||
|
||||
updateFlags |= Update::Repaint;
|
||||
asyncUpdate->send();
|
||||
}
|
||||
|
||||
@@ -530,14 +530,9 @@ void Source::invalidateTiles(const std::unordered_set<TileID, TileID::Hash>& ids
|
||||
}
|
||||
|
||||
void Source::updateTilePtrs() {
|
||||
std::vector<Tile*> newPtrs;
|
||||
tilePtrs.clear();
|
||||
for (const auto& pair : tiles) {
|
||||
newPtrs.push_back(pair.second.get());
|
||||
}
|
||||
|
||||
if (tilePtrs != newPtrs) {
|
||||
tilePtrs = newPtrs;
|
||||
emitTileLoaded(true);
|
||||
tilePtrs.push_back(pair.second.get());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
#include <mbgl/util/mat4.hpp>
|
||||
|
||||
#include <atomic>
|
||||
|
||||
#define BUFFER_OFFSET(i) ((char*)nullptr + (i))
|
||||
|
||||
namespace mbgl {
|
||||
@@ -16,6 +18,8 @@ class CollisionTile;
|
||||
|
||||
class Bucket : private util::noncopyable {
|
||||
public:
|
||||
Bucket() : uploaded(false) {}
|
||||
|
||||
// As long as this bucket has a Prepare render pass, this function is getting called. Typically,
|
||||
// this only happens once when the bucket is being rendered for the first time.
|
||||
virtual void upload() = 0;
|
||||
@@ -34,7 +38,7 @@ public:
|
||||
virtual void swapRenderData() {}
|
||||
|
||||
protected:
|
||||
bool uploaded = false;
|
||||
std::atomic<bool> uploaded;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -178,6 +178,9 @@ void Painter::render(const Style& style, TransformState state_, const FrameData&
|
||||
resize();
|
||||
changeMatrix();
|
||||
|
||||
// Figure out what buckets we have to draw and what order we have to draw them in.
|
||||
const auto order = determineRenderOrder(style);
|
||||
|
||||
// - UPLOAD PASS -------------------------------------------------------------------------------
|
||||
// Uploads all required buffers and images before we do any actual rendering.
|
||||
{
|
||||
@@ -196,6 +199,7 @@ void Painter::render(const Style& style, TransformState state_, const FrameData&
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// - CLIPPING MASKS ----------------------------------------------------------------------------
|
||||
// Draws the clipping masks to the stencil buffer.
|
||||
{
|
||||
@@ -265,8 +269,6 @@ void Painter::renderPass(RenderPass pass_,
|
||||
std::size_t i, int8_t increment) {
|
||||
pass = pass_;
|
||||
|
||||
const double zoom = state.getZoom();
|
||||
|
||||
MBGL_DEBUG_GROUP(pass == RenderPass::Opaque ? "opaque" : "translucent");
|
||||
|
||||
if (debug::renderTree) {
|
||||
@@ -280,13 +282,6 @@ void Painter::renderPass(RenderPass pass_,
|
||||
currentLayer = i;
|
||||
const auto& item = *it;
|
||||
if (item.bucket && item.tile) {
|
||||
// Skip this layer if it's outside the range of min/maxzoom.
|
||||
// This may occur when there /is/ a bucket created for this layer, but the min/max-zoom
|
||||
// is set to a fractional value, or value that is larger than the source maxzoom.
|
||||
if (item.layer.bucket->min_zoom > zoom ||
|
||||
item.layer.bucket->max_zoom <= zoom) {
|
||||
continue;
|
||||
}
|
||||
if (item.layer.hasRenderPass(pass)) {
|
||||
MBGL_DEBUG_GROUP(item.layer.id + " - " + std::string(item.tile->id));
|
||||
prepareTile(*item.tile);
|
||||
@@ -303,8 +298,8 @@ void Painter::renderPass(RenderPass pass_,
|
||||
}
|
||||
}
|
||||
|
||||
void Painter::updateRenderOrder(const Style& style) {
|
||||
order.clear();
|
||||
std::vector<RenderItem> Painter::determineRenderOrder(const Style& style) {
|
||||
std::vector<RenderItem> order;
|
||||
|
||||
for (const auto& layerPtr : style.layers) {
|
||||
const auto& layer = *layerPtr;
|
||||
@@ -341,6 +336,15 @@ void Painter::updateRenderOrder(const Style& style) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip this layer if it's outside the range of min/maxzoom.
|
||||
// This may occur when there /is/ a bucket created for this layer, but the min/max-zoom
|
||||
// is set to a fractional value, or value that is larger than the source maxzoom.
|
||||
const double zoom = state.getZoom();
|
||||
if (layer.bucket->min_zoom > zoom ||
|
||||
layer.bucket->max_zoom <= zoom) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto& tiles = source->getTiles();
|
||||
for (auto tile : tiles) {
|
||||
assert(tile);
|
||||
@@ -354,6 +358,8 @@ void Painter::updateRenderOrder(const Style& style) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return order;
|
||||
}
|
||||
|
||||
void Painter::renderBackground(const StyleLayer &layer_desc) {
|
||||
|
||||
@@ -134,12 +134,12 @@ public:
|
||||
|
||||
bool needsAnimation() const;
|
||||
|
||||
void updateRenderOrder(const Style& style);
|
||||
|
||||
private:
|
||||
void setupShaders();
|
||||
mat4 translatedMatrix(const mat4& matrix, const std::array<float, 2> &translation, const TileID &id, TranslateAnchorType anchor);
|
||||
|
||||
std::vector<RenderItem> determineRenderOrder(const Style& style);
|
||||
|
||||
template <class Iterator>
|
||||
void renderPass(RenderPass,
|
||||
Iterator it, Iterator end,
|
||||
@@ -200,8 +200,6 @@ private:
|
||||
RenderPass pass = RenderPass::Opaque;
|
||||
Color background = {{ 0, 0, 0, 0 }};
|
||||
|
||||
std::vector<RenderItem> order;
|
||||
|
||||
int numSublayers = 3;
|
||||
size_t currentLayer;
|
||||
float depthRangeSize;
|
||||
|
||||
Reference in New Issue
Block a user