dom/canvas/WebGLExtensionColorBufferHalfFloat.cpp
author Jeff Gilbert <jgilbert@mozilla.com>
Wed, 20 Jul 2016 17:11:33 -0700
changeset 391213 ba1bd91de8858daeeac68e84736e193e87b2a34a
parent 391212 75f2b17550316ecb4b320bca9325520c2f1c7673
permissions -rw-r--r--
Bug 1288643 - Don't put up with macro redefinition. - r=jerry MozReview-Commit-ID: BJ3V7dOUfjx

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "WebGLExtensions.h"

#include "GLContext.h"
#include "mozilla/dom/WebGLRenderingContextBinding.h"
#include "WebGLContext.h"
#include "WebGLFormats.h"

namespace mozilla {

WebGLExtensionColorBufferHalfFloat::WebGLExtensionColorBufferHalfFloat(WebGLContext* webgl)
    : WebGLExtensionBase(webgl)
{
    MOZ_ASSERT(IsSupported(webgl), "Don't construct extension if unsupported.");

    auto& fua = webgl->mFormatUsage;

    auto fnUpdateUsage = [&fua](GLenum sizedFormat, webgl::EffectiveFormat effFormat) {
        auto usage = fua->EditUsage(effFormat);
        usage->SetRenderable();
        fua->AllowRBFormat(sizedFormat, usage);
    };

#define FOO(x) fnUpdateUsage(LOCAL_GL_ ## x, webgl::EffectiveFormat::x)

    FOO(RGBA16F);
    FOO(RGB16F);

#undef FOO
}

/*static*/ bool
WebGLExtensionColorBufferHalfFloat::IsSupported(const WebGLContext* webgl)
{
    if (webgl->IsWebGL2())
        return false;

    return webgl->GL()->IsSupported(gl::GLFeature::renderbuffer_color_half_float);
}

IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionColorBufferHalfFloat, EXT_color_buffer_half_float)

} // namespace mozilla