2014-03-07 13:26:17 -08: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-16 17:27:26 -07:00
|
|
|
#include "WebGLFormats.h"
|
2014-03-07 13:26:17 -08:00
|
|
|
|
2015-11-24 20:15:29 -08:00
|
|
|
#ifdef FOO
|
|
|
|
#error FOO is already defined! We use FOO() macros to keep things succinct in this file.
|
|
|
|
#endif
|
2015-07-16 17:27:26 -07:00
|
|
|
|
2015-11-24 20:15:29 -08:00
|
|
|
namespace mozilla {
|
2015-11-23 21:55:59 -08:00
|
|
|
|
2014-11-13 20:03:50 -08:00
|
|
|
WebGLExtensionColorBufferHalfFloat::WebGLExtensionColorBufferHalfFloat(WebGLContext* webgl)
|
|
|
|
: WebGLExtensionBase(webgl)
|
2014-03-07 13:26:17 -08:00
|
|
|
{
|
2014-11-13 20:03:50 -08:00
|
|
|
MOZ_ASSERT(IsSupported(webgl), "Don't construct extension if unsupported.");
|
2015-07-16 17:27:26 -07:00
|
|
|
|
2015-11-24 20:15:29 -08:00
|
|
|
auto& fua = webgl->mFormatUsage;
|
2015-07-16 17:27:26 -07:00
|
|
|
|
2015-11-24 20:15:29 -08:00
|
|
|
auto fnUpdateUsage = [&fua](GLenum sizedFormat, webgl::EffectiveFormat effFormat) {
|
|
|
|
auto usage = fua->EditUsage(effFormat);
|
|
|
|
usage->isRenderable = true;
|
|
|
|
fua->AllowRBFormat(sizedFormat, usage);
|
2015-07-16 17:27:26 -07:00
|
|
|
};
|
|
|
|
|
2015-11-24 20:15:29 -08:00
|
|
|
#define FOO(x) fnUpdateUsage(LOCAL_GL_ ## x, webgl::EffectiveFormat::x)
|
|
|
|
|
|
|
|
FOO(RGBA16F);
|
|
|
|
FOO(RGB16F);
|
2015-07-16 17:27:26 -07:00
|
|
|
|
2015-11-24 20:15:29 -08:00
|
|
|
#undef FOO
|
2014-03-07 13:26:17 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
WebGLExtensionColorBufferHalfFloat::~WebGLExtensionColorBufferHalfFloat()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2014-11-13 20:03:50 -08:00
|
|
|
WebGLExtensionColorBufferHalfFloat::IsSupported(const WebGLContext* webgl)
|
2014-03-07 13:26:17 -08:00
|
|
|
{
|
2014-11-13 20:03:50 -08:00
|
|
|
gl::GLContext* gl = webgl->GL();
|
2014-11-21 15:04:08 -08:00
|
|
|
|
|
|
|
// ANGLE doesn't support ReadPixels from a RGBA16F with RGBA/FLOAT.
|
2015-02-24 14:09:09 -08:00
|
|
|
return gl->IsSupported(gl::GLFeature::renderbuffer_color_half_float) ||
|
|
|
|
gl->IsANGLE();
|
2014-03-07 13:26:17 -08:00
|
|
|
}
|
|
|
|
|
2015-06-01 07:17:00 -07:00
|
|
|
IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionColorBufferHalfFloat, EXT_color_buffer_half_float)
|
2014-11-13 20:03:50 -08:00
|
|
|
|
|
|
|
} // namespace mozilla
|