summaryrefslogtreecommitdiff
path: root/src/mbgl/renderer/painter_circle.cpp
blob: 462ed59ebfe77bcd3b83a9a0029c7a194669a19f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <mbgl/renderer/painter.hpp>
#include <mbgl/renderer/paint_parameters.hpp>
#include <mbgl/renderer/circle_bucket.hpp>
#include <mbgl/renderer/render_tile.hpp>

#include <mbgl/style/layers/circle_layer.hpp>
#include <mbgl/style/layers/circle_layer_impl.hpp>

#include <mbgl/shader/shaders.hpp>

namespace mbgl {

using namespace style;

void Painter::renderCircle(PaintParameters& parameters,
                           CircleBucket& bucket,
                           const CircleLayer& layer,
                           const RenderTile& tile) {
    // Abort early.
    if (pass == RenderPass::Opaque) return;

    context.stencilTest = frame.mapMode == MapMode::Still;
    context.depthFunc = gl::DepthTestFunction::LessEqual;
    context.depthTest = true;
    context.depthMask = false;
    setDepthSublayer(0);

    const CirclePaintProperties& properties = layer.impl->paint;
    auto& circleShader = parameters.shaders.circle;

    context.program = circleShader.getID();

    circleShader.u_matrix = tile.translatedMatrix(properties.circleTranslate,
                                                  properties.circleTranslateAnchor,
                                                  state);

    if (properties.circlePitchScale == CirclePitchScaleType::Map) {
        circleShader.u_extrude_scale = {{
            pixelsToGLUnits[0] * state.getAltitude(),
            pixelsToGLUnits[1] * state.getAltitude()
        }};
        circleShader.u_scale_with_map = true;
    } else {
        circleShader.u_extrude_scale = pixelsToGLUnits;
        circleShader.u_scale_with_map = false;
    }

    circleShader.u_devicepixelratio = frame.pixelRatio;
    circleShader.u_color = properties.circleColor;
    circleShader.u_radius = properties.circleRadius;
    circleShader.u_blur = properties.circleBlur;
    circleShader.u_opacity = properties.circleOpacity;

    bucket.drawCircles(circleShader, context, paintMode());
}

} // namespace mbgl