diff --git a/package.json b/package.json index 32879c70e27..0e1ca758b68 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ ], "devDependencies": { "aws-sdk": "^2.2.21", - "mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#46c907f48d2b3b8ae6531963cdc40cb07958fd01", + "mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#c8982f16ef5d39164b2e4f33bc3f993f9ac17502", "node-gyp": "^3.2.1", "request": "^2.67.0", "tape": "^4.2.2" diff --git a/src/mbgl/renderer/painter_symbol.cpp b/src/mbgl/renderer/painter_symbol.cpp index 43cd3d54052..9f2d06df226 100644 --- a/src/mbgl/renderer/painter_symbol.cpp +++ b/src/mbgl/renderer/painter_symbol.cpp @@ -187,8 +187,9 @@ void Painter::renderSymbol(SymbolBucket& bucket, const SymbolLayer& layer, const const float fontScale = fontSize / 1.0f; SpriteAtlas* activeSpriteAtlas = layer.spriteAtlas; - activeSpriteAtlas->bind(state.isChanging() || layout.placement == PlacementType::Line - || angleOffset != 0 || fontScale != 1 || sdf || state.getPitch() != 0); + const bool iconScaled = fontScale != 1 || data.pixelRatio != activeSpriteAtlas->getPixelRatio() || bucket.iconsNeedLinear; + const bool iconTransformed = layout.placement == PlacementType::Line || angleOffset != 0 || state.getPitch() != 0; + activeSpriteAtlas->bind(sdf || state.isChanging() || iconScaled || iconTransformed); if (sdf) { renderSDF(bucket, diff --git a/src/mbgl/renderer/symbol_bucket.cpp b/src/mbgl/renderer/symbol_bucket.cpp index d8273fd4f8a..67539637bc4 100644 --- a/src/mbgl/renderer/symbol_bucket.cpp +++ b/src/mbgl/renderer/symbol_bucket.cpp @@ -248,11 +248,14 @@ void SymbolBucket::addFeatures(uintptr_t tileUID, if (feature.sprite.length()) { auto image = spriteAtlas.getImage(feature.sprite, false); if (image) { - shapedIcon = shapeIcon((*image).pos, layout); + shapedIcon = shapeIcon(*image, layout); assert((*image).texture); if ((*image).texture->sdf) { sdfIcons = true; } + if ((*image).relativePixelRatio != 1.0f) { + iconsNeedLinear = true; + } } } diff --git a/src/mbgl/renderer/symbol_bucket.hpp b/src/mbgl/renderer/symbol_bucket.hpp index b447db4ec98..4f52f2300b6 100644 --- a/src/mbgl/renderer/symbol_bucket.hpp +++ b/src/mbgl/renderer/symbol_bucket.hpp @@ -112,6 +112,7 @@ class SymbolBucket : public Bucket { public: SymbolLayoutProperties layout; bool sdfIcons = false; + bool iconsNeedLinear = false; private: diff --git a/src/mbgl/sprite/sprite_atlas.cpp b/src/mbgl/sprite/sprite_atlas.cpp index d09330e17bf..497721a61c8 100644 --- a/src/mbgl/sprite/sprite_atlas.cpp +++ b/src/mbgl/sprite/sprite_atlas.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include @@ -27,7 +26,11 @@ SpriteAtlas::SpriteAtlas(dimension width_, dimension height_, float pixelRatio_, dirty(true) { } -Rect SpriteAtlas::allocateImage(const size_t pixel_width, const size_t pixel_height) { +Rect SpriteAtlas::allocateImage(float src_width, float src_height) { + + const uint16_t pixel_width = std::ceil(src_width / pixelRatio); + const uint16_t pixel_height = std::ceil(src_height / pixelRatio); + // Increase to next number divisible by 4, but at least 1. // This is so we can scale down the texture coordinates and pack them // into 2 bytes rather than 4 bytes. @@ -41,9 +44,6 @@ Rect SpriteAtlas::allocateImage(const size_t pixel_width return rect; } - rect.originalW = pixel_width; - rect.originalH = pixel_height; - return rect; } @@ -52,7 +52,7 @@ mapbox::util::optional SpriteAtlas::getImage(const std::stri auto rect_it = images.find({ name, wrap }); if (rect_it != images.end()) { - return SpriteAtlasElement { rect_it->second.pos, rect_it->second.texture }; + return SpriteAtlasElement { rect_it->second.pos, rect_it->second.texture, rect_it->second.texture->pixelRatio / pixelRatio }; } auto sprite = store.getSprite(name); @@ -60,7 +60,7 @@ mapbox::util::optional SpriteAtlas::getImage(const std::stri return {}; } - Rect rect = allocateImage(sprite->width, sprite->height); + Rect rect = allocateImage(sprite->width * sprite->pixelRatio, sprite->height * sprite->pixelRatio); if (rect.w == 0) { if (debug::spriteWarnings) { Log::Warning(Event::Sprite, "sprite atlas bitmap overflow"); @@ -71,7 +71,7 @@ mapbox::util::optional SpriteAtlas::getImage(const std::stri const Holder& holder = images.emplace(Key{ name, wrap }, Holder{ sprite, rect }).first->second; copy(holder, wrap); - return SpriteAtlasElement { rect, sprite }; + return SpriteAtlasElement { rect, sprite, sprite->pixelRatio / pixelRatio }; } mapbox::util::optional SpriteAtlas::getPosition(const std::string& name, bool repeating) { @@ -83,28 +83,48 @@ mapbox::util::optional SpriteAtlas::getPosition(const std:: } auto rect = (*img).pos; - if (repeating) { - // When the image is repeating, get the correct position of the image, rather than the - // one rounded up to 4 pixels. - // TODO: Can't we just use originalW/originalH? - auto sprite = store.getSprite(name); - if (!sprite) { - return SpriteAtlasPosition {}; - } - - rect.w = sprite->width; - rect.h = sprite->height; - } const float padding = 1; + auto image = (*img).texture; + + const float w = image->width * (*img).relativePixelRatio; + const float h = image->height * (*img).relativePixelRatio; return SpriteAtlasPosition { - {{ float(rect.w), float(rect.h) }}, - {{ float(rect.x + padding) / width, float(rect.y + padding) / height }}, - {{ float(rect.x + padding + rect.w) / width, float(rect.y + padding + rect.h) / height }} + {{ float(image->width), float(image->height) }}, + {{ float(rect.x + padding) / width, float(rect.y + padding) / height }}, + {{ float(rect.x + padding + w) / width, float(rect.y + padding + h) / height }} }; } +void copyBitmap(const uint32_t *src, const uint32_t srcStride, const uint32_t srcX, const uint32_t srcY, + uint32_t *const dst, const uint32_t dstStride, const uint32_t dstX, const uint32_t dstY, int dstSize, + const int width, const int height, const bool wrap) { + + int srcI = srcY * srcStride + srcX; + int dstI = dstY * dstStride + dstX; + int x, y; + + if (wrap) { + // add 1 pixel wrapped padding on each side of the image + dstI -= dstStride; + for (y = -1; y <= height; y++, srcI = ((y + height) % height + srcY) * srcStride + srcX, dstI += dstStride) { + for (x = -1; x <= width; x++) { + const int dstIndex = (dstI + x + dstSize) % dstSize; + dst[dstIndex] = src[srcI + ((x + width) % width)]; + } + } + + } else { + for (y = 0; y < height; y++, srcI += srcStride, dstI += dstStride) { + for (x = 0; x < width; x++) { + const int dstIndex = (dstI + x + dstSize) % dstSize; + dst[dstIndex] = src[srcI + x]; + } + } + } +} + void SpriteAtlas::copy(const Holder& holder, const bool wrap) { if (!data) { data = std::make_unique(pixelWidth * pixelHeight); @@ -113,51 +133,13 @@ void SpriteAtlas::copy(const Holder& holder, const bool wrap) { const uint32_t *srcData = reinterpret_cast(holder.texture->data.data()); if (!srcData) return; - const vec2 srcSize { holder.texture->pixelWidth, holder.texture->pixelHeight }; - const Rect srcPos { 0, 0, srcSize.x, srcSize.y }; - const auto& dst = holder.pos; - - const int offset = 1; - uint32_t *const dstData = data.get(); - const vec2 dstSize{ pixelWidth, pixelHeight }; - const Rect dstPos{ static_cast((offset + dst.x) * pixelRatio), - static_cast((offset + dst.y) * pixelRatio), - static_cast(dst.originalW * pixelRatio), - static_cast(dst.originalH * pixelRatio) }; - util::bilinearScale(srcData, srcSize, srcPos, dstData, dstSize, dstPos, wrap); + const int padding = 1; - // Add borders around the copied image if required. - if (wrap) { - // We're copying from the same image so we don't have to scale again. - const uint32_t border = 1; - const uint32_t borderX = dstPos.x != 0 ? border : 0; - const uint32_t borderY = dstPos.y != 0 ? border : 0; - - // Left border - util::nearestNeighborScale( - dstData, dstSize, { dstPos.x + dstPos.w - borderX, dstPos.y, borderX, dstPos.h }, - dstData, dstSize, { dstPos.x - borderX, dstPos.y, borderX, dstPos.h }); - - // Right border - util::nearestNeighborScale(dstData, dstSize, { dstPos.x, dstPos.y, border, dstPos.h }, - dstData, dstSize, - { dstPos.x + dstPos.w, dstPos.y, border, dstPos.h }); - - // Top border - util::nearestNeighborScale( - dstData, dstSize, { dstPos.x - borderX, dstPos.y + dstPos.h - borderY, - dstPos.w + border + borderX, borderY }, - dstData, dstSize, - { dstPos.x - borderX, dstPos.y - borderY, dstPos.w + 2 * borderX, borderY }); - - // Bottom border - util::nearestNeighborScale( - dstData, dstSize, { dstPos.x - borderX, dstPos.y, dstPos.w + 2 * borderX, border }, - dstData, dstSize, - { dstPos.x - borderX, dstPos.y + dstPos.h, dstPos.w + border + borderX, border }); - } + copyBitmap(srcData, holder.texture->pixelWidth, 0, 0, + dstData, pixelWidth, (holder.pos.x + padding) * pixelRatio, (holder.pos.y + padding) * pixelRatio, pixelWidth * pixelHeight, + holder.texture->pixelWidth, holder.texture->pixelHeight, wrap); dirty = true; } diff --git a/src/mbgl/sprite/sprite_atlas.hpp b/src/mbgl/sprite/sprite_atlas.hpp index 167d012c6b4..aca82b3fea5 100644 --- a/src/mbgl/sprite/sprite_atlas.hpp +++ b/src/mbgl/sprite/sprite_atlas.hpp @@ -34,6 +34,7 @@ struct SpriteAtlasPosition { struct SpriteAtlasElement { const Rect pos; const std::shared_ptr texture; + const float relativePixelRatio; }; class SpriteAtlas : public util::noncopyable { @@ -83,7 +84,7 @@ class SpriteAtlas : public util::noncopyable { using Key = std::pair; - Rect allocateImage(size_t width, size_t height); + Rect allocateImage(float width, float height); void copy(const Holder& holder, const bool wrap); std::recursive_mutex mtx; diff --git a/src/mbgl/text/quads.cpp b/src/mbgl/text/quads.cpp index 20427924a40..92866566d87 100644 --- a/src/mbgl/text/quads.cpp +++ b/src/mbgl/text/quads.cpp @@ -13,11 +13,13 @@ SymbolQuads getIconQuads(Anchor& anchor, const PositionedIcon& shapedIcon, const std::vector& line, const SymbolLayoutProperties& layout, const bool alongLine) { + auto image = *(shapedIcon.image); + const float border = 1.0; auto left = shapedIcon.left - border; - auto right = left + shapedIcon.image.w; + auto right = left + image.pos.w / image.relativePixelRatio; auto top = shapedIcon.top - border; - auto bottom = top + shapedIcon.image.h; + auto bottom = top + image.pos.h / image.relativePixelRatio; vec2 tl{left, top}; vec2 tr{right, top}; vec2 br{right, bottom}; @@ -51,7 +53,7 @@ SymbolQuads getIconQuads(Anchor& anchor, const PositionedIcon& shapedIcon, } SymbolQuads quads; - quads.emplace_back(tl, tr, bl, br, shapedIcon.image, 0, anchor, globalMinScale, std::numeric_limits::infinity()); + quads.emplace_back(tl, tr, bl, br, image.pos, 0, anchor, globalMinScale, std::numeric_limits::infinity()); return quads; } diff --git a/src/mbgl/text/shaping.cpp b/src/mbgl/text/shaping.cpp index 735841e8cae..f12658c669a 100644 --- a/src/mbgl/text/shaping.cpp +++ b/src/mbgl/text/shaping.cpp @@ -3,13 +3,13 @@ namespace mbgl { -PositionedIcon shapeIcon(const Rect& image, const SymbolLayoutProperties& layout) { +PositionedIcon shapeIcon(const SpriteAtlasElement& image, const SymbolLayoutProperties& layout) { float dx = layout.icon.offset.value[0]; float dy = layout.icon.offset.value[1]; - float x1 = dx - image.originalW / 2.0f; - float x2 = x1 + image.originalW; - float y1 = dy - image.originalH / 2.0f; - float y2 = y1 + image.originalH; + float x1 = dx - image.texture->width / 2.0f; + float x2 = x1 + image.texture->width; + float y1 = dy - image.texture->height / 2.0f; + float y2 = y1 + image.texture->height; return PositionedIcon(image, y1, y2, x1, x2); } diff --git a/src/mbgl/text/shaping.hpp b/src/mbgl/text/shaping.hpp index acf8c470bff..decf7b946eb 100644 --- a/src/mbgl/text/shaping.hpp +++ b/src/mbgl/text/shaping.hpp @@ -2,29 +2,35 @@ #define MBGL_TEXT_SHAPING #include +#include +#include +#include #include namespace mbgl { + struct SpriteAtlasElement; + class PositionedIcon { public: inline explicit PositionedIcon() {} - inline explicit PositionedIcon(Rect _image, + inline explicit PositionedIcon(const SpriteAtlasElement& _image, float _top, float _bottom, float _left, float _right) : image(_image), top(_top), bottom(_bottom), left(_left), right(_right) {} - Rect image; + + mapbox::util::optional image; float top = 0; float bottom = 0; float left = 0; float right = 0; - operator bool() const { return image.hasArea(); } + operator bool() const { return image && (*image).pos.hasArea(); } }; class SymbolLayoutProperties; - PositionedIcon shapeIcon(const Rect& image, const SymbolLayoutProperties&); + PositionedIcon shapeIcon(const SpriteAtlasElement& image, const SymbolLayoutProperties&); } // namespace mbgl diff --git a/src/mbgl/util/rect.hpp b/src/mbgl/util/rect.hpp index 7bb3214b9bc..1dc8cb8af96 100644 --- a/src/mbgl/util/rect.hpp +++ b/src/mbgl/util/rect.hpp @@ -9,7 +9,6 @@ struct Rect { inline Rect(T x_, T y_, T w_, T h_) : x(x_), y(y_), w(w_), h(h_) {} T x = 0, y = 0; T w = 0, h = 0; - T originalW = 0, originalH = 0; template inline Rect operator *(Number value) const { diff --git a/src/mbgl/util/scaling.cpp b/src/mbgl/util/scaling.cpp deleted file mode 100644 index 9b32650511a..00000000000 --- a/src/mbgl/util/scaling.cpp +++ /dev/null @@ -1,112 +0,0 @@ -#include "scaling.hpp" - -namespace { - -using namespace mbgl; - -inline uint8_t bilinearInterpolate(uint8_t tl, uint8_t tr, uint8_t bl, uint8_t br, double dx, double dy) { - const double t = dx * (tr - tl) + tl; - const double b = dx * (br - bl) + bl; - return t + dy * (b - t); -} - -template -inline const uint8_t& b(const uint32_t& w) { - return reinterpret_cast(&w)[i]; -} - -template -inline uint8_t& b(uint32_t& w) { - return reinterpret_cast(&w)[i]; -} - -vec2 getFactor(const Rect& srcPos, const Rect& dstPos) { - return { - double(srcPos.w) / dstPos.w, - double(srcPos.h) / dstPos.h - }; -} - -vec2 getBounds(const vec2& srcSize, const Rect& srcPos, - const vec2& dstSize, const Rect& dstPos, - const vec2& factor) { - if (srcPos.x > srcSize.x || srcPos.y > srcSize.y || - dstPos.x > dstSize.x || dstPos.y > dstSize.y) { - // Source or destination position is out of range. - return { 0, 0 }; - } - - // Make sure we don't read/write values out of range. - return { std::min(uint32_t(double(srcSize.x - srcPos.x) / factor.x), - std::min(dstSize.x - dstPos.x, dstPos.w)), - std::min(uint32_t(double(srcSize.y - srcPos.y) / factor.y), - std::min(dstSize.y - dstPos.y, dstPos.h)) }; -} -} // namespace - -namespace mbgl { -namespace util { - -void bilinearScale(const uint32_t* srcData, const vec2& srcSize, - const Rect& srcPos, uint32_t* dstData, const vec2& dstSize, - const Rect& dstPos, bool wrap) { - const auto factor = getFactor(srcPos, dstPos); - const auto bounds = getBounds(srcSize, srcPos, dstSize, dstPos, factor); - - uint32_t x, y; - size_t i = dstSize.x * dstPos.y + dstPos.x; - for (y = 0; y < bounds.y; y++) { - const double fractY = y * factor.y; - const uint32_t Y0 = fractY; - const uint32_t Y1 = wrap ? (Y0 + 1) % srcPos.h : (Y0 + 1); - const uint32_t srcY0 = srcPos.y + Y0; - const uint32_t srcY1 = std::min(srcPos.y + Y1, srcSize.y - 1); - for (x = 0; x < bounds.x; x++) { - const double fractX = x * factor.x; - const uint32_t X0 = fractX; - const uint32_t X1 = wrap ? (X0 + 1) % srcPos.w : (X0 + 1); - const uint32_t srcX0 = srcPos.x + X0; - const uint32_t srcX1 = std::min(srcPos.x + X1, srcSize.x - 1); - - const uint32_t tl = srcData[srcSize.x * srcY0 + srcX0]; - const uint32_t tr = srcData[srcSize.x * srcY0 + srcX1]; - const uint32_t bl = srcData[srcSize.x * srcY1 + srcX0]; - const uint32_t br = srcData[srcSize.x * srcY1 + srcX1]; - - const double dx = fractX - X0; - const double dy = fractY - Y0; - uint32_t& dst = dstData[i + x]; - b<0>(dst) = bilinearInterpolate(b<0>(tl), b<0>(tr), b<0>(bl), b<0>(br), dx, dy); - b<1>(dst) = bilinearInterpolate(b<1>(tl), b<1>(tr), b<1>(bl), b<1>(br), dx, dy); - b<2>(dst) = bilinearInterpolate(b<2>(tl), b<2>(tr), b<2>(bl), b<2>(br), dx, dy); - b<3>(dst) = bilinearInterpolate(b<3>(tl), b<3>(tr), b<3>(bl), b<3>(br), dx, dy); - } - i += dstSize.x; - } -} - -void nearestNeighborScale(const uint32_t* srcData, const vec2& srcSize, - const Rect& srcPos, uint32_t* dstData, - const vec2& dstSize, const Rect& dstPos) { - const auto factor = getFactor(srcPos, dstPos); - const auto bounds = getBounds(srcSize, srcPos, dstSize, dstPos, factor); - - double fractSrcY = srcPos.y; - double fractSrcX; - size_t i = dstSize.x * dstPos.y + dstPos.x; - uint32_t srcY; - uint32_t x, y; - for (y = 0; y < bounds.y; y++) { - fractSrcX = srcPos.x; - srcY = srcSize.x * uint32_t(fractSrcY); - for (x = 0; x < bounds.x; x++) { - dstData[i + x] = srcData[srcY + uint32_t(fractSrcX)]; - fractSrcX += factor.x; - } - i += dstSize.x; - fractSrcY += factor.y; - } -} - -} // namespace util -} // namespace mbgl diff --git a/src/mbgl/util/scaling.hpp b/src/mbgl/util/scaling.hpp deleted file mode 100644 index a2d582de1c0..00000000000 --- a/src/mbgl/util/scaling.hpp +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef MBGL_UTIL_SCALING -#define MBGL_UTIL_SCALING - - -#include -#include - -#include - -namespace mbgl { -namespace util { - -void bilinearScale(const uint32_t* srcData, const vec2& srcSize, - const Rect& srcPos, uint32_t* dstData, const vec2& dstSize, - const Rect& dstPos, bool wrap); - -void nearestNeighborScale(const uint32_t* srcData, const vec2& srcSize, - const Rect& srcPos, uint32_t* dstData, - const vec2& dstSize, const Rect& dstPos); -} // namespace util -} // namespace mbgl - -#endif diff --git a/test/miscellaneous/bilinear.cpp b/test/miscellaneous/bilinear.cpp deleted file mode 100644 index 3184e5739d4..00000000000 --- a/test/miscellaneous/bilinear.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include "../fixtures/util.hpp" -#include -#include -#include -#include -#include - -#include -#include - -using namespace mbgl; - -TEST(Bilinear, Scaling) { - // We're reading from a custom "image format" that has a uint32_t width/height prefix and then - // raw RGBA data. We can't use the built-in PNG reading routines because they are reading - // premultiplied images by default. - const std::string sprite = util::decompress(util::read_file("test/fixtures/sprites/bright.bin")); - const uint8_t *src = reinterpret_cast(sprite.data()); - ASSERT_GT(sprite.length(), 8u); - const uint32_t width = src[0] << 24 | src[1] << 16 | src[2] << 8 | src[3]; - const uint32_t height = src[4] << 24 | src[5] << 16 | src[6] << 8 | src[7]; - ASSERT_EQ(sprite.length(), 2 * sizeof(uint32_t) + width * height * sizeof(uint32_t)); - - const uint32_t *srcData = reinterpret_cast(src + 8); - const vec2 srcSize { width, height }; - const vec2 dstSize { 128, 128 }; - - UnassociatedImage dst { dstSize.x, dstSize.y }; - uint32_t *dstData = reinterpret_cast(dst.data.get()); - std::fill(dstData, dstData + dstSize.x * dstSize.y, 0xFFFF00FF); - - util::bilinearScale(srcData, srcSize, { 0, 0, 24, 24 }, dstData, dstSize, { 8, 8, 24, 24 }, false); - util::bilinearScale(srcData, srcSize, { 26, 0, 24, 24 }, dstData, dstSize, { 0, 40, 48, 48 }, false); - util::bilinearScale(srcData, srcSize, { 26, 26, 24, 24 }, dstData, dstSize, { 52, 40, 36, 36 }, false); - util::bilinearScale(srcData, srcSize, { 26, 26, 24, 24 }, dstData, dstSize, { 52, 40, 36, 36 }, false); - util::bilinearScale(srcData, srcSize, { 104, 0, 24, 24 }, dstData, dstSize, { 96, 0, 48, 48 }, false); - util::bilinearScale(srcData, srcSize, { 52, 260, 24, 24 }, dstData, dstSize, { 108, 108, 38, 38 }, false); - util::bilinearScale(srcData, srcSize, { 380, 0, 24, 24 }, dstData, dstSize, { 36, 0, 24, 24 }, false); - util::bilinearScale(srcData, srcSize, { 396, 396, 24, 24 }, dstData, dstSize, { 0, 0, 50, 50 }, false); - util::bilinearScale(srcData, srcSize, { 380, 182, 12, 12 }, dstData, dstSize, { 52, 80, 24, 24 }, false); - - // From the bottom - util::bilinearScale(srcData, srcSize, { 252, 380, 12, 12 }, dstData, dstSize, { 0, 90, 12, 12 }, false); - util::bilinearScale(srcData, srcSize, { 252, 380, 12, 12 }, dstData, dstSize, { 18, 90, 24, 24 }, false); - - const std::string data { reinterpret_cast(dstData), dstSize.x * dstSize.y * sizeof(uint32_t) }; - util::write_file("test/fixtures/sprites/atlas_actual.png", encodePNG(util::premultiply(std::move(dst)))); - util::write_file("test/fixtures/sprites/atlas_actual.bin", util::compress(data)); - - const std::string reference = util::decompress(util::read_file("test/fixtures/sprites/atlas_reference.bin")); - - EXPECT_EQ(reference.size(), data.size()); - EXPECT_TRUE(0 == std::memcmp(data.data(), reference.data(), data.size())); -} diff --git a/test/sprite/sprite_atlas.cpp b/test/sprite/sprite_atlas.cpp index fd78e971fcf..8e3c4317c08 100644 --- a/test/sprite/sprite_atlas.cpp +++ b/test/sprite/sprite_atlas.cpp @@ -34,8 +34,6 @@ TEST(Sprite, SpriteAtlas) { EXPECT_EQ(0, metro.pos.y); EXPECT_EQ(20, metro.pos.w); EXPECT_EQ(20, metro.pos.h); - EXPECT_EQ(18, metro.pos.originalW); - EXPECT_EQ(18, metro.pos.originalH); EXPECT_EQ(18, metro.texture->width); EXPECT_EQ(18, metro.texture->height); EXPECT_EQ(18, metro.texture->pixelWidth); @@ -45,12 +43,12 @@ TEST(Sprite, SpriteAtlas) { EXPECT_TRUE(atlas.getData()); auto pos = *atlas.getPosition("metro", false); - EXPECT_DOUBLE_EQ(20, pos.size[0]); - EXPECT_DOUBLE_EQ(20, pos.size[1]); + EXPECT_DOUBLE_EQ(18, pos.size[0]); + EXPECT_DOUBLE_EQ(18, pos.size[1]); EXPECT_DOUBLE_EQ(1.0f / 63, pos.tl[0]); EXPECT_DOUBLE_EQ(1.0f / 112, pos.tl[1]); - EXPECT_DOUBLE_EQ(21.0f / 63, pos.br[0]); - EXPECT_DOUBLE_EQ(21.0f / 112, pos.br[1]); + EXPECT_DOUBLE_EQ(19.0f / 63, pos.br[0]); + EXPECT_DOUBLE_EQ(19.0f / 112, pos.br[1]); auto missing = atlas.getImage("doesnotexist", false); EXPECT_FALSE(missing); @@ -68,12 +66,10 @@ TEST(Sprite, SpriteAtlas) { EXPECT_EQ(0, metro2.pos.y); EXPECT_EQ(20, metro2.pos.w); EXPECT_EQ(20, metro2.pos.h); - EXPECT_EQ(18, metro2.pos.originalW); - EXPECT_EQ(18, metro2.pos.originalH); const size_t bytes = atlas.getTextureWidth() * atlas.getTextureHeight() * 4; const auto hash = test::crc64(reinterpret_cast(atlas.getData()), bytes); - EXPECT_EQ(0x9875FC0595489A9Fu, hash) << std::hex << hash; + EXPECT_EQ(11868256915183397177u, hash) << std::hex << hash; // util::write_file( // "test/fixtures/annotations/atlas1.png", @@ -98,10 +94,8 @@ TEST(Sprite, SpriteAtlasSize) { auto metro = *atlas.getImage("metro", false); EXPECT_EQ(0, metro.pos.x); EXPECT_EQ(0, metro.pos.y); - EXPECT_EQ(20, metro.pos.w); - EXPECT_EQ(20, metro.pos.h); - EXPECT_EQ(18, metro.pos.originalW); - EXPECT_EQ(18, metro.pos.originalH); + EXPECT_EQ(16, metro.pos.w); + EXPECT_EQ(16, metro.pos.h); EXPECT_EQ(18, metro.texture->width); EXPECT_EQ(18, metro.texture->height); EXPECT_EQ(18, metro.texture->pixelWidth); @@ -110,7 +104,7 @@ TEST(Sprite, SpriteAtlasSize) { const size_t bytes = atlas.getTextureWidth() * atlas.getTextureHeight() * 4; const auto hash = test::crc64(reinterpret_cast(atlas.getData()), bytes); - EXPECT_EQ(0x2CDDA7DBB04D116Du, hash) << std::hex << hash; + EXPECT_EQ(18324190582232646342u, hash) << std::hex << hash; // util::write_file( // "test/fixtures/annotations/atlas2.png", @@ -134,8 +128,6 @@ TEST(Sprite, SpriteAtlasUpdates) { EXPECT_EQ(0, one.pos.y); EXPECT_EQ(20, one.pos.w); EXPECT_EQ(16, one.pos.h); - EXPECT_EQ(16, one.pos.originalW); - EXPECT_EQ(12, one.pos.originalH); EXPECT_EQ(16, one.texture->width); EXPECT_EQ(12, one.texture->height); EXPECT_EQ(16, one.texture->pixelWidth); diff --git a/test/test.gypi b/test/test.gypi index f8818e20840..21b20388767 100644 --- a/test/test.gypi +++ b/test/test.gypi @@ -47,7 +47,6 @@ 'miscellaneous/async_task.cpp', 'miscellaneous/clip_ids.cpp', 'miscellaneous/binpack.cpp', - 'miscellaneous/bilinear.cpp', 'miscellaneous/comparisons.cpp', 'miscellaneous/functions.cpp', 'miscellaneous/geo.cpp',