2014-03-07 21:26:17 +00:00
|
|
|
/* 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"
|
2015-07-17 00:27:26 +00:00
|
|
|
#include "WebGLFormats.h"
|
2014-03-07 21:26:17 +00:00
|
|
|
|
2015-11-25 04:15:29 +00:00
|
|
|
namespace mozilla {
|
2015-11-24 05:55:59 +00:00
|
|
|
|
2014-11-14 04:03:50 +00:00
|
|
|
WebGLExtensionColorBufferHalfFloat::WebGLExtensionColorBufferHalfFloat(
|
|
|
|
WebGLContext* webgl)
|
|
|
|
: WebGLExtensionBase(webgl) {
|
|
|
|
MOZ_ASSERT(IsSupported(webgl), "Don't construct extension if unsupported.");
|
2015-07-17 00:27:26 +00:00
|
|
|
|
2015-11-25 04:15:29 +00:00
|
|
|
auto& fua = webgl->mFormatUsage;
|
2015-07-17 00:27:26 +00:00
|
|
|
|
2015-11-25 04:15:29 +00:00
|
|
|
auto fnUpdateUsage = [&fua](GLenum sizedFormat,
|
|
|
|
webgl::EffectiveFormat effFormat) {
|
|
|
|
auto usage = fua->EditUsage(effFormat);
|
2016-06-06 20:43:18 +00:00
|
|
|
usage->SetRenderable();
|
2015-11-25 04:15:29 +00:00
|
|
|
fua->AllowRBFormat(sizedFormat, usage);
|
2015-07-17 00:27:26 +00:00
|
|
|
};
|
|
|
|
|
2015-11-25 04:15:29 +00:00
|
|
|
#define FOO(x) fnUpdateUsage(LOCAL_GL_##x, webgl::EffectiveFormat::x)
|
|
|
|
|
|
|
|
FOO(RGBA16F);
|
|
|
|
FOO(RGB16F);
|
2015-07-17 00:27:26 +00:00
|
|
|
|
2015-11-25 04:15:29 +00:00
|
|
|
#undef FOO
|
2014-03-07 21:26:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
WebGLExtensionColorBufferHalfFloat::~WebGLExtensionColorBufferHalfFloat() {}
|
|
|
|
|
2014-11-14 04:03:50 +00:00
|
|
|
bool WebGLExtensionColorBufferHalfFloat::IsSupported(
|
|
|
|
const WebGLContext* webgl) {
|
2017-12-22 21:21:26 +00:00
|
|
|
const auto& gl = webgl->gl;
|
|
|
|
return gl->IsSupported(gl::GLFeature::renderbuffer_color_half_float) &&
|
|
|
|
gl->IsSupported(gl::GLFeature::frag_color_float);
|
2014-03-07 21:26:17 +00:00
|
|
|
}
|
|
|
|
|
2015-06-01 14:17:00 +00:00
|
|
|
IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionColorBufferHalfFloat,
|
|
|
|
EXT_color_buffer_half_float)
|
2014-11-14 04:03:50 +00:00
|
|
|
|
|
|
|
} // namespace mozilla
|