Fix issue caused by frustum offset when map is resized (#4015)

This commit is contained in:
Alex Cristici
2025-12-18 18:56:29 +02:00
committed by GitHub
parent 598ff87c2e
commit ee9ddebc33
10 changed files with 43 additions and 22 deletions

View File

@@ -1,5 +1,9 @@
# Changelog MapLibre Native for Android
## 12.3.1
- Fix issue caused by frustum offset when map is resized [#4015](https://github.com/maplibre/maplibre-native/pull/4015).
## 12.3.0
### ✨ Features and improvements

View File

@@ -1 +1 @@
12.3.0
12.3.1

View File

@@ -2,6 +2,10 @@
MapLibre welcomes participation and contributions from everyone. Please read [`MapLibre iOS Developer Guide`](https://maplibre.org/maplibre-native/docs/book/ios/index.html) to get started.
## 6.22.1
- Fix issue caused by frustum offset when map is resized [#4015](https://github.com/maplibre/maplibre-native/pull/4015).
## 6.22.0
- Implemented synchronous update for GeoJSON source ([#3968](https://github.com/maplibre/maplibre-native/pull/3968)).

View File

@@ -1 +1 @@
6.22.0
6.22.1

View File

@@ -230,7 +230,9 @@ void RenderPass::setScissorRect(MTL::ScissorRect rect) {
if (rect.height + rect.y > height) {
rect.height = height - rect.y;
}
encoder->setScissorRect(rect);
if (rect.x != 0 || rect.y != 0 || rect.width != 0 || rect.height != 0) {
encoder->setScissorRect(rect);
}
currentScissorRect = rect;
}
}

View File

@@ -71,9 +71,8 @@ void RenderTarget::render(RenderOrchestrator& orchestrator, const RenderTree& re
.clearDepth = {},
.clearStencil = {}});
const gfx::ScissorRect prevSicssorRect = parameters.scissorRect;
const auto& size = getTexture()->getSize();
parameters.scissorRect = {.x = 0, .y = 0, .width = size.width, .height = size.height};
const gfx::ScissorRect prevScissorRect = parameters.scissorRect;
parameters.scissorRect = {.x = 0, .y = 0, .width = 0, .height = 0};
// Run layer tweakers to update any dynamic elements
parameters.currentLayer = 0;
@@ -109,7 +108,7 @@ void RenderTarget::render(RenderOrchestrator& orchestrator, const RenderTree& re
parameters.renderPass.reset();
parameters.encoder->present(*offscreenTexture);
parameters.scissorRect = prevSicssorRect;
parameters.scissorRect = prevScissorRect;
}
} // namespace mbgl

View File

@@ -188,16 +188,20 @@ void Renderer::Impl::render(const RenderTree& renderTree, const std::shared_ptr<
const TransformState& state = renderTreeParameters.transformParams.state;
const Size& size = state.getSize();
const EdgeInsets& frustumOffset = state.getFrustumOffset();
const gfx::ScissorRect scissorRect = {
.x = static_cast<int32_t>(frustumOffset.left() * pixelRatio),
gfx::ScissorRect scissorRect = {.x = 0, .y = 0, .width = 0, .height = 0};
if (!frustumOffset.isFlush()) {
scissorRect = {
.x = static_cast<int32_t>(frustumOffset.left() * pixelRatio),
#if MLN_RENDER_BACKEND_OPENGL
.y = static_cast<int32_t>(frustumOffset.bottom() * pixelRatio),
.y = static_cast<int32_t>(frustumOffset.bottom() * pixelRatio),
#else
.y = static_cast<int32_t>(frustumOffset.top() * pixelRatio),
.y = static_cast<int32_t>(frustumOffset.top() * pixelRatio),
#endif
.width = static_cast<uint32_t>((size.width - (frustumOffset.left() + frustumOffset.right())) * pixelRatio),
.height = static_cast<uint32_t>((size.height - (frustumOffset.top() + frustumOffset.bottom())) * pixelRatio),
};
.width = static_cast<uint32_t>((size.width - (frustumOffset.left() + frustumOffset.right())) * pixelRatio),
.height = static_cast<uint32_t>((size.height - (frustumOffset.top() + frustumOffset.bottom())) *
pixelRatio),
};
}
PaintParameters parameters{
context,

View File

@@ -429,7 +429,10 @@ void PipelineInfo::setDynamicValues(const RendererBackend& backend, const vk::Un
const vk::Viewport viewport(0.0f, 0.0f, viewExtent.width, viewExtent.height, 0.0f, 1.0f);
buffer->setViewport(0, viewport, dispatcher);
buffer->setScissor(0, scissorRect, dispatcher);
if (scissorRect.offset.x != 0 || scissorRect.offset.y != 0 || scissorRect.extent.width != 0 ||
scissorRect.extent.height != 0) {
buffer->setScissor(0, scissorRect, dispatcher);
}
}
std::vector<vk::DynamicState> PipelineInfo::getDynamicStates(const RendererBackend& backend) const {
@@ -450,7 +453,10 @@ std::vector<vk::DynamicState> PipelineInfo::getDynamicStates(const RendererBacke
}
dynamicStates.push_back(vk::DynamicState::eViewport);
dynamicStates.push_back(vk::DynamicState::eScissor);
if (scissorRect.offset.x != 0 || scissorRect.offset.y != 0 || scissorRect.extent.width != 0 ||
scissorRect.extent.height != 0) {
dynamicStates.push_back(vk::DynamicState::eScissor);
}
return dynamicStates;
}

View File

@@ -841,11 +841,14 @@ void Drawable::draw(PaintParameters& parameters) const {
return;
}
wgpuRenderPassEncoderSetScissorRect(renderPassEncoder,
parameters.scissorRect.x,
parameters.scissorRect.y,
parameters.scissorRect.width,
parameters.scissorRect.height);
if (parameters.scissorRect.x != 0 || parameters.scissorRect.y != 0 || parameters.scissorRect.width != 0 ||
parameters.scissorRect.height != 0) {
wgpuRenderPassEncoderSetScissorRect(renderPassEncoder,
parameters.scissorRect.x,
parameters.scissorRect.y,
parameters.scissorRect.width,
parameters.scissorRect.height);
}
uint32_t bufferSlot = 0;
for (const auto& binding : uniqueBindings) {

View File

@@ -175,7 +175,6 @@ RenderPass::RenderPass(CommandEncoder& commandEncoder_, const char* name, const
auto size = descriptor.renderable.getSize();
wgpuRenderPassEncoderSetViewport(
impl->encoder, 0.0f, 0.0f, static_cast<float>(size.width), static_cast<float>(size.height), 0.0f, 1.0f);
wgpuRenderPassEncoderSetScissorRect(impl->encoder, 0, 0, size.width, size.height);
} else {
mbgl::Log::Error(mbgl::Event::Render, "WebGPU: Failed to begin render pass");
impl->colorView = nullptr;