@@ -16,7 +16,9 @@ namespace mbgl {
|
||||
|
||||
using namespace style;
|
||||
|
||||
RenderTile::RenderTile(UnwrappedTileID id_, Tile& tile_) : id(id_), tile(tile_) {}
|
||||
RenderTile::RenderTile(UnwrappedTileID id_, Tile& tile_)
|
||||
: id(id_),
|
||||
tile(tile_) {}
|
||||
|
||||
RenderTile::~RenderTile() = default;
|
||||
|
||||
@@ -31,16 +33,18 @@ mat4 RenderTile::translateVtxMatrix(const mat4& tileMatrix,
|
||||
|
||||
mat4 vtxMatrix;
|
||||
|
||||
const float angle = inViewportPixelUnits ?
|
||||
(anchor == TranslateAnchorType::Map ? static_cast<float>(state.getBearing()) : 0.0f) :
|
||||
(anchor == TranslateAnchorType::Viewport ? static_cast<float>(-state.getBearing()) : 0.0f);
|
||||
const float angle = inViewportPixelUnits
|
||||
? (anchor == TranslateAnchorType::Map ? static_cast<float>(state.getBearing()) : 0.0f)
|
||||
: (anchor == TranslateAnchorType::Viewport ? static_cast<float>(-state.getBearing())
|
||||
: 0.0f);
|
||||
|
||||
Point<float> translate = util::rotate(Point<float>{ translation[0], translation[1] }, angle);
|
||||
Point<float> translate = util::rotate(Point<float>{translation[0], translation[1]}, angle);
|
||||
|
||||
if (inViewportPixelUnits) {
|
||||
matrix::translate(vtxMatrix, tileMatrix, translate.x, translate.y, 0);
|
||||
} else {
|
||||
matrix::translate(vtxMatrix, tileMatrix,
|
||||
matrix::translate(vtxMatrix,
|
||||
tileMatrix,
|
||||
id.pixelsToTileUnits(translate.x, static_cast<float>(state.getZoom())),
|
||||
id.pixelsToTileUnits(translate.y, static_cast<float>(state.getZoom())),
|
||||
0);
|
||||
@@ -61,8 +65,12 @@ mat4 RenderTile::translatedClipMatrix(const std::array<float, 2>& translation,
|
||||
return translateVtxMatrix(nearClippedMatrix, translation, anchor, state, false);
|
||||
}
|
||||
|
||||
const OverscaledTileID& RenderTile::getOverscaledTileID() const { return tile.id; }
|
||||
bool RenderTile::holdForFade() const { return tile.holdForFade(); }
|
||||
const OverscaledTileID& RenderTile::getOverscaledTileID() const {
|
||||
return tile.id;
|
||||
}
|
||||
bool RenderTile::holdForFade() const {
|
||||
return tile.holdForFade();
|
||||
}
|
||||
|
||||
Bucket* RenderTile::getBucket(const style::Layer::Impl& impl) const {
|
||||
assert(renderData);
|
||||
@@ -106,20 +114,18 @@ void RenderTile::prepare(const SourcePrepareParameters& parameters) {
|
||||
needsRendering = tile.usedByRenderedLayers;
|
||||
|
||||
if (parameters.debugOptions != MapDebugOptions::NoDebug &&
|
||||
(!debugBucket || debugBucket->renderable != tile.isRenderable() ||
|
||||
debugBucket->complete != tile.isComplete() ||
|
||||
!(debugBucket->modified == tile.modified) ||
|
||||
!(debugBucket->expires == tile.expires) ||
|
||||
(!debugBucket || debugBucket->renderable != tile.isRenderable() || debugBucket->complete != tile.isComplete() ||
|
||||
!(debugBucket->modified == tile.modified) || !(debugBucket->expires == tile.expires) ||
|
||||
debugBucket->debugMode != parameters.debugOptions)) {
|
||||
debugBucket = std::make_unique<DebugBucket>(
|
||||
tile.id, tile.isRenderable(), tile.isComplete(), tile.modified, tile.expires,
|
||||
parameters.debugOptions);
|
||||
tile.id, tile.isRenderable(), tile.isComplete(), tile.modified, tile.expires, parameters.debugOptions);
|
||||
} else if (parameters.debugOptions == MapDebugOptions::NoDebug) {
|
||||
debugBucket.reset();
|
||||
}
|
||||
|
||||
// Calculate two matrices for this tile: matrix is the standard tile matrix; nearClippedMatrix
|
||||
// has near plane moved further, to enhance depth buffer precision
|
||||
// Calculate two matrices for this tile: matrix is the standard tile matrix;
|
||||
// nearClippedMatrix has near plane moved further, to enhance depth buffer
|
||||
// precision
|
||||
const auto& transform = parameters.transform;
|
||||
transform.state.matrixFor(matrix, id);
|
||||
transform.state.matrixFor(nearClippedMatrix, id);
|
||||
@@ -128,10 +134,9 @@ void RenderTile::prepare(const SourcePrepareParameters& parameters) {
|
||||
}
|
||||
|
||||
void RenderTile::finishRender(PaintParameters& parameters) const {
|
||||
if (!needsRendering || parameters.debugOptions == MapDebugOptions::NoDebug)
|
||||
return;
|
||||
if (!needsRendering || parameters.debugOptions == MapDebugOptions::NoDebug) return;
|
||||
|
||||
static const style::Properties<>::PossiblyEvaluated properties {};
|
||||
static const style::Properties<>::PossiblyEvaluated properties{};
|
||||
static const DebugProgram::Binders paintAttributeData(properties, 0);
|
||||
|
||||
auto program = parameters.shaders.get<DebugProgram>();
|
||||
@@ -141,48 +146,48 @@ void RenderTile::finishRender(PaintParameters& parameters) const {
|
||||
|
||||
if (parameters.debugOptions & (MapDebugOptions::Timestamps | MapDebugOptions::ParseStatus)) {
|
||||
assert(debugBucket);
|
||||
const auto allAttributeBindings =
|
||||
DebugProgram::computeAllAttributeBindings(*debugBucket->vertexBuffer, paintAttributeData, properties);
|
||||
const auto allAttributeBindings = DebugProgram::computeAllAttributeBindings(
|
||||
*debugBucket->vertexBuffer, paintAttributeData, properties);
|
||||
|
||||
program->draw(parameters.context,
|
||||
*parameters.renderPass,
|
||||
gfx::Lines{4.0f * parameters.pixelRatio},
|
||||
gfx::DepthMode::disabled(),
|
||||
gfx::StencilMode::disabled(),
|
||||
gfx::ColorMode::unblended(),
|
||||
gfx::CullFaceMode::disabled(),
|
||||
*debugBucket->indexBuffer,
|
||||
debugBucket->segments,
|
||||
DebugProgram::computeAllUniformValues(
|
||||
DebugProgram::LayoutUniformValues{uniforms::matrix::Value(matrix),
|
||||
uniforms::color::Value(Color::white()),
|
||||
uniforms::overlay_scale::Value(1.0f)},
|
||||
paintAttributeData,
|
||||
properties,
|
||||
static_cast<float>(parameters.state.getZoom())),
|
||||
allAttributeBindings,
|
||||
DebugProgram::TextureBindings{textures::image::Value{debugBucket->texture->getResource()}},
|
||||
"text-outline");
|
||||
*parameters.renderPass,
|
||||
gfx::Lines{4.0f * parameters.pixelRatio},
|
||||
gfx::DepthMode::disabled(),
|
||||
gfx::StencilMode::disabled(),
|
||||
gfx::ColorMode::unblended(),
|
||||
gfx::CullFaceMode::disabled(),
|
||||
*debugBucket->indexBuffer,
|
||||
debugBucket->segments,
|
||||
DebugProgram::computeAllUniformValues(
|
||||
DebugProgram::LayoutUniformValues{uniforms::matrix::Value(matrix),
|
||||
uniforms::color::Value(Color::white()),
|
||||
uniforms::overlay_scale::Value(1.0f)},
|
||||
paintAttributeData,
|
||||
properties,
|
||||
static_cast<float>(parameters.state.getZoom())),
|
||||
allAttributeBindings,
|
||||
DebugProgram::TextureBindings{textures::image::Value{debugBucket->texture->getResource()}},
|
||||
"text-outline");
|
||||
|
||||
program->draw(parameters.context,
|
||||
*parameters.renderPass,
|
||||
gfx::Lines{2.0f * parameters.pixelRatio},
|
||||
gfx::DepthMode::disabled(),
|
||||
gfx::StencilMode::disabled(),
|
||||
gfx::ColorMode::unblended(),
|
||||
gfx::CullFaceMode::disabled(),
|
||||
*debugBucket->indexBuffer,
|
||||
debugBucket->segments,
|
||||
DebugProgram::computeAllUniformValues(
|
||||
DebugProgram::LayoutUniformValues{uniforms::matrix::Value(matrix),
|
||||
uniforms::color::Value(Color::black()),
|
||||
uniforms::overlay_scale::Value(1.0f)},
|
||||
paintAttributeData,
|
||||
properties,
|
||||
static_cast<float>(parameters.state.getZoom())),
|
||||
allAttributeBindings,
|
||||
DebugProgram::TextureBindings{textures::image::Value{debugBucket->texture->getResource()}},
|
||||
"text");
|
||||
*parameters.renderPass,
|
||||
gfx::Lines{2.0f * parameters.pixelRatio},
|
||||
gfx::DepthMode::disabled(),
|
||||
gfx::StencilMode::disabled(),
|
||||
gfx::ColorMode::unblended(),
|
||||
gfx::CullFaceMode::disabled(),
|
||||
*debugBucket->indexBuffer,
|
||||
debugBucket->segments,
|
||||
DebugProgram::computeAllUniformValues(
|
||||
DebugProgram::LayoutUniformValues{uniforms::matrix::Value(matrix),
|
||||
uniforms::color::Value(Color::black()),
|
||||
uniforms::overlay_scale::Value(1.0f)},
|
||||
paintAttributeData,
|
||||
properties,
|
||||
static_cast<float>(parameters.state.getZoom())),
|
||||
allAttributeBindings,
|
||||
DebugProgram::TextureBindings{textures::image::Value{debugBucket->texture->getResource()}},
|
||||
"text");
|
||||
}
|
||||
|
||||
if (parameters.debugOptions & MapDebugOptions::TileBorders) {
|
||||
@@ -190,27 +195,26 @@ void RenderTile::finishRender(PaintParameters& parameters) const {
|
||||
if (debugBucket->tileBorderSegments.empty()) {
|
||||
debugBucket->tileBorderSegments = RenderStaticData::tileBorderSegments();
|
||||
}
|
||||
program->draw(
|
||||
parameters.context,
|
||||
*parameters.renderPass,
|
||||
gfx::LineStrip{4.0f * parameters.pixelRatio},
|
||||
gfx::DepthMode::disabled(),
|
||||
gfx::StencilMode::disabled(),
|
||||
gfx::ColorMode::unblended(),
|
||||
gfx::CullFaceMode::disabled(),
|
||||
*parameters.staticData.tileBorderIndexBuffer,
|
||||
debugBucket->tileBorderSegments,
|
||||
DebugProgram::computeAllUniformValues(
|
||||
DebugProgram::LayoutUniformValues{uniforms::matrix::Value(matrix),
|
||||
uniforms::color::Value(Color::red()),
|
||||
uniforms::overlay_scale::Value(1.0f)},
|
||||
paintAttributeData,
|
||||
properties,
|
||||
static_cast<float>(parameters.state.getZoom())),
|
||||
DebugProgram::computeAllAttributeBindings(
|
||||
*parameters.staticData.tileVertexBuffer, paintAttributeData, properties),
|
||||
DebugProgram::TextureBindings{textures::image::Value{debugBucket->texture->getResource()}},
|
||||
"border");
|
||||
program->draw(parameters.context,
|
||||
*parameters.renderPass,
|
||||
gfx::LineStrip{4.0f * parameters.pixelRatio},
|
||||
gfx::DepthMode::disabled(),
|
||||
gfx::StencilMode::disabled(),
|
||||
gfx::ColorMode::unblended(),
|
||||
gfx::CullFaceMode::disabled(),
|
||||
*parameters.staticData.tileBorderIndexBuffer,
|
||||
debugBucket->tileBorderSegments,
|
||||
DebugProgram::computeAllUniformValues(
|
||||
DebugProgram::LayoutUniformValues{uniforms::matrix::Value(matrix),
|
||||
uniforms::color::Value(Color::red()),
|
||||
uniforms::overlay_scale::Value(1.0f)},
|
||||
paintAttributeData,
|
||||
properties,
|
||||
static_cast<float>(parameters.state.getZoom())),
|
||||
DebugProgram::computeAllAttributeBindings(
|
||||
*parameters.staticData.tileVertexBuffer, paintAttributeData, properties),
|
||||
DebugProgram::TextureBindings{textures::image::Value{debugBucket->texture->getResource()}},
|
||||
"border");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user