[core] do not call glStencilFunc when we're not clipping
This commit is contained in:
@@ -38,6 +38,8 @@ public:
|
||||
|
||||
virtual bool hasData() const = 0;
|
||||
|
||||
virtual bool needsClipping() const = 0;
|
||||
|
||||
inline bool needsUpload() const {
|
||||
return !uploaded;
|
||||
}
|
||||
|
||||
@@ -31,6 +31,10 @@ bool CircleBucket::hasData() const {
|
||||
return !triangleGroups_.empty();
|
||||
}
|
||||
|
||||
bool CircleBucket::needsClipping() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
void CircleBucket::addGeometry(const GeometryCollection& geometryCollection) {
|
||||
for (auto& circle : geometryCollection) {
|
||||
for(auto & geometry : circle) {
|
||||
|
||||
@@ -23,6 +23,7 @@ public:
|
||||
void render(Painter&, const StyleLayer&, const TileID&, const mat4&) override;
|
||||
|
||||
bool hasData() const override;
|
||||
bool needsClipping() const override;
|
||||
void addGeometry(const GeometryCollection&);
|
||||
|
||||
void drawCircles(CircleShader&, gl::GLObjectStore&);
|
||||
|
||||
@@ -206,6 +206,10 @@ bool FillBucket::hasData() const {
|
||||
return !triangleGroups.empty() || !lineGroups.empty();
|
||||
}
|
||||
|
||||
bool FillBucket::needsClipping() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
void FillBucket::drawElements(PlainShader& shader, gl::GLObjectStore& glObjectStore) {
|
||||
GLbyte* vertex_index = BUFFER_OFFSET(0);
|
||||
GLbyte* elements_index = BUFFER_OFFSET(0);
|
||||
|
||||
@@ -35,6 +35,7 @@ public:
|
||||
void upload(gl::GLObjectStore&) override;
|
||||
void render(Painter&, const StyleLayer&, const TileID&, const mat4&) override;
|
||||
bool hasData() const override;
|
||||
bool needsClipping() const override;
|
||||
|
||||
void addGeometry(const GeometryCollection&);
|
||||
void tessellate();
|
||||
|
||||
@@ -452,6 +452,10 @@ bool LineBucket::hasData() const {
|
||||
return !triangleGroups.empty();
|
||||
}
|
||||
|
||||
bool LineBucket::needsClipping() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
void LineBucket::drawLines(LineShader& shader, gl::GLObjectStore& glObjectStore) {
|
||||
GLbyte* vertex_index = BUFFER_OFFSET(0);
|
||||
GLbyte* elements_index = BUFFER_OFFSET(0);
|
||||
|
||||
@@ -30,6 +30,7 @@ public:
|
||||
void upload(gl::GLObjectStore&) override;
|
||||
void render(Painter&, const StyleLayer&, const TileID&, const mat4&) override;
|
||||
bool hasData() const override;
|
||||
bool needsClipping() const override;
|
||||
|
||||
void addGeometry(const GeometryCollection&);
|
||||
void addGeometry(const GeometryCoordinates& line);
|
||||
|
||||
@@ -74,9 +74,9 @@ bool Painter::needsAnimation() const {
|
||||
return frameHistory.needsAnimation(util::DEFAULT_FADE_DURATION);
|
||||
}
|
||||
|
||||
void Painter::prepareTile(const Tile& tile) {
|
||||
const GLint ref = (GLint)tile.clip.reference.to_ulong();
|
||||
const GLuint mask = (GLuint)tile.clip.mask.to_ulong();
|
||||
void Painter::setClipping(const ClipID& clip) {
|
||||
const GLint ref = (GLint)clip.reference.to_ulong();
|
||||
const GLuint mask = (GLuint)clip.mask.to_ulong();
|
||||
config.stencilFunc = { GL_EQUAL, ref, mask };
|
||||
}
|
||||
|
||||
@@ -249,7 +249,9 @@ void Painter::renderPass(RenderPass pass_,
|
||||
config.setDirty();
|
||||
} else {
|
||||
MBGL_DEBUG_GROUP(layer.id + " - " + std::string(item.tile->id));
|
||||
prepareTile(*item.tile);
|
||||
if (item.bucket->needsClipping()) {
|
||||
setClipping(item.tile->clip);
|
||||
}
|
||||
item.bucket->render(*this, layer, item.tile->id, item.tile->matrix);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ private:
|
||||
Iterator it, Iterator end,
|
||||
GLsizei i, int8_t increment);
|
||||
|
||||
void prepareTile(const Tile& tile);
|
||||
void setClipping(const ClipID&);
|
||||
|
||||
template <typename BucketProperties, typename StyleProperties>
|
||||
void renderSDF(SymbolBucket &bucket,
|
||||
|
||||
@@ -13,7 +13,7 @@ void Painter::renderTileDebug(const Tile& tile) {
|
||||
MBGL_DEBUG_GROUP(std::string { "debug " } + std::string(tile.id));
|
||||
assert(tile.data);
|
||||
if (data.getDebug() != MapDebugOptions::NoDebug) {
|
||||
prepareTile(tile);
|
||||
setClipping(tile.clip);
|
||||
if (data.getDebug() & (MapDebugOptions::Timestamps | MapDebugOptions::ParseStatus)) {
|
||||
renderDebugText(*tile.data, tile.matrix);
|
||||
}
|
||||
|
||||
@@ -37,3 +37,7 @@ void RasterBucket::drawRaster(RasterShader& shader, StaticVertexBuffer &vertices
|
||||
bool RasterBucket::hasData() const {
|
||||
return raster.isLoaded();
|
||||
}
|
||||
|
||||
bool RasterBucket::needsClipping() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ public:
|
||||
void upload(gl::GLObjectStore&) override;
|
||||
void render(Painter&, const StyleLayer&, const TileID&, const mat4&) override;
|
||||
bool hasData() const override;
|
||||
bool needsClipping() const override;
|
||||
|
||||
void setImage(PremultipliedImage);
|
||||
|
||||
|
||||
@@ -95,6 +95,10 @@ bool SymbolBucket::hasIconData() const { return renderData && !renderData->icon.
|
||||
|
||||
bool SymbolBucket::hasCollisionBoxData() const { return renderData && !renderData->collisionBox.groups.empty(); }
|
||||
|
||||
bool SymbolBucket::needsClipping() const {
|
||||
return mode == MapMode::Still;
|
||||
}
|
||||
|
||||
void SymbolBucket::parseFeatures(const GeometryTileLayer& layer,
|
||||
const FilterExpression& filter) {
|
||||
const bool has_text = !layout.text.field.value.empty() && !layout.text.font.value.empty();
|
||||
|
||||
@@ -76,6 +76,7 @@ public:
|
||||
bool hasTextData() const;
|
||||
bool hasIconData() const;
|
||||
bool hasCollisionBoxData() const;
|
||||
bool needsClipping() const override;
|
||||
|
||||
void addFeatures(uintptr_t tileUID,
|
||||
SpriteAtlas&,
|
||||
|
||||
Reference in New Issue
Block a user