WebGLExtensionCompressedTexturePVRTC.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. #ifdef FOO
  9. #error FOO is already defined! We use FOO() macros to keep things succinct in this file.
  10. #endif
  11. namespace mozilla {
  12. WebGLExtensionCompressedTexturePVRTC::WebGLExtensionCompressedTexturePVRTC(WebGLContext* webgl)
  13. : WebGLExtensionBase(webgl)
  14. {
  15. RefPtr<WebGLContext> webgl_ = webgl; // Bug 1201275
  16. const auto fnAdd = [&webgl_](GLenum sizedFormat, webgl::EffectiveFormat effFormat) {
  17. auto& fua = webgl_->mFormatUsage;
  18. auto usage = fua->EditUsage(effFormat);
  19. usage->isFilterable = true;
  20. fua->AllowSizedTexFormat(sizedFormat, usage);
  21. webgl_->mCompressedTextureFormats.AppendElement(sizedFormat);
  22. };
  23. #define FOO(x) LOCAL_GL_ ## x, webgl::EffectiveFormat::x
  24. fnAdd(FOO(COMPRESSED_RGB_PVRTC_4BPPV1));
  25. fnAdd(FOO(COMPRESSED_RGB_PVRTC_2BPPV1));
  26. fnAdd(FOO(COMPRESSED_RGBA_PVRTC_4BPPV1));
  27. fnAdd(FOO(COMPRESSED_RGBA_PVRTC_2BPPV1));
  28. #undef FOO
  29. }
  30. WebGLExtensionCompressedTexturePVRTC::~WebGLExtensionCompressedTexturePVRTC()
  31. {
  32. }
  33. IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionCompressedTexturePVRTC, WEBGL_compressed_texture_pvrtc)
  34. } // namespace mozilla