@@ -25,6 +25,7 @@ struct NodeMap::RenderOptions {
|
||||
unsigned int width = 512;
|
||||
unsigned int height = 512;
|
||||
std::vector<std::string> classes;
|
||||
mbgl::MapDebugOptions debugOptions = mbgl::MapDebugOptions::NoDebug;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -240,6 +241,30 @@ NodeMap::RenderOptions NodeMap::ParseOptions(v8::Local<v8::Object> obj) {
|
||||
}
|
||||
}
|
||||
|
||||
if (Nan::Has(obj, Nan::New("debug").ToLocalChecked()).FromJust()) {
|
||||
auto debug = Nan::Get(obj, Nan::New("debug").ToLocalChecked()).ToLocalChecked()->ToObject().As<v8::Object>();
|
||||
if (Nan::Has(debug, Nan::New("tileBorders").ToLocalChecked()).FromJust()) {
|
||||
if (Nan::Get(debug, Nan::New("tileBorders").ToLocalChecked()).ToLocalChecked()->BooleanValue()) {
|
||||
options.debugOptions = options.debugOptions | mbgl::MapDebugOptions::TileBorders;
|
||||
}
|
||||
}
|
||||
if (Nan::Has(debug, Nan::New("parseStatus").ToLocalChecked()).FromJust()) {
|
||||
if (Nan::Get(debug, Nan::New("parseStatus").ToLocalChecked()).ToLocalChecked()->BooleanValue()) {
|
||||
options.debugOptions = options.debugOptions | mbgl::MapDebugOptions::ParseStatus;
|
||||
}
|
||||
}
|
||||
if (Nan::Has(debug, Nan::New("timestamps").ToLocalChecked()).FromJust()) {
|
||||
if (Nan::Get(debug, Nan::New("timestamps").ToLocalChecked()).ToLocalChecked()->BooleanValue()) {
|
||||
options.debugOptions = options.debugOptions | mbgl::MapDebugOptions::Timestamps;
|
||||
}
|
||||
}
|
||||
if (Nan::Has(debug, Nan::New("collision").ToLocalChecked()).FromJust()) {
|
||||
if (Nan::Get(debug, Nan::New("collision").ToLocalChecked()).ToLocalChecked()->BooleanValue()) {
|
||||
options.debugOptions = options.debugOptions | mbgl::MapDebugOptions::Collision;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
@@ -302,6 +327,7 @@ void NodeMap::startRender(NodeMap::RenderOptions options) {
|
||||
map->setLatLngZoom(mbgl::LatLng(options.latitude, options.longitude), options.zoom);
|
||||
map->setBearing(options.bearing);
|
||||
map->setPitch(options.pitch);
|
||||
map->setDebug(options.debugOptions);
|
||||
|
||||
map->renderStill([this](const std::exception_ptr eptr, mbgl::PremultipliedImage&& result) {
|
||||
if (eptr) {
|
||||
|
||||
@@ -41,6 +41,10 @@ suite.run('native', {tests: tests}, function (style, options, callback) {
|
||||
options.zoom = style.zoom;
|
||||
options.bearing = style.bearing;
|
||||
options.pitch = style.pitch;
|
||||
options.debug = {
|
||||
tileBorders: options.debug,
|
||||
collision: options.collisionDebug
|
||||
};
|
||||
|
||||
map.load(style);
|
||||
map.render(options, function (err, pixels) {
|
||||
|
||||
@@ -15,7 +15,9 @@ void Painter::renderTileDebug(const Tile& tile) {
|
||||
if (data.getDebug() != MapDebugOptions::NoDebug) {
|
||||
prepareTile(tile);
|
||||
renderDebugText(*tile.data, tile.matrix);
|
||||
renderDebugFrame(tile.matrix);
|
||||
if (data.getDebug() & MapDebugOptions::TileBorders) {
|
||||
renderDebugFrame(tile.matrix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -137,22 +137,6 @@ void Painter::renderSymbol(SymbolBucket& bucket, const SymbolLayer& layer, const
|
||||
|
||||
config.depthMask = GL_FALSE;
|
||||
|
||||
if (bucket.hasCollisionBoxData()) {
|
||||
config.stencilOp.reset();
|
||||
config.stencilTest = GL_TRUE;
|
||||
|
||||
config.program = collisionBoxShader->program;
|
||||
collisionBoxShader->u_matrix = matrix;
|
||||
collisionBoxShader->u_scale = std::pow(2, state.getZoom() - id.z);
|
||||
collisionBoxShader->u_zoom = state.getZoom() * 10;
|
||||
collisionBoxShader->u_maxzoom = (id.z + 1) * 10;
|
||||
config.lineWidth = 1.0f;
|
||||
|
||||
setDepthSublayer(0);
|
||||
bucket.drawCollisionBoxes(*collisionBoxShader);
|
||||
|
||||
}
|
||||
|
||||
// TODO remove the `true ||` when #1673 is implemented
|
||||
const bool drawAcrossEdges = (data.mode == MapMode::Continuous) && (true || !(layout.text.allowOverlap || layout.icon.allowOverlap ||
|
||||
layout.text.ignorePlacement || layout.icon.ignorePlacement));
|
||||
@@ -271,4 +255,20 @@ void Painter::renderSymbol(SymbolBucket& bucket, const SymbolLayer& layer, const
|
||||
&SymbolBucket::drawGlyphs);
|
||||
}
|
||||
|
||||
if (bucket.hasCollisionBoxData()) {
|
||||
config.stencilOp.reset();
|
||||
config.stencilTest = GL_TRUE;
|
||||
|
||||
config.program = collisionBoxShader->program;
|
||||
collisionBoxShader->u_matrix = matrix;
|
||||
collisionBoxShader->u_scale = std::pow(2, state.getZoom() - id.z);
|
||||
collisionBoxShader->u_zoom = state.getZoom() * 10;
|
||||
collisionBoxShader->u_maxzoom = (id.z + 1) * 10;
|
||||
config.lineWidth = 1.0f;
|
||||
|
||||
setDepthSublayer(0);
|
||||
bucket.drawCollisionBoxes(*collisionBoxShader);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user