* [qt] Updating CMake project files for Qt6 * [qt] Updating non-test projects for Qt6 and msvc2019 * [qt] Test fixes for Qt6 and msvc2019 * [qt] Link whole test archive for Qt and msvc2019 * [qt] Fixing Qt6 headless backend renderer * [qt] Fixes for test failures * [qt] Expression and style parser test fixes * [qt] Backwards compatibility with Qt5 and Qt6 Minimum version is Qt 5.4 due to use of QOpenGLWidget * [qt] LLVM is no longer required for a Windows build * [msvc] msvc2019 fixes for maplibre * Update test/storage/offline_database.test.cpp Co-authored-by: Tadej Novak <tadej@tano.si> * Vector + const is not standard C++ Co-authored-by: Tadej Novak <tadej@tano.si>
45 lines
1.3 KiB
C++
45 lines
1.3 KiB
C++
#include <mbgl/gl/context.hpp>
|
|
#include <mbgl/gl/texture_resource.hpp>
|
|
|
|
namespace mbgl {
|
|
namespace gl {
|
|
|
|
static int channelCount(gfx::TexturePixelType format) {
|
|
switch (format) {
|
|
case gfx::TexturePixelType::Alpha:
|
|
case gfx::TexturePixelType::Depth:
|
|
case gfx::TexturePixelType::Luminance:
|
|
case gfx::TexturePixelType::Stencil:
|
|
return 1;
|
|
case gfx::TexturePixelType::RGBA:
|
|
return 4;
|
|
default:
|
|
assert(!"Unknown texture pixel type");
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
static int channelStorageSize(gfx::TextureChannelDataType type) {
|
|
switch (type) {
|
|
case gfx::TextureChannelDataType::HalfFloat:
|
|
return 2;
|
|
case gfx::TextureChannelDataType::UnsignedByte:
|
|
return 1;
|
|
default:
|
|
assert(!"Unknown texture channel data type");
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
TextureResource::~TextureResource() noexcept {
|
|
auto& stats = texture.get_deleter().context->renderingStats();
|
|
stats.memTextures -= byteSize;
|
|
assert(stats.memTextures >= 0);
|
|
}
|
|
|
|
int TextureResource::getStorageSize(const Size& size, gfx::TexturePixelType format, gfx::TextureChannelDataType type) {
|
|
return size.width * size.height * channelCount(format) * channelStorageSize(type);
|
|
}
|
|
|
|
} // namespace gl
|
|
} // namespace mbgl
|