From 1759603e128ad0a08f4a25009b82695420ec2840 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Thu, 18 May 2017 09:37:21 -0700 Subject: [core] Simplify and fix sprite atlas coordinate calculations * Always return image metrics exclusive of padding * Work with integer coordinates whenever possible * Eliminate redundant SpriteAtlasElement members * Fix asymmetric re-padding in getIconQuad when pixelRatio != 1 * Add explanatory comments --- src/mbgl/renderer/bucket_parameters.hpp | 1 + src/mbgl/renderer/painters/painter_background.cpp | 2 +- src/mbgl/renderer/painters/painter_fill.cpp | 2 +- src/mbgl/renderer/painters/painter_fill_extrusion.cpp | 2 +- src/mbgl/renderer/painters/painter_line.cpp | 2 +- src/mbgl/renderer/painters/painter_symbol.cpp | 6 ++---- 6 files changed, 7 insertions(+), 8 deletions(-) (limited to 'src/mbgl/renderer') diff --git a/src/mbgl/renderer/bucket_parameters.hpp b/src/mbgl/renderer/bucket_parameters.hpp index 1774ba2bbe..50ec4cf521 100644 --- a/src/mbgl/renderer/bucket_parameters.hpp +++ b/src/mbgl/renderer/bucket_parameters.hpp @@ -9,6 +9,7 @@ class BucketParameters { public: const OverscaledTileID tileID; const MapMode mode; + const float pixelRatio; }; } // namespace mbgl diff --git a/src/mbgl/renderer/painters/painter_background.cpp b/src/mbgl/renderer/painters/painter_background.cpp index 9c6df06094..9cbc3d516c 100644 --- a/src/mbgl/renderer/painters/painter_background.cpp +++ b/src/mbgl/renderer/painters/painter_background.cpp @@ -42,7 +42,7 @@ void Painter::renderBackground(PaintParameters& parameters, const RenderBackgrou FillPatternUniforms::values( matrixForTile(tileID), context.viewport.getCurrentValue().size, - spriteAtlas->getSize(), + spriteAtlas->getPixelSize(), *imagePosA, *imagePosB, background.get(), diff --git a/src/mbgl/renderer/painters/painter_fill.cpp b/src/mbgl/renderer/painters/painter_fill.cpp index e34b4107a9..d15a871d98 100644 --- a/src/mbgl/renderer/painters/painter_fill.cpp +++ b/src/mbgl/renderer/painters/painter_fill.cpp @@ -49,7 +49,7 @@ void Painter::renderFill(PaintParameters& parameters, properties.get(), state), context.viewport.getCurrentValue().size, - spriteAtlas->getSize(), + spriteAtlas->getPixelSize(), *imagePosA, *imagePosB, properties.get(), diff --git a/src/mbgl/renderer/painters/painter_fill_extrusion.cpp b/src/mbgl/renderer/painters/painter_fill_extrusion.cpp index c7aede3aa6..c28cb76bff 100644 --- a/src/mbgl/renderer/painters/painter_fill_extrusion.cpp +++ b/src/mbgl/renderer/painters/painter_fill_extrusion.cpp @@ -46,7 +46,7 @@ void Painter::renderFillExtrusion(PaintParameters& parameters, tile.translatedClipMatrix(properties.get(), properties.get(), state), - spriteAtlas->getSize(), + spriteAtlas->getPixelSize(), *imagePosA, *imagePosB, properties.get(), diff --git a/src/mbgl/renderer/painters/painter_line.cpp b/src/mbgl/renderer/painters/painter_line.cpp index df627a76aa..40076726af 100644 --- a/src/mbgl/renderer/painters/painter_line.cpp +++ b/src/mbgl/renderer/painters/painter_line.cpp @@ -75,7 +75,7 @@ void Painter::renderLine(PaintParameters& parameters, tile, state, pixelsToGLUnits, - spriteAtlas->getSize(), + spriteAtlas->getPixelSize(), *posA, *posB)); diff --git a/src/mbgl/renderer/painters/painter_symbol.cpp b/src/mbgl/renderer/painters/painter_symbol.cpp index 45094777c6..a89e7db28d 100644 --- a/src/mbgl/renderer/painters/painter_symbol.cpp +++ b/src/mbgl/renderer/painters/painter_symbol.cpp @@ -68,13 +68,11 @@ void Painter::renderSymbol(PaintParameters& parameters, auto paintPropertyValues = layer.iconPaintProperties(); SpriteAtlas& atlas = *bucket.spriteAtlas; - const bool iconScaled = layout.get().constantOr(1.0) != 1.0 || - frame.pixelRatio != atlas.getPixelRatio() || - bucket.iconsNeedLinear; + const bool iconScaled = layout.get().constantOr(1.0) != 1.0 || bucket.iconsNeedLinear; const bool iconTransformed = values.rotationAlignment == AlignmentType::Map || state.getPitch() != 0; atlas.bind(bucket.sdfIcons || state.isChanging() || iconScaled || iconTransformed, context, 0); - const Size texsize = atlas.getSize(); + const Size texsize = atlas.getPixelSize(); if (bucket.sdfIcons) { if (values.hasHalo) { -- cgit v1.2.1