Bug 1610775 [wpt PR 21336] - Update urllib3 to 1.25.8, a=testonly
[gecko.git] / dom / canvas / WebGLExtensionColorBufferHalfFloat.cpp
blobfea29d3e278e4eb2b46bd005943887e9f13b1e66
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #include "WebGLExtensions.h"
7 #include "GLContext.h"
8 #include "mozilla/dom/WebGLRenderingContextBinding.h"
9 #include "WebGLContext.h"
10 #include "WebGLFormats.h"
12 namespace mozilla {
14 WebGLExtensionColorBufferHalfFloat::WebGLExtensionColorBufferHalfFloat(
15 WebGLContext* webgl)
16 : WebGLExtensionBase(webgl) {
17 MOZ_ASSERT(IsSupported(webgl), "Don't construct extension if unsupported.");
18 SetRenderable(webgl::FormatRenderableState::Implicit(
19 WebGLExtensionID::EXT_color_buffer_half_float));
22 void WebGLExtensionColorBufferHalfFloat::SetRenderable(
23 const webgl::FormatRenderableState state) {
24 auto& fua = mContext->mFormatUsage;
26 auto fnUpdateUsage = [&](GLenum sizedFormat, webgl::EffectiveFormat effFormat,
27 const bool renderable) {
28 auto usage = fua->EditUsage(effFormat);
29 if (renderable) {
30 usage->SetRenderable(state);
32 fua->AllowRBFormat(sizedFormat, usage, renderable);
35 #define FOO(x, y) fnUpdateUsage(LOCAL_GL_##x, webgl::EffectiveFormat::x, y)
37 FOO(RGBA16F, true);
38 FOO(RGB16F, false); // It's not required, thus not portable. (Also there's a
39 // wicked driver bug on Mac+Intel)
41 #undef FOO
44 void WebGLExtensionColorBufferHalfFloat::OnSetExplicit() {
45 SetRenderable(webgl::FormatRenderableState::Explicit());
48 bool WebGLExtensionColorBufferHalfFloat::IsSupported(
49 const WebGLContext* webgl) {
50 if (webgl->IsWebGL2()) return false;
52 const auto& gl = webgl->gl;
53 return gl->IsSupported(gl::GLFeature::renderbuffer_color_half_float) &&
54 gl->IsSupported(gl::GLFeature::frag_color_float);
57 } // namespace mozilla