[core] move supportsHalfFloatTextures to gfx::Context

This commit is contained in:
Konstantin Käfer
2019-03-20 16:24:36 +01:00
parent 394e2aa717
commit 5270b2ffbd
3 changed files with 6 additions and 9 deletions

View File

@@ -52,15 +52,12 @@ void RenderHeatmapLayer::render(PaintParameters& parameters, RenderSource*) {
return;
}
// TODO: remove cast
gl::Context& glContext = static_cast<gl::Context&>(parameters.context);
if (parameters.pass == RenderPass::Pass3D) {
const auto& viewportSize = parameters.staticData.backendSize;
const auto size = Size{viewportSize.width / 4, viewportSize.height / 4};
if (!renderTexture || renderTexture->getSize() != size) {
if (glContext.supportsHalfFloatTextures) {
if (parameters.context.supportsHalfFloatTextures) {
renderTexture = OffscreenTexture(parameters.context, size, gfx::TextureChannelDataType::HalfFloat);
try {
@@ -68,11 +65,11 @@ void RenderHeatmapLayer::render(PaintParameters& parameters, RenderSource*) {
} catch (const std::runtime_error& ex) {
// can't render to a half-float texture; falling back to unsigned byte one
renderTexture = nullopt;
glContext.supportsHalfFloatTextures = false;
parameters.context.supportsHalfFloatTextures = false;
}
}
if (!glContext.supportsHalfFloatTextures || !renderTexture) {
if (!parameters.context.supportsHalfFloatTextures || !renderTexture) {
renderTexture = OffscreenTexture(parameters.context, size, gfx::TextureChannelDataType::UnsignedByte);
renderTexture->bind();
}
@@ -85,7 +82,8 @@ void RenderHeatmapLayer::render(PaintParameters& parameters, RenderSource*) {
colorRampTexture = parameters.context.createTexture(colorRamp, gfx::TextureChannelDataType::UnsignedByte);
}
glContext.clear(Color{ 0.0f, 0.0f, 0.0f, 1.0f }, {}, {});
// TODO: remove cast
static_cast<gl::Context&>(parameters.context).clear(Color{ 0.0f, 0.0f, 0.0f, 1.0f }, {}, {});
for (const RenderTile& tile : renderTiles) {
auto bucket_ = tile.tile.getBucket<HeatmapBucket>(*baseImpl);