blob: 98443a561a09ed4535a8e8567ae5d22eac9aa792 (
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
|
#include <mbgl/renderer/painter.hpp>
#include <mbgl/renderer/circle_bucket.hpp>
#include <mbgl/layer/circle_layer.hpp>
#include <mbgl/map/sprite.hpp>
#include <mbgl/map/tile_id.hpp>
#include <mbgl/map/map_data.hpp>
#include <mbgl/shader/circle_shader.hpp>
using namespace mbgl;
void Painter::renderCircle(CircleBucket& bucket,
const CircleLayer& layer,
const TileID& id,
const mat4& matrix) {
// Abort early.
if (pass == RenderPass::Opaque) return;
config.stencilTest = GL_FALSE;
const CirclePaintProperties& properties = layer.properties;
mat4 vtxMatrix = translatedMatrix(matrix, properties.translate, id, properties.translateAnchor);
Color color = properties.color;
color[0] *= properties.opacity;
color[1] *= properties.opacity;
color[2] *= properties.opacity;
color[3] *= properties.opacity;
// Antialiasing factor: this is a minimum blur distance that serves as
// a faux-antialiasing for the circle. since blur is a ratio of the circle's
// size and the intent is to keep the blur at roughly 1px, the two
// are inversely related.
float antialiasing = 1 / data.pixelRatio / properties.radius;
config.program = circleShader->program;
circleShader->u_matrix = vtxMatrix;
circleShader->u_exmatrix = extrudeMatrix;
circleShader->u_color = color;
circleShader->u_blur = std::max(properties.blur, antialiasing);
circleShader->u_size = properties.radius;
bucket.drawCircles(*circleShader);
}
|