Пример #1
0
void Painter::renderCircle(CircleBucket& bucket,
                           const CircleLayer& layer,
                           const UnwrappedTileID& tileID,
                           const mat4& matrix) {
    // Abort early.
    if (pass == RenderPass::Opaque) return;

    config.stencilTest = frame.mapMode == MapMode::Still ? GL_TRUE : GL_FALSE;
    config.depthFunc.reset();
    config.depthTest = GL_TRUE;
    config.depthMask = GL_FALSE;
    setDepthSublayer(0);

    const CirclePaintProperties& properties = layer.impl->paint;
    mat4 vtxMatrix = translatedMatrix(matrix, properties.circleTranslate, tileID,
                                      properties.circleTranslateAnchor);

    config.program = circleShader->getID();

    circleShader->u_matrix = vtxMatrix;
    circleShader->u_extrude_scale = extrudeScale;
    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, store);
}
Пример #2
0
void Painter::renderCircle(CircleBucket& bucket,
                           const StyleLayer& layer_desc,
                           const TileID& id,
                           const mat4& matrix) {
    // Abort early.
    if (pass == RenderPass::Opaque) return;

    config.stencilTest = false;

    const CircleProperties& properties = layer_desc.getProperties<CircleProperties>();
    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;

    useProgram(circleShader->program);

    circleShader->u_matrix = vtxMatrix;
    circleShader->u_exmatrix = projMatrix;
    circleShader->u_color = color;
    circleShader->u_blur = std::max(properties.blur, antialiasing);
    circleShader->u_size = properties.radius;

    bucket.drawCircles(*circleShader);
}
Пример #3
0
TEST(Buckets, CircleBucket) {
    HeadlessBackend backend({ 512, 256 });
    BackendScope scope { backend };

    gl::Context context;
    CircleBucket bucket { { {0, 0, 0}, MapMode::Static, 1.0 }, {} };
    ASSERT_FALSE(bucket.hasData());
    ASSERT_FALSE(bucket.needsUpload());

    GeometryCollection point { { { 0, 0 } } };
    bucket.addFeature(StubGeometryTileFeature { {}, FeatureType::Point, point, properties }, point);
    ASSERT_TRUE(bucket.hasData());
    ASSERT_TRUE(bucket.needsUpload());

    bucket.upload(context);
    ASSERT_TRUE(bucket.hasData());
    ASSERT_FALSE(bucket.needsUpload());
}