#include #include #include #include #include #include #include #include #include #include namespace mbgl { using namespace style; void Painter::renderLine(PaintParameters& parameters, LineBucket& bucket, const RenderLineLayer& layer, const RenderTile& tile) { if (pass == RenderPass::Opaque) { return; } const RenderLinePaintProperties::PossiblyEvaluated& properties = layer.evaluated; auto draw = [&] (auto& program, auto&& uniformValues) { program.get(properties).draw( context, gl::Triangles(), depthModeForSublayer(0, gl::DepthMode::ReadOnly), stencilModeForClipping(tile.clip), colorModeForRenderPass(), std::move(uniformValues), *bucket.vertexBuffer, *bucket.indexBuffer, bucket.segments, bucket.paintPropertyBinders.at(layer.getID()), properties, state.getZoom() ); }; if (!properties.get().from.empty()) { const LinePatternCap cap = bucket.layout.get() == LineCapType::Round ? LinePatternCap::Round : LinePatternCap::Square; LinePatternPos posA = lineAtlas->getDashPosition(properties.get().from, cap); LinePatternPos posB = lineAtlas->getDashPosition(properties.get().to, cap); lineAtlas->bind(context, 0); draw(parameters.programs.lineSDF, LineSDFProgram::uniformValues( properties, frame.pixelRatio, tile, state, pixelsToGLUnits, posA, posB, lineAtlas->getSize().width)); } else if (!properties.get().from.empty()) { optional posA = imageManager->getPattern(properties.get().from); optional posB = imageManager->getPattern(properties.get().to); if (!posA || !posB) return; imageManager->bind(context, 0); draw(parameters.programs.linePattern, LinePatternProgram::uniformValues( properties, tile, state, pixelsToGLUnits, imageManager->getPixelSize(), *posA, *posB)); } else { draw(parameters.programs.line, LineProgram::uniformValues( properties, tile, state, pixelsToGLUnits)); } } } // namespace mbgl