-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Self Masking for Vector Layers #584
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,9 +98,21 @@ void PolygonGroup2dOpenGl::render(const std::shared_ptr<::RenderingContextInterf | |
if (!ready) | ||
return; | ||
|
||
GLuint stencilMask = 0; | ||
GLuint validTarget = 0; | ||
GLenum zpass = GL_KEEP; | ||
if (isMasked) { | ||
glStencilFunc(GL_EQUAL, isMaskInversed ? 0 : 128, 128); | ||
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); | ||
stencilMask += 128; | ||
validTarget = isMaskInversed ? 0 : 128; | ||
} | ||
if (renderPass.isPassMasked) { | ||
stencilMask += 127; | ||
zpass = GL_INCR; | ||
} | ||
|
||
if (stencilMask != 0) { | ||
glStencilFunc(GL_EQUAL, validTarget, stencilMask); | ||
glStencilOp(GL_KEEP, GL_KEEP, zpass); | ||
Comment on lines
+101
to
+115
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The implementation of stencil operations in the
Consider adding comments to explain the rationale behind the chosen stencil operation values, especially the significance of |
||
} | ||
|
||
std::shared_ptr<OpenGlContext> openGlContext = std::static_pointer_cast<OpenGlContext>(context); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -193,9 +193,21 @@ void Quad2dOpenGl::render(const std::shared_ptr<::RenderingContextInterface> &co | |
|
||
glUseProgram(program); | ||
|
||
GLuint stencilMask = 0; | ||
GLuint validTarget = 0; | ||
GLenum zpass = GL_KEEP; | ||
if (isMasked) { | ||
glStencilFunc(GL_EQUAL, isMaskInversed ? 0 : 128, 128); | ||
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); | ||
stencilMask += 128; | ||
validTarget = isMaskInversed ? 0 : 128; | ||
} | ||
if (renderPass.isPassMasked) { | ||
stencilMask += 127; | ||
zpass = GL_INCR; | ||
} | ||
|
||
if (stencilMask != 0) { | ||
glStencilFunc(GL_EQUAL, validTarget, stencilMask); | ||
glStencilOp(GL_KEEP, GL_KEEP, zpass); | ||
Comment on lines
+196
to
+210
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The modifications to the
Adding comments to explain the rationale behind the chosen stencil operation values and ensuring that the implementation is robust against all possible combinations of masking conditions would improve code clarity and maintainability. |
||
} | ||
|
||
if (usesTextureCoords) { | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,14 +134,15 @@ class LineVectorLayerDescription: public VectorLayerDescription { | |
LineVectorStyle style, | ||
std::optional<int32_t> renderPassIndex, | ||
std::shared_ptr<Value> interactable, | ||
bool multiselect): | ||
VectorLayerDescription(identifier, source, sourceId, minZoom, maxZoom, filter, renderPassIndex, interactable, multiselect), | ||
bool multiselect, | ||
bool selfMasked): | ||
VectorLayerDescription(identifier, source, sourceId, minZoom, maxZoom, filter, renderPassIndex, interactable, multiselect, selfMasked), | ||
style(style) {}; | ||
|
||
std::unique_ptr<VectorLayerDescription> clone() override { | ||
return std::make_unique<LineVectorLayerDescription>(identifier, source, sourceLayer, minZoom, maxZoom, | ||
filter ? filter->clone() : nullptr, style, renderPassIndex, | ||
interactable ? interactable->clone() : nullptr, multiselect); | ||
interactable ? interactable->clone() : nullptr, multiselect, selfMasked); | ||
Comment on lines
+137
to
+145
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The addition of the
Consider implementing default values for the |
||
} | ||
|
||
virtual UsedKeysCollection getUsedKeys() const override { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,7 +144,7 @@ class RasterVectorLayerDescription: public VectorLayerDescription { | |
bool underzoom, | ||
bool overzoom, | ||
std::optional<::RectCoord> bounds): | ||
VectorLayerDescription(identifier, source, "", minZoom, maxZoom, nullptr, renderPassIndex, interactable, false), | ||
VectorLayerDescription(identifier, source, "", minZoom, maxZoom, nullptr, renderPassIndex, interactable, false, false), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The introduction of an additional boolean parameter in the
Adding explicit documentation for the new parameter and its expected behavior would enhance code readability and maintainability. Consider reviewing related classes or methods that might be affected by this change to ensure consistency across the codebase. |
||
style(style), url(url), underzoom(underzoom), overzoom(overzoom), adaptScaleToScreen(adaptScaleToScreen), numDrawPreviousLayers(numDrawPreviousLayers), | ||
maskTiles(maskTiles), zoomLevelScaleFactor(zoomLevelScaleFactor), bounds(bounds) {}; | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -8,9 +8,11 @@ | |||||
|
||||||
struct RenderPassConfig final { | ||||||
int32_t renderPassIndex; | ||||||
bool isPassMasked; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The use of - : renderPassIndex(std::move(renderPassIndex_))
- , isPassMasked(std::move(isPassMasked_))
+ : renderPassIndex(renderPassIndex_)
+ , isPassMasked(isPassMasked_) Committable suggestion
Suggested change
|
||||||
|
||||||
//NOLINTNEXTLINE(google-explicit-constructor) | ||||||
RenderPassConfig(int32_t renderPassIndex_) | ||||||
RenderPassConfig(int32_t renderPassIndex_, | ||||||
bool isPassMasked_) | ||||||
: renderPassIndex(std::move(renderPassIndex_)) | ||||||
, isPassMasked(std::move(isPassMasked_)) | ||||||
{} | ||||||
}; |
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.
The modifications to the
render
method for handling stencil operations based on masking conditions are well-intended for enhancing rendering flexibility. However, consider the following:stencilMask
andvalidTarget
should be thoroughly tested to ensure it behaves as expected under all combinations ofisMasked
andrenderPass.isPassMasked
.128
and127
for modifyingstencilMask
values appears arbitrary without context. Ensure these values are documented to explain their significance and how they contribute to the intended stencil operations.GL_INCR
forzpass
assumes a specific usage pattern of the stencil buffer. Confirm that this approach is compatible with the overall rendering strategy and does not risk stencil buffer overflow, which could lead to rendering issues.Adding detailed comments to explain the logic behind the chosen values and operations would greatly aid in the maintainability of this code. Additionally, consider edge cases where the combined stencil operations might not produce the expected results and adjust or document as necessary.