Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[core] fix rendering of fill outlines that have a different color tha…
Browse files Browse the repository at this point in the history
…n the fill itself
  • Loading branch information
kkaefer committed Aug 4, 2017
1 parent 466728b commit b70ba6d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 37 deletions.
2 changes: 1 addition & 1 deletion mapbox-gl-js
Submodule mapbox-gl-js updated 158 files
7 changes: 1 addition & 6 deletions platform/node/test/ignores.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@
"render-tests/fill-extrusion-pattern/literal": "https://github.com/mapbox/mapbox-gl-js/issues/3327",
"render-tests/fill-extrusion-pattern/missing": "https://github.com/mapbox/mapbox-gl-js/issues/3327",
"render-tests/fill-extrusion-pattern/opacity": "https://github.com/mapbox/mapbox-gl-js/issues/3327",
"render-tests/fill-outline-color/fill": "https://github.com/mapbox/mapbox-gl-native/pull/8760",
"render-tests/fill-outline-color/function": "https://github.com/mapbox/mapbox-gl-native/issues/6927",
"render-tests/fill-outline-color/literal": "https://github.com/mapbox/mapbox-gl-native/issues/6927",
"render-tests/fill-outline-color/multiply": "https://github.com/mapbox/mapbox-gl-native/issues/6927",
"render-tests/fill-outline-color/opacity": "https://github.com/mapbox/mapbox-gl-native/issues/6927",
"render-tests/fill-outline-color/zoom-and-property-function": "https://github.com/mapbox/mapbox-gl-native/issues/6927",
"render-tests/geojson/inline-linestring-fill": "current behavior is arbitrary",
"render-tests/geojson/inline-polygon-symbol": "behavior needs reconciliation with gl-js",
"render-tests/icon-size/composite-function-high-base-plain": "https://github.com/mapbox/mapbox-gl-native/issues/8654",
Expand All @@ -46,6 +40,7 @@
"render-tests/line-join/property-function": "https://github.com/mapbox/mapbox-gl-js/pull/5020",
"render-tests/line-join/property-function-dasharray": "https://github.com/mapbox/mapbox-gl-js/pull/5020",
"render-tests/regressions/mapbox-gl-js#2305": "https://github.com/mapbox/mapbox-gl-native/issues/6927",
"render-tests/regressions/mapbox-gl-js#2929": "skip - needs issue",
"render-tests/regressions/mapbox-gl-js#3010": "skip - needs issue",
"render-tests/regressions/mapbox-gl-js#3548": "skip - needs issue",
"render-tests/regressions/mapbox-gl-js#3682": "https://github.com/mapbox/mapbox-gl-js/issues/3682",
Expand Down
52 changes: 22 additions & 30 deletions src/mbgl/renderer/layers/render_fill_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ void RenderFillLayer::render(PaintParameters& parameters, RenderSource*) {
assert(dynamic_cast<FillBucket*>(tile.tile.getBucket(*baseImpl)));
FillBucket& bucket = *reinterpret_cast<FillBucket*>(tile.tile.getBucket(*baseImpl));

auto draw = [&] (uint8_t sublayer,
auto& program,
auto draw = [&] (auto& program,
const auto& drawMode,
const auto& depthMode,
const auto& indexBuffer,
const auto& segments) {
program.get(evaluated).draw(
parameters.context,
drawMode,
parameters.depthModeForSublayer(sublayer, gl::DepthMode::ReadWrite),
depthMode,
parameters.stencilModeForClipping(tile.clip),
parameters.colorModeForRenderPass(),
FillProgram::UniformValues {
Expand All @@ -93,29 +93,23 @@ void RenderFillLayer::render(PaintParameters& parameters, RenderSource*) {
);
};

if (evaluated.get<FillAntialias>() && !unevaluated.get<FillOutlineColor>().isUndefined() && parameters.pass == RenderPass::Translucent) {
draw(2,
parameters.programs.fillOutline,
gl::Lines { 2.0f },
*bucket.lineIndexBuffer,
bucket.lineSegments);
}

// Only draw the fill when it's opaque and we're drawing opaque fragments,
// or when it's translucent and we're drawing translucent fragments.
if ((evaluated.get<FillColor>().constantOr(Color()).a >= 1.0f
&& evaluated.get<FillOpacity>().constantOr(0) >= 1.0f) == (parameters.pass == RenderPass::Opaque)) {
draw(1,
parameters.programs.fill,
draw(parameters.programs.fill,
gl::Triangles(),
parameters.depthModeForSublayer(1, gl::DepthMode::ReadWrite),
*bucket.triangleIndexBuffer,
bucket.triangleSegments);
}

if (evaluated.get<FillAntialias>() && unevaluated.get<FillOutlineColor>().isUndefined() && parameters.pass == RenderPass::Translucent) {
draw(2,
parameters.programs.fillOutline,
gl::Lines { 2.0f },
if (evaluated.get<FillAntialias>() && parameters.pass == RenderPass::Translucent) {
draw(parameters.programs.fillOutline,
gl::Lines{ 2.0f },
parameters.depthModeForSublayer(
unevaluated.get<FillOutlineColor>().isUndefined() ? 2 : 0,
gl::DepthMode::ReadOnly),
*bucket.lineIndexBuffer,
bucket.lineSegments);
}
Expand All @@ -138,15 +132,15 @@ void RenderFillLayer::render(PaintParameters& parameters, RenderSource*) {
assert(dynamic_cast<FillBucket*>(tile.tile.getBucket(*baseImpl)));
FillBucket& bucket = *reinterpret_cast<FillBucket*>(tile.tile.getBucket(*baseImpl));

auto draw = [&] (uint8_t sublayer,
auto& program,
auto draw = [&] (auto& program,
const auto& drawMode,
const auto& depthMode,
const auto& indexBuffer,
const auto& segments) {
program.get(evaluated).draw(
parameters.context,
drawMode,
parameters.depthModeForSublayer(sublayer, gl::DepthMode::ReadWrite),
depthMode,
parameters.stencilModeForClipping(tile.clip),
parameters.colorModeForRenderPass(),
FillPatternUniforms::values(
Expand All @@ -171,21 +165,19 @@ void RenderFillLayer::render(PaintParameters& parameters, RenderSource*) {
);
};

draw(0,
parameters.programs.fillPattern,
draw(parameters.programs.fillPattern,
gl::Triangles(),
parameters.depthModeForSublayer(1, gl::DepthMode::ReadWrite),
*bucket.triangleIndexBuffer,
bucket.triangleSegments);

if (!evaluated.get<FillAntialias>() || !unevaluated.get<FillOutlineColor>().isUndefined()) {
continue;
if (evaluated.get<FillAntialias>() && unevaluated.get<FillOutlineColor>().isUndefined()) {
draw(parameters.programs.fillOutlinePattern,
gl::Lines { 2.0f },
parameters.depthModeForSublayer(2, gl::DepthMode::ReadOnly),
*bucket.lineIndexBuffer,
bucket.lineSegments);
}

draw(2,
parameters.programs.fillOutlinePattern,
gl::Lines { 2.0f },
*bucket.lineIndexBuffer,
bucket.lineSegments);
}
}
}
Expand Down

0 comments on commit b70ba6d

Please sign in to comment.