WebGLExtensionColorBufferFloat.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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/WebGLRenderingContextBinding.h"
  7. #include "WebGLContext.h"
  8. #include "WebGLFormats.h"
  9. #ifdef FOO
  10. #error FOO is already defined! We use FOO() macros to keep things succinct in this file.
  11. #endif
  12. namespace mozilla {
  13. WebGLExtensionColorBufferFloat::WebGLExtensionColorBufferFloat(WebGLContext* webgl)
  14. : WebGLExtensionBase(webgl)
  15. {
  16. MOZ_ASSERT(IsSupported(webgl), "Don't construct extension if unsupported.");
  17. auto& fua = webgl->mFormatUsage;
  18. auto fnUpdateUsage = [&fua](GLenum sizedFormat, webgl::EffectiveFormat effFormat) {
  19. auto usage = fua->EditUsage(effFormat);
  20. usage->SetRenderable();
  21. fua->AllowRBFormat(sizedFormat, usage);
  22. };
  23. #define FOO(x) fnUpdateUsage(LOCAL_GL_ ## x, webgl::EffectiveFormat::x)
  24. // The extension doesn't actually add RGB32F; only RGBA32F.
  25. FOO(RGBA32F);
  26. #undef FOO
  27. }
  28. WebGLExtensionColorBufferFloat::~WebGLExtensionColorBufferFloat()
  29. {
  30. }
  31. bool
  32. WebGLExtensionColorBufferFloat::IsSupported(const WebGLContext* webgl)
  33. {
  34. gl::GLContext* gl = webgl->GL();
  35. // ANGLE supports this, but doesn't have a way to advertize its support,
  36. // since it's compliant with WEBGL_color_buffer_float's clamping, but not
  37. // EXT_color_buffer_float.
  38. return gl->IsSupported(gl::GLFeature::renderbuffer_color_float) ||
  39. gl->IsANGLE();
  40. }
  41. IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionColorBufferFloat, WEBGL_color_buffer_float)
  42. } // namespace mozilla