This is first part of work on porting mapbox/mapbox-gl-js#8694 - in follow up patch(es) it is required to remove CPU side copy using 2d canvas support on all supported platforms, similar to approach taken in gl.js https://github.com/mapbox/mapbox-gl-js/pull/8694/files#diff-34dbe5f7de34dc4b9a8745dcde9bdc37R48 Decoding on CPU removed. Padding is still done in DEMData() but, instead od doing it wwhile decoding, it is using memcpy to pad original values. Rebase to latest mapbox-gl-js master and re-generate shaders. Partly fixes: #15503
45 lines
940 B
C++
45 lines
940 B
C++
#pragma once
|
|
|
|
#include <mbgl/math/clamp.hpp>
|
|
#include <mbgl/util/image.hpp>
|
|
#include <mbgl/util/tileset.hpp>
|
|
|
|
#include <memory>
|
|
#include <array>
|
|
#include <cassert>
|
|
#include <vector>
|
|
|
|
namespace mbgl {
|
|
|
|
class DEMData {
|
|
public:
|
|
DEMData(const PremultipliedImage& image, Tileset::DEMEncoding encoding);
|
|
void backfillBorder(const DEMData& borderTileData, int8_t dx, int8_t dy);
|
|
|
|
int32_t get(const int32_t x, const int32_t y) const;
|
|
const std::array<float, 4>& getUnpackVector() const;
|
|
|
|
const PremultipliedImage* getImage() const {
|
|
return ℑ
|
|
}
|
|
|
|
const int32_t dim;
|
|
const int32_t stride;
|
|
|
|
|
|
private:
|
|
Tileset::DEMEncoding encoding;
|
|
PremultipliedImage image;
|
|
|
|
size_t idx(const int32_t x, const int32_t y) const {
|
|
assert(x >= -1);
|
|
assert(x < dim + 1);
|
|
assert(y >= -1);
|
|
assert(y < dim + 1);
|
|
return (y + 1) * stride + (x + 1);
|
|
}
|
|
|
|
};
|
|
|
|
} // namespace mbgl
|