summaryrefslogtreecommitdiff
path: root/include/mbgl/util/size.hpp
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2017-02-10 17:18:18 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-02-14 12:29:01 -0600
commit94f011895c8e1bde36ee2ec235dbbcf2c994ac4c (patch)
tree9a9724792f87eb3c74aa2ac3d3114ca45d91471b /include/mbgl/util/size.hpp
parentc6d5eaf47941162ee6166842d5434a0e3a6c33a0 (diff)
downloadqtlocation-mapboxgl-94f011895c8e1bde36ee2ec235dbbcf2c994ac4c.tar.gz
[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.
Diffstat (limited to 'include/mbgl/util/size.hpp')
-rw-r--r--include/mbgl/util/size.hpp4
1 files changed, 4 insertions, 0 deletions
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;
}