WebGLExtensionEXTColorBufferFloat.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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/. */
  4. #include "WebGLExtensions.h"
  5. #include "GLContext.h"
  6. #include "mozilla/dom/WebGL2RenderingContextBinding.h"
  7. #include "WebGLContext.h"
  8. #include "WebGLFormats.h"
  9. namespace mozilla {
  10. WebGLExtensionEXTColorBufferFloat::WebGLExtensionEXTColorBufferFloat(WebGLContext* webgl)
  11. : WebGLExtensionBase(webgl)
  12. {
  13. MOZ_ASSERT(IsSupported(webgl), "Don't construct extension if unsupported.");
  14. auto& fua = webgl->mFormatUsage;
  15. auto fnUpdateUsage = [&fua](GLenum sizedFormat, webgl::EffectiveFormat effFormat) {
  16. auto usage = fua->EditUsage(effFormat);
  17. usage->SetRenderable();
  18. fua->AllowRBFormat(sizedFormat, usage);
  19. };
  20. #define FOO(x) fnUpdateUsage(LOCAL_GL_ ## x, webgl::EffectiveFormat::x)
  21. FOO(R16F);
  22. FOO(RG16F);
  23. FOO(RGBA16F);
  24. FOO(R32F);
  25. FOO(RG32F);
  26. FOO(RGBA32F);
  27. FOO(R11F_G11F_B10F);
  28. #undef FOO
  29. }
  30. /*static*/ bool
  31. WebGLExtensionEXTColorBufferFloat::IsSupported(const WebGLContext* webgl)
  32. {
  33. const gl::GLContext* gl = webgl->GL();
  34. return gl->IsSupported(gl::GLFeature::EXT_color_buffer_float);
  35. }
  36. IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionEXTColorBufferFloat, EXT_color_buffer_float)
  37. } // namespace mozilla