2014-03-08 01:26:17 +04: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 03:27:26 +03:00
|
|
|
#include "WebGLFormats.h"
|
2014-03-08 01:26:17 +04:00
|
|
|
|
2015-11-25 07:15:29 +03:00
|
|
|
namespace mozilla {
|
2015-11-24 08:55:59 +03:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
WebGLExtensionColorBufferFloat::WebGLExtensionColorBufferFloat(
|
|
|
|
WebGLContext* webgl)
|
|
|
|
: WebGLExtensionBase(webgl) {
|
|
|
|
MOZ_ASSERT(IsSupported(webgl), "Don't construct extension if unsupported.");
|
2019-07-09 08:21:30 +03:00
|
|
|
SetRenderable(webgl::FormatRenderableState::Implicit(
|
|
|
|
WebGLExtensionID::WEBGL_color_buffer_float));
|
|
|
|
}
|
2015-07-17 03:27:26 +03:00
|
|
|
|
2019-07-09 08:21:30 +03:00
|
|
|
void WebGLExtensionColorBufferFloat::SetRenderable(
|
|
|
|
const webgl::FormatRenderableState state) {
|
|
|
|
auto& fua = mContext->mFormatUsage;
|
2015-07-17 03:27:26 +03:00
|
|
|
|
2019-07-09 08:21:30 +03:00
|
|
|
auto fnUpdateUsage = [&](GLenum sizedFormat,
|
|
|
|
webgl::EffectiveFormat effFormat) {
|
2015-11-25 07:15:29 +03:00
|
|
|
auto usage = fua->EditUsage(effFormat);
|
2019-07-09 08:21:30 +03:00
|
|
|
usage->SetRenderable(state);
|
2015-11-25 07:15:29 +03:00
|
|
|
fua->AllowRBFormat(sizedFormat, usage);
|
2015-07-17 03:27:26 +03:00
|
|
|
};
|
|
|
|
|
2015-11-25 07:15:29 +03:00
|
|
|
#define FOO(x) fnUpdateUsage(LOCAL_GL_##x, webgl::EffectiveFormat::x)
|
|
|
|
|
|
|
|
// The extension doesn't actually add RGB32F; only RGBA32F.
|
|
|
|
FOO(RGBA32F);
|
2015-07-17 03:27:26 +03:00
|
|
|
|
2015-11-25 07:15:29 +03:00
|
|
|
#undef FOO
|
2014-03-08 01:26:17 +04:00
|
|
|
}
|
|
|
|
|
2019-07-09 08:21:30 +03:00
|
|
|
void WebGLExtensionColorBufferFloat::OnSetExplicit() {
|
|
|
|
SetRenderable(webgl::FormatRenderableState::Explicit());
|
|
|
|
}
|
|
|
|
|
2014-03-08 01:26:17 +04:00
|
|
|
WebGLExtensionColorBufferFloat::~WebGLExtensionColorBufferFloat() {}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
bool WebGLExtensionColorBufferFloat::IsSupported(const WebGLContext* webgl) {
|
2019-02-05 06:34:49 +03:00
|
|
|
if (webgl->IsWebGL2()) return false;
|
|
|
|
|
2017-12-23 00:21:26 +03:00
|
|
|
const auto& gl = webgl->gl;
|
|
|
|
return gl->IsSupported(gl::GLFeature::renderbuffer_color_float) &&
|
|
|
|
gl->IsSupported(gl::GLFeature::frag_color_float);
|
2014-03-08 01:26:17 +04:00
|
|
|
}
|
|
|
|
|
2015-06-01 17:17:00 +03:00
|
|
|
IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionColorBufferFloat,
|
|
|
|
WEBGL_color_buffer_float)
|
2014-11-14 07:03:50 +03:00
|
|
|
|
|
|
|
} // namespace mozilla
|