[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.
This commit is contained in:
John Firebaugh
2017-02-10 17:18:18 -08:00
parent c6d5eaf479
commit 94f011895c
15 changed files with 163 additions and 116 deletions

View File

@@ -8,7 +8,7 @@ namespace mbgl {
FrameHistory::FrameHistory() {
changeOpacities.fill(0);
std::fill(opacities.data.get(), opacities.data.get() + opacities.bytes(), 0);
opacities.fill(0);
}
void FrameHistory::record(const TimePoint& now, float zoom, const Duration& duration) {

View File

@@ -26,7 +26,7 @@ public:
private:
std::array<TimePoint, 256> changeTimes;
std::array<uint8_t, 256> changeOpacities;
const AlphaImage opacities{ { 256, 1 } };
AlphaImage opacities{ { 256, 1 } };
int16_t previousZoomIndex = 0;
TimePoint previousTime;