Bug 823454 - Implement EXT_frag_depth for WebGL. - r=kamidphish

This commit is contained in:
Jeff Gilbert 2014-02-13 15:00:12 -08:00
parent 7cce3037c1
commit 6c7fc28cfd
11 changed files with 78 additions and 0 deletions

View File

@ -895,6 +895,7 @@ protected:
// -------------------------------------------------------------------------
// WebGL extensions (implemented in WebGLContextExtensions.cpp)
enum WebGLExtensionID {
EXT_frag_depth,
EXT_sRGB,
EXT_texture_filter_anisotropic,
OES_element_index_uint,

View File

@ -17,6 +17,7 @@ using namespace mozilla::gl;
// must match WebGLContext::WebGLExtensionID
static const char *sExtensionNames[] = {
"EXT_frag_depth",
"EXT_sRGB",
"EXT_texture_filter_anisotropic",
"OES_element_index_uint",
@ -139,6 +140,8 @@ bool WebGLContext::IsExtensionSupported(WebGLExtensionID ext) const
return WebGLExtensionSRGB::IsSupported(this);
case WEBGL_draw_buffers:
return WebGLExtensionDrawBuffers::IsSupported(this);
case EXT_frag_depth:
return WebGLExtensionFragDepth::IsSupported(this);
default:
// For warnings-as-errors.
break;
@ -295,6 +298,9 @@ WebGLContext::EnableExtension(WebGLExtensionID ext)
case EXT_sRGB:
obj = new WebGLExtensionSRGB(this);
break;
case EXT_frag_depth:
obj = new WebGLExtensionFragDepth(this);
break;
default:
MOZ_ASSERT(false, "should not get there.");
}

View File

@ -3087,6 +3087,9 @@ WebGLContext::CompileShader(WebGLShader *shader)
resources.MaxFragmentUniformVectors = mGLMaxFragmentUniformVectors;
resources.MaxDrawBuffers = mGLMaxDrawBuffers;
if (IsExtensionEnabled(EXT_frag_depth))
resources.EXT_frag_depth = 1;
if (IsExtensionEnabled(OES_standard_derivatives))
resources.OES_standard_derivatives = 1;

View File

@ -0,0 +1,33 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* 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 "WebGLContext.h"
#include "WebGLExtensions.h"
#include "mozilla/dom/WebGLRenderingContextBinding.h"
#include "GLContext.h"
using namespace mozilla;
WebGLExtensionFragDepth::WebGLExtensionFragDepth(WebGLContext* context)
: WebGLExtensionBase(context)
{
MOZ_ASSERT(IsSupported(context),
"Should not construct extension object if unsupported.");
}
WebGLExtensionFragDepth::~WebGLExtensionFragDepth()
{
}
bool
WebGLExtensionFragDepth::IsSupported(const WebGLContext* context)
{
gl::GLContext* gl = context->GL();
return gl->IsSupported(gl::GLFeature::frag_depth);
}
IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionFragDepth)

View File

@ -108,6 +108,18 @@ public:
DECL_WEBGL_EXTENSION_GOOP
};
class WebGLExtensionFragDepth
: public WebGLExtensionBase
{
public:
WebGLExtensionFragDepth(WebGLContext*);
virtual ~WebGLExtensionFragDepth();
static bool IsSupported(const WebGLContext* context);
DECL_WEBGL_EXTENSION_GOOP
};
class WebGLExtensionLoseContext
: public WebGLExtensionBase
{

View File

@ -52,6 +52,7 @@ if CONFIG['MOZ_WEBGL']:
'WebGLExtensionDepthTexture.cpp',
'WebGLExtensionDrawBuffers.cpp',
'WebGLExtensionElementIndexUint.cpp',
'WebGLExtensionFragDepth.cpp',
'WebGLExtensionInstancedArrays.cpp',
'WebGLExtensionLoseContext.cpp',
'WebGLExtensionSRGB.cpp',

View File

@ -1380,6 +1380,11 @@ DOMInterfaces = {
'headerFile': 'WebGLExtensions.h'
},
'WebGLExtensionFragDepth': {
'nativeType': 'mozilla::WebGLExtensionFragDepth',
'headerFile': 'WebGLExtensions.h'
},
'WebGLExtensionLoseContext': {
'nativeType': 'mozilla::WebGLExtensionLoseContext',
'headerFile': 'WebGLExtensions.h'

View File

@ -822,6 +822,11 @@ interface WebGLExtensionElementIndexUint
{
};
[NoInterfaceObject]
interface WebGLExtensionFragDepth
{
};
[NoInterfaceObject]
interface WebGLExtensionLoseContext {
void loseContext();

View File

@ -133,6 +133,7 @@ static const char *sExtensionNames[] = {
"GL_EXT_framebuffer_sRGB",
"GL_KHR_debug",
"GL_ARB_half_float_pixel",
"GL_EXT_frag_depth",
nullptr
};

View File

@ -90,6 +90,7 @@ MOZ_BEGIN_ENUM_CLASS(GLFeature)
element_index_uint,
ES2_compatibility,
ES3_compatibility,
frag_depth,
framebuffer_blit,
framebuffer_multisample,
framebuffer_object,
@ -410,6 +411,7 @@ public:
EXT_framebuffer_sRGB,
KHR_debug,
ARB_half_float_pixel,
EXT_frag_depth,
Extensions_Max,
Extensions_End
};

View File

@ -111,6 +111,15 @@ static const FeatureInfo sFeatureInfoArr[] = {
GLContext::Extensions_End
}
},
{
"frag_depth",
200, // OpenGL version
300, // OpenGL ES version
{
GLContext::EXT_frag_depth,
GLContext::Extensions_End
}
},
{
"framebuffer_blit",
300, // OpenGL version