2013-01-17 16:45:11 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* vim: set ts=8 sts=4 et sw=4 tw=80: */
|
2012-05-21 04:12:37 -07: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/. */
|
2010-04-26 19:09:44 -07:00
|
|
|
|
|
|
|
#ifndef GLCONTEXT_H_
|
|
|
|
#define GLCONTEXT_H_
|
|
|
|
|
2010-07-01 09:30:38 -07:00
|
|
|
#include <stdio.h>
|
2011-04-14 01:48:27 -07:00
|
|
|
#include <stdint.h>
|
2010-10-06 13:43:14 -07:00
|
|
|
#include <ctype.h>
|
2013-07-17 20:24:15 -07:00
|
|
|
#include <map>
|
2013-09-04 05:14:52 -07:00
|
|
|
#include <bitset>
|
2010-07-01 09:30:38 -07:00
|
|
|
|
2013-09-06 19:13:37 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
#include <string.h>
|
|
|
|
#endif
|
|
|
|
|
2010-04-26 19:09:44 -07:00
|
|
|
#ifdef WIN32
|
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
|
|
|
|
2013-05-29 20:15:31 -07:00
|
|
|
#ifdef GetClassName
|
|
|
|
#undef GetClassName
|
|
|
|
#endif
|
|
|
|
|
2010-04-26 19:09:44 -07:00
|
|
|
#include "GLDefs.h"
|
2012-03-16 15:24:12 -07:00
|
|
|
#include "GLLibraryLoader.h"
|
2010-11-11 12:31:23 -08:00
|
|
|
#include "gfxImageSurface.h"
|
2012-07-20 12:20:51 -07:00
|
|
|
#include "gfx3DMatrix.h"
|
2010-04-26 19:09:44 -07:00
|
|
|
#include "nsISupportsImpl.h"
|
2013-02-05 10:02:17 -08:00
|
|
|
#include "plstr.h"
|
2010-05-24 23:35:35 -07:00
|
|
|
#include "nsDataHashtable.h"
|
|
|
|
#include "nsHashKeys.h"
|
2010-07-18 22:01:14 -07:00
|
|
|
#include "nsAutoPtr.h"
|
2012-11-26 14:23:27 -08:00
|
|
|
#include "GLContextTypes.h"
|
2012-11-26 14:23:27 -08:00
|
|
|
#include "GLTextureImage.h"
|
2013-02-13 15:26:24 -08:00
|
|
|
#include "SurfaceTypes.h"
|
|
|
|
#include "GLScreenBuffer.h"
|
2010-10-12 14:01:59 -07:00
|
|
|
#include "GLContextSymbols.h"
|
2013-06-16 19:05:56 -07:00
|
|
|
#include "mozilla/GenericRefCounted.h"
|
2012-04-16 12:56:12 -07:00
|
|
|
|
2013-09-06 19:13:37 -07:00
|
|
|
class nsIntRegion;
|
2013-09-24 13:45:13 -07:00
|
|
|
class nsIRunnable;
|
|
|
|
class nsIThread;
|
2013-09-06 19:13:37 -07:00
|
|
|
|
2012-07-23 16:58:37 -07:00
|
|
|
namespace android {
|
2013-02-13 15:26:24 -08:00
|
|
|
class GraphicBuffer;
|
2012-07-23 16:58:37 -07:00
|
|
|
}
|
|
|
|
|
2010-04-26 19:09:44 -07:00
|
|
|
namespace mozilla {
|
2013-02-13 15:26:24 -08:00
|
|
|
namespace gfx {
|
|
|
|
class SharedSurface;
|
2013-09-26 17:37:19 -07:00
|
|
|
class SourceSurface;
|
2013-07-08 21:21:05 -07:00
|
|
|
class DataSourceSurface;
|
2013-02-13 15:26:24 -08:00
|
|
|
struct SurfaceCaps;
|
|
|
|
}
|
2010-07-18 22:01:14 -07:00
|
|
|
|
2013-02-13 15:26:24 -08:00
|
|
|
namespace gl {
|
|
|
|
class GLContext;
|
|
|
|
class GLLibraryEGL;
|
|
|
|
class GLScreenBuffer;
|
|
|
|
class TextureGarbageBin;
|
2013-02-13 15:26:24 -08:00
|
|
|
}
|
2013-02-20 07:01:20 -08:00
|
|
|
|
2013-02-13 15:26:24 -08:00
|
|
|
namespace layers {
|
|
|
|
class ColorTextureLayerProgram;
|
|
|
|
class LayerManagerOGL;
|
|
|
|
}
|
|
|
|
}
|
2013-02-21 11:54:25 -08:00
|
|
|
|
2013-02-13 15:26:24 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace gl {
|
2013-08-22 10:42:04 -07:00
|
|
|
|
|
|
|
/** GLFeature::Enum
|
|
|
|
* We don't use typed enum to keep the implicit integer conversion.
|
|
|
|
* This enum should be sorted by name.
|
|
|
|
*/
|
|
|
|
namespace GLFeature {
|
|
|
|
enum Enum {
|
|
|
|
bind_buffer_offset,
|
2013-08-26 14:12:54 -07:00
|
|
|
blend_minmax,
|
2013-08-22 10:42:04 -07:00
|
|
|
depth_texture,
|
|
|
|
draw_buffers,
|
|
|
|
draw_instanced,
|
|
|
|
element_index_uint,
|
|
|
|
ES2_compatibility,
|
|
|
|
ES3_compatibility,
|
|
|
|
framebuffer_blit,
|
|
|
|
framebuffer_multisample,
|
|
|
|
framebuffer_object,
|
|
|
|
get_query_object_iv,
|
|
|
|
instanced_arrays,
|
2013-09-19 15:33:11 -07:00
|
|
|
instanced_non_arrays,
|
2013-08-22 10:42:04 -07:00
|
|
|
occlusion_query,
|
|
|
|
occlusion_query_boolean,
|
|
|
|
occlusion_query2,
|
|
|
|
packed_depth_stencil,
|
|
|
|
query_objects,
|
|
|
|
robustness,
|
|
|
|
standard_derivatives,
|
|
|
|
texture_float,
|
|
|
|
texture_float_linear,
|
|
|
|
texture_non_power_of_two,
|
|
|
|
transform_feedback,
|
|
|
|
vertex_array_object,
|
|
|
|
EnumMax
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2013-08-01 16:43:27 -07:00
|
|
|
MOZ_BEGIN_ENUM_CLASS(ContextProfile, uint8_t)
|
|
|
|
Unknown = 0,
|
|
|
|
OpenGL, // only for IsAtLeast's <profile> parameter
|
|
|
|
OpenGLCore,
|
|
|
|
OpenGLCompatibility,
|
|
|
|
OpenGLES
|
|
|
|
MOZ_END_ENUM_CLASS(ContextProfile)
|
|
|
|
|
2010-10-10 15:48:33 -07:00
|
|
|
class GLContext
|
2012-03-16 15:24:12 -07:00
|
|
|
: public GLLibraryLoader
|
2013-06-16 19:05:56 -07:00
|
|
|
, public GenericAtomicRefCounted
|
2010-04-26 19:09:44 -07:00
|
|
|
{
|
2013-07-31 16:18:06 -07:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// basic enums
|
2010-04-26 19:09:44 -07:00
|
|
|
public:
|
2012-08-21 20:30:20 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
enum {
|
|
|
|
VendorIntel,
|
|
|
|
VendorNVIDIA,
|
|
|
|
VendorATI,
|
|
|
|
VendorQualcomm,
|
|
|
|
VendorImagination,
|
|
|
|
VendorNouveau,
|
|
|
|
VendorOther
|
|
|
|
};
|
2010-04-26 19:09:44 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
enum {
|
|
|
|
RendererAdreno200,
|
|
|
|
RendererAdreno205,
|
|
|
|
RendererAdrenoTM205,
|
|
|
|
RendererAdrenoTM320,
|
|
|
|
RendererSGX530,
|
|
|
|
RendererSGX540,
|
|
|
|
RendererTegra,
|
2013-09-06 05:03:08 -07:00
|
|
|
RendererAndroidEmulator,
|
2013-07-31 16:18:06 -07:00
|
|
|
RendererOther
|
|
|
|
};
|
2010-04-26 19:09:44 -07:00
|
|
|
|
2012-05-08 06:47:34 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// basic getters
|
|
|
|
public:
|
2012-08-01 11:57:54 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
/**
|
|
|
|
* Returns true if the context is using ANGLE. This should only be overridden
|
|
|
|
* for an ANGLE implementation.
|
|
|
|
*/
|
|
|
|
virtual bool IsANGLE() {
|
|
|
|
return false;
|
2010-10-12 14:01:59 -07:00
|
|
|
}
|
|
|
|
|
2013-08-01 16:43:27 -07:00
|
|
|
/**
|
|
|
|
* Return true if we are running on a OpenGL core profile context
|
|
|
|
*/
|
|
|
|
inline bool IsCoreProfile() const {
|
|
|
|
MOZ_ASSERT(mProfile != ContextProfile::Unknown, "unknown context profile");
|
|
|
|
|
|
|
|
return mProfile == ContextProfile::OpenGLCore;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if we are running on a OpenGL compatibility profile context
|
|
|
|
* (legacy profile 2.1 on Max OS X)
|
|
|
|
*/
|
|
|
|
inline bool IsCompatibilityProfile() const {
|
|
|
|
MOZ_ASSERT(mProfile != ContextProfile::Unknown, "unknown context profile");
|
|
|
|
|
|
|
|
return mProfile == ContextProfile::OpenGLCompatibility;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if the context is a true OpenGL ES context or an ANGLE context
|
|
|
|
*/
|
|
|
|
inline bool IsGLES() const {
|
|
|
|
MOZ_ASSERT(mProfile != ContextProfile::Unknown, "unknown context profile");
|
|
|
|
|
|
|
|
return mProfile == ContextProfile::OpenGLES;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char* GetProfileName(ContextProfile profile)
|
|
|
|
{
|
|
|
|
switch (profile)
|
|
|
|
{
|
|
|
|
case ContextProfile::OpenGL:
|
|
|
|
return "OpenGL";
|
|
|
|
case ContextProfile::OpenGLCore:
|
|
|
|
return "OpenGL Core";
|
|
|
|
case ContextProfile::OpenGLCompatibility:
|
|
|
|
return "OpenGL Compatibility";
|
|
|
|
case ContextProfile::OpenGLES:
|
|
|
|
return "OpenGL ES";
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
MOZ_ASSERT(profile != ContextProfile::Unknown, "unknown context profile");
|
|
|
|
return "OpenGL unknown profile";
|
|
|
|
}
|
|
|
|
|
2013-08-02 14:30:58 -07:00
|
|
|
/**
|
|
|
|
* Return true if we are running on a OpenGL core profile context
|
|
|
|
*/
|
|
|
|
const char* ProfileString() const {
|
|
|
|
return GetProfileName(mProfile);
|
|
|
|
}
|
|
|
|
|
2013-08-01 16:43:27 -07:00
|
|
|
/**
|
|
|
|
* Return true if the context is compatible with given parameters
|
|
|
|
*
|
|
|
|
* IsAtLeast(ContextProfile::OpenGL, N) is exactly same as
|
|
|
|
* IsAtLeast(ContextProfile::OpenGLCore, N) || IsAtLeast(ContextProfile::OpenGLCompatibility, N)
|
|
|
|
*/
|
|
|
|
inline bool IsAtLeast(ContextProfile profile, unsigned int version) const
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(profile != ContextProfile::Unknown, "IsAtLeast: bad <profile> parameter");
|
|
|
|
MOZ_ASSERT(mProfile != ContextProfile::Unknown, "unknown context profile");
|
|
|
|
MOZ_ASSERT(mVersion != 0, "unknown context version");
|
|
|
|
|
2013-08-30 11:17:43 -07:00
|
|
|
if (version > mVersion) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-08-01 16:43:27 -07:00
|
|
|
if (profile == ContextProfile::OpenGL) {
|
2013-08-30 11:17:43 -07:00
|
|
|
return profile == ContextProfile::OpenGLCore ||
|
|
|
|
profile == ContextProfile::OpenGLCompatibility;
|
2013-08-01 16:43:27 -07:00
|
|
|
}
|
|
|
|
|
2013-08-30 11:17:43 -07:00
|
|
|
return profile == mProfile;
|
2013-08-01 16:43:27 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the version of the context.
|
|
|
|
* Example :
|
|
|
|
* If this a OpenGL 2.1, that will return 210
|
|
|
|
*/
|
|
|
|
inline unsigned int Version() const {
|
|
|
|
return mVersion;
|
|
|
|
}
|
|
|
|
|
2013-08-02 14:30:58 -07:00
|
|
|
const char* VersionString() const {
|
|
|
|
return mVersionString.get();
|
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
int Vendor() const {
|
|
|
|
return mVendor;
|
2010-05-24 23:35:35 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
int Renderer() const {
|
|
|
|
return mRenderer;
|
2010-05-24 23:35:35 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
bool IsContextLost() const {
|
|
|
|
return mContextLost;
|
2010-09-09 20:09:39 -07:00
|
|
|
}
|
|
|
|
|
2012-04-10 13:20:02 -07:00
|
|
|
/**
|
2013-07-31 16:18:06 -07:00
|
|
|
* If this context is double-buffered, returns TRUE.
|
2012-04-10 13:20:02 -07:00
|
|
|
*/
|
2013-07-31 16:18:06 -07:00
|
|
|
virtual bool IsDoubleBuffered() {
|
|
|
|
return false;
|
2012-04-10 13:20:02 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
virtual GLContextType GetContextType() {
|
|
|
|
return ContextTypeUnknown;
|
2013-02-13 15:26:24 -08:00
|
|
|
}
|
2011-01-06 14:07:12 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
virtual bool IsCurrent() = 0;
|
2010-07-28 14:24:09 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If this context is the GLES2 API, returns TRUE.
|
|
|
|
* This means that various GLES2 restrictions might be in effect (modulo
|
|
|
|
* extensions).
|
|
|
|
*/
|
2013-07-31 16:18:06 -07:00
|
|
|
inline bool IsGLES2() const {
|
2013-08-01 16:43:27 -07:00
|
|
|
return IsAtLeast(ContextProfile::OpenGLES, 200);
|
2010-07-28 14:24:09 -07:00
|
|
|
}
|
2013-05-22 00:05:38 -07:00
|
|
|
|
2011-11-18 19:57:29 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
protected:
|
2010-10-06 13:43:14 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
bool mInitialized;
|
|
|
|
bool mIsOffscreen;
|
|
|
|
bool mIsGlobalSharedContext;
|
|
|
|
bool mContextLost;
|
2013-08-01 16:43:27 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* mVersion store the OpenGL's version, multiplied by 100. For example, if
|
|
|
|
* the context is an OpenGL 2.1 context, mVersion value will be 210.
|
|
|
|
*/
|
|
|
|
unsigned int mVersion;
|
2013-08-02 14:30:58 -07:00
|
|
|
nsCString mVersionString;
|
2013-08-01 16:43:27 -07:00
|
|
|
ContextProfile mProfile;
|
2012-01-30 12:09:02 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
int32_t mVendor;
|
|
|
|
int32_t mRenderer;
|
2010-10-06 13:43:14 -07:00
|
|
|
|
2013-08-01 16:43:27 -07:00
|
|
|
inline void SetProfileVersion(ContextProfile profile, unsigned int version) {
|
|
|
|
MOZ_ASSERT(!mInitialized, "SetProfileVersion can only be called before initialization!");
|
|
|
|
MOZ_ASSERT(profile != ContextProfile::Unknown && profile != ContextProfile::OpenGL, "Invalid `profile` for SetProfileVersion");
|
|
|
|
MOZ_ASSERT(version >= 100, "Invalid `version` for SetProfileVersion");
|
|
|
|
|
|
|
|
mVersion = version;
|
|
|
|
mProfile = profile;
|
2012-01-30 12:09:02 -08:00
|
|
|
}
|
|
|
|
|
2012-11-06 14:39:38 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Extensions management
|
|
|
|
/**
|
|
|
|
* This mechanism is designed to know if an extension is supported. In the long
|
|
|
|
* term, we would like to only use the extension group queries XXX_* to have
|
|
|
|
* full compatibility with context version and profiles (especialy the core that
|
|
|
|
* officialy don't bring any extensions).
|
|
|
|
*/
|
2012-11-06 14:39:38 -08:00
|
|
|
public:
|
2011-10-05 11:20:33 -07:00
|
|
|
|
2012-08-30 11:39:01 -07:00
|
|
|
/**
|
2013-07-31 16:18:06 -07:00
|
|
|
* Known GL extensions that can be queried by
|
|
|
|
* IsExtensionSupported. The results of this are cached, and as
|
|
|
|
* such it's safe to use this even in performance critical code.
|
|
|
|
* If you add to this array, remember to add to the string names
|
|
|
|
* in GLContext.cpp.
|
2012-08-30 11:39:01 -07:00
|
|
|
*/
|
2013-07-31 16:18:06 -07:00
|
|
|
enum GLExtensions {
|
|
|
|
EXT_framebuffer_object,
|
|
|
|
ARB_framebuffer_object,
|
|
|
|
ARB_texture_rectangle,
|
|
|
|
EXT_bgra,
|
|
|
|
EXT_texture_format_BGRA8888,
|
|
|
|
OES_depth24,
|
|
|
|
OES_depth32,
|
|
|
|
OES_stencil8,
|
|
|
|
OES_texture_npot,
|
2013-08-15 12:58:20 -07:00
|
|
|
ARB_depth_texture,
|
2013-07-31 16:18:06 -07:00
|
|
|
OES_depth_texture,
|
|
|
|
OES_packed_depth_stencil,
|
|
|
|
IMG_read_format,
|
|
|
|
EXT_read_format_bgra,
|
|
|
|
APPLE_client_storage,
|
|
|
|
ARB_texture_non_power_of_two,
|
|
|
|
ARB_pixel_buffer_object,
|
|
|
|
ARB_ES2_compatibility,
|
2013-08-15 12:58:20 -07:00
|
|
|
ARB_ES3_compatibility,
|
2013-07-31 16:18:06 -07:00
|
|
|
OES_texture_float,
|
|
|
|
OES_texture_float_linear,
|
|
|
|
ARB_texture_float,
|
|
|
|
EXT_unpack_subimage,
|
|
|
|
OES_standard_derivatives,
|
|
|
|
EXT_texture_filter_anisotropic,
|
|
|
|
EXT_texture_compression_s3tc,
|
|
|
|
EXT_texture_compression_dxt1,
|
|
|
|
ANGLE_texture_compression_dxt3,
|
|
|
|
ANGLE_texture_compression_dxt5,
|
|
|
|
AMD_compressed_ATC_texture,
|
|
|
|
IMG_texture_compression_pvrtc,
|
|
|
|
EXT_framebuffer_blit,
|
|
|
|
ANGLE_framebuffer_blit,
|
|
|
|
EXT_framebuffer_multisample,
|
|
|
|
ANGLE_framebuffer_multisample,
|
|
|
|
OES_rgb8_rgba8,
|
|
|
|
ARB_robustness,
|
|
|
|
EXT_robustness,
|
|
|
|
ARB_sync,
|
|
|
|
OES_EGL_image,
|
|
|
|
OES_EGL_sync,
|
|
|
|
OES_EGL_image_external,
|
|
|
|
EXT_packed_depth_stencil,
|
|
|
|
OES_element_index_uint,
|
|
|
|
OES_vertex_array_object,
|
|
|
|
ARB_vertex_array_object,
|
|
|
|
APPLE_vertex_array_object,
|
|
|
|
ARB_draw_buffers,
|
|
|
|
EXT_draw_buffers,
|
|
|
|
EXT_gpu_shader4,
|
|
|
|
EXT_blend_minmax,
|
|
|
|
ARB_draw_instanced,
|
|
|
|
EXT_draw_instanced,
|
|
|
|
NV_draw_instanced,
|
2013-08-06 17:05:51 -07:00
|
|
|
ARB_instanced_arrays,
|
|
|
|
NV_instanced_arrays,
|
|
|
|
ANGLE_instanced_arrays,
|
2013-08-06 14:23:46 -07:00
|
|
|
EXT_occlusion_query_boolean,
|
2013-08-15 12:58:20 -07:00
|
|
|
ARB_occlusion_query2,
|
2013-08-15 17:43:47 -07:00
|
|
|
EXT_transform_feedback,
|
|
|
|
NV_transform_feedback,
|
2013-09-30 17:58:57 -07:00
|
|
|
ANGLE_depth_texture,
|
2013-10-08 16:20:24 -07:00
|
|
|
KHR_debug,
|
2013-08-02 14:30:58 -07:00
|
|
|
Extensions_Max,
|
|
|
|
Extensions_End
|
2013-07-31 16:18:06 -07:00
|
|
|
};
|
2012-07-23 16:58:37 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
bool IsExtensionSupported(GLExtensions aKnownExtension) const {
|
|
|
|
return mAvailableExtensions[aKnownExtension];
|
|
|
|
}
|
2011-12-16 14:24:46 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void MarkExtensionUnsupported(GLExtensions aKnownExtension) {
|
|
|
|
mAvailableExtensions[aKnownExtension] = 0;
|
|
|
|
}
|
2012-08-21 20:30:20 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void MarkExtensionSupported(GLExtensions aKnownExtension) {
|
|
|
|
mAvailableExtensions[aKnownExtension] = 1;
|
|
|
|
}
|
2012-08-21 20:30:20 -07:00
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2013-09-04 05:14:52 -07:00
|
|
|
template<size_t N>
|
|
|
|
static void InitializeExtensionsBitSet(std::bitset<N>& extensionsBitset, const char* extStr, const char** extList, bool verbose = false)
|
2013-07-31 16:18:06 -07:00
|
|
|
{
|
2013-09-04 05:14:52 -07:00
|
|
|
char* exts = strdup(extStr);
|
|
|
|
|
|
|
|
if (verbose)
|
|
|
|
printf_stderr("Extensions: %s\n", exts);
|
|
|
|
|
|
|
|
char* cur = exts;
|
|
|
|
bool done = false;
|
|
|
|
while (!done) {
|
|
|
|
char* space = strchr(cur, ' ');
|
|
|
|
if (space) {
|
|
|
|
*space = '\0';
|
|
|
|
} else {
|
|
|
|
done = true;
|
|
|
|
}
|
2011-10-19 12:09:57 -07:00
|
|
|
|
2013-09-04 05:14:52 -07:00
|
|
|
for (int i = 0; extList[i]; ++i) {
|
|
|
|
if (PL_strcasecmp(cur, extList[i]) == 0) {
|
|
|
|
if (verbose)
|
|
|
|
printf_stderr("Found extension %s\n", cur);
|
|
|
|
extensionsBitset[i] = true;
|
2013-07-31 16:18:06 -07:00
|
|
|
}
|
|
|
|
}
|
2012-11-26 14:23:27 -08:00
|
|
|
|
2013-09-04 05:14:52 -07:00
|
|
|
cur = space + 1;
|
2013-07-31 16:18:06 -07:00
|
|
|
}
|
2012-07-20 12:20:51 -07:00
|
|
|
|
2013-09-04 05:14:52 -07:00
|
|
|
free(exts);
|
|
|
|
}
|
2012-07-20 12:20:51 -07:00
|
|
|
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
protected:
|
2013-09-04 05:14:52 -07:00
|
|
|
std::bitset<Extensions_Max> mAvailableExtensions;
|
2012-02-08 16:06:03 -08:00
|
|
|
|
2012-02-09 17:57:26 -08:00
|
|
|
|
2013-08-22 10:42:04 -07:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Feature queries
|
|
|
|
/*
|
|
|
|
* This mecahnism introduces a new way to check if a OpenGL feature is
|
|
|
|
* supported, regardless of whether it is supported by an extension or natively
|
|
|
|
* by the context version/profile
|
|
|
|
*/
|
|
|
|
public:
|
2013-08-23 16:33:42 -07:00
|
|
|
bool IsSupported(GLFeature::Enum feature) const {
|
|
|
|
return mAvailableFeatures[feature];
|
|
|
|
}
|
2013-08-22 10:42:04 -07:00
|
|
|
|
|
|
|
static const char* GetFeatureName(GLFeature::Enum feature);
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
2013-09-04 05:14:52 -07:00
|
|
|
std::bitset<GLFeature::EnumMax> mAvailableFeatures;
|
2013-08-22 10:42:04 -07:00
|
|
|
|
|
|
|
/**
|
2013-08-23 16:33:42 -07:00
|
|
|
* Init features regarding OpenGL extension and context version and profile
|
|
|
|
*/
|
|
|
|
void InitFeatures();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Mark the feature and associated extensions as unsupported
|
2013-08-22 10:42:04 -07:00
|
|
|
*/
|
2013-08-23 16:33:42 -07:00
|
|
|
void MarkUnsupported(GLFeature::Enum feature);
|
2013-07-31 16:18:06 -07:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Robustness handling
|
|
|
|
public:
|
2013-03-06 06:34:35 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
bool HasRobustness() {
|
|
|
|
return mHasRobustness;
|
|
|
|
}
|
2013-03-06 06:34:35 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
/**
|
|
|
|
* The derived class is expected to provide information on whether or not it
|
|
|
|
* supports robustness.
|
|
|
|
*/
|
|
|
|
virtual bool SupportsRobustness() = 0;
|
2013-03-06 06:34:35 -08:00
|
|
|
|
2012-11-13 14:35:35 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
private:
|
|
|
|
bool mHasRobustness;
|
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Error handling
|
|
|
|
public:
|
|
|
|
|
2013-08-02 14:08:55 -07:00
|
|
|
static const char* GLErrorToString(GLenum aError)
|
2013-07-31 16:18:06 -07:00
|
|
|
{
|
|
|
|
switch (aError) {
|
|
|
|
case LOCAL_GL_INVALID_ENUM:
|
|
|
|
return "GL_INVALID_ENUM";
|
|
|
|
case LOCAL_GL_INVALID_VALUE:
|
|
|
|
return "GL_INVALID_VALUE";
|
|
|
|
case LOCAL_GL_INVALID_OPERATION:
|
|
|
|
return "GL_INVALID_OPERATION";
|
|
|
|
case LOCAL_GL_STACK_OVERFLOW:
|
|
|
|
return "GL_STACK_OVERFLOW";
|
|
|
|
case LOCAL_GL_STACK_UNDERFLOW:
|
|
|
|
return "GL_STACK_UNDERFLOW";
|
|
|
|
case LOCAL_GL_OUT_OF_MEMORY:
|
|
|
|
return "GL_OUT_OF_MEMORY";
|
|
|
|
case LOCAL_GL_TABLE_TOO_LARGE:
|
|
|
|
return "GL_TABLE_TOO_LARGE";
|
|
|
|
case LOCAL_GL_INVALID_FRAMEBUFFER_OPERATION:
|
|
|
|
return "GL_INVALID_FRAMEBUFFER_OPERATION";
|
2012-08-31 16:44:33 -07:00
|
|
|
default:
|
2013-07-31 16:18:06 -07:00
|
|
|
return "";
|
2012-08-31 16:44:33 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-21 11:54:25 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
/** \returns the first GL error, and guarantees that all GL error flags are cleared,
|
|
|
|
* i.e. that a subsequent GetError call will return NO_ERROR
|
|
|
|
*/
|
|
|
|
GLenum GetAndClearError()
|
|
|
|
{
|
|
|
|
// the first error is what we want to return
|
|
|
|
GLenum error = fGetError();
|
2013-02-21 11:54:25 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
if (error) {
|
|
|
|
// clear all pending errors
|
|
|
|
while(fGetError()) {}
|
|
|
|
}
|
2013-02-21 11:54:25 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
return error;
|
2013-02-21 11:54:25 -08:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
|
|
|
|
/*** In GL debug mode, we completely override glGetError ***/
|
|
|
|
|
|
|
|
GLenum fGetError()
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
// debug mode ends up eating the error in AFTER_GL_CALL
|
|
|
|
if (DebugMode()) {
|
|
|
|
GLenum err = mGLError;
|
|
|
|
mGLError = LOCAL_GL_NO_ERROR;
|
|
|
|
return err;
|
2013-02-13 15:26:24 -08:00
|
|
|
}
|
2013-07-31 16:18:06 -07:00
|
|
|
#endif // DEBUG
|
2013-02-21 11:54:25 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
return mSymbols.fGetError();
|
2011-10-19 12:09:57 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2011-10-19 12:09:57 -07:00
|
|
|
private:
|
2013-07-31 16:18:06 -07:00
|
|
|
|
|
|
|
GLenum mGLError;
|
|
|
|
#endif // DEBUG
|
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// MOZ_GL_DEBUG implementation
|
|
|
|
private:
|
|
|
|
|
2013-09-04 05:14:52 -07:00
|
|
|
#undef BEFORE_GL_CALL
|
|
|
|
#undef AFTER_GL_CALL
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
|
|
|
|
#ifndef MOZ_FUNCTION_NAME
|
|
|
|
# ifdef __GNUC__
|
|
|
|
# define MOZ_FUNCTION_NAME __PRETTY_FUNCTION__
|
|
|
|
# elif defined(_MSC_VER)
|
|
|
|
# define MOZ_FUNCTION_NAME __FUNCTION__
|
|
|
|
# else
|
|
|
|
# define MOZ_FUNCTION_NAME __func__ // defined in C99, supported in various C++ compilers. Just raw function name.
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void BeforeGLCall(const char* glFunction)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(IsCurrent());
|
|
|
|
if (DebugMode()) {
|
|
|
|
GLContext *currentGLContext = nullptr;
|
|
|
|
|
|
|
|
currentGLContext = (GLContext*)PR_GetThreadPrivate(sCurrentGLContextTLS);
|
|
|
|
|
|
|
|
if (DebugMode() & DebugTrace)
|
|
|
|
printf_stderr("[gl:%p] > %s\n", this, glFunction);
|
|
|
|
if (this != currentGLContext) {
|
|
|
|
printf_stderr("Fatal: %s called on non-current context %p. "
|
|
|
|
"The current context for this thread is %p.\n",
|
|
|
|
glFunction, this, currentGLContext);
|
|
|
|
NS_ABORT();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AfterGLCall(const char* glFunction)
|
|
|
|
{
|
|
|
|
if (DebugMode()) {
|
|
|
|
// calling fFinish() immediately after every GL call makes sure that if this GL command crashes,
|
|
|
|
// the stack trace will actually point to it. Otherwise, OpenGL being an asynchronous API, stack traces
|
|
|
|
// tend to be meaningless
|
|
|
|
mSymbols.fFinish();
|
|
|
|
mGLError = mSymbols.fGetError();
|
|
|
|
if (DebugMode() & DebugTrace)
|
|
|
|
printf_stderr("[gl:%p] < %s [0x%04x]\n", this, glFunction, mGLError);
|
|
|
|
if (mGLError != LOCAL_GL_NO_ERROR) {
|
|
|
|
printf_stderr("GL ERROR: %s generated GL error %s(0x%04x)\n",
|
|
|
|
glFunction,
|
|
|
|
GLErrorToString(mGLError),
|
|
|
|
mGLError);
|
|
|
|
if (DebugMode() & DebugAbortOnError)
|
|
|
|
NS_ABORT();
|
|
|
|
}
|
2011-12-16 13:11:59 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
GLContext *TrackingContext()
|
|
|
|
{
|
|
|
|
GLContext *tip = this;
|
|
|
|
while (tip->mSharedContext)
|
|
|
|
tip = tip->mSharedContext;
|
|
|
|
return tip;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define BEFORE_GL_CALL \
|
|
|
|
do { \
|
|
|
|
BeforeGLCall(MOZ_FUNCTION_NAME); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define AFTER_GL_CALL \
|
|
|
|
do { \
|
|
|
|
AfterGLCall(MOZ_FUNCTION_NAME); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define TRACKING_CONTEXT(a) \
|
|
|
|
do { \
|
|
|
|
TrackingContext()->a; \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#else // ifdef DEBUG
|
|
|
|
|
|
|
|
#define BEFORE_GL_CALL do { } while (0)
|
|
|
|
#define AFTER_GL_CALL do { } while (0)
|
|
|
|
#define TRACKING_CONTEXT(a) do {} while (0)
|
|
|
|
|
|
|
|
#endif // ifdef DEBUG
|
|
|
|
|
|
|
|
#define ASSERT_SYMBOL_PRESENT(func) \
|
|
|
|
do {\
|
|
|
|
MOZ_ASSERT(strstr(MOZ_FUNCTION_NAME, #func) != nullptr, "Mismatched symbol check.");\
|
|
|
|
if (MOZ_UNLIKELY(!mSymbols.func)) {\
|
|
|
|
printf_stderr("RUNTIME ASSERT: Uninitialized GL function: %s\n", #func);\
|
|
|
|
MOZ_CRASH();\
|
|
|
|
}\
|
|
|
|
} while (0)
|
|
|
|
|
2012-02-09 17:57:26 -08:00
|
|
|
// Do whatever setup is necessary to draw to our offscreen FBO, if it's
|
|
|
|
// bound.
|
2011-10-19 12:09:57 -07:00
|
|
|
void BeforeGLDrawCall() {
|
|
|
|
}
|
|
|
|
|
2012-02-09 17:57:26 -08:00
|
|
|
// Do whatever tear-down is necessary after drawing to our offscreen FBO,
|
|
|
|
// if it's bound.
|
2013-07-31 16:18:06 -07:00
|
|
|
void AfterGLDrawCall()
|
|
|
|
{
|
2013-02-13 15:26:24 -08:00
|
|
|
if (mScreen)
|
|
|
|
mScreen->AfterDrawCall();
|
2011-10-19 12:09:57 -07:00
|
|
|
}
|
|
|
|
|
2012-02-09 17:57:26 -08:00
|
|
|
// Do whatever setup is necessary to read from our offscreen FBO, if it's
|
|
|
|
// bound.
|
2013-07-31 16:18:06 -07:00
|
|
|
void BeforeGLReadCall()
|
|
|
|
{
|
2013-02-13 15:26:24 -08:00
|
|
|
if (mScreen)
|
|
|
|
mScreen->BeforeReadCall();
|
2011-10-19 12:09:57 -07:00
|
|
|
}
|
|
|
|
|
2012-02-09 17:57:26 -08:00
|
|
|
// Do whatever tear-down is necessary after reading from our offscreen FBO,
|
|
|
|
// if it's bound.
|
2011-10-19 12:09:57 -07:00
|
|
|
void AfterGLReadCall() {
|
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// GL official entry points
|
2011-10-19 12:09:57 -07:00
|
|
|
public:
|
2013-07-31 16:18:06 -07:00
|
|
|
|
|
|
|
void fActiveTexture(GLenum texture) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fActiveTexture(texture);
|
|
|
|
AFTER_GL_CALL;
|
2011-10-19 12:09:57 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fAttachShader(GLuint program, GLuint shader) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fAttachShader(program, shader);
|
|
|
|
AFTER_GL_CALL;
|
2011-10-19 12:09:57 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fBeginQuery(GLenum target, GLuint id) {
|
|
|
|
BEFORE_GL_CALL;
|
2013-08-06 14:23:46 -07:00
|
|
|
ASSERT_SYMBOL_PRESENT(fBeginQuery);
|
2013-07-31 16:18:06 -07:00
|
|
|
mSymbols.fBeginQuery(target, id);
|
|
|
|
AFTER_GL_CALL;
|
2011-10-19 12:09:57 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fBindAttribLocation(GLuint program, GLuint index, const GLchar* name) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fBindAttribLocation(program, index, name);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2012-12-18 23:16:01 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fBindBuffer(GLenum target, GLuint buffer) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fBindBuffer(target, buffer);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2013-07-17 20:24:15 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fBindFramebuffer(GLenum target, GLuint framebuffer) {
|
|
|
|
if (!mScreen) {
|
|
|
|
raw_fBindFramebuffer(target, framebuffer);
|
|
|
|
return;
|
2013-07-17 20:24:15 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
switch (target) {
|
|
|
|
case LOCAL_GL_DRAW_FRAMEBUFFER_EXT:
|
|
|
|
mScreen->BindDrawFB(framebuffer);
|
|
|
|
return;
|
|
|
|
|
|
|
|
case LOCAL_GL_READ_FRAMEBUFFER_EXT:
|
|
|
|
mScreen->BindReadFB(framebuffer);
|
|
|
|
return;
|
|
|
|
|
|
|
|
case LOCAL_GL_FRAMEBUFFER:
|
|
|
|
mScreen->BindFB(framebuffer);
|
|
|
|
return;
|
|
|
|
|
|
|
|
default:
|
|
|
|
// Nothing we care about, likely an error.
|
|
|
|
break;
|
2013-07-17 20:24:15 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
raw_fBindFramebuffer(target, framebuffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
void fBindTexture(GLenum target, GLuint texture) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fBindTexture(target, texture);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fBlendColor(red, green, blue, alpha);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fBlendEquation(GLenum mode) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fBlendEquation(mode);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fBlendEquationSeparate(modeRGB, modeAlpha);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fBlendFunc(GLenum sfactor, GLenum dfactor) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fBlendFunc(sfactor, dfactor);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fBlendFuncSeparate(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fBlendFuncSeparate(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
void raw_fBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fBufferData(target, size, data, usage);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
void fBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage) {
|
|
|
|
raw_fBufferData(target, size, data, usage);
|
|
|
|
|
|
|
|
// bug 744888
|
|
|
|
if (WorkAroundDriverBugs() &&
|
|
|
|
!data &&
|
|
|
|
Vendor() == VendorNVIDIA)
|
|
|
|
{
|
|
|
|
char c = 0;
|
|
|
|
fBufferSubData(target, size-1, 1, &c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void fBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fBufferSubData(target, offset, size, data);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
void raw_fClear(GLbitfield mask) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fClear(mask);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
void fClear(GLbitfield mask) {
|
|
|
|
BeforeGLDrawCall();
|
|
|
|
raw_fClear(mask);
|
|
|
|
AfterGLDrawCall();
|
|
|
|
}
|
|
|
|
|
|
|
|
void fClearColor(GLclampf r, GLclampf g, GLclampf b, GLclampf a) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fClearColor(r, g, b, a);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fClearStencil(GLint s) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fClearStencil(s);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fColorMask(realGLboolean red, realGLboolean green, realGLboolean blue, realGLboolean alpha) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fColorMask(red, green, blue, alpha);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *pixels) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, pixels);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *pixels) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, pixels);
|
|
|
|
AFTER_GL_CALL;
|
2011-10-19 12:09:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void fCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) {
|
2012-12-18 23:16:01 -08:00
|
|
|
y = FixYValue(y, height);
|
|
|
|
|
|
|
|
if (!IsTextureSizeSafeToPassToDriver(target, width, height)) {
|
|
|
|
// pass wrong values to cause the GL to generate GL_INVALID_VALUE.
|
|
|
|
// See bug 737182 and the comment in IsTextureSizeSafeToPassToDriver.
|
|
|
|
level = -1;
|
|
|
|
width = -1;
|
|
|
|
height = -1;
|
|
|
|
border = -1;
|
|
|
|
}
|
|
|
|
|
2011-10-19 12:09:57 -07:00
|
|
|
BeforeGLReadCall();
|
|
|
|
raw_fCopyTexImage2D(target, level, internalformat,
|
|
|
|
x, y, width, height, border);
|
|
|
|
AfterGLReadCall();
|
|
|
|
}
|
|
|
|
|
|
|
|
void fCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) {
|
2012-12-18 23:16:01 -08:00
|
|
|
y = FixYValue(y, height);
|
|
|
|
|
2011-10-19 12:09:57 -07:00
|
|
|
BeforeGLReadCall();
|
|
|
|
raw_fCopyTexSubImage2D(target, level, xoffset, yoffset,
|
|
|
|
x, y, width, height);
|
|
|
|
AfterGLReadCall();
|
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fCullFace(GLenum mode) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fCullFace(mode);
|
|
|
|
AFTER_GL_CALL;
|
2011-10-19 12:09:57 -07:00
|
|
|
}
|
|
|
|
|
2013-10-08 16:20:24 -07:00
|
|
|
void fDebugMessageCallback(GLDEBUGPROC callback, const GLvoid* userParam) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
ASSERT_SYMBOL_PRESENT(fDebugMessageCallback);
|
|
|
|
mSymbols.fDebugMessageCallback(callback, userParam);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fDebugMessageControl(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint* ids, realGLboolean enabled) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
ASSERT_SYMBOL_PRESENT(fDebugMessageControl);
|
|
|
|
mSymbols.fDebugMessageControl(source, type, severity, count, ids, enabled);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fDebugMessageInsert(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* buf) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
ASSERT_SYMBOL_PRESENT(fDebugMessageInsert);
|
|
|
|
mSymbols.fDebugMessageInsert(source, type, id, severity, length, buf);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fDetachShader(GLuint program, GLuint shader) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fDetachShader(program, shader);
|
|
|
|
AFTER_GL_CALL;
|
2010-09-21 12:41:24 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fDepthFunc(GLenum func) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fDepthFunc(func);
|
|
|
|
AFTER_GL_CALL;
|
2012-07-16 07:59:59 -07:00
|
|
|
}
|
2011-07-06 11:00:47 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fDepthMask(realGLboolean flag) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fDepthMask(flag);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2011-11-08 07:51:44 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fDisable(GLenum capability) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fDisable(capability);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2011-11-08 07:51:44 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fDisableVertexAttribArray(GLuint index) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fDisableVertexAttribArray(index);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-11-12 12:02:17 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fDrawBuffer(GLenum mode) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fDrawBuffer(mode);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-11-12 12:02:17 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
private:
|
|
|
|
void raw_fDrawArrays(GLenum mode, GLint first, GLsizei count) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fDrawArrays(mode, first, count);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2011-05-19 03:53:02 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void raw_fDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fDrawElements(mode, count, type, indices);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2011-05-19 03:53:02 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
public:
|
|
|
|
void fDrawArrays(GLenum mode, GLint first, GLsizei count) {
|
|
|
|
BeforeGLDrawCall();
|
|
|
|
raw_fDrawArrays(mode, first, count);
|
|
|
|
AfterGLDrawCall();
|
|
|
|
}
|
2011-05-19 03:53:02 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) {
|
|
|
|
BeforeGLDrawCall();
|
|
|
|
raw_fDrawElements(mode, count, type, indices);
|
|
|
|
AfterGLDrawCall();
|
|
|
|
}
|
2010-11-12 12:02:17 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fEnable(GLenum capability) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fEnable(capability);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-11-12 12:02:17 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fEnableVertexAttribArray(GLuint index) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fEnableVertexAttribArray(index);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2012-06-12 14:39:18 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fEndQuery(GLenum target) {
|
|
|
|
BEFORE_GL_CALL;
|
2013-08-06 14:23:46 -07:00
|
|
|
ASSERT_SYMBOL_PRESENT(fEndQuery);
|
2013-07-31 16:18:06 -07:00
|
|
|
mSymbols.fEndQuery(target);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-08-06 22:09:18 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fFinish() {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fFinish();
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2013-07-23 14:33:51 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fFlush() {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fFlush();
|
|
|
|
AFTER_GL_CALL;
|
2010-08-06 22:09:18 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fFrontFace(GLenum face) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fFrontFace(face);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2013-07-23 14:33:51 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fGetActiveAttrib(GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fGetActiveAttrib(program, index, maxLength, length, size, type, name);
|
|
|
|
AFTER_GL_CALL;
|
2013-07-23 14:33:51 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fGetActiveUniform(GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fGetActiveUniform(program, index, maxLength, length, size, type, name);
|
|
|
|
AFTER_GL_CALL;
|
2012-04-04 18:44:55 -07:00
|
|
|
}
|
2011-05-20 12:53:53 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fGetAttachedShaders(GLuint program, GLsizei maxCount, GLsizei* count, GLuint* shaders) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fGetAttachedShaders(program, maxCount, count, shaders);
|
|
|
|
AFTER_GL_CALL;
|
2013-02-23 09:14:11 -08:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
GLint fGetAttribLocation (GLuint program, const GLchar* name) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
GLint retval = mSymbols.fGetAttribLocation(program, name);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
return retval;
|
|
|
|
}
|
2010-11-10 07:49:52 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
private:
|
|
|
|
void raw_fGetIntegerv(GLenum pname, GLint *params) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fGetIntegerv(pname, params);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2012-06-12 14:39:18 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
public:
|
|
|
|
|
|
|
|
void fGetIntegerv(GLenum pname, GLint *params) {
|
|
|
|
switch (pname)
|
|
|
|
{
|
|
|
|
// LOCAL_GL_FRAMEBUFFER_BINDING is equal to
|
|
|
|
// LOCAL_GL_DRAW_FRAMEBUFFER_BINDING_EXT,
|
|
|
|
// so we don't need two cases.
|
|
|
|
case LOCAL_GL_DRAW_FRAMEBUFFER_BINDING_EXT:
|
|
|
|
if (mScreen) {
|
|
|
|
*params = mScreen->GetDrawFB();
|
2012-06-12 14:39:18 -07:00
|
|
|
} else {
|
2013-07-31 16:18:06 -07:00
|
|
|
raw_fGetIntegerv(pname, params);
|
2012-06-12 14:39:18 -07:00
|
|
|
}
|
2013-07-31 16:18:06 -07:00
|
|
|
break;
|
2012-06-12 14:39:18 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
case LOCAL_GL_READ_FRAMEBUFFER_BINDING_EXT:
|
|
|
|
if (mScreen) {
|
|
|
|
*params = mScreen->GetReadFB();
|
|
|
|
} else {
|
|
|
|
raw_fGetIntegerv(pname, params);
|
2012-06-12 14:39:18 -07:00
|
|
|
}
|
2013-07-31 16:18:06 -07:00
|
|
|
break;
|
2012-06-12 14:39:18 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
case LOCAL_GL_MAX_TEXTURE_SIZE:
|
|
|
|
MOZ_ASSERT(mMaxTextureSize>0);
|
|
|
|
*params = mMaxTextureSize;
|
|
|
|
break;
|
2012-06-12 14:39:18 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
case LOCAL_GL_MAX_CUBE_MAP_TEXTURE_SIZE:
|
|
|
|
MOZ_ASSERT(mMaxCubeMapTextureSize>0);
|
|
|
|
*params = mMaxCubeMapTextureSize;
|
|
|
|
break;
|
2011-05-20 12:53:53 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
case LOCAL_GL_MAX_RENDERBUFFER_SIZE:
|
|
|
|
MOZ_ASSERT(mMaxRenderbufferSize>0);
|
|
|
|
*params = mMaxRenderbufferSize;
|
|
|
|
break;
|
2011-05-20 12:53:53 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
default:
|
|
|
|
raw_fGetIntegerv(pname, params);
|
|
|
|
break;
|
2012-10-03 14:13:05 -07:00
|
|
|
}
|
2013-07-31 16:18:06 -07:00
|
|
|
}
|
2012-10-03 14:13:05 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void GetUIntegerv(GLenum pname, GLuint *params) {
|
|
|
|
fGetIntegerv(pname, reinterpret_cast<GLint*>(params));
|
|
|
|
}
|
2011-10-26 13:00:44 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fGetFloatv(GLenum pname, GLfloat *params) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fGetFloatv(pname, params);
|
|
|
|
AFTER_GL_CALL;
|
2011-11-18 19:57:29 -08:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fGetBooleanv(GLenum pname, realGLboolean *params) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fGetBooleanv(pname, params);
|
|
|
|
AFTER_GL_CALL;
|
2013-02-13 15:26:24 -08:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fGetBufferParameteriv(GLenum target, GLenum pname, GLint* params) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fGetBufferParameteriv(target, pname, params);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-09-21 12:41:24 -07:00
|
|
|
|
2013-10-08 16:20:24 -07:00
|
|
|
GLuint fGetDebugMessageLog(GLuint count, GLsizei bufsize, GLenum* sources, GLenum* types, GLuint* ids, GLenum* severities, GLsizei* lengths, GLchar* messageLog) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
ASSERT_SYMBOL_PRESENT(fGetDebugMessageLog);
|
|
|
|
GLuint ret = mSymbols.fGetDebugMessageLog(count, bufsize, sources, types, ids, severities, lengths, messageLog);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fGetPointerv(GLenum pname, GLvoid** params) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
ASSERT_SYMBOL_PRESENT(fGetPointerv);
|
|
|
|
mSymbols.fGetPointerv(pname, params);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fGetObjectLabel(GLenum identifier, GLuint name, GLsizei bufSize, GLsizei* length, GLchar* label) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
ASSERT_SYMBOL_PRESENT(fGetObjectLabel);
|
|
|
|
mSymbols.fGetObjectLabel(identifier, name, bufSize, length, label);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fGetObjectPtrLabel(GLvoid* ptr, GLsizei bufSize, GLsizei* length, GLchar* label) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
ASSERT_SYMBOL_PRESENT(fGetObjectPtrLabel);
|
|
|
|
mSymbols.fGetObjectPtrLabel(ptr, bufSize, length, label);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fGenerateMipmap(GLenum target) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fGenerateMipmap(target);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-10-06 13:43:14 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fGetProgramiv(GLuint program, GLenum pname, GLint* param) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fGetProgramiv(program, pname, param);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2013-07-17 20:24:15 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fGetProgramInfoLog(GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fGetProgramInfoLog(program, bufSize, length, infoLog);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fTexParameteri(GLenum target, GLenum pname, GLint param) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fTexParameteri(target, pname, param);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fTexParameteriv(GLenum target, GLenum pname, GLint* params) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fTexParameteriv(target, pname, params);
|
|
|
|
AFTER_GL_CALL;
|
2011-12-16 14:24:46 -08:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fTexParameterf(GLenum target, GLenum pname, GLfloat param) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fTexParameterf(target, pname, param);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-07-18 22:01:14 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
const GLubyte* fGetString(GLenum name) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
const GLubyte *result = mSymbols.fGetString(name);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
return result;
|
|
|
|
}
|
2012-04-10 13:20:02 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fGetTexImage(GLenum target, GLint level, GLenum format, GLenum type, GLvoid *img) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
ASSERT_SYMBOL_PRESENT(fGetTexImage);
|
|
|
|
mSymbols.fGetTexImage(target, level, format, type, img);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint *params)
|
|
|
|
{
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
ASSERT_SYMBOL_PRESENT(fGetTexLevelParameteriv);
|
|
|
|
mSymbols.fGetTexLevelParameteriv(target, level, pname, params);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-07-18 22:01:14 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fGetTexParameterfv(GLenum target, GLenum pname, const GLfloat *params) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fGetTexParameterfv(target, pname, params);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-09-21 12:41:24 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fGetTexParameteriv(GLenum target, GLenum pname, const GLint *params) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fGetTexParameteriv(target, pname, params);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2013-02-13 15:26:24 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fGetUniformfv(GLuint program, GLint location, GLfloat* params) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fGetUniformfv(program, location, params);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2013-02-13 15:26:24 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fGetUniformiv(GLuint program, GLint location, GLint* params) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fGetUniformiv(program, location, params);
|
|
|
|
AFTER_GL_CALL;
|
2013-02-13 15:26:24 -08:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
GLint fGetUniformLocation (GLint programObj, const GLchar* name) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
GLint retval = mSymbols.fGetUniformLocation(programObj, name);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
return retval;
|
|
|
|
}
|
2013-02-13 15:26:24 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* retval) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fGetVertexAttribfv(index, pname, retval);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2013-02-13 15:26:24 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fGetVertexAttribiv(GLuint index, GLenum pname, GLint* retval) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fGetVertexAttribiv(index, pname, retval);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2013-04-25 09:35:50 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** retval) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fGetVertexAttribPointerv(index, pname, retval);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2013-02-13 15:26:24 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fHint(GLenum target, GLenum mode) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fHint(target, mode);
|
|
|
|
AFTER_GL_CALL;
|
2013-02-13 15:26:24 -08:00
|
|
|
}
|
2013-02-21 11:54:25 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
realGLboolean fIsBuffer(GLuint buffer) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
realGLboolean retval = mSymbols.fIsBuffer(buffer);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
return retval;
|
|
|
|
}
|
2013-02-13 15:26:24 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
realGLboolean fIsEnabled(GLenum capability) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
realGLboolean retval = mSymbols.fIsEnabled(capability);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
return retval;
|
|
|
|
}
|
2012-04-25 07:10:43 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
realGLboolean fIsProgram(GLuint program) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
realGLboolean retval = mSymbols.fIsProgram(program);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
return retval;
|
|
|
|
}
|
2011-10-20 20:41:02 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
realGLboolean fIsShader(GLuint shader) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
realGLboolean retval = mSymbols.fIsShader(shader);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
return retval;
|
|
|
|
}
|
2012-03-12 15:10:38 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
realGLboolean fIsTexture(GLuint texture) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
realGLboolean retval = mSymbols.fIsTexture(texture);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
return retval;
|
2011-10-19 12:09:57 -07:00
|
|
|
}
|
2012-03-12 15:10:38 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fLineWidth(GLfloat width) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fLineWidth(width);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2013-02-13 15:26:24 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fLinkProgram(GLuint program) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fLinkProgram(program);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2013-02-13 15:26:24 -08:00
|
|
|
|
2013-10-08 16:20:24 -07:00
|
|
|
void fObjectLabel(GLenum identifier, GLuint name, GLsizei length, const GLchar* label) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
ASSERT_SYMBOL_PRESENT(fObjectLabel);
|
|
|
|
mSymbols.fObjectLabel(identifier, name, length, label);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fObjectPtrLabel(GLvoid* ptr, GLsizei length, const GLchar* label) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
ASSERT_SYMBOL_PRESENT(fObjectPtrLabel);
|
|
|
|
mSymbols.fObjectPtrLabel(ptr, length, label);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fPixelStorei(GLenum pname, GLint param) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fPixelStorei(pname, param);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2013-02-13 15:26:24 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fPointParameterf(GLenum pname, GLfloat param) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fPointParameterf(pname, param);
|
|
|
|
AFTER_GL_CALL;
|
2013-02-13 15:26:24 -08:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fPolygonOffset(GLfloat factor, GLfloat bias) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fPolygonOffset(factor, bias);
|
|
|
|
AFTER_GL_CALL;
|
2013-02-13 15:26:24 -08:00
|
|
|
}
|
|
|
|
|
2013-10-08 16:20:24 -07:00
|
|
|
void fPopDebugGroup() {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
ASSERT_SYMBOL_PRESENT(fPopDebugGroup);
|
|
|
|
mSymbols.fPopDebugGroup();
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fPushDebugGroup(GLenum source, GLuint id, GLsizei length, const GLchar* message) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
ASSERT_SYMBOL_PRESENT(fPushDebugGroup);
|
|
|
|
mSymbols.fPushDebugGroup(source, id, length, message);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fReadBuffer(GLenum mode) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fReadBuffer(mode);
|
|
|
|
AFTER_GL_CALL;
|
2013-02-13 15:26:24 -08:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
private:
|
|
|
|
void raw_fReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fReadPixels(x, FixYValue(y, height), width, height, format, type, pixels);
|
|
|
|
AFTER_GL_CALL;
|
2013-02-13 15:26:24 -08:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
public:
|
|
|
|
void fReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) {
|
|
|
|
y = FixYValue(y, height);
|
2013-02-13 15:26:24 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
BeforeGLReadCall();
|
2013-02-13 15:26:24 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
bool didReadPixels = false;
|
|
|
|
if (mScreen) {
|
|
|
|
didReadPixels = mScreen->ReadPixels(x, y, width, height, format, type, pixels);
|
|
|
|
}
|
2013-02-13 15:26:24 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
if (!didReadPixels) {
|
|
|
|
raw_fReadPixels(x, y, width, height, format, type, pixels);
|
|
|
|
}
|
2013-02-13 15:26:24 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
AfterGLReadCall();
|
|
|
|
}
|
2013-02-13 15:26:24 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
public:
|
|
|
|
void fSampleCoverage(GLclampf value, realGLboolean invert) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fSampleCoverage(value, invert);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2013-02-13 15:26:24 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
private:
|
|
|
|
void raw_fScissor(GLint x, GLint y, GLsizei width, GLsizei height) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fScissor(x, y, width, height);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2012-07-15 08:11:17 -07:00
|
|
|
|
2011-12-19 15:47:54 -08:00
|
|
|
public:
|
2013-07-31 16:18:06 -07:00
|
|
|
void fStencilFunc(GLenum func, GLint ref, GLuint mask) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fStencilFunc(func, ref, mask);
|
|
|
|
AFTER_GL_CALL;
|
2013-02-13 15:26:24 -08:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fStencilFuncSeparate(GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fStencilFuncSeparate(frontfunc, backfunc, ref, mask);
|
|
|
|
AFTER_GL_CALL;
|
2013-02-13 15:26:24 -08:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fStencilMask(GLuint mask) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fStencilMask(mask);
|
|
|
|
AFTER_GL_CALL;
|
2013-02-13 15:26:24 -08:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fStencilMaskSeparate(GLenum face, GLuint mask) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fStencilMaskSeparate(face, mask);
|
|
|
|
AFTER_GL_CALL;
|
2013-02-13 15:26:24 -08:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fStencilOp(GLenum fail, GLenum zfail, GLenum zpass) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fStencilOp(fail, zfail, zpass);
|
|
|
|
AFTER_GL_CALL;
|
2013-02-13 15:26:24 -08:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fStencilOpSeparate(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fStencilOpSeparate(face, sfail, dpfail, dppass);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2013-02-13 15:26:24 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
private:
|
|
|
|
void raw_fTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-04-26 19:09:44 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
public:
|
|
|
|
void fTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) {
|
|
|
|
if (!IsTextureSizeSafeToPassToDriver(target, width, height)) {
|
|
|
|
// pass wrong values to cause the GL to generate GL_INVALID_VALUE.
|
|
|
|
// See bug 737182 and the comment in IsTextureSizeSafeToPassToDriver.
|
|
|
|
level = -1;
|
|
|
|
width = -1;
|
|
|
|
height = -1;
|
|
|
|
border = -1;
|
|
|
|
}
|
|
|
|
raw_fTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
|
|
|
|
}
|
2012-04-10 08:49:10 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2013-02-13 15:26:24 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fUniform1f(GLint location, GLfloat v0) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fUniform1f(location, v0);
|
|
|
|
AFTER_GL_CALL;
|
2013-02-13 15:26:24 -08:00
|
|
|
}
|
2011-12-19 15:47:54 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fUniform1fv(GLint location, GLsizei count, const GLfloat* value) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fUniform1fv(location, count, value);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2013-02-13 15:26:24 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fUniform1i(GLint location, GLint v0) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fUniform1i(location, v0);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-04-26 19:09:44 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fUniform1iv(GLint location, GLsizei count, const GLint* value) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fUniform1iv(location, count, value);
|
|
|
|
AFTER_GL_CALL;
|
2010-07-28 14:24:09 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fUniform2f(GLint location, GLfloat v0, GLfloat v1) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fUniform2f(location, v0, v1);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-04-26 19:09:44 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fUniform2fv(GLint location, GLsizei count, const GLfloat* value) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fUniform2fv(location, count, value);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-06-14 23:55:08 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fUniform2i(GLint location, GLint v0, GLint v1) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fUniform2i(location, v0, v1);
|
|
|
|
AFTER_GL_CALL;
|
2011-05-20 12:53:53 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fUniform2iv(GLint location, GLsizei count, const GLint* value) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fUniform2iv(location, count, value);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fUniform3f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fUniform3f(location, v0, v1, v2);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-12-16 23:19:28 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fUniform3fv(GLint location, GLsizei count, const GLfloat* value) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fUniform3fv(location, count, value);
|
|
|
|
AFTER_GL_CALL;
|
2012-03-26 09:15:53 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fUniform3i(GLint location, GLint v0, GLint v1, GLint v2) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fUniform3i(location, v0, v1, v2);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2013-05-22 00:05:38 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fUniform3iv(GLint location, GLsizei count, const GLint* value) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fUniform3iv(location, count, value);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fUniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fUniform4f(location, v0, v1, v2, v3);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fUniform4fv(GLint location, GLsizei count, const GLfloat* value) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fUniform4fv(location, count, value);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2013-05-22 00:05:38 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fUniform4i(GLint location, GLint v0, GLint v1, GLint v2, GLint v3) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fUniform4i(location, v0, v1, v2, v3);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2013-05-22 00:05:38 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fUniform4iv(GLint location, GLsizei count, const GLint* value) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fUniform4iv(location, count, value);
|
|
|
|
AFTER_GL_CALL;
|
2011-07-07 17:01:16 -07:00
|
|
|
}
|
2010-08-06 22:09:18 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fUniformMatrix2fv(GLint location, GLsizei count, realGLboolean transpose, const GLfloat* value) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fUniformMatrix2fv(location, count, transpose, value);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fUniformMatrix3fv(GLint location, GLsizei count, realGLboolean transpose, const GLfloat* value) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fUniformMatrix3fv(location, count, transpose, value);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fUniformMatrix4fv(GLint location, GLsizei count, realGLboolean transpose, const GLfloat* value) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fUniformMatrix4fv(location, count, transpose, value);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fUseProgram(GLuint program) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fUseProgram(program);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2011-07-07 17:01:16 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fValidateProgram(GLuint program) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fValidateProgram(program);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2012-05-12 16:23:56 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fVertexAttribPointer(GLuint index, GLint size, GLenum type, realGLboolean normalized, GLsizei stride, const GLvoid* pointer) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fVertexAttribPointer(index, size, type, normalized, stride, pointer);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2012-05-12 16:23:56 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fVertexAttrib1f(GLuint index, GLfloat x) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fVertexAttrib1f(index, x);
|
|
|
|
AFTER_GL_CALL;
|
2010-07-28 14:24:09 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fVertexAttrib2f(GLuint index, GLfloat x, GLfloat y) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fVertexAttrib2f(index, x, y);
|
|
|
|
AFTER_GL_CALL;
|
2010-10-12 14:01:59 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fVertexAttrib3f(index, x, y, z);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2011-04-18 15:47:40 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fVertexAttrib4f(index, x, y, z, w);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2013-05-22 00:05:38 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fVertexAttrib1fv(GLuint index, const GLfloat* v) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fVertexAttrib1fv(index, v);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fVertexAttrib2fv(GLuint index, const GLfloat* v) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fVertexAttrib2fv(index, v);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fVertexAttrib3fv(GLuint index, const GLfloat* v) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fVertexAttrib3fv(index, v);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fVertexAttrib4fv(GLuint index, const GLfloat* v) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fVertexAttrib4fv(index, v);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fCompileShader(GLuint shader) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fCompileShader(shader);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2012-12-18 23:16:01 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
private:
|
|
|
|
void raw_fCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void raw_fCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
public:
|
|
|
|
void fGetShaderiv(GLuint shader, GLenum pname, GLint* param) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fGetShaderiv(shader, pname, param);
|
|
|
|
AFTER_GL_CALL;
|
2010-07-28 14:24:09 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fGetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fGetShaderInfoLog(shader, bufSize, length, infoLog);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
private:
|
|
|
|
void raw_fGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) {
|
|
|
|
MOZ_ASSERT(IsGLES2());
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
BEFORE_GL_CALL;
|
|
|
|
ASSERT_SYMBOL_PRESENT(fGetShaderPrecisionFormat);
|
|
|
|
mSymbols.fGetShaderPrecisionFormat(shadertype, precisiontype, range, precision);
|
|
|
|
AFTER_GL_CALL;
|
2011-02-24 23:44:18 -08:00
|
|
|
}
|
|
|
|
|
2010-10-12 14:01:59 -07:00
|
|
|
public:
|
2013-07-31 16:18:06 -07:00
|
|
|
void fGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) {
|
|
|
|
if (IsGLES2()) {
|
|
|
|
raw_fGetShaderPrecisionFormat(shadertype, precisiontype, range, precision);
|
|
|
|
} else {
|
|
|
|
// Fall back to automatic values because almost all desktop hardware supports the OpenGL standard precisions.
|
|
|
|
GetShaderPrecisionFormatNonES2(shadertype, precisiontype, range, precision);
|
|
|
|
}
|
|
|
|
}
|
2012-12-18 23:16:01 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fGetShaderSource(GLint obj, GLsizei maxLength, GLsizei* length, GLchar* source) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fGetShaderSource(obj, maxLength, length, source);
|
|
|
|
AFTER_GL_CALL;
|
2010-09-21 12:41:24 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fShaderSource(GLuint shader, GLsizei count, const GLchar** strings, const GLint* lengths) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fShaderSource(shader, count, strings, lengths);
|
|
|
|
AFTER_GL_CALL;
|
2010-09-21 12:41:24 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
private:
|
|
|
|
void raw_fBindFramebuffer(GLenum target, GLuint framebuffer) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fBindFramebuffer(target, framebuffer);
|
|
|
|
AFTER_GL_CALL;
|
2010-09-21 12:41:24 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
public:
|
|
|
|
void fBindRenderbuffer(GLenum target, GLuint renderbuffer) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fBindRenderbuffer(target, renderbuffer);
|
|
|
|
AFTER_GL_CALL;
|
2010-09-21 12:41:24 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
GLenum fCheckFramebufferStatus(GLenum target) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
GLenum retval = mSymbols.fCheckFramebufferStatus(target);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
return retval;
|
|
|
|
}
|
2010-09-21 12:41:24 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fFramebufferRenderbuffer(GLenum target, GLenum attachmentPoint, GLenum renderbufferTarget, GLuint renderbuffer) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fFramebufferRenderbuffer(target, attachmentPoint, renderbufferTarget, renderbuffer);
|
|
|
|
AFTER_GL_CALL;
|
2010-09-21 12:41:24 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fFramebufferTexture2D(GLenum target, GLenum attachmentPoint, GLenum textureTarget, GLuint texture, GLint level) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fFramebufferTexture2D(target, attachmentPoint, textureTarget, texture, level);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* value) {
|
2010-10-12 14:01:59 -07:00
|
|
|
BEFORE_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
mSymbols.fGetFramebufferAttachmentParameteriv(target, attachment, pname, value);
|
2010-10-12 14:01:59 -07:00
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* value) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fGetRenderbufferParameteriv(target, pname, value);
|
|
|
|
AFTER_GL_CALL;
|
2010-09-21 12:41:24 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
realGLboolean fIsFramebuffer (GLuint framebuffer) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
realGLboolean retval = mSymbols.fIsFramebuffer(framebuffer);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
return retval;
|
2010-09-21 12:41:24 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
public:
|
|
|
|
realGLboolean fIsRenderbuffer (GLuint renderbuffer) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
realGLboolean retval = mSymbols.fIsRenderbuffer(renderbuffer);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
return retval;
|
2010-09-21 12:41:24 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fRenderbufferStorage(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fRenderbufferStorage(target, internalFormat, width, height);
|
|
|
|
AFTER_GL_CALL;
|
2010-09-21 12:41:24 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
private:
|
|
|
|
void raw_fDepthRange(GLclampf a, GLclampf b) {
|
|
|
|
MOZ_ASSERT(!IsGLES2());
|
2010-09-21 12:41:24 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
BEFORE_GL_CALL;
|
|
|
|
ASSERT_SYMBOL_PRESENT(fDepthRange);
|
|
|
|
mSymbols.fDepthRange(a, b);
|
|
|
|
AFTER_GL_CALL;
|
2010-09-21 12:41:24 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void raw_fDepthRangef(GLclampf a, GLclampf b) {
|
|
|
|
MOZ_ASSERT(IsGLES2());
|
2010-09-21 12:41:24 -07:00
|
|
|
|
2010-10-12 14:01:59 -07:00
|
|
|
BEFORE_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
ASSERT_SYMBOL_PRESENT(fDepthRangef);
|
|
|
|
mSymbols.fDepthRangef(a, b);
|
2010-10-12 14:01:59 -07:00
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-09-21 12:41:24 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void raw_fClearDepth(GLclampf v) {
|
|
|
|
MOZ_ASSERT(!IsGLES2());
|
|
|
|
|
2010-10-12 14:01:59 -07:00
|
|
|
BEFORE_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
ASSERT_SYMBOL_PRESENT(fClearDepth);
|
|
|
|
mSymbols.fClearDepth(v);
|
2010-10-12 14:01:59 -07:00
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-09-21 12:41:24 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void raw_fClearDepthf(GLclampf v) {
|
|
|
|
MOZ_ASSERT(IsGLES2());
|
|
|
|
|
2012-11-01 09:11:42 -07:00
|
|
|
BEFORE_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
ASSERT_SYMBOL_PRESENT(fClearDepthf);
|
|
|
|
mSymbols.fClearDepthf(v);
|
2012-11-01 09:11:42 -07:00
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
public:
|
|
|
|
void fDepthRange(GLclampf a, GLclampf b) {
|
|
|
|
if (IsGLES2()) {
|
|
|
|
raw_fDepthRangef(a, b);
|
|
|
|
} else {
|
|
|
|
raw_fDepthRange(a, b);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void fClearDepth(GLclampf v) {
|
|
|
|
if (IsGLES2()) {
|
|
|
|
raw_fClearDepthf(v);
|
|
|
|
} else {
|
|
|
|
raw_fClearDepth(v);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void* fMapBuffer(GLenum target, GLenum access) {
|
2010-10-12 14:01:59 -07:00
|
|
|
BEFORE_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
ASSERT_SYMBOL_PRESENT(fMapBuffer);
|
|
|
|
void *ret = mSymbols.fMapBuffer(target, access);
|
2010-10-12 14:01:59 -07:00
|
|
|
AFTER_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
return ret;
|
2010-10-12 14:01:59 -07:00
|
|
|
}
|
2010-09-21 12:41:24 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
realGLboolean fUnmapBuffer(GLenum target) {
|
2010-10-12 14:01:59 -07:00
|
|
|
BEFORE_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
ASSERT_SYMBOL_PRESENT(fUnmapBuffer);
|
|
|
|
realGLboolean ret = mSymbols.fUnmapBuffer(target);
|
2010-10-12 14:01:59 -07:00
|
|
|
AFTER_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
return ret;
|
2010-10-12 14:01:59 -07:00
|
|
|
}
|
2010-07-18 22:01:14 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
GLuint GLAPIENTRY raw_fCreateProgram() {
|
2010-10-12 14:01:59 -07:00
|
|
|
BEFORE_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
GLuint ret = mSymbols.fCreateProgram();
|
2010-10-12 14:01:59 -07:00
|
|
|
AFTER_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
return ret;
|
2010-10-12 14:01:59 -07:00
|
|
|
}
|
2010-07-18 22:01:14 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
GLuint GLAPIENTRY raw_fCreateShader(GLenum t) {
|
2010-10-12 14:01:59 -07:00
|
|
|
BEFORE_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
GLuint ret = mSymbols.fCreateShader(t);
|
2010-10-12 14:01:59 -07:00
|
|
|
AFTER_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
return ret;
|
2010-07-18 22:01:14 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void GLAPIENTRY raw_fGenBuffers(GLsizei n, GLuint* names) {
|
2010-10-12 14:01:59 -07:00
|
|
|
BEFORE_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
mSymbols.fGenBuffers(n, names);
|
2010-10-12 14:01:59 -07:00
|
|
|
AFTER_GL_CALL;
|
2010-07-18 22:01:14 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void GLAPIENTRY raw_fGenFramebuffers(GLsizei n, GLuint* names) {
|
2010-10-12 14:01:59 -07:00
|
|
|
BEFORE_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
mSymbols.fGenFramebuffers(n, names);
|
2010-10-12 14:01:59 -07:00
|
|
|
AFTER_GL_CALL;
|
2010-07-18 22:01:14 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void GLAPIENTRY raw_fGenRenderbuffers(GLsizei n, GLuint* names) {
|
2010-10-12 14:01:59 -07:00
|
|
|
BEFORE_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
mSymbols.fGenRenderbuffers(n, names);
|
2010-10-12 14:01:59 -07:00
|
|
|
AFTER_GL_CALL;
|
2010-07-18 22:01:14 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void GLAPIENTRY raw_fGenTextures(GLsizei n, GLuint* names) {
|
2010-10-12 14:01:59 -07:00
|
|
|
BEFORE_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
mSymbols.fGenTextures(n, names);
|
2012-12-18 23:16:01 -08:00
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2013-07-31 16:18:06 -07:00
|
|
|
GLuint fCreateProgram() {
|
|
|
|
GLuint ret = raw_fCreateProgram();
|
|
|
|
TRACKING_CONTEXT(CreatedProgram(this, ret));
|
|
|
|
return ret;
|
|
|
|
}
|
2012-04-16 12:56:12 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
GLuint fCreateShader(GLenum t) {
|
|
|
|
GLuint ret = raw_fCreateShader(t);
|
|
|
|
TRACKING_CONTEXT(CreatedShader(this, ret));
|
|
|
|
return ret;
|
2010-07-18 22:01:14 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fGenBuffers(GLsizei n, GLuint* names) {
|
|
|
|
raw_fGenBuffers(n, names);
|
|
|
|
TRACKING_CONTEXT(CreatedBuffers(this, n, names));
|
|
|
|
}
|
|
|
|
|
|
|
|
void fGenFramebuffers(GLsizei n, GLuint* names) {
|
|
|
|
raw_fGenFramebuffers(n, names);
|
|
|
|
TRACKING_CONTEXT(CreatedFramebuffers(this, n, names));
|
|
|
|
}
|
|
|
|
|
|
|
|
void fGenRenderbuffers(GLsizei n, GLuint* names) {
|
|
|
|
raw_fGenRenderbuffers(n, names);
|
|
|
|
TRACKING_CONTEXT(CreatedRenderbuffers(this, n, names));
|
|
|
|
}
|
|
|
|
|
|
|
|
void fGenTextures(GLsizei n, GLuint* names) {
|
|
|
|
raw_fGenTextures(n, names);
|
|
|
|
TRACKING_CONTEXT(CreatedTextures(this, n, names));
|
2010-07-18 22:01:14 -07:00
|
|
|
}
|
|
|
|
|
2012-12-18 23:16:01 -08:00
|
|
|
private:
|
2013-07-31 16:18:06 -07:00
|
|
|
void GLAPIENTRY raw_fDeleteProgram(GLuint program) {
|
2010-10-12 14:01:59 -07:00
|
|
|
BEFORE_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
mSymbols.fDeleteProgram(program);
|
2010-10-12 14:01:59 -07:00
|
|
|
AFTER_GL_CALL;
|
2010-07-18 22:01:14 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void GLAPIENTRY raw_fDeleteShader(GLuint shader) {
|
2010-10-12 14:01:59 -07:00
|
|
|
BEFORE_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
mSymbols.fDeleteShader(shader);
|
2010-10-12 14:01:59 -07:00
|
|
|
AFTER_GL_CALL;
|
2010-07-18 22:01:14 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void GLAPIENTRY raw_fDeleteBuffers(GLsizei n, GLuint *names) {
|
2010-10-12 14:01:59 -07:00
|
|
|
BEFORE_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
mSymbols.fDeleteBuffers(n, names);
|
2010-10-12 14:01:59 -07:00
|
|
|
AFTER_GL_CALL;
|
2010-07-18 22:01:14 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void GLAPIENTRY raw_fDeleteFramebuffers(GLsizei n, GLuint *names) {
|
2010-10-12 14:01:59 -07:00
|
|
|
BEFORE_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
mSymbols.fDeleteFramebuffers(n, names);
|
2012-05-08 10:29:31 -07:00
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void GLAPIENTRY raw_fDeleteRenderbuffers(GLsizei n, GLuint *names) {
|
2012-05-08 10:29:31 -07:00
|
|
|
BEFORE_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
mSymbols.fDeleteRenderbuffers(n, names);
|
2012-05-08 10:29:31 -07:00
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void GLAPIENTRY raw_fDeleteTextures(GLsizei n, GLuint *names) {
|
2012-05-08 10:29:31 -07:00
|
|
|
BEFORE_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
mSymbols.fDeleteTextures(n, names);
|
2010-10-12 14:01:59 -07:00
|
|
|
AFTER_GL_CALL;
|
2010-07-18 22:01:14 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
public:
|
|
|
|
|
|
|
|
void fDeleteProgram(GLuint program) {
|
|
|
|
raw_fDeleteProgram(program);
|
|
|
|
TRACKING_CONTEXT(DeletedProgram(this, program));
|
|
|
|
}
|
|
|
|
|
|
|
|
void fDeleteShader(GLuint shader) {
|
|
|
|
raw_fDeleteShader(shader);
|
|
|
|
TRACKING_CONTEXT(DeletedShader(this, shader));
|
|
|
|
}
|
|
|
|
|
|
|
|
void fDeleteBuffers(GLsizei n, GLuint *names) {
|
|
|
|
raw_fDeleteBuffers(n, names);
|
|
|
|
TRACKING_CONTEXT(DeletedBuffers(this, n, names));
|
|
|
|
}
|
|
|
|
|
|
|
|
void fDeleteFramebuffers(GLsizei n, GLuint *names) {
|
|
|
|
if (mScreen) {
|
|
|
|
// Notify mScreen which framebuffers we're deleting.
|
|
|
|
// Otherwise, we will get framebuffer binding mispredictions.
|
|
|
|
for (int i = 0; i < n; i++) {
|
|
|
|
mScreen->DeletingFB(names[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (n == 1 && *names == 0) {
|
|
|
|
// Deleting framebuffer 0 causes hangs on the DROID. See bug 623228.
|
|
|
|
} else {
|
|
|
|
raw_fDeleteFramebuffers(n, names);
|
|
|
|
}
|
|
|
|
TRACKING_CONTEXT(DeletedFramebuffers(this, n, names));
|
|
|
|
}
|
|
|
|
|
|
|
|
void fDeleteRenderbuffers(GLsizei n, GLuint *names) {
|
|
|
|
raw_fDeleteRenderbuffers(n, names);
|
|
|
|
TRACKING_CONTEXT(DeletedRenderbuffers(this, n, names));
|
2010-10-12 14:01:59 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fDeleteTextures(GLsizei n, GLuint *names) {
|
|
|
|
raw_fDeleteTextures(n, names);
|
|
|
|
TRACKING_CONTEXT(DeletedTextures(this, n, names));
|
2010-10-12 14:01:59 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
GLenum GLAPIENTRY fGetGraphicsResetStatus() {
|
|
|
|
MOZ_ASSERT(mHasRobustness);
|
2010-10-12 14:01:59 -07:00
|
|
|
|
|
|
|
BEFORE_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
ASSERT_SYMBOL_PRESENT(fGetGraphicsResetStatus);
|
|
|
|
GLenum ret = mSymbols.fGetGraphicsResetStatus();
|
2010-10-12 14:01:59 -07:00
|
|
|
AFTER_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
return ret;
|
2010-10-12 14:01:59 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Extension ARB_sync (GL)
|
|
|
|
public:
|
|
|
|
GLsync GLAPIENTRY fFenceSync(GLenum condition, GLbitfield flags) {
|
2012-11-01 09:11:42 -07:00
|
|
|
BEFORE_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
ASSERT_SYMBOL_PRESENT(fFenceSync);
|
|
|
|
GLsync ret = mSymbols.fFenceSync(condition, flags);
|
2012-11-01 09:11:42 -07:00
|
|
|
AFTER_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
return ret;
|
2012-11-01 09:11:42 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
realGLboolean GLAPIENTRY fIsSync(GLsync sync) {
|
2012-11-01 09:11:42 -07:00
|
|
|
BEFORE_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
ASSERT_SYMBOL_PRESENT(fIsSync);
|
|
|
|
realGLboolean ret = mSymbols.fIsSync(sync);
|
2012-11-01 09:11:42 -07:00
|
|
|
AFTER_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
return ret;
|
2012-11-01 09:11:42 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void GLAPIENTRY fDeleteSync(GLsync sync) {
|
2010-10-12 14:01:59 -07:00
|
|
|
BEFORE_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
ASSERT_SYMBOL_PRESENT(fDeleteSync);
|
|
|
|
mSymbols.fDeleteSync(sync);
|
2010-10-12 14:01:59 -07:00
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
GLenum GLAPIENTRY fClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) {
|
2010-10-12 14:01:59 -07:00
|
|
|
BEFORE_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
ASSERT_SYMBOL_PRESENT(fClientWaitSync);
|
|
|
|
GLenum ret = mSymbols.fClientWaitSync(sync, flags, timeout);
|
2010-10-12 14:01:59 -07:00
|
|
|
AFTER_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
return ret;
|
2010-10-12 14:01:59 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void GLAPIENTRY fWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) {
|
2010-10-12 14:01:59 -07:00
|
|
|
BEFORE_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
ASSERT_SYMBOL_PRESENT(fWaitSync);
|
|
|
|
mSymbols.fWaitSync(sync, flags, timeout);
|
2010-10-12 14:01:59 -07:00
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void GLAPIENTRY fGetInteger64v(GLenum pname, GLint64 *params) {
|
2010-10-12 14:01:59 -07:00
|
|
|
BEFORE_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
ASSERT_SYMBOL_PRESENT(fGetInteger64v);
|
|
|
|
mSymbols.fGetInteger64v(pname, params);
|
2010-10-12 14:01:59 -07:00
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void GLAPIENTRY fGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values) {
|
2012-11-01 09:11:42 -07:00
|
|
|
BEFORE_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
ASSERT_SYMBOL_PRESENT(fGetSynciv);
|
|
|
|
mSymbols.fGetSynciv(sync, pname, bufSize, length, values);
|
2012-11-01 09:11:42 -07:00
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Extension OES_EGL_image (GLES)
|
|
|
|
public:
|
|
|
|
void fEGLImageTargetTexture2D(GLenum target, GLeglImage image) {
|
2010-10-12 14:01:59 -07:00
|
|
|
BEFORE_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
ASSERT_SYMBOL_PRESENT(fEGLImageTargetTexture2D);
|
|
|
|
mSymbols.fEGLImageTargetTexture2D(target, image);
|
2010-10-12 14:01:59 -07:00
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fEGLImageTargetRenderbufferStorage(GLenum target, GLeglImage image)
|
|
|
|
{
|
2010-10-12 14:01:59 -07:00
|
|
|
BEFORE_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
ASSERT_SYMBOL_PRESENT(fEGLImageTargetRenderbufferStorage);
|
|
|
|
mSymbols.fEGLImageTargetRenderbufferStorage(target, image);
|
2010-10-12 14:01:59 -07:00
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-20 08:36:20 -07:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Package XXX_bind_buffer_offset
|
|
|
|
public:
|
|
|
|
void fBindBufferOffset(GLenum target, GLuint index, GLuint buffer, GLintptr offset)
|
|
|
|
{
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
ASSERT_SYMBOL_PRESENT(fBindBufferOffset);
|
|
|
|
mSymbols.fBindBufferOffset(target, index, buffer, offset);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Package XXX_draw_buffers
|
|
|
|
public:
|
|
|
|
void fDrawBuffers(GLsizei n, const GLenum* bufs) {
|
2010-10-12 14:01:59 -07:00
|
|
|
BEFORE_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
mSymbols.fDrawBuffers(n, bufs);
|
2010-10-12 14:01:59 -07:00
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Package XXX_draw_instanced
|
|
|
|
public:
|
|
|
|
void fDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei primcount)
|
|
|
|
{
|
2013-08-01 15:27:54 -07:00
|
|
|
BeforeGLDrawCall();
|
2010-10-12 14:01:59 -07:00
|
|
|
BEFORE_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
ASSERT_SYMBOL_PRESENT(fDrawArraysInstanced);
|
|
|
|
mSymbols.fDrawArraysInstanced(mode, first, count, primcount);
|
2010-10-12 14:01:59 -07:00
|
|
|
AFTER_GL_CALL;
|
2013-08-01 15:27:54 -07:00
|
|
|
AfterGLDrawCall();
|
2010-10-12 14:01:59 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void fDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei primcount)
|
|
|
|
{
|
2013-08-01 15:27:54 -07:00
|
|
|
BeforeGLDrawCall();
|
2012-11-01 09:11:42 -07:00
|
|
|
BEFORE_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
ASSERT_SYMBOL_PRESENT(fDrawElementsInstanced);
|
|
|
|
mSymbols.fDrawElementsInstanced(mode, count, type, indices, primcount);
|
2012-11-01 09:11:42 -07:00
|
|
|
AFTER_GL_CALL;
|
2013-08-01 15:27:54 -07:00
|
|
|
AfterGLDrawCall();
|
2012-11-01 09:11:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Package XXX_framebuffer_blit
|
|
|
|
public:
|
|
|
|
// Draw/Read
|
|
|
|
void fBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) {
|
|
|
|
BeforeGLDrawCall();
|
|
|
|
BeforeGLReadCall();
|
|
|
|
raw_fBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
|
|
|
|
AfterGLReadCall();
|
|
|
|
AfterGLDrawCall();
|
2012-11-01 09:11:42 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
|
2012-02-09 17:57:26 -08:00
|
|
|
private:
|
2013-07-31 16:18:06 -07:00
|
|
|
void raw_fBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) {
|
2010-10-12 14:01:59 -07:00
|
|
|
BEFORE_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
ASSERT_SYMBOL_PRESENT(fBlitFramebuffer);
|
|
|
|
mSymbols.fBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
|
2010-10-12 14:01:59 -07:00
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
2012-08-21 20:30:20 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Package XXX_framebuffer_multisample
|
|
|
|
public:
|
|
|
|
void fRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height) {
|
2010-10-12 14:01:59 -07:00
|
|
|
BEFORE_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
ASSERT_SYMBOL_PRESENT(fRenderbufferStorageMultisample);
|
|
|
|
mSymbols.fRenderbufferStorageMultisample(target, samples, internalFormat, width, height);
|
2010-10-12 14:01:59 -07:00
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-06 17:05:51 -07:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Package XXX_instanced_arrays
|
|
|
|
public:
|
|
|
|
void fVertexAttribDivisor(GLuint index, GLuint divisor)
|
|
|
|
{
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
ASSERT_SYMBOL_PRESENT(fVertexAttribDivisor);
|
|
|
|
mSymbols.fVertexAttribDivisor(index, divisor);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-15 12:58:20 -07:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Package XXX_query_objects
|
|
|
|
/**
|
|
|
|
* XXX_query_objects:
|
|
|
|
* - provide all followed entry points
|
|
|
|
*
|
|
|
|
* XXX_occlusion_query2:
|
|
|
|
* - depends on XXX_query_objects
|
|
|
|
* - provide ANY_SAMPLES_PASSED
|
|
|
|
*
|
|
|
|
* XXX_occlusion_query_boolean:
|
|
|
|
* - depends on XXX_occlusion_query2
|
|
|
|
* - provide ANY_SAMPLES_PASSED_CONSERVATIVE
|
|
|
|
*/
|
|
|
|
public:
|
|
|
|
void fDeleteQueries(GLsizei n, const GLuint* names) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
ASSERT_SYMBOL_PRESENT(fDeleteQueries);
|
|
|
|
mSymbols.fDeleteQueries(n, names);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
TRACKING_CONTEXT(DeletedQueries(this, n, names));
|
|
|
|
}
|
|
|
|
|
|
|
|
void fGenQueries(GLsizei n, GLuint* names) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
ASSERT_SYMBOL_PRESENT(fGenQueries);
|
|
|
|
mSymbols.fGenQueries(n, names);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
TRACKING_CONTEXT(CreatedQueries(this, n, names));
|
|
|
|
}
|
|
|
|
|
|
|
|
void fGetQueryiv(GLenum target, GLenum pname, GLint* params) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
ASSERT_SYMBOL_PRESENT(fGetQueryiv);
|
|
|
|
mSymbols.fGetQueryiv(target, pname, params);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
ASSERT_SYMBOL_PRESENT(fGetQueryObjectuiv);
|
|
|
|
mSymbols.fGetQueryObjectuiv(id, pname, params);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
realGLboolean fIsQuery(GLuint query) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
ASSERT_SYMBOL_PRESENT(fIsQuery);
|
|
|
|
realGLboolean retval = mSymbols.fIsQuery(query);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Package XXX_get_query_object_iv
|
|
|
|
/**
|
|
|
|
* XXX_get_query_object_iv:
|
|
|
|
* - depends on XXX_query_objects
|
|
|
|
* - provide the followed entry point
|
|
|
|
*
|
|
|
|
* XXX_occlusion_query:
|
|
|
|
* - depends on XXX_get_query_object_iv
|
|
|
|
* - provide LOCAL_GL_SAMPLES_PASSED
|
|
|
|
*/
|
|
|
|
public:
|
|
|
|
void fGetQueryObjectiv(GLuint id, GLenum pname, GLint* params) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
ASSERT_SYMBOL_PRESENT(fGetQueryObjectiv);
|
|
|
|
mSymbols.fGetQueryObjectiv(id, pname, params);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-20 08:36:20 -07:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Package XXX_transform_feedback
|
|
|
|
public:
|
|
|
|
void fBindBufferBase(GLenum target, GLuint index, GLuint buffer)
|
|
|
|
{
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
ASSERT_SYMBOL_PRESENT(fBindBufferBase);
|
|
|
|
mSymbols.fBindBufferBase(target, index, buffer);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
|
|
|
|
{
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
ASSERT_SYMBOL_PRESENT(fBindBufferRange);
|
|
|
|
mSymbols.fBindBufferRange(target, index, buffer, offset, size);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fBeginTransformFeedback(GLenum primitiveMode)
|
|
|
|
{
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
ASSERT_SYMBOL_PRESENT(fBeginTransformFeedback);
|
|
|
|
mSymbols.fBeginTransformFeedback(primitiveMode);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fEndTransformFeedback()
|
|
|
|
{
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
ASSERT_SYMBOL_PRESENT(fEndTransformFeedback);
|
|
|
|
mSymbols.fEndTransformFeedback();
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode)
|
|
|
|
{
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
ASSERT_SYMBOL_PRESENT(fTransformFeedbackVaryings);
|
|
|
|
mSymbols.fTransformFeedbackVaryings(program, count, varyings, bufferMode);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fGetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name)
|
|
|
|
{
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
ASSERT_SYMBOL_PRESENT(fGetTransformFeedbackVarying);
|
|
|
|
mSymbols.fGetTransformFeedbackVarying(program, index, bufSize, length, size, type, name);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fGetIntegeri_v(GLenum param, GLuint index, GLint* values)
|
|
|
|
{
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
ASSERT_SYMBOL_PRESENT(fGetIntegeri_v);
|
|
|
|
mSymbols.fGetIntegeri_v(param, index, values);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Package XXX_vertex_array_object
|
|
|
|
public:
|
|
|
|
void GLAPIENTRY fBindVertexArray(GLuint array)
|
|
|
|
{
|
2010-10-12 14:01:59 -07:00
|
|
|
BEFORE_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
ASSERT_SYMBOL_PRESENT(fBindVertexArray);
|
|
|
|
mSymbols.fBindVertexArray(array);
|
2010-10-12 14:01:59 -07:00
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void GLAPIENTRY fDeleteVertexArrays(GLsizei n, const GLuint *arrays)
|
|
|
|
{
|
2010-10-12 14:01:59 -07:00
|
|
|
BEFORE_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
ASSERT_SYMBOL_PRESENT(fDeleteVertexArrays);
|
|
|
|
mSymbols.fDeleteVertexArrays(n, arrays);
|
2010-10-12 14:01:59 -07:00
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void GLAPIENTRY fGenVertexArrays(GLsizei n, GLuint *arrays)
|
|
|
|
{
|
2010-10-12 14:01:59 -07:00
|
|
|
BEFORE_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
ASSERT_SYMBOL_PRESENT(fGenVertexArrays);
|
|
|
|
mSymbols.fGenVertexArrays(n, arrays);
|
2010-10-12 14:01:59 -07:00
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
realGLboolean GLAPIENTRY fIsVertexArray(GLuint array)
|
|
|
|
{
|
2010-10-12 14:01:59 -07:00
|
|
|
BEFORE_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
ASSERT_SYMBOL_PRESENT(fIsVertexArray);
|
|
|
|
realGLboolean ret = mSymbols.fIsVertexArray(array);
|
2010-10-12 14:01:59 -07:00
|
|
|
AFTER_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
return ret;
|
2010-10-12 14:01:59 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Constructor
|
|
|
|
public:
|
2012-11-01 09:11:42 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
typedef struct gfx::SurfaceCaps SurfaceCaps;
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
GLContext(const SurfaceCaps& caps,
|
|
|
|
GLContext* sharedContext = nullptr,
|
2013-09-06 19:13:37 -07:00
|
|
|
bool isOffscreen = false);
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Destructor
|
|
|
|
public:
|
2013-09-06 19:13:37 -07:00
|
|
|
virtual ~GLContext();
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2012-03-05 10:09:05 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Everything that isn't standard GL APIs
|
|
|
|
protected:
|
2012-03-05 10:09:05 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
typedef class gfx::SharedSurface SharedSurface;
|
|
|
|
typedef gfx::SharedSurfaceType SharedSurfaceType;
|
2013-09-24 13:45:13 -07:00
|
|
|
typedef gfxImageFormat ImageFormat;
|
2013-07-31 16:18:06 -07:00
|
|
|
typedef gfx::SurfaceFormat SurfaceFormat;
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
public:
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
virtual bool MakeCurrentImpl(bool aForce = false) = 0;
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
static void StaticInit() {
|
|
|
|
PR_NewThreadPrivateIndex(&sCurrentGLContextTLS, nullptr);
|
2010-10-12 14:01:59 -07:00
|
|
|
}
|
2013-07-31 16:18:06 -07:00
|
|
|
#endif
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
bool MakeCurrent(bool aForce = false) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
PR_SetThreadPrivate(sCurrentGLContextTLS, this);
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
// XXX this assertion is disabled because it's triggering on Mac;
|
|
|
|
// we need to figure out why and reenable it.
|
|
|
|
#if 0
|
|
|
|
// IsOwningThreadCurrent is a bit of a misnomer;
|
|
|
|
// the "owning thread" is the creation thread,
|
|
|
|
// and the only thread that can own this. We don't
|
|
|
|
// support contexts used on multiple threads.
|
|
|
|
NS_ASSERTION(IsOwningThreadCurrent(),
|
|
|
|
"MakeCurrent() called on different thread than this context was created on!");
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
return MakeCurrentImpl(aForce);
|
2010-10-12 14:01:59 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
virtual bool SetupLookupFunction() = 0;
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
virtual void ReleaseSurface() {}
|
2012-08-21 20:30:20 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void *GetUserData(void *aKey) {
|
|
|
|
void *result = nullptr;
|
|
|
|
mUserData.Get(aKey, &result);
|
|
|
|
return result;
|
2010-10-12 14:01:59 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void SetUserData(void *aKey, void *aValue) {
|
|
|
|
mUserData.Put(aKey, aValue);
|
2010-10-12 14:01:59 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
// Mark this context as destroyed. This will nullptr out all
|
|
|
|
// the GL function pointers!
|
|
|
|
void MarkDestroyed();
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
bool IsDestroyed() {
|
|
|
|
// MarkDestroyed will mark all these as null.
|
|
|
|
return mSymbols.fUseProgram == nullptr;
|
2010-10-12 14:01:59 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
enum NativeDataType {
|
|
|
|
NativeGLContext,
|
|
|
|
NativeImageSurface,
|
|
|
|
NativeThebesSurface,
|
|
|
|
NativeDataTypeMax
|
|
|
|
};
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
virtual void *GetNativeData(NativeDataType aType) { return nullptr; }
|
|
|
|
GLContext *GetSharedContext() { return mSharedContext; }
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
bool IsGlobalSharedContext() { return mIsGlobalSharedContext; }
|
|
|
|
void SetIsGlobalSharedContext(bool aIsOne) { mIsGlobalSharedContext = aIsOne; }
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
/**
|
|
|
|
* Returns true if the thread on which this context was created is the currently
|
|
|
|
* executing thread.
|
|
|
|
*/
|
2013-09-06 19:13:37 -07:00
|
|
|
bool IsOwningThreadCurrent();
|
|
|
|
void DispatchToOwningThread(nsIRunnable *event);
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
virtual EGLContext GetEGLContext() { return nullptr; }
|
|
|
|
virtual GLLibraryEGL* GetLibraryEGL() { return nullptr; }
|
2012-07-05 07:13:46 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
virtual void MakeCurrent_EGLSurface(void* surf) {
|
|
|
|
MOZ_CRASH("Must be called against a GLContextEGL.");
|
2010-10-12 14:01:59 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
bool CanUploadSubTextures();
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
static void PlatformStartup();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
static bool sPowerOfTwoForced;
|
|
|
|
static bool sPowerOfTwoPrefCached;
|
|
|
|
static void CacheCanUploadNPOT();
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2012-12-18 23:16:01 -08:00
|
|
|
public:
|
2013-07-31 16:18:06 -07:00
|
|
|
bool CanUploadNonPowerOfTwo();
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
bool WantsSmallTiles();
|
2012-12-18 23:16:01 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
/**
|
|
|
|
* If this context wraps a double-buffered target, swap the back
|
|
|
|
* and front buffers. It should be assumed that after a swap, the
|
|
|
|
* contents of the new back buffer are undefined.
|
|
|
|
*/
|
|
|
|
virtual bool SwapBuffers() { return false; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Defines a two-dimensional texture image for context target surface
|
|
|
|
*/
|
|
|
|
virtual bool BindTexImage() { return false; }
|
|
|
|
/*
|
|
|
|
* Releases a color buffer that is being used as a texture
|
|
|
|
*/
|
|
|
|
virtual bool ReleaseTexImage() { return false; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Applies aFilter to the texture currently bound to GL_TEXTURE_2D.
|
|
|
|
*/
|
2013-10-01 14:01:19 -07:00
|
|
|
void ApplyFilterToBoundTexture(GraphicsFilter aFilter);
|
2013-07-31 16:18:06 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Applies aFilter to the texture currently bound to aTarget.
|
|
|
|
*/
|
|
|
|
void ApplyFilterToBoundTexture(GLuint aTarget,
|
2013-10-01 14:01:19 -07:00
|
|
|
GraphicsFilter aFilter);
|
2013-07-31 16:18:06 -07:00
|
|
|
|
|
|
|
virtual bool BindExternalBuffer(GLuint texture, void* buffer) { return false; }
|
|
|
|
virtual bool UnbindExternalBuffer(GLuint texture) { return false; }
|
|
|
|
|
|
|
|
#ifdef MOZ_WIDGET_GONK
|
|
|
|
virtual EGLImage CreateEGLImageForNativeBuffer(void* buffer) = 0;
|
|
|
|
virtual void DestroyEGLImage(EGLImage image) = 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
virtual already_AddRefed<TextureImage>
|
2013-09-27 14:02:09 -07:00
|
|
|
CreateDirectTextureImage(android::GraphicBuffer* aBuffer, GLenum aWrapMode)
|
2013-07-31 16:18:06 -07:00
|
|
|
{ return nullptr; }
|
|
|
|
|
|
|
|
// Before reads from offscreen texture
|
|
|
|
void GuaranteeResolve();
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
protected:
|
|
|
|
GLuint mTexBlit_Buffer;
|
|
|
|
GLuint mTexBlit_VertShader;
|
|
|
|
GLuint mTex2DBlit_FragShader;
|
|
|
|
GLuint mTex2DRectBlit_FragShader;
|
|
|
|
GLuint mTex2DBlit_Program;
|
|
|
|
GLuint mTex2DRectBlit_Program;
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
bool mTexBlit_UseDrawNotCopy;
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
bool UseTexQuadProgram(GLenum target = LOCAL_GL_TEXTURE_2D,
|
|
|
|
const gfxIntSize& srcSize = gfxIntSize());
|
|
|
|
bool InitTexQuadProgram(GLenum target = LOCAL_GL_TEXTURE_2D);
|
|
|
|
void DeleteTexBlitProgram();
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
public:
|
|
|
|
// If you don't have |srcFormats| for the 2nd definition,
|
|
|
|
// then you'll need the framebuffer_blit extensions to use
|
|
|
|
// the first BlitFramebufferToFramebuffer.
|
|
|
|
void BlitFramebufferToFramebuffer(GLuint srcFB, GLuint destFB,
|
|
|
|
const gfxIntSize& srcSize,
|
|
|
|
const gfxIntSize& destSize);
|
|
|
|
void BlitFramebufferToFramebuffer(GLuint srcFB, GLuint destFB,
|
|
|
|
const gfxIntSize& srcSize,
|
|
|
|
const gfxIntSize& destSize,
|
|
|
|
const GLFormats& srcFormats);
|
|
|
|
void BlitTextureToFramebuffer(GLuint srcTex, GLuint destFB,
|
|
|
|
const gfxIntSize& srcSize,
|
|
|
|
const gfxIntSize& destSize,
|
|
|
|
GLenum srcTarget = LOCAL_GL_TEXTURE_2D);
|
|
|
|
void BlitFramebufferToTexture(GLuint srcFB, GLuint destTex,
|
|
|
|
const gfxIntSize& srcSize,
|
|
|
|
const gfxIntSize& destSize,
|
|
|
|
GLenum destTarget = LOCAL_GL_TEXTURE_2D);
|
|
|
|
void BlitTextureToTexture(GLuint srcTex, GLuint destTex,
|
|
|
|
const gfxIntSize& srcSize,
|
|
|
|
const gfxIntSize& destSize,
|
|
|
|
GLenum srcTarget = LOCAL_GL_TEXTURE_2D,
|
|
|
|
GLenum destTarget = LOCAL_GL_TEXTURE_2D);
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
/*
|
|
|
|
* Resize the current offscreen buffer. Returns true on success.
|
|
|
|
* If it returns false, the context should be treated as unusable
|
|
|
|
* and should be recreated. After the resize, the viewport is not
|
|
|
|
* changed; glViewport should be called as appropriate.
|
|
|
|
*
|
|
|
|
* Only valid if IsOffscreen() returns true.
|
|
|
|
*/
|
|
|
|
virtual bool ResizeOffscreen(const gfxIntSize& size) {
|
|
|
|
return ResizeScreenBuffer(size);
|
2010-10-12 14:01:59 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
/*
|
|
|
|
* Return size of this offscreen context.
|
|
|
|
*
|
|
|
|
* Only valid if IsOffscreen() returns true.
|
|
|
|
*/
|
|
|
|
const gfxIntSize& OffscreenSize() const;
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
/*
|
|
|
|
* Create a new shared GLContext content handle, using the passed buffer as a source.
|
|
|
|
* Must be released by ReleaseSharedHandle. UpdateSharedHandle will have no effect
|
|
|
|
* on handles created with this method, as the caller owns the source (the passed buffer)
|
|
|
|
* and is responsible for updating it accordingly.
|
|
|
|
*/
|
|
|
|
virtual SharedTextureHandle CreateSharedHandle(SharedTextureShareType shareType,
|
|
|
|
void* buffer,
|
|
|
|
SharedTextureBufferType bufferType)
|
|
|
|
{ return 0; }
|
|
|
|
/**
|
|
|
|
* Publish GLContext content to intermediate buffer attached to shared handle.
|
|
|
|
* Shared handle content is ready to be used after call returns, and no need extra Flush/Finish are required.
|
|
|
|
* GLContext must be current before this call
|
|
|
|
*/
|
|
|
|
virtual void UpdateSharedHandle(SharedTextureShareType shareType,
|
|
|
|
SharedTextureHandle sharedHandle)
|
|
|
|
{ }
|
|
|
|
/**
|
|
|
|
* - It is better to call ReleaseSharedHandle before original GLContext destroyed,
|
|
|
|
* otherwise warning will be thrown on attempt to destroy Texture associated with SharedHandle, depends on backend implementation.
|
|
|
|
* - It does not require to be called on context where it was created,
|
|
|
|
* because SharedHandle suppose to keep Context reference internally,
|
|
|
|
* or don't require specific context at all, for example IPC SharedHandle.
|
|
|
|
* - Not recommended to call this between AttachSharedHandle and Draw Target call.
|
|
|
|
* if it is really required for some special backend, then DetachSharedHandle API must be added with related implementation.
|
|
|
|
* - It is recommended to stop any possible access to SharedHandle (Attachments, pending GL calls) before calling Release,
|
|
|
|
* otherwise some artifacts might appear or even crash if API backend implementation does not expect that.
|
|
|
|
* SharedHandle (currently EGLImage) does not require GLContext because it is EGL call, and can be destroyed
|
|
|
|
* at any time, unless EGLImage have siblings (which are not expected with current API).
|
|
|
|
*/
|
|
|
|
virtual void ReleaseSharedHandle(SharedTextureShareType shareType,
|
|
|
|
SharedTextureHandle sharedHandle)
|
|
|
|
{ }
|
2010-10-12 14:01:59 -07:00
|
|
|
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
typedef struct {
|
|
|
|
GLenum mTarget;
|
|
|
|
SurfaceFormat mTextureFormat;
|
|
|
|
gfx3DMatrix mTextureTransform;
|
|
|
|
} SharedHandleDetails;
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
/**
|
|
|
|
* Returns information necessary for rendering a shared handle.
|
|
|
|
* These values change depending on what sharing mechanism is in use
|
|
|
|
*/
|
|
|
|
virtual bool GetSharedHandleDetails(SharedTextureShareType shareType,
|
|
|
|
SharedTextureHandle sharedHandle,
|
|
|
|
SharedHandleDetails& details)
|
|
|
|
{ return false; }
|
|
|
|
/**
|
|
|
|
* Attach Shared GL Handle to GL_TEXTURE_2D target
|
|
|
|
* GLContext must be current before this call
|
|
|
|
*/
|
|
|
|
virtual bool AttachSharedHandle(SharedTextureShareType shareType,
|
|
|
|
SharedTextureHandle sharedHandle)
|
|
|
|
{ return false; }
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
/**
|
|
|
|
* Detach Shared GL Handle from GL_TEXTURE_2D target
|
|
|
|
*/
|
|
|
|
virtual void DetachSharedHandle(SharedTextureShareType shareType,
|
|
|
|
SharedTextureHandle sharedHandle)
|
|
|
|
{ }
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void BindFB(GLuint fb) {
|
|
|
|
fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, fb);
|
|
|
|
MOZ_ASSERT(!fb || fIsFramebuffer(fb));
|
2010-10-12 14:01:59 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void BindDrawFB(GLuint fb) {
|
|
|
|
fBindFramebuffer(LOCAL_GL_DRAW_FRAMEBUFFER_EXT, fb);
|
2010-08-06 22:09:18 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void BindReadFB(GLuint fb) {
|
|
|
|
fBindFramebuffer(LOCAL_GL_READ_FRAMEBUFFER_EXT, fb);
|
2010-07-18 22:01:14 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
GLuint GetDrawFB() {
|
|
|
|
if (mScreen)
|
|
|
|
return mScreen->GetDrawFB();
|
2010-07-18 22:01:14 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
GLuint ret = 0;
|
|
|
|
GetUIntegerv(LOCAL_GL_DRAW_FRAMEBUFFER_BINDING_EXT, &ret);
|
|
|
|
return ret;
|
2010-07-18 22:01:14 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
GLuint GetReadFB() {
|
|
|
|
if (mScreen)
|
|
|
|
return mScreen->GetReadFB();
|
2010-07-18 22:01:14 -07:00
|
|
|
|
2013-08-22 10:42:05 -07:00
|
|
|
GLenum bindEnum = IsSupported(GLFeature::framebuffer_blit)
|
2013-08-02 18:13:46 -07:00
|
|
|
? LOCAL_GL_READ_FRAMEBUFFER_BINDING_EXT
|
|
|
|
: LOCAL_GL_FRAMEBUFFER_BINDING;
|
2010-07-18 22:01:14 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
GLuint ret = 0;
|
|
|
|
GetUIntegerv(bindEnum, &ret);
|
|
|
|
return ret;
|
2010-07-18 22:01:14 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
GLuint GetFB() {
|
|
|
|
if (mScreen) {
|
|
|
|
// This has a very important extra assert that checks that we're
|
|
|
|
// not accidentally ignoring a situation where the draw and read
|
|
|
|
// FBs differ.
|
|
|
|
return mScreen->GetFB();
|
|
|
|
}
|
2010-07-18 22:01:14 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
GLuint ret = 0;
|
|
|
|
GetUIntegerv(LOCAL_GL_FRAMEBUFFER_BINDING, &ret);
|
|
|
|
return ret;
|
2010-07-18 22:01:14 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
private:
|
|
|
|
void GetShaderPrecisionFormatNonES2(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) {
|
|
|
|
switch (precisiontype) {
|
|
|
|
case LOCAL_GL_LOW_FLOAT:
|
|
|
|
case LOCAL_GL_MEDIUM_FLOAT:
|
|
|
|
case LOCAL_GL_HIGH_FLOAT:
|
|
|
|
// Assume IEEE 754 precision
|
|
|
|
range[0] = 127;
|
|
|
|
range[1] = 127;
|
|
|
|
*precision = 23;
|
|
|
|
break;
|
|
|
|
case LOCAL_GL_LOW_INT:
|
|
|
|
case LOCAL_GL_MEDIUM_INT:
|
|
|
|
case LOCAL_GL_HIGH_INT:
|
|
|
|
// Some (most) hardware only supports single-precision floating-point numbers,
|
|
|
|
// which can accurately represent integers up to +/-16777216
|
|
|
|
range[0] = 24;
|
|
|
|
range[1] = 24;
|
|
|
|
*precision = 0;
|
|
|
|
break;
|
|
|
|
}
|
2010-07-18 22:01:14 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
public:
|
2010-07-18 22:01:14 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void ForceDirtyScreen();
|
|
|
|
void CleanDirtyScreen();
|
2010-07-18 22:01:14 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
virtual bool TextureImageSupportsGetBackingSurface() {
|
|
|
|
return false;
|
2010-07-18 22:01:14 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
virtual GLenum GetPreferredARGB32Format() { return LOCAL_GL_RGBA; }
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
virtual bool RenewSurface() { return false; }
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
/**
|
|
|
|
* Return a valid, allocated TextureImage of |aSize| with
|
2013-08-07 15:38:21 -07:00
|
|
|
* |aContentType|. If |aContentType| is COLOR, |aImageFormat| can be used
|
|
|
|
* to hint at the preferred RGB format, however it is not necessarily
|
|
|
|
* respected. The TextureImage's texture is configured to use
|
|
|
|
* |aWrapMode| (usually GL_CLAMP_TO_EDGE or GL_REPEAT) and by
|
2013-07-31 16:18:06 -07:00
|
|
|
* default, GL_LINEAR filtering. Specify
|
|
|
|
* |aFlags=UseNearestFilter| for GL_NEAREST filtering. Specify
|
|
|
|
* |aFlags=NeedsYFlip| if the image is flipped. Return
|
|
|
|
* nullptr if creating the TextureImage fails.
|
|
|
|
*
|
|
|
|
* The returned TextureImage may only be used with this GLContext.
|
|
|
|
* Attempting to use the returned TextureImage after this
|
|
|
|
* GLContext is destroyed will result in undefined (and likely
|
|
|
|
* crashy) behavior.
|
|
|
|
*/
|
|
|
|
virtual already_AddRefed<TextureImage>
|
|
|
|
CreateTextureImage(const nsIntSize& aSize,
|
|
|
|
TextureImage::ContentType aContentType,
|
|
|
|
GLenum aWrapMode,
|
2013-08-07 15:38:21 -07:00
|
|
|
TextureImage::Flags aFlags = TextureImage::NoFlags,
|
2013-09-24 13:45:13 -07:00
|
|
|
TextureImage::ImageFormat aImageFormat = gfxImageFormatUnknown);
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
/**
|
|
|
|
* In EGL we want to use Tiled Texture Images, which we return
|
|
|
|
* from CreateTextureImage above.
|
|
|
|
* Inside TiledTextureImage we need to create actual images and to
|
|
|
|
* prevent infinite recursion we need to differentiate the two
|
|
|
|
* functions.
|
|
|
|
**/
|
|
|
|
virtual already_AddRefed<TextureImage>
|
|
|
|
TileGenFunc(const nsIntSize& aSize,
|
|
|
|
TextureImage::ContentType aContentType,
|
2013-08-07 15:38:21 -07:00
|
|
|
TextureImage::Flags aFlags = TextureImage::NoFlags,
|
2013-09-24 13:45:13 -07:00
|
|
|
TextureImage::ImageFormat aImageFormat = gfxImageFormatUnknown)
|
2013-07-31 16:18:06 -07:00
|
|
|
{
|
|
|
|
return nullptr;
|
2010-10-12 14:01:59 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
/**
|
|
|
|
* Read the image data contained in aTexture, and return it as an ImageSurface.
|
2013-09-24 13:45:13 -07:00
|
|
|
* If GL_RGBA is given as the format, a gfxImageFormatARGB32 surface is returned.
|
2013-07-31 16:18:06 -07:00
|
|
|
* Not implemented yet:
|
2013-09-24 13:45:13 -07:00
|
|
|
* If GL_RGB is given as the format, a gfxImageFormatRGB24 surface is returned.
|
|
|
|
* If GL_LUMINANCE is given as the format, a gfxImageFormatA8 surface is returned.
|
2013-07-31 16:18:06 -07:00
|
|
|
*
|
|
|
|
* THIS IS EXPENSIVE. It is ridiculously expensive. Only do this
|
|
|
|
* if you absolutely positively must, and never in any performance
|
|
|
|
* critical path.
|
|
|
|
*/
|
|
|
|
already_AddRefed<gfxImageSurface> ReadTextureImage(GLuint aTexture,
|
|
|
|
const gfxIntSize& aSize,
|
|
|
|
GLenum aTextureFormat,
|
|
|
|
bool aYInvert = false);
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
already_AddRefed<gfxImageSurface> GetTexImage(GLuint aTexture, bool aYInvert, SurfaceFormat aFormat);
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
/**
|
|
|
|
* Call ReadPixels into an existing gfxImageSurface.
|
|
|
|
* The image surface must be using image format RGBA32 or RGB24,
|
|
|
|
* and must have stride == width*4.
|
|
|
|
* Note that neither ReadPixelsIntoImageSurface nor
|
|
|
|
* ReadScreenIntoImageSurface call dest->Flush/MarkDirty.
|
|
|
|
*/
|
|
|
|
void ReadPixelsIntoImageSurface(gfxImageSurface* dest);
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
// Similar to ReadPixelsIntoImageSurface, but pulls from the screen
|
|
|
|
// instead of the currently bound framebuffer.
|
|
|
|
void ReadScreenIntoImageSurface(gfxImageSurface* dest);
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-09-26 17:37:19 -07:00
|
|
|
TemporaryRef<gfx::SourceSurface> ReadPixelsToSourceSurface(const gfx::IntSize &aSize);
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
/**
|
|
|
|
* Copy a rectangle from one TextureImage into another. The
|
|
|
|
* source and destination are given in integer coordinates, and
|
|
|
|
* will be converted to texture coordinates.
|
|
|
|
*
|
|
|
|
* For the source texture, the wrap modes DO apply -- it's valid
|
|
|
|
* to use REPEAT or PAD and expect appropriate behaviour if the source
|
|
|
|
* rectangle extends beyond its bounds.
|
|
|
|
*
|
|
|
|
* For the destination texture, the wrap modes DO NOT apply -- the
|
|
|
|
* destination will be clipped by the bounds of the texture.
|
|
|
|
*
|
|
|
|
* Note: calling this function will cause the following OpenGL state
|
|
|
|
* to be changed:
|
|
|
|
*
|
|
|
|
* - current program
|
|
|
|
* - framebuffer binding
|
|
|
|
* - viewport
|
|
|
|
* - blend state (will be enabled at end)
|
|
|
|
* - scissor state (will be enabled at end)
|
|
|
|
* - vertex attrib 0 and 1 (pointer and enable state [enable state will be disabled at exit])
|
|
|
|
* - array buffer binding (will be 0)
|
|
|
|
* - active texture (will be 0)
|
|
|
|
* - texture 0 binding
|
|
|
|
*/
|
|
|
|
void BlitTextureImage(TextureImage *aSrc, const nsIntRect& aSrcRect,
|
|
|
|
TextureImage *aDst, const nsIntRect& aDstRect);
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
/**
|
|
|
|
* Creates a RGB/RGBA texture (or uses one provided) and uploads the surface
|
|
|
|
* contents to it within aSrcRect.
|
|
|
|
*
|
|
|
|
* aSrcRect.x/y will be uploaded to 0/0 in the texture, and the size
|
|
|
|
* of the texture with be aSrcRect.width/height.
|
|
|
|
*
|
|
|
|
* If an existing texture is passed through aTexture, it is assumed it
|
|
|
|
* has already been initialised with glTexImage2D (or this function),
|
|
|
|
* and that its size is equal to or greater than aSrcRect + aDstPoint.
|
|
|
|
* You can alternatively set the overwrite flag to true and have a new
|
|
|
|
* texture memory block allocated.
|
|
|
|
*
|
|
|
|
* The aDstPoint parameter is ignored if no texture was provided
|
|
|
|
* or aOverwrite is true.
|
|
|
|
*
|
|
|
|
* \param aData Image data to upload.
|
|
|
|
* \param aDstRegion Region of texture to upload to.
|
|
|
|
* \param aTexture Texture to use, or 0 to have one created for you.
|
|
|
|
* \param aOverwrite Over an existing texture with a new one.
|
|
|
|
* \param aSrcPoint Offset into aSrc where the region's bound's
|
|
|
|
* TopLeft() sits.
|
|
|
|
* \param aPixelBuffer Pass true to upload texture data with an
|
|
|
|
* offset from the base data (generally for pixel buffer objects),
|
|
|
|
* otherwise textures are upload with an absolute pointer to the data.
|
|
|
|
* \param aTextureUnit, the texture unit used temporarily to upload the
|
|
|
|
* surface. This testure may be overridden, clients should not rely on
|
|
|
|
* the contents of this texture after this call or even on this
|
|
|
|
* texture unit being active.
|
|
|
|
* \return Surface format of this texture.
|
|
|
|
*/
|
|
|
|
SurfaceFormat UploadImageDataToTexture(unsigned char* aData,
|
|
|
|
int32_t aStride,
|
2013-09-24 13:45:13 -07:00
|
|
|
gfxImageFormat aFormat,
|
2013-07-31 16:18:06 -07:00
|
|
|
const nsIntRegion& aDstRegion,
|
|
|
|
GLuint& aTexture,
|
|
|
|
bool aOverwrite = false,
|
|
|
|
bool aPixelBuffer = false,
|
|
|
|
GLenum aTextureUnit = LOCAL_GL_TEXTURE0,
|
|
|
|
GLenum aTextureTarget = LOCAL_GL_TEXTURE_2D);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convenience wrapper around UploadImageDataToTexture for gfxASurfaces.
|
|
|
|
*/
|
|
|
|
SurfaceFormat UploadSurfaceToTexture(gfxASurface *aSurface,
|
|
|
|
const nsIntRegion& aDstRegion,
|
|
|
|
GLuint& aTexture,
|
|
|
|
bool aOverwrite = false,
|
|
|
|
const nsIntPoint& aSrcPoint = nsIntPoint(0, 0),
|
|
|
|
bool aPixelBuffer = false,
|
|
|
|
GLenum aTextureUnit = LOCAL_GL_TEXTURE0,
|
|
|
|
GLenum aTextureTarget = LOCAL_GL_TEXTURE_2D);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Same as above, for DataSourceSurfaces.
|
|
|
|
*/
|
|
|
|
SurfaceFormat UploadSurfaceToTexture(gfx::DataSourceSurface *aSurface,
|
|
|
|
const nsIntRegion& aDstRegion,
|
|
|
|
GLuint& aTexture,
|
|
|
|
bool aOverwrite = false,
|
|
|
|
const nsIntPoint& aSrcPoint = nsIntPoint(0, 0),
|
|
|
|
bool aPixelBuffer = false,
|
|
|
|
GLenum aTextureUnit = LOCAL_GL_TEXTURE0,
|
|
|
|
GLenum aTextureTarget = LOCAL_GL_TEXTURE_2D);
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void TexImage2D(GLenum target, GLint level, GLint internalformat,
|
|
|
|
GLsizei width, GLsizei height, GLsizei stride,
|
|
|
|
GLint pixelsize, GLint border, GLenum format,
|
|
|
|
GLenum type, const GLvoid *pixels);
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void TexSubImage2D(GLenum target, GLint level,
|
|
|
|
GLint xoffset, GLint yoffset,
|
|
|
|
GLsizei width, GLsizei height, GLsizei stride,
|
|
|
|
GLint pixelsize, GLenum format,
|
|
|
|
GLenum type, const GLvoid* pixels);
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
/**
|
|
|
|
* Uses the Khronos GL_EXT_unpack_subimage extension, working around
|
|
|
|
* quirks in the Tegra implementation of this extension.
|
|
|
|
*/
|
|
|
|
void TexSubImage2DWithUnpackSubimageGLES(GLenum target, GLint level,
|
|
|
|
GLint xoffset, GLint yoffset,
|
|
|
|
GLsizei width, GLsizei height,
|
|
|
|
GLsizei stride, GLint pixelsize,
|
|
|
|
GLenum format, GLenum type,
|
|
|
|
const GLvoid* pixels);
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void TexSubImage2DWithoutUnpackSubimage(GLenum target, GLint level,
|
|
|
|
GLint xoffset, GLint yoffset,
|
|
|
|
GLsizei width, GLsizei height,
|
|
|
|
GLsizei stride, GLint pixelsize,
|
|
|
|
GLenum format, GLenum type,
|
|
|
|
const GLvoid* pixels);
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
/** Helper for DecomposeIntoNoRepeatTriangles
|
|
|
|
*/
|
|
|
|
struct RectTriangles {
|
|
|
|
RectTriangles() { }
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
// Always pass texture coordinates upright. If you want to flip the
|
|
|
|
// texture coordinates emitted to the tex_coords array, set flip_y to
|
|
|
|
// true.
|
|
|
|
void addRect(GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1,
|
|
|
|
GLfloat tx0, GLfloat ty0, GLfloat tx1, GLfloat ty1,
|
|
|
|
bool flip_y = false);
|
2012-12-18 23:16:01 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
/**
|
|
|
|
* these return a float pointer to the start of each array respectively.
|
|
|
|
* Use it for glVertexAttribPointer calls.
|
|
|
|
* We can return nullptr if we choose to use Vertex Buffer Objects here.
|
|
|
|
*/
|
|
|
|
float* vertexPointer() {
|
|
|
|
return &vertexCoords[0].x;
|
|
|
|
}
|
2012-12-18 23:16:01 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
float* texCoordPointer() {
|
|
|
|
return &texCoords[0].u;
|
2011-12-16 13:11:59 -08:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
unsigned int elements() {
|
|
|
|
return vertexCoords.Length();
|
|
|
|
}
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
typedef struct { GLfloat x,y; } vert_coord;
|
|
|
|
typedef struct { GLfloat u,v; } tex_coord;
|
|
|
|
private:
|
|
|
|
// default is 4 rectangles, each made up of 2 triangles (3 coord vertices each)
|
|
|
|
nsAutoTArray<vert_coord, 6> vertexCoords;
|
|
|
|
nsAutoTArray<tex_coord, 6> texCoords;
|
|
|
|
};
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
/**
|
|
|
|
* Decompose drawing the possibly-wrapped aTexCoordRect rectangle
|
|
|
|
* of a texture of aTexSize into one or more rectangles (represented
|
|
|
|
* as 2 triangles) and associated tex coordinates, such that
|
|
|
|
* we don't have to use the REPEAT wrap mode. If aFlipY is true, the
|
|
|
|
* texture coordinates will be specified vertically flipped.
|
|
|
|
*
|
|
|
|
* The resulting triangle vertex coordinates will be in the space of
|
|
|
|
* (0.0, 0.0) to (1.0, 1.0) -- transform the coordinates appropriately
|
|
|
|
* if you need a different space.
|
|
|
|
*
|
|
|
|
* The resulting vertex coordinates should be drawn using GL_TRIANGLES,
|
|
|
|
* and rects.numRects * 3 * 6
|
|
|
|
*/
|
|
|
|
static void DecomposeIntoNoRepeatTriangles(const nsIntRect& aTexCoordRect,
|
|
|
|
const nsIntSize& aTexSize,
|
|
|
|
RectTriangles& aRects,
|
|
|
|
bool aFlipY = false);
|
2010-10-12 14:01:59 -07:00
|
|
|
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
// Shared code for GL extensions and GLX extensions.
|
|
|
|
static bool ListHasExtension(const GLubyte *extensions,
|
|
|
|
const char *extension);
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
GLint GetMaxTextureImageSize() { return mMaxTextureImageSize; }
|
|
|
|
void SetFlipped(bool aFlipped) { mFlipped = aFlipped; }
|
2010-10-12 14:01:59 -07:00
|
|
|
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Context reset constants.
|
|
|
|
* These are used to determine who is guilty when a context reset
|
|
|
|
* happens.
|
|
|
|
*/
|
|
|
|
enum ContextResetARB {
|
|
|
|
CONTEXT_NO_ERROR = 0,
|
|
|
|
CONTEXT_GUILTY_CONTEXT_RESET_ARB = 0x8253,
|
|
|
|
CONTEXT_INNOCENT_CONTEXT_RESET_ARB = 0x8254,
|
|
|
|
CONTEXT_UNKNOWN_CONTEXT_RESET_ARB = 0x8255
|
|
|
|
};
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
public:
|
|
|
|
std::map<GLuint, SharedSurface_GL*> mFBOMapping;
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
enum {
|
|
|
|
DebugEnabled = 1 << 0,
|
|
|
|
DebugTrace = 1 << 1,
|
|
|
|
DebugAbortOnError = 1 << 2
|
|
|
|
};
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
static uint32_t sDebugMode;
|
2011-10-19 12:09:57 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
static uint32_t DebugMode() {
|
|
|
|
#ifdef DEBUG
|
|
|
|
return sDebugMode;
|
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
2010-10-12 14:01:59 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
protected:
|
|
|
|
nsRefPtr<GLContext> mSharedContext;
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
// The thread on which this context was created.
|
|
|
|
nsCOMPtr<nsIThread> mOwningThread;
|
2011-10-19 12:09:57 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
GLContextSymbols mSymbols;
|
2012-12-18 23:16:01 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
// GLDebugMode will check that we don't send call
|
|
|
|
// to a GLContext that isn't current on the current
|
|
|
|
// thread.
|
|
|
|
// Store the current context when binding to thread local
|
|
|
|
// storage to support DebugMode on an arbitrary thread.
|
|
|
|
static unsigned sCurrentGLContextTLS;
|
|
|
|
#endif
|
|
|
|
bool mFlipped;
|
2012-12-18 23:16:01 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
// lazy-initialized things
|
|
|
|
GLuint mBlitProgram, mBlitFramebuffer;
|
|
|
|
void UseBlitProgram();
|
|
|
|
void SetBlitFramebufferForDestTexture(GLuint aTexture);
|
2012-12-18 23:16:01 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
public:
|
|
|
|
// Assumes shares are created by all sharing with the same global context.
|
|
|
|
bool SharesWith(const GLContext* other) const {
|
|
|
|
MOZ_ASSERT(!this->mSharedContext || !this->mSharedContext->mSharedContext);
|
|
|
|
MOZ_ASSERT(!other->mSharedContext || !other->mSharedContext->mSharedContext);
|
|
|
|
MOZ_ASSERT(!this->mSharedContext ||
|
|
|
|
!other->mSharedContext ||
|
|
|
|
this->mSharedContext == other->mSharedContext);
|
2012-12-18 23:16:01 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
const GLContext* thisShared = this->mSharedContext ? this->mSharedContext
|
|
|
|
: this;
|
|
|
|
const GLContext* otherShared = other->mSharedContext ? other->mSharedContext
|
|
|
|
: other;
|
2012-12-18 23:16:01 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
return thisShared == otherShared;
|
2012-12-18 23:16:01 -08:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
bool InitOffscreen(const gfxIntSize& size, const SurfaceCaps& caps) {
|
|
|
|
if (!CreateScreenBuffer(size, caps))
|
|
|
|
return false;
|
2012-12-18 23:16:01 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
MakeCurrent();
|
|
|
|
fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, 0);
|
|
|
|
fScissor(0, 0, size.width, size.height);
|
|
|
|
fViewport(0, 0, size.width, size.height);
|
2012-12-18 23:16:01 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
mCaps = mScreen->Caps();
|
|
|
|
if (mCaps.any)
|
|
|
|
DetermineCaps();
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
UpdateGLFormats(mCaps);
|
|
|
|
UpdatePixelFormat();
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
return true;
|
2010-12-16 23:49:42 -08:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
protected:
|
|
|
|
// Note that it does -not- clear the resized buffers.
|
|
|
|
bool CreateScreenBuffer(const gfxIntSize& size, const SurfaceCaps& caps) {
|
|
|
|
if (!IsOffscreenSizeAllowed(size))
|
|
|
|
return false;
|
2010-12-16 23:49:42 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
SurfaceCaps tryCaps = caps;
|
|
|
|
if (tryCaps.antialias) {
|
|
|
|
// AA path
|
|
|
|
if (CreateScreenBufferImpl(size, tryCaps))
|
|
|
|
return true;
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
NS_WARNING("CreateScreenBuffer failed to initialize an AA context! Falling back to no AA...");
|
|
|
|
tryCaps.antialias = false;
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(!tryCaps.antialias);
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
if (CreateScreenBufferImpl(size, tryCaps))
|
|
|
|
return true;
|
2011-01-05 20:54:27 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
NS_WARNING("CreateScreenBuffer failed to initialize non-AA context!");
|
|
|
|
return false;
|
2012-12-17 17:58:44 -08:00
|
|
|
}
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
bool CreateScreenBufferImpl(const gfxIntSize& size,
|
|
|
|
const SurfaceCaps& caps);
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
public:
|
|
|
|
bool ResizeScreenBuffer(const gfxIntSize& size);
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
protected:
|
|
|
|
SurfaceCaps mCaps;
|
|
|
|
nsAutoPtr<GLFormats> mGLFormats;
|
|
|
|
nsAutoPtr<PixelBufferFormat> mPixelFormat;
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
public:
|
|
|
|
void DetermineCaps();
|
|
|
|
const SurfaceCaps& Caps() const {
|
|
|
|
return mCaps;
|
2012-11-01 09:11:42 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
// Only varies based on bpp16 and alpha.
|
|
|
|
GLFormats ChooseGLFormats(const SurfaceCaps& caps) const;
|
|
|
|
void UpdateGLFormats(const SurfaceCaps& caps) {
|
|
|
|
mGLFormats = new GLFormats(ChooseGLFormats(caps));
|
2012-12-17 17:58:44 -08:00
|
|
|
}
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
const GLFormats& GetGLFormats() const {
|
|
|
|
MOZ_ASSERT(mGLFormats);
|
|
|
|
return *mGLFormats;
|
2012-12-18 23:16:01 -08:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
PixelBufferFormat QueryPixelFormat();
|
|
|
|
void UpdatePixelFormat();
|
2012-12-18 23:16:01 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
const PixelBufferFormat& GetPixelFormat() const {
|
|
|
|
MOZ_ASSERT(mPixelFormat);
|
|
|
|
return *mPixelFormat;
|
2012-12-18 23:16:01 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
GLuint CreateTextureForOffscreen(const GLFormats& formats,
|
|
|
|
const gfxIntSize& size);
|
|
|
|
GLuint CreateTexture(GLenum internalFormat,
|
|
|
|
GLenum format, GLenum type,
|
|
|
|
const gfxIntSize& size);
|
|
|
|
GLuint CreateRenderbuffer(GLenum format,
|
|
|
|
GLsizei samples,
|
|
|
|
const gfxIntSize& size);
|
|
|
|
bool IsFramebufferComplete(GLuint fb, GLenum* status = nullptr);
|
2012-12-18 23:16:01 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
// Pass null to an RB arg to disable its creation.
|
|
|
|
void CreateRenderbuffersForOffscreen(const GLFormats& formats,
|
|
|
|
const gfxIntSize& size,
|
|
|
|
bool multisample,
|
|
|
|
GLuint* colorMSRB,
|
|
|
|
GLuint* depthRB,
|
|
|
|
GLuint* stencilRB);
|
2012-11-01 09:11:42 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
// Does not check completeness.
|
|
|
|
void AttachBuffersToFB(GLuint colorTex, GLuint colorRB,
|
|
|
|
GLuint depthRB, GLuint stencilRB,
|
|
|
|
GLuint fb, GLenum target = LOCAL_GL_TEXTURE_2D);
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
// Passing null is fine if the value you'd get is 0.
|
|
|
|
bool AssembleOffscreenFBs(const GLuint colorMSRB,
|
|
|
|
const GLuint depthRB,
|
|
|
|
const GLuint stencilRB,
|
|
|
|
const GLuint texture,
|
|
|
|
GLuint* drawFB,
|
|
|
|
GLuint* readFB);
|
2012-12-18 23:16:01 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
protected:
|
|
|
|
friend class GLScreenBuffer;
|
|
|
|
GLScreenBuffer* mScreen;
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void DestroyScreenBuffer();
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
SharedSurface* mLockedSurface;
|
|
|
|
|
|
|
|
public:
|
|
|
|
void LockSurface(SharedSurface* surf) {
|
|
|
|
MOZ_ASSERT(!mLockedSurface);
|
|
|
|
mLockedSurface = surf;
|
2012-12-17 17:58:44 -08:00
|
|
|
}
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void UnlockSurface(SharedSurface* surf) {
|
|
|
|
MOZ_ASSERT(mLockedSurface == surf);
|
|
|
|
mLockedSurface = nullptr;
|
2012-12-18 23:16:01 -08:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
SharedSurface* GetLockedSurface() const {
|
|
|
|
return mLockedSurface;
|
2012-12-17 17:58:44 -08:00
|
|
|
}
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
bool IsOffscreen() const {
|
|
|
|
return mScreen;
|
2012-12-18 23:16:01 -08:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
GLScreenBuffer* Screen() const {
|
|
|
|
return mScreen;
|
2012-11-01 09:11:42 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
bool PublishFrame();
|
|
|
|
SharedSurface* RequestFrame();
|
|
|
|
|
|
|
|
/* Clear to transparent black, with 0 depth and stencil,
|
|
|
|
* while preserving current ClearColor etc. values.
|
|
|
|
* Useful for resizing offscreen buffers.
|
|
|
|
*/
|
|
|
|
void ClearSafely();
|
|
|
|
|
|
|
|
bool WorkAroundDriverBugs() const { return mWorkAroundDriverBugs; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
nsRefPtr<TextureGarbageBin> mTexGarbageBin;
|
|
|
|
|
2012-12-18 23:16:01 -08:00
|
|
|
public:
|
2013-07-31 16:18:06 -07:00
|
|
|
TextureGarbageBin* TexGarbageBin() {
|
|
|
|
MOZ_ASSERT(mTexGarbageBin);
|
|
|
|
return mTexGarbageBin;
|
2012-11-01 09:11:42 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void EmptyTexGarbageBin();
|
2012-12-18 23:16:01 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
protected:
|
|
|
|
nsDataHashtable<nsPtrHashKey<void>, void*> mUserData;
|
2012-12-18 23:16:01 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
bool InitWithPrefix(const char *prefix, bool trygl);
|
2012-12-18 23:16:01 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void InitExtensions();
|
2013-02-13 15:26:24 -08:00
|
|
|
|
2013-09-06 19:13:37 -07:00
|
|
|
bool IsOffscreenSizeAllowed(const gfxIntSize& aSize) const;
|
2010-10-12 14:01:59 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
nsTArray<nsIntRect> mViewportStack;
|
|
|
|
nsTArray<nsIntRect> mScissorStack;
|
2011-10-26 13:00:44 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
GLint mMaxTextureSize;
|
|
|
|
GLint mMaxCubeMapTextureSize;
|
|
|
|
GLint mMaxTextureImageSize;
|
|
|
|
GLint mMaxRenderbufferSize;
|
|
|
|
GLsizei mMaxSamples;
|
|
|
|
bool mNeedsTextureSizeChecks;
|
|
|
|
bool mWorkAroundDriverBugs;
|
|
|
|
|
|
|
|
bool IsTextureSizeSafeToPassToDriver(GLenum target, GLsizei width, GLsizei height) const {
|
|
|
|
if (mNeedsTextureSizeChecks) {
|
|
|
|
// some drivers incorrectly handle some large texture sizes that are below the
|
|
|
|
// max texture size that they report. So we check ourselves against our own values
|
|
|
|
// (mMax[CubeMap]TextureSize).
|
|
|
|
// see bug 737182 for Mac Intel 2D textures
|
|
|
|
// see bug 684882 for Mac Intel cube map textures
|
|
|
|
// see bug 814716 for Mesa Nouveau
|
|
|
|
GLsizei maxSize = target == LOCAL_GL_TEXTURE_CUBE_MAP ||
|
|
|
|
(target >= LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_X &&
|
|
|
|
target <= LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z)
|
|
|
|
? mMaxCubeMapTextureSize
|
|
|
|
: mMaxTextureSize;
|
|
|
|
return width <= maxSize && height <= maxSize;
|
|
|
|
}
|
|
|
|
return true;
|
2012-12-18 23:16:01 -08:00
|
|
|
}
|
|
|
|
|
2011-10-26 13:00:44 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
/*** Scissor functions ***/
|
2012-12-18 23:16:01 -08:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
protected:
|
|
|
|
GLint FixYValue(GLint y, GLint height)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT( !(mIsOffscreen && mFlipped) );
|
|
|
|
return mFlipped ? ViewportRect().height - (height + y) : y;
|
2012-12-17 17:58:44 -08:00
|
|
|
}
|
2012-04-06 16:57:55 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
public:
|
|
|
|
void fScissor(GLint x, GLint y, GLsizei width, GLsizei height) {
|
|
|
|
ScissorRect().SetRect(x, y, width, height);
|
2012-04-06 16:57:55 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
// GL's coordinate system is flipped compared to the one we use in
|
|
|
|
// OGL Layers (in the Y axis), so we may need to flip our rectangle.
|
|
|
|
y = FixYValue(y, height);
|
|
|
|
raw_fScissor(x, y, width, height);
|
2012-12-17 17:58:44 -08:00
|
|
|
}
|
2012-04-06 16:57:55 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
nsIntRect& ScissorRect() {
|
|
|
|
return mScissorStack[mScissorStack.Length()-1];
|
2012-12-17 17:58:44 -08:00
|
|
|
}
|
2012-04-06 16:57:55 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void PushScissorRect() {
|
|
|
|
nsIntRect copy(ScissorRect());
|
|
|
|
mScissorStack.AppendElement(copy);
|
2012-12-17 17:58:44 -08:00
|
|
|
}
|
2012-04-06 16:57:55 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void PushScissorRect(const nsIntRect& aRect) {
|
|
|
|
mScissorStack.AppendElement(aRect);
|
|
|
|
fScissor(aRect.x, aRect.y, aRect.width, aRect.height);
|
2012-12-17 17:58:44 -08:00
|
|
|
}
|
2012-04-06 16:57:55 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void PopScissorRect() {
|
|
|
|
if (mScissorStack.Length() < 2) {
|
|
|
|
NS_WARNING("PopScissorRect with Length < 2!");
|
|
|
|
return;
|
|
|
|
}
|
2012-04-06 16:57:55 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
nsIntRect thisRect = ScissorRect();
|
|
|
|
mScissorStack.TruncateLength(mScissorStack.Length() - 1);
|
|
|
|
if (!thisRect.IsEqualInterior(ScissorRect())) {
|
|
|
|
fScissor(ScissorRect().x, ScissorRect().y,
|
|
|
|
ScissorRect().width, ScissorRect().height);
|
|
|
|
}
|
2012-12-17 17:58:44 -08:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
/*** Viewport functions ***/
|
2012-06-12 14:36:10 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
private:
|
|
|
|
// only does the glViewport call, no ViewportRect business
|
|
|
|
void raw_fViewport(GLint x, GLint y, GLsizei width, GLsizei height) {
|
2013-02-13 15:26:24 -08:00
|
|
|
BEFORE_GL_CALL;
|
2013-07-31 16:18:06 -07:00
|
|
|
// XXX: Flipping should really happen using the destination height, but
|
|
|
|
// we use viewport instead and assume viewport size matches the
|
|
|
|
// destination. If we ever try use partial viewports for layers we need
|
|
|
|
// to fix this, and remove the assertion.
|
|
|
|
NS_ASSERTION(!mFlipped || (x == 0 && y == 0), "TODO: Need to flip the viewport rect");
|
|
|
|
mSymbols.fViewport(x, y, width, height);
|
2013-02-13 15:26:24 -08:00
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
public:
|
|
|
|
void fViewport(GLint x, GLint y, GLsizei width, GLsizei height) {
|
|
|
|
ViewportRect().SetRect(x, y, width, height);
|
|
|
|
raw_fViewport(x, y, width, height);
|
2013-06-17 13:17:59 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
nsIntRect& ViewportRect() {
|
|
|
|
return mViewportStack[mViewportStack.Length()-1];
|
2013-06-17 13:17:59 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void PushViewportRect() {
|
|
|
|
nsIntRect copy(ViewportRect());
|
|
|
|
mViewportStack.AppendElement(copy);
|
2013-06-17 13:17:59 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void PushViewportRect(const nsIntRect& aRect) {
|
|
|
|
mViewportStack.AppendElement(aRect);
|
|
|
|
raw_fViewport(aRect.x, aRect.y, aRect.width, aRect.height);
|
2013-06-17 13:17:59 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
void PopViewportRect() {
|
|
|
|
if (mViewportStack.Length() < 2) {
|
|
|
|
NS_WARNING("PopViewportRect with Length < 2!");
|
|
|
|
return;
|
|
|
|
}
|
2013-07-25 17:38:58 -07:00
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
nsIntRect thisRect = ViewportRect();
|
|
|
|
mViewportStack.TruncateLength(mViewportStack.Length() - 1);
|
|
|
|
if (!thisRect.IsEqualInterior(ViewportRect())) {
|
|
|
|
raw_fViewport(ViewportRect().x, ViewportRect().y,
|
|
|
|
ViewportRect().width, ViewportRect().height);
|
|
|
|
}
|
2013-07-25 17:38:58 -07:00
|
|
|
}
|
|
|
|
|
2013-07-31 16:18:06 -07:00
|
|
|
|
2012-12-18 23:16:01 -08:00
|
|
|
#undef ASSERT_SYMBOL_PRESENT
|
|
|
|
|
2011-01-05 20:54:27 -08:00
|
|
|
#ifdef DEBUG
|
2013-05-29 14:59:24 -07:00
|
|
|
void CreatedProgram(GLContext *aOrigin, GLuint aName);
|
|
|
|
void CreatedShader(GLContext *aOrigin, GLuint aName);
|
|
|
|
void CreatedBuffers(GLContext *aOrigin, GLsizei aCount, GLuint *aNames);
|
|
|
|
void CreatedQueries(GLContext *aOrigin, GLsizei aCount, GLuint *aNames);
|
|
|
|
void CreatedTextures(GLContext *aOrigin, GLsizei aCount, GLuint *aNames);
|
|
|
|
void CreatedFramebuffers(GLContext *aOrigin, GLsizei aCount, GLuint *aNames);
|
|
|
|
void CreatedRenderbuffers(GLContext *aOrigin, GLsizei aCount, GLuint *aNames);
|
|
|
|
void DeletedProgram(GLContext *aOrigin, GLuint aName);
|
|
|
|
void DeletedShader(GLContext *aOrigin, GLuint aName);
|
|
|
|
void DeletedBuffers(GLContext *aOrigin, GLsizei aCount, GLuint *aNames);
|
2013-08-15 12:58:20 -07:00
|
|
|
void DeletedQueries(GLContext *aOrigin, GLsizei aCount, const GLuint *aNames);
|
2013-05-29 14:59:24 -07:00
|
|
|
void DeletedTextures(GLContext *aOrigin, GLsizei aCount, GLuint *aNames);
|
|
|
|
void DeletedFramebuffers(GLContext *aOrigin, GLsizei aCount, GLuint *aNames);
|
|
|
|
void DeletedRenderbuffers(GLContext *aOrigin, GLsizei aCount, GLuint *aNames);
|
2010-07-18 22:01:14 -07:00
|
|
|
|
|
|
|
void SharedContextDestroyed(GLContext *aChild);
|
|
|
|
void ReportOutstandingNames();
|
|
|
|
|
|
|
|
struct NamedResource {
|
|
|
|
NamedResource()
|
2012-07-30 07:20:58 -07:00
|
|
|
: origin(nullptr), name(0), originDeleted(false)
|
2010-07-18 22:01:14 -07:00
|
|
|
{ }
|
|
|
|
|
|
|
|
NamedResource(GLContext *aOrigin, GLuint aName)
|
2011-10-17 07:59:28 -07:00
|
|
|
: origin(aOrigin), name(aName), originDeleted(false)
|
2010-07-18 22:01:14 -07:00
|
|
|
{ }
|
|
|
|
|
|
|
|
GLContext *origin;
|
|
|
|
GLuint name;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool originDeleted;
|
2010-07-18 22:01:14 -07:00
|
|
|
|
|
|
|
// for sorting
|
|
|
|
bool operator<(const NamedResource& aOther) const {
|
|
|
|
if (intptr_t(origin) < intptr_t(aOther.origin))
|
|
|
|
return true;
|
|
|
|
if (name < aOther.name)
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool operator==(const NamedResource& aOther) const {
|
|
|
|
return origin == aOther.origin &&
|
|
|
|
name == aOther.name &&
|
|
|
|
originDeleted == aOther.originDeleted;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
nsTArray<NamedResource> mTrackedPrograms;
|
|
|
|
nsTArray<NamedResource> mTrackedShaders;
|
|
|
|
nsTArray<NamedResource> mTrackedTextures;
|
|
|
|
nsTArray<NamedResource> mTrackedFramebuffers;
|
|
|
|
nsTArray<NamedResource> mTrackedRenderbuffers;
|
|
|
|
nsTArray<NamedResource> mTrackedBuffers;
|
2012-11-01 09:11:42 -07:00
|
|
|
nsTArray<NamedResource> mTrackedQueries;
|
2010-07-18 22:01:14 -07:00
|
|
|
#endif
|
2013-01-17 16:45:11 -08:00
|
|
|
};
|
2010-10-06 13:43:14 -07:00
|
|
|
|
2013-09-06 19:13:37 -07:00
|
|
|
bool DoesStringMatch(const char* aString, const char *aWantedString);
|
2010-10-06 13:43:14 -07:00
|
|
|
|
2012-08-21 20:30:20 -07:00
|
|
|
//RAII via CRTP!
|
|
|
|
template <class Derived>
|
|
|
|
struct ScopedGLWrapper
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
bool mIsUnwrapped;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
GLContext* const mGL;
|
|
|
|
|
|
|
|
ScopedGLWrapper(GLContext* gl)
|
|
|
|
: mIsUnwrapped(false)
|
|
|
|
, mGL(gl)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(&ScopedGLWrapper<Derived>::Unwrap == &Derived::Unwrap);
|
|
|
|
MOZ_ASSERT(&Derived::UnwrapImpl);
|
|
|
|
MOZ_ASSERT(mGL->IsCurrent());
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~ScopedGLWrapper() {
|
|
|
|
if (!mIsUnwrapped)
|
|
|
|
Unwrap();
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
void Unwrap() {
|
|
|
|
MOZ_ASSERT(!mIsUnwrapped);
|
|
|
|
|
|
|
|
Derived* derived = static_cast<Derived*>(this);
|
|
|
|
derived->UnwrapImpl();
|
|
|
|
|
|
|
|
mIsUnwrapped = true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-02-13 15:26:24 -08:00
|
|
|
// Wraps glEnable/Disable.
|
|
|
|
struct ScopedGLState
|
|
|
|
: public ScopedGLWrapper<ScopedGLState>
|
2012-08-21 20:30:20 -07:00
|
|
|
{
|
2013-02-13 15:26:24 -08:00
|
|
|
friend struct ScopedGLWrapper<ScopedGLState>;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
const GLenum mCapability;
|
|
|
|
bool mOldState;
|
|
|
|
|
|
|
|
public:
|
|
|
|
// Use |newState = true| to enable, |false| to disable.
|
|
|
|
ScopedGLState(GLContext* gl, GLenum capability, bool newState)
|
|
|
|
: ScopedGLWrapper<ScopedGLState>(gl)
|
|
|
|
, mCapability(capability)
|
|
|
|
{
|
|
|
|
mOldState = mGL->fIsEnabled(mCapability);
|
|
|
|
|
|
|
|
// Early out if we're already in the right state.
|
|
|
|
if (newState == mOldState)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (newState)
|
|
|
|
mGL->fEnable(mCapability);
|
|
|
|
else
|
|
|
|
mGL->fDisable(mCapability);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void UnwrapImpl() {
|
|
|
|
if (mOldState)
|
|
|
|
mGL->fEnable(mCapability);
|
|
|
|
else
|
|
|
|
mGL->fDisable(mCapability);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Saves and restores with GetUserBoundFB and BindUserFB.
|
|
|
|
struct ScopedBindFramebuffer
|
|
|
|
: public ScopedGLWrapper<ScopedBindFramebuffer>
|
|
|
|
{
|
|
|
|
friend struct ScopedGLWrapper<ScopedBindFramebuffer>;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
GLuint mOldFB;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void Init() {
|
|
|
|
mOldFB = mGL->GetFB();
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit ScopedBindFramebuffer(GLContext* gl)
|
|
|
|
: ScopedGLWrapper<ScopedBindFramebuffer>(gl)
|
|
|
|
{
|
|
|
|
Init();
|
|
|
|
}
|
|
|
|
|
|
|
|
ScopedBindFramebuffer(GLContext* gl, GLuint newFB)
|
|
|
|
: ScopedGLWrapper<ScopedBindFramebuffer>(gl)
|
|
|
|
{
|
|
|
|
Init();
|
|
|
|
mGL->BindFB(newFB);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void UnwrapImpl() {
|
|
|
|
// Check that we're not falling out of scope after
|
|
|
|
// the current context changed.
|
|
|
|
MOZ_ASSERT(mGL->IsCurrent());
|
|
|
|
|
|
|
|
mGL->BindFB(mOldFB);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-07-17 20:24:15 -07:00
|
|
|
struct ScopedBindTextureUnit
|
|
|
|
: public ScopedGLWrapper<ScopedBindTextureUnit>
|
|
|
|
{
|
|
|
|
friend struct ScopedGLWrapper<ScopedBindTextureUnit>;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
GLenum mOldTexUnit;
|
|
|
|
|
|
|
|
public:
|
|
|
|
ScopedBindTextureUnit(GLContext* gl, GLenum texUnit)
|
|
|
|
: ScopedGLWrapper<ScopedBindTextureUnit>(gl)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(texUnit >= LOCAL_GL_TEXTURE0);
|
|
|
|
mGL->GetUIntegerv(LOCAL_GL_ACTIVE_TEXTURE, &mOldTexUnit);
|
|
|
|
mGL->fActiveTexture(texUnit);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void UnwrapImpl() {
|
|
|
|
// Check that we're not falling out of scope after
|
|
|
|
// the current context changed.
|
|
|
|
MOZ_ASSERT(mGL->IsCurrent());
|
|
|
|
|
|
|
|
mGL->fActiveTexture(mOldTexUnit);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-07-17 20:24:15 -07:00
|
|
|
struct ScopedTexture
|
|
|
|
: public ScopedGLWrapper<ScopedTexture>
|
|
|
|
{
|
|
|
|
friend struct ScopedGLWrapper<ScopedTexture>;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
GLuint mTexture;
|
|
|
|
|
|
|
|
public:
|
|
|
|
ScopedTexture(GLContext* gl)
|
|
|
|
: ScopedGLWrapper<ScopedTexture>(gl)
|
|
|
|
{
|
|
|
|
mGL->fGenTextures(1, &mTexture);
|
|
|
|
}
|
|
|
|
|
|
|
|
GLuint Texture() { return mTexture; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void UnwrapImpl() {
|
|
|
|
// Check that we're not falling out of scope after
|
|
|
|
// the current context changed.
|
|
|
|
MOZ_ASSERT(mGL->IsCurrent());
|
|
|
|
|
|
|
|
mGL->fDeleteTextures(1, &mTexture);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-02-13 15:26:24 -08:00
|
|
|
struct ScopedBindTexture
|
|
|
|
: public ScopedGLWrapper<ScopedBindTexture>
|
|
|
|
{
|
|
|
|
friend struct ScopedGLWrapper<ScopedBindTexture>;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
GLuint mOldTex;
|
2013-07-17 20:24:15 -07:00
|
|
|
GLenum mTarget;
|
2013-02-13 15:26:24 -08:00
|
|
|
|
|
|
|
private:
|
2013-07-17 20:24:15 -07:00
|
|
|
void Init(GLenum target) {
|
|
|
|
mTarget = target;
|
2013-02-13 15:26:24 -08:00
|
|
|
mOldTex = 0;
|
2013-10-11 06:16:43 -07:00
|
|
|
GLenum bindingTarget = (target == LOCAL_GL_TEXTURE_2D) ? LOCAL_GL_TEXTURE_BINDING_2D
|
|
|
|
: (target == LOCAL_GL_TEXTURE_RECTANGLE_ARB) ? LOCAL_GL_TEXTURE_BINDING_RECTANGLE_ARB
|
|
|
|
: (target == LOCAL_GL_TEXTURE_CUBE_MAP) ? LOCAL_GL_TEXTURE_BINDING_CUBE_MAP
|
|
|
|
: LOCAL_GL_NONE;
|
|
|
|
MOZ_ASSERT(bindingTarget != LOCAL_GL_NONE);
|
2013-07-17 20:24:15 -07:00
|
|
|
mGL->GetUIntegerv(bindingTarget, &mOldTex);
|
2013-02-13 15:26:24 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2013-07-17 20:24:15 -07:00
|
|
|
ScopedBindTexture(GLContext* gl, GLuint newTex, GLenum target = LOCAL_GL_TEXTURE_2D)
|
2013-02-13 15:26:24 -08:00
|
|
|
: ScopedGLWrapper<ScopedBindTexture>(gl)
|
|
|
|
{
|
2013-07-17 20:24:15 -07:00
|
|
|
Init(target);
|
|
|
|
mGL->fBindTexture(target, newTex);
|
2013-02-13 15:26:24 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void UnwrapImpl() {
|
|
|
|
// Check that we're not falling out of scope after
|
|
|
|
// the current context changed.
|
|
|
|
MOZ_ASSERT(mGL->IsCurrent());
|
|
|
|
|
2013-07-17 20:24:15 -07:00
|
|
|
mGL->fBindTexture(mTarget, mOldTex);
|
2013-02-13 15:26:24 -08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct ScopedBindRenderbuffer
|
|
|
|
: public ScopedGLWrapper<ScopedBindRenderbuffer>
|
|
|
|
{
|
|
|
|
friend struct ScopedGLWrapper<ScopedBindRenderbuffer>;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
GLuint mOldRB;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void Init() {
|
|
|
|
mOldRB = 0;
|
|
|
|
mGL->GetUIntegerv(LOCAL_GL_RENDERBUFFER_BINDING, &mOldRB);
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit ScopedBindRenderbuffer(GLContext* gl)
|
|
|
|
: ScopedGLWrapper<ScopedBindRenderbuffer>(gl)
|
|
|
|
{
|
|
|
|
Init();
|
|
|
|
}
|
|
|
|
|
|
|
|
ScopedBindRenderbuffer(GLContext* gl, GLuint newRB)
|
|
|
|
: ScopedGLWrapper<ScopedBindRenderbuffer>(gl)
|
|
|
|
{
|
|
|
|
Init();
|
|
|
|
mGL->fBindRenderbuffer(LOCAL_GL_RENDERBUFFER, newRB);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void UnwrapImpl() {
|
|
|
|
// Check that we're not falling out of scope after
|
|
|
|
// the current context changed.
|
|
|
|
MOZ_ASSERT(mGL->IsCurrent());
|
|
|
|
|
|
|
|
mGL->fBindRenderbuffer(LOCAL_GL_RENDERBUFFER, mOldRB);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ScopedFramebufferForTexture
|
|
|
|
: public ScopedGLWrapper<ScopedFramebufferForTexture>
|
|
|
|
{
|
|
|
|
friend struct ScopedGLWrapper<ScopedFramebufferForTexture>;
|
2012-08-21 20:30:20 -07:00
|
|
|
|
|
|
|
protected:
|
|
|
|
bool mComplete; // True if the framebuffer we create is complete.
|
|
|
|
GLuint mFB;
|
|
|
|
|
|
|
|
public:
|
2013-07-17 20:24:15 -07:00
|
|
|
ScopedFramebufferForTexture(GLContext* gl, GLuint texture,
|
|
|
|
GLenum target = LOCAL_GL_TEXTURE_2D)
|
2013-02-13 15:26:24 -08:00
|
|
|
: ScopedGLWrapper<ScopedFramebufferForTexture>(gl)
|
2012-08-21 20:30:20 -07:00
|
|
|
, mComplete(false)
|
|
|
|
, mFB(0)
|
|
|
|
{
|
|
|
|
mGL->fGenFramebuffers(1, &mFB);
|
2013-02-13 15:26:24 -08:00
|
|
|
ScopedBindFramebuffer autoFB(gl, mFB);
|
2012-08-21 20:30:20 -07:00
|
|
|
mGL->fFramebufferTexture2D(LOCAL_GL_FRAMEBUFFER,
|
|
|
|
LOCAL_GL_COLOR_ATTACHMENT0,
|
2013-07-17 20:24:15 -07:00
|
|
|
target,
|
2012-08-21 20:30:20 -07:00
|
|
|
texture,
|
|
|
|
0);
|
|
|
|
|
|
|
|
GLenum status = mGL->fCheckFramebufferStatus(LOCAL_GL_FRAMEBUFFER);
|
|
|
|
if (status == LOCAL_GL_FRAMEBUFFER_COMPLETE) {
|
|
|
|
mComplete = true;
|
|
|
|
} else {
|
|
|
|
mGL->fDeleteFramebuffers(1, &mFB);
|
|
|
|
mFB = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void UnwrapImpl() {
|
|
|
|
if (!mFB)
|
|
|
|
return;
|
|
|
|
|
|
|
|
mGL->fDeleteFramebuffers(1, &mFB);
|
|
|
|
mFB = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
GLuint FB() const {
|
2013-02-13 15:26:24 -08:00
|
|
|
MOZ_ASSERT(IsComplete());
|
2012-08-21 20:30:20 -07:00
|
|
|
return mFB;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsComplete() const {
|
|
|
|
return mComplete;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-02-13 15:26:24 -08:00
|
|
|
struct ScopedFramebufferForRenderbuffer
|
|
|
|
: public ScopedGLWrapper<ScopedFramebufferForRenderbuffer>
|
2012-08-21 20:30:20 -07:00
|
|
|
{
|
2013-02-13 15:26:24 -08:00
|
|
|
friend struct ScopedGLWrapper<ScopedFramebufferForRenderbuffer>;
|
2012-08-21 20:30:20 -07:00
|
|
|
|
|
|
|
protected:
|
2013-02-13 15:26:24 -08:00
|
|
|
bool mComplete; // True if the framebuffer we create is complete.
|
|
|
|
GLuint mFB;
|
2012-08-21 20:30:20 -07:00
|
|
|
|
|
|
|
public:
|
2013-02-13 15:26:24 -08:00
|
|
|
ScopedFramebufferForRenderbuffer(GLContext* gl, GLuint rb)
|
|
|
|
: ScopedGLWrapper<ScopedFramebufferForRenderbuffer>(gl)
|
|
|
|
, mComplete(false)
|
|
|
|
, mFB(0)
|
2012-08-21 20:30:20 -07:00
|
|
|
{
|
2013-02-13 15:26:24 -08:00
|
|
|
mGL->fGenFramebuffers(1, &mFB);
|
|
|
|
ScopedBindFramebuffer autoFB(gl, mFB);
|
|
|
|
mGL->fFramebufferRenderbuffer(LOCAL_GL_FRAMEBUFFER,
|
|
|
|
LOCAL_GL_COLOR_ATTACHMENT0,
|
|
|
|
LOCAL_GL_RENDERBUFFER,
|
|
|
|
rb);
|
2013-02-21 11:54:25 -08:00
|
|
|
|
2013-02-13 15:26:24 -08:00
|
|
|
GLenum status = mGL->fCheckFramebufferStatus(LOCAL_GL_FRAMEBUFFER);
|
|
|
|
if (status == LOCAL_GL_FRAMEBUFFER_COMPLETE) {
|
|
|
|
mComplete = true;
|
|
|
|
} else {
|
|
|
|
mGL->fDeleteFramebuffers(1, &mFB);
|
|
|
|
mFB = 0;
|
|
|
|
}
|
2012-08-21 20:30:20 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void UnwrapImpl() {
|
2013-02-13 15:26:24 -08:00
|
|
|
if (!mFB)
|
|
|
|
return;
|
2013-02-21 11:54:25 -08:00
|
|
|
|
2013-02-13 15:26:24 -08:00
|
|
|
mGL->fDeleteFramebuffers(1, &mFB);
|
|
|
|
mFB = 0;
|
2013-02-20 07:01:20 -08:00
|
|
|
}
|
2013-02-13 15:26:24 -08:00
|
|
|
|
2013-02-21 11:54:25 -08:00
|
|
|
public:
|
2013-02-13 15:26:24 -08:00
|
|
|
GLuint FB() const {
|
|
|
|
return mFB;
|
2013-02-21 11:54:25 -08:00
|
|
|
}
|
2013-02-13 15:26:24 -08:00
|
|
|
|
2013-02-13 15:26:24 -08:00
|
|
|
bool IsComplete() const {
|
|
|
|
return mComplete;
|
2013-02-21 11:54:25 -08:00
|
|
|
}
|
2013-02-13 15:26:24 -08:00
|
|
|
};
|
|
|
|
|
2010-04-26 19:09:44 -07:00
|
|
|
} /* namespace gl */
|
|
|
|
} /* namespace mozilla */
|
|
|
|
|
2010-05-17 21:04:22 -07:00
|
|
|
#endif /* GLCONTEXT_H_ */
|