2014-03-08 01:26:17 +04: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-17 03:27:26 +03:00
|
|
|
#include "WebGLFormats.h"
|
2014-03-08 01:26:17 +04:00
|
|
|
|
2015-11-24 06:27:13 +03:00
|
|
|
namespace mozilla {
|
2015-07-17 03:27:26 +03:00
|
|
|
|
2015-11-24 08:55:59 +03:00
|
|
|
using mozilla::webgl::EffectiveFormat;
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
WebGLExtensionColorBufferHalfFloat::WebGLExtensionColorBufferHalfFloat(WebGLContext* webgl)
|
|
|
|
: WebGLExtensionBase(webgl)
|
2014-03-08 01:26:17 +04:00
|
|
|
{
|
2014-11-14 07:03:50 +03:00
|
|
|
MOZ_ASSERT(IsSupported(webgl), "Don't construct extension if unsupported.");
|
2015-07-17 03:27:26 +03:00
|
|
|
|
2015-11-24 08:55:59 +03:00
|
|
|
webgl::FormatUsageAuthority* authority = webgl->mFormatUsage.get();
|
2015-07-17 03:27:26 +03:00
|
|
|
|
2015-11-24 08:55:59 +03:00
|
|
|
auto updateUsage = [authority](EffectiveFormat effectiveFormat) {
|
|
|
|
webgl::FormatUsageInfo* usage = authority->GetUsage(effectiveFormat);
|
|
|
|
MOZ_ASSERT(usage);
|
|
|
|
usage->asRenderbuffer = usage->isRenderable = true;
|
2015-07-17 03:27:26 +03:00
|
|
|
};
|
|
|
|
|
2015-11-24 08:55:59 +03:00
|
|
|
// Ensure require formats are initialized.
|
|
|
|
WebGLExtensionTextureHalfFloat::InitWebGLFormats(authority);
|
2015-07-17 03:27:26 +03:00
|
|
|
|
2015-11-24 08:55:59 +03:00
|
|
|
// Update usage to allow asRenderbuffer and isRenderable
|
|
|
|
updateUsage(EffectiveFormat::RGBA16F);
|
|
|
|
updateUsage(EffectiveFormat::RGB16F);
|
|
|
|
updateUsage(EffectiveFormat::Luminance16FAlpha16F);
|
|
|
|
updateUsage(EffectiveFormat::Luminance16F);
|
|
|
|
updateUsage(EffectiveFormat::Alpha16F);
|
2014-03-08 01:26:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
WebGLExtensionColorBufferHalfFloat::~WebGLExtensionColorBufferHalfFloat()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2014-11-14 07:03:50 +03:00
|
|
|
WebGLExtensionColorBufferHalfFloat::IsSupported(const WebGLContext* webgl)
|
2014-03-08 01:26:17 +04:00
|
|
|
{
|
2014-11-14 07:03:50 +03:00
|
|
|
gl::GLContext* gl = webgl->GL();
|
2014-11-22 02:04:08 +03:00
|
|
|
|
|
|
|
// ANGLE doesn't support ReadPixels from a RGBA16F with RGBA/FLOAT.
|
2015-02-25 01:09:09 +03:00
|
|
|
return gl->IsSupported(gl::GLFeature::renderbuffer_color_half_float) ||
|
|
|
|
gl->IsANGLE();
|
2014-03-08 01:26:17 +04:00
|
|
|
}
|
|
|
|
|
2015-06-01 17:17:00 +03:00
|
|
|
IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionColorBufferHalfFloat, EXT_color_buffer_half_float)
|
2014-11-14 07:03:50 +03:00
|
|
|
|
|
|
|
} // namespace mozilla
|