From 94f011895c8e1bde36ee2ec235dbbcf2c994ac4c Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Fri, 10 Feb 2017 17:18:18 -0800 Subject: [core] Make Image safer Provide Image::copy, which handles copying rectangles from a source to a destination, with thorough bounds checking. Also fixes an indexing error in SpriteAtlas, where the top row of pixels in a wrapped image was copied from the wrong source row. --- include/mbgl/util/size.hpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include/mbgl/util/size.hpp') diff --git a/include/mbgl/util/size.hpp b/include/mbgl/util/size.hpp index 1af85bcff5..79679a92fb 100644 --- a/include/mbgl/util/size.hpp +++ b/include/mbgl/util/size.hpp @@ -13,6 +13,10 @@ public: constexpr Size(const uint32_t width_, const uint32_t height_) : width(width_), height(height_) { } + constexpr uint32_t area() const { + return width * height; + } + constexpr explicit operator bool() const { return width > 0 && height > 0; } -- cgit v1.2.1