Files
MapLibreParticleLab/include/mbgl/util/size.hpp
John Firebaugh 94f011895c [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.
2017-02-14 12:29:01 -06:00

37 lines
698 B
C++

#pragma once
#include <cstdint>
#include <array>
namespace mbgl {
class Size {
public:
constexpr Size() : width(0), height(0) {
}
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;
}
uint32_t width;
uint32_t height;
};
constexpr inline bool operator==(const Size& a, const Size& b) {
return a.width == b.width && a.height == b.height;
}
constexpr inline bool operator!=(const Size& a, const Size& b) {
return !(a == b);
}
} // namespace mbgl