2010-06-09 22:07:12 +00:00
|
|
|
/* -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40; -*- */
|
2012-05-21 11:12:37 +00: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-27 02:09:44 +00:00
|
|
|
|
|
|
|
#ifndef GLCONTEXT_H_
|
|
|
|
#define GLCONTEXT_H_
|
|
|
|
|
2010-07-01 16:30:38 +00:00
|
|
|
#include <stdio.h>
|
2011-04-14 08:48:27 +00:00
|
|
|
#if defined(XP_UNIX)
|
|
|
|
#include <stdint.h>
|
|
|
|
#endif
|
2010-10-06 20:43:14 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
2010-07-01 16:30:38 +00:00
|
|
|
|
2010-04-27 02:09:44 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "GLDefs.h"
|
2012-03-16 22:24:12 +00:00
|
|
|
#include "GLLibraryLoader.h"
|
2010-07-01 16:30:38 +00:00
|
|
|
#include "gfxASurface.h"
|
2010-11-11 20:31:23 +00:00
|
|
|
#include "gfxImageSurface.h"
|
2010-07-01 16:30:38 +00:00
|
|
|
#include "gfxContext.h"
|
2010-06-09 22:07:12 +00:00
|
|
|
#include "gfxRect.h"
|
2012-07-20 19:20:51 +00:00
|
|
|
#include "gfx3DMatrix.h"
|
2010-04-27 02:09:44 +00:00
|
|
|
#include "nsISupportsImpl.h"
|
|
|
|
#include "prlink.h"
|
|
|
|
|
2010-05-25 06:35:35 +00:00
|
|
|
#include "nsDataHashtable.h"
|
|
|
|
#include "nsHashKeys.h"
|
2010-07-01 16:30:38 +00:00
|
|
|
#include "nsRegion.h"
|
2010-07-19 05:01:14 +00:00
|
|
|
#include "nsAutoPtr.h"
|
2010-10-12 21:01:59 +00:00
|
|
|
#include "nsThreadUtils.h"
|
2012-11-26 22:23:27 +00:00
|
|
|
#include "GLContextTypes.h"
|
2012-11-26 22:23:27 +00:00
|
|
|
#include "GLTextureImage.h"
|
2010-04-27 02:09:44 +00:00
|
|
|
|
|
|
|
typedef char realGLboolean;
|
|
|
|
|
2010-10-12 21:01:59 +00:00
|
|
|
#include "GLContextSymbols.h"
|
|
|
|
|
2012-04-16 19:56:12 +00:00
|
|
|
#include "mozilla/mozalloc.h"
|
2012-08-22 03:30:20 +00:00
|
|
|
#include "mozilla/Preferences.h"
|
2012-04-16 19:56:12 +00:00
|
|
|
|
2012-07-23 23:58:37 +00:00
|
|
|
namespace android {
|
|
|
|
class GraphicBuffer;
|
|
|
|
}
|
|
|
|
|
2010-04-27 02:09:44 +00:00
|
|
|
namespace mozilla {
|
2011-07-06 18:00:47 +00:00
|
|
|
namespace layers {
|
|
|
|
class LayerManagerOGL;
|
|
|
|
class ColorTextureLayerProgram;
|
2011-12-03 16:02:10 +00:00
|
|
|
}
|
2010-04-27 02:09:44 +00:00
|
|
|
|
2011-07-06 18:00:47 +00:00
|
|
|
namespace gl {
|
2010-07-01 16:30:38 +00:00
|
|
|
class GLContext;
|
|
|
|
|
2012-06-01 01:30:08 +00:00
|
|
|
typedef uintptr_t SharedTextureHandle;
|
2010-04-27 02:09:44 +00:00
|
|
|
|
2010-10-12 21:01:59 +00:00
|
|
|
struct THEBES_API ContextFormat
|
|
|
|
{
|
2010-07-19 05:01:14 +00:00
|
|
|
static const ContextFormat BasicRGBA32Format;
|
|
|
|
|
|
|
|
enum StandardContextFormat {
|
|
|
|
Empty,
|
|
|
|
BasicRGBA32,
|
|
|
|
StrictBasicRGBA32,
|
|
|
|
BasicRGB24,
|
|
|
|
StrictBasicRGB24,
|
|
|
|
BasicRGB16_565,
|
|
|
|
StrictBasicRGB16_565
|
|
|
|
};
|
|
|
|
|
|
|
|
ContextFormat() {
|
2011-10-19 19:09:57 +00:00
|
|
|
memset(this, 0, sizeof(ContextFormat));
|
2010-07-19 05:01:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ContextFormat(const StandardContextFormat cf) {
|
2011-10-19 19:09:57 +00:00
|
|
|
memset(this, 0, sizeof(ContextFormat));
|
2010-07-19 05:01:14 +00:00
|
|
|
switch (cf) {
|
|
|
|
case BasicRGBA32:
|
|
|
|
red = green = blue = alpha = 8;
|
|
|
|
minRed = minGreen = minBlue = minAlpha = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case StrictBasicRGBA32:
|
|
|
|
red = green = blue = alpha = 8;
|
|
|
|
minRed = minGreen = minBlue = minAlpha = 8;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BasicRGB24:
|
|
|
|
red = green = blue = 8;
|
|
|
|
minRed = minGreen = minBlue = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case StrictBasicRGB24:
|
|
|
|
red = green = blue = 8;
|
|
|
|
minRed = minGreen = minBlue = 8;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case StrictBasicRGB16_565:
|
|
|
|
red = minRed = 5;
|
|
|
|
green = minGreen = 6;
|
|
|
|
blue = minBlue = 5;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int depth, minDepth;
|
|
|
|
int stencil, minStencil;
|
|
|
|
int red, minRed;
|
|
|
|
int green, minGreen;
|
|
|
|
int blue, minBlue;
|
|
|
|
int alpha, minAlpha;
|
2011-10-19 19:09:57 +00:00
|
|
|
int samples;
|
2010-07-19 05:01:14 +00:00
|
|
|
|
|
|
|
int colorBits() const { return red + green + blue; }
|
|
|
|
};
|
|
|
|
|
2010-10-10 22:48:33 +00:00
|
|
|
class GLContext
|
2012-03-16 22:24:12 +00:00
|
|
|
: public GLLibraryLoader
|
2010-04-27 02:09:44 +00:00
|
|
|
{
|
2011-12-15 10:26:42 +00:00
|
|
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GLContext)
|
2010-04-27 02:09:44 +00:00
|
|
|
public:
|
2010-07-19 05:01:14 +00:00
|
|
|
GLContext(const ContextFormat& aFormat,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aIsOffscreen = false,
|
2012-07-30 14:20:58 +00:00
|
|
|
GLContext *aSharedContext = nullptr)
|
2012-08-22 03:30:20 +00:00
|
|
|
: mTexBlit_Buffer(0),
|
|
|
|
mTexBlit_VertShader(0),
|
|
|
|
mTexBlit_FragShader(0),
|
|
|
|
mTexBlit_Program(0),
|
|
|
|
mTexBlit_UseDrawNotCopy(false),
|
|
|
|
mUserBoundDrawFBO(0),
|
2012-02-10 01:57:26 +00:00
|
|
|
mUserBoundReadFBO(0),
|
|
|
|
mInternalBoundDrawFBO(0),
|
|
|
|
mInternalBoundReadFBO(0),
|
2012-03-12 22:10:38 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
mInInternalBindingMode_DrawFBO(true),
|
|
|
|
mInInternalBindingMode_ReadFBO(true),
|
|
|
|
#endif
|
2011-12-16 22:24:46 +00:00
|
|
|
mOffscreenFBOsDirty(false),
|
2011-10-26 20:00:44 +00:00
|
|
|
mInitialized(false),
|
2010-07-19 05:01:14 +00:00
|
|
|
mIsOffscreen(aIsOffscreen),
|
2011-10-17 14:59:28 +00:00
|
|
|
mIsGLES2(false),
|
|
|
|
mIsGlobalSharedContext(false),
|
2011-11-19 03:57:29 +00:00
|
|
|
mHasRobustness(false),
|
2011-12-03 07:52:35 +00:00
|
|
|
mContextLost(false),
|
2010-10-06 20:43:14 +00:00
|
|
|
mVendor(-1),
|
2012-01-30 20:09:02 +00:00
|
|
|
mRenderer(-1),
|
2010-07-28 21:24:09 +00:00
|
|
|
mCreationFormat(aFormat),
|
2010-07-19 05:01:14 +00:00
|
|
|
mSharedContext(aSharedContext),
|
|
|
|
mOffscreenTexture(0),
|
2011-10-17 14:59:28 +00:00
|
|
|
mFlipped(false),
|
2010-09-21 19:41:24 +00:00
|
|
|
mBlitProgram(0),
|
|
|
|
mBlitFramebuffer(0),
|
2011-10-19 19:09:57 +00:00
|
|
|
mOffscreenDrawFBO(0),
|
|
|
|
mOffscreenReadFBO(0),
|
2011-10-19 19:09:57 +00:00
|
|
|
mOffscreenColorRB(0),
|
2010-07-19 05:01:14 +00:00
|
|
|
mOffscreenDepthRB(0),
|
2012-03-26 16:15:53 +00:00
|
|
|
mOffscreenStencilRB(0),
|
|
|
|
mMaxTextureSize(0),
|
|
|
|
mMaxCubeMapTextureSize(0),
|
|
|
|
mMaxTextureImageSize(0),
|
2012-04-10 15:49:10 +00:00
|
|
|
mMaxRenderbufferSize(0),
|
2012-11-26 23:21:39 +00:00
|
|
|
mNeedsTextureSizeChecks(false),
|
2012-04-10 15:49:10 +00:00
|
|
|
mWorkAroundDriverBugs(true)
|
2010-10-12 21:01:59 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
, mGLError(LOCAL_GL_NO_ERROR)
|
|
|
|
#endif
|
2010-05-25 06:35:35 +00:00
|
|
|
{
|
|
|
|
mUserData.Init();
|
2012-04-10 20:20:02 +00:00
|
|
|
mOwningThread = NS_GetCurrentThread();
|
2012-08-22 03:30:20 +00:00
|
|
|
|
|
|
|
mTexBlit_UseDrawNotCopy = Preferences::GetBool("gl.blit-draw-not-copy", false);
|
2010-05-25 06:35:35 +00:00
|
|
|
}
|
2010-04-27 02:09:44 +00:00
|
|
|
|
2010-07-19 05:01:14 +00:00
|
|
|
virtual ~GLContext() {
|
2012-05-12 23:23:56 +00:00
|
|
|
NS_ASSERTION(IsDestroyed(), "GLContext implementation must call MarkDestroyed in destructor!");
|
2010-07-19 05:01:14 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (mSharedContext) {
|
|
|
|
GLContext *tip = mSharedContext;
|
|
|
|
while (tip->mSharedContext)
|
|
|
|
tip = tip->mSharedContext;
|
|
|
|
tip->SharedContextDestroyed(this);
|
|
|
|
tip->ReportOutstandingNames();
|
2012-08-01 18:57:54 +00:00
|
|
|
} else {
|
|
|
|
ReportOutstandingNames();
|
2010-07-19 05:01:14 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
2010-04-27 02:09:44 +00:00
|
|
|
|
2012-03-21 23:13:59 +00:00
|
|
|
enum ContextFlags {
|
|
|
|
ContextFlagsNone = 0x0,
|
2012-06-02 16:05:45 +00:00
|
|
|
ContextFlagsGlobal = 0x1,
|
|
|
|
ContextFlagsMesaLLVMPipe = 0x2
|
2012-03-21 23:13:59 +00:00
|
|
|
};
|
|
|
|
|
2010-07-19 05:01:14 +00:00
|
|
|
enum GLContextType {
|
|
|
|
ContextTypeUnknown,
|
|
|
|
ContextTypeWGL,
|
|
|
|
ContextTypeCGL,
|
|
|
|
ContextTypeGLX,
|
2012-09-07 22:35:22 +00:00
|
|
|
ContextTypeEGL
|
2010-07-19 05:01:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
virtual GLContextType GetContextType() { return ContextTypeUnknown; }
|
2010-10-12 21:01:59 +00:00
|
|
|
|
2012-05-12 23:23:56 +00:00
|
|
|
virtual bool MakeCurrentImpl(bool aForce = false) = 0;
|
2010-10-12 21:01:59 +00:00
|
|
|
|
2012-05-08 13:47:34 +00:00
|
|
|
#ifdef DEBUG
|
2012-05-12 23:23:56 +00:00
|
|
|
static void StaticInit() {
|
|
|
|
PR_NewThreadPrivateIndex(&sCurrentGLContextTLS, NULL);
|
2012-05-08 13:47:34 +00:00
|
|
|
}
|
2012-05-12 23:23:56 +00:00
|
|
|
#endif
|
2012-05-08 13:47:34 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool MakeCurrent(bool aForce = false) {
|
2012-05-12 23:23:56 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
PR_SetThreadPrivate(sCurrentGLContextTLS, this);
|
2012-08-01 18:57:54 +00:00
|
|
|
|
2012-08-01 20:01:25 +00:00
|
|
|
// XXX this assertion is disabled because it's triggering on Mac;
|
|
|
|
// we need to figure out why and reenable it.
|
|
|
|
#if 0
|
2012-08-01 18:57:54 +00:00
|
|
|
// 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!");
|
2012-08-01 20:01:25 +00:00
|
|
|
#endif
|
2012-05-12 23:23:56 +00:00
|
|
|
#endif
|
|
|
|
return MakeCurrentImpl(aForce);
|
2010-10-12 21:01:59 +00:00
|
|
|
}
|
|
|
|
|
2012-08-22 03:30:20 +00:00
|
|
|
virtual bool IsCurrent() = 0;
|
|
|
|
|
2011-12-03 07:52:35 +00:00
|
|
|
bool IsContextLost() { return mContextLost; }
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
virtual bool SetupLookupFunction() = 0;
|
2010-04-27 02:09:44 +00:00
|
|
|
|
2010-06-23 23:37:00 +00:00
|
|
|
virtual void WindowDestroyed() {}
|
|
|
|
|
2011-08-23 20:48:27 +00:00
|
|
|
virtual void ReleaseSurface() {}
|
|
|
|
|
2010-05-25 06:35:35 +00:00
|
|
|
void *GetUserData(void *aKey) {
|
2012-07-30 14:20:58 +00:00
|
|
|
void *result = nullptr;
|
2010-06-09 22:07:12 +00:00
|
|
|
mUserData.Get(aKey, &result);
|
|
|
|
return result;
|
2010-05-25 06:35:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetUserData(void *aKey, void *aValue) {
|
2010-06-09 22:07:12 +00:00
|
|
|
mUserData.Put(aKey, aValue);
|
2010-05-25 06:35:35 +00:00
|
|
|
}
|
|
|
|
|
2010-08-07 05:09:18 +00:00
|
|
|
// Mark this context as destroyed. This will NULL out all
|
|
|
|
// the GL function pointers!
|
2010-08-07 07:49:01 +00:00
|
|
|
void THEBES_API MarkDestroyed();
|
2010-08-07 05:09:18 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsDestroyed() {
|
2010-09-10 03:09:39 +00:00
|
|
|
// MarkDestroyed will mark all these as null.
|
2012-07-30 14:20:58 +00:00
|
|
|
return mSymbols.fUseProgram == nullptr;
|
2010-09-10 03:09:39 +00:00
|
|
|
}
|
|
|
|
|
2010-05-18 04:04:22 +00:00
|
|
|
enum NativeDataType {
|
|
|
|
NativeGLContext,
|
2010-05-19 20:46:08 +00:00
|
|
|
NativeImageSurface,
|
2010-07-19 05:01:14 +00:00
|
|
|
NativeThebesSurface,
|
2010-05-18 04:04:22 +00:00
|
|
|
NativeDataTypeMax
|
|
|
|
};
|
|
|
|
|
|
|
|
virtual void *GetNativeData(NativeDataType aType) { return NULL; }
|
2010-07-19 05:01:14 +00:00
|
|
|
GLContext *GetSharedContext() { return mSharedContext; }
|
2010-06-09 22:07:12 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsGlobalSharedContext() { return mIsGlobalSharedContext; }
|
|
|
|
void SetIsGlobalSharedContext(bool aIsOne) { mIsGlobalSharedContext = aIsOne; }
|
2010-08-07 05:09:18 +00:00
|
|
|
|
2012-04-10 20:20:02 +00:00
|
|
|
/**
|
|
|
|
* Returns true if the thread on which this context was created is the currently
|
|
|
|
* executing thread.
|
|
|
|
*/
|
|
|
|
bool IsOwningThreadCurrent() { return NS_GetCurrentThread() == mOwningThread; }
|
|
|
|
|
|
|
|
void DispatchToOwningThread(nsIRunnable *event) {
|
|
|
|
// Before dispatching, we need to ensure we're not in the middle of
|
|
|
|
// shutting down. Dispatching runnables in the middle of shutdown
|
|
|
|
// (that is, when the main thread is no longer get-able) can cause them
|
|
|
|
// to leak. See Bug 741319, and Bug 744115.
|
|
|
|
nsCOMPtr<nsIThread> mainThread;
|
|
|
|
if (NS_SUCCEEDED(NS_GetMainThread(getter_AddRefs(mainThread)))) {
|
|
|
|
mOwningThread->Dispatch(event, NS_DISPATCH_NORMAL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-19 05:01:14 +00:00
|
|
|
const ContextFormat& CreationFormat() { return mCreationFormat; }
|
|
|
|
const ContextFormat& ActualFormat() { return mActualFormat; }
|
2010-06-09 22:07:12 +00:00
|
|
|
|
2011-01-06 22:07:12 +00:00
|
|
|
/**
|
|
|
|
* If this GL context has a D3D texture share handle, returns non-null.
|
|
|
|
*/
|
2012-07-30 14:20:58 +00:00
|
|
|
virtual void *GetD3DShareHandle() { return nullptr; }
|
2011-01-06 22:07:12 +00:00
|
|
|
|
2010-07-19 05:01:14 +00:00
|
|
|
/**
|
|
|
|
* If this context is double-buffered, returns TRUE.
|
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
virtual bool IsDoubleBuffered() { return false; }
|
2010-07-28 21:24:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If this context is the GLES2 API, returns TRUE.
|
|
|
|
* This means that various GLES2 restrictions might be in effect (modulo
|
|
|
|
* extensions).
|
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsGLES2() const {
|
2010-07-28 21:24:09 +00:00
|
|
|
return mIsGLES2;
|
|
|
|
}
|
2011-02-11 23:11:30 +00:00
|
|
|
|
|
|
|
/**
|
2011-10-17 14:59:28 +00:00
|
|
|
* Returns true if either this is the GLES2 API, or had the GL_ARB_ES2_compatibility extension
|
2011-02-11 23:11:30 +00:00
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
bool HasES2Compatibility() {
|
2011-02-11 23:11:30 +00:00
|
|
|
return mIsGLES2 || IsExtensionSupported(ARB_ES2_compatibility);
|
|
|
|
}
|
2010-10-06 20:43:14 +00:00
|
|
|
|
2011-12-15 00:57:09 +00:00
|
|
|
/**
|
|
|
|
* Returns true if the context is using ANGLE. This should only be overridden for an ANGLE
|
|
|
|
* implementation.
|
|
|
|
*/
|
|
|
|
virtual bool IsANGLE() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-11-19 03:57:29 +00:00
|
|
|
/**
|
|
|
|
* The derived class is expected to provide information on whether or not it
|
|
|
|
* supports robustness.
|
|
|
|
*/
|
|
|
|
virtual bool SupportsRobustness() = 0;
|
|
|
|
|
2010-11-12 20:02:11 +00:00
|
|
|
enum {
|
|
|
|
VendorIntel,
|
|
|
|
VendorNVIDIA,
|
|
|
|
VendorATI,
|
|
|
|
VendorQualcomm,
|
2012-02-17 21:33:37 +00:00
|
|
|
VendorImagination,
|
2012-11-26 23:21:39 +00:00
|
|
|
VendorNouveau,
|
2010-11-12 20:02:11 +00:00
|
|
|
VendorOther
|
|
|
|
};
|
2010-10-06 20:43:14 +00:00
|
|
|
|
2012-01-30 20:09:02 +00:00
|
|
|
enum {
|
|
|
|
RendererAdreno200,
|
2012-02-19 02:23:06 +00:00
|
|
|
RendererAdreno205,
|
2012-03-20 23:13:50 +00:00
|
|
|
RendererSGX530,
|
2012-02-17 21:33:37 +00:00
|
|
|
RendererSGX540,
|
2012-01-30 20:09:02 +00:00
|
|
|
RendererOther
|
|
|
|
};
|
|
|
|
|
2010-11-12 20:02:11 +00:00
|
|
|
int Vendor() const {
|
2010-10-06 20:43:14 +00:00
|
|
|
return mVendor;
|
|
|
|
}
|
|
|
|
|
2012-01-30 20:09:02 +00:00
|
|
|
int Renderer() const {
|
|
|
|
return mRenderer;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CanUploadSubTextures();
|
2012-11-06 22:39:38 +00:00
|
|
|
|
|
|
|
static void PlatformStartup();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
static bool sPowerOfTwoForced;
|
|
|
|
static bool sPowerOfTwoPrefCached;
|
|
|
|
static void CacheCanUploadNPOT();
|
|
|
|
|
|
|
|
public:
|
2012-02-19 02:23:06 +00:00
|
|
|
bool CanUploadNonPowerOfTwo();
|
2012-11-06 22:39:38 +00:00
|
|
|
|
2012-02-17 21:33:37 +00:00
|
|
|
bool WantsSmallTiles();
|
2012-04-28 13:05:41 +00:00
|
|
|
virtual bool HasLockSurface() { return false; }
|
2012-01-30 20:09:02 +00:00
|
|
|
|
2010-06-18 23:17:00 +00: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.
|
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
virtual bool SwapBuffers() { return false; }
|
2010-06-18 23:17:00 +00:00
|
|
|
|
2010-06-23 09:24:31 +00:00
|
|
|
/**
|
|
|
|
* Defines a two-dimensional texture image for context target surface
|
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
virtual bool BindTexImage() { return false; }
|
2010-06-23 09:24:31 +00:00
|
|
|
/*
|
|
|
|
* Releases a color buffer that is being used as a texture
|
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
virtual bool ReleaseTexImage() { return false; }
|
2010-06-23 23:37:00 +00:00
|
|
|
|
2011-10-05 18:20:33 +00:00
|
|
|
/**
|
|
|
|
* Applies aFilter to the texture currently bound to GL_TEXTURE_2D.
|
|
|
|
*/
|
|
|
|
void ApplyFilterToBoundTexture(gfxPattern::GraphicsFilter aFilter);
|
|
|
|
|
2012-08-30 18:39:01 +00:00
|
|
|
/**
|
|
|
|
* Applies aFilter to the texture currently bound to aTarget.
|
|
|
|
*/
|
|
|
|
void ApplyFilterToBoundTexture(GLuint aTarget,
|
|
|
|
gfxPattern::GraphicsFilter aFilter);
|
|
|
|
|
2012-07-17 02:12:58 +00:00
|
|
|
virtual bool BindExternalBuffer(GLuint texture, void* buffer) { return false; }
|
2012-07-19 18:40:04 +00:00
|
|
|
virtual bool UnbindExternalBuffer(GLuint texture) { return false; }
|
2011-10-05 18:20:33 +00:00
|
|
|
|
2012-07-23 23:58:37 +00:00
|
|
|
virtual already_AddRefed<TextureImage>
|
|
|
|
CreateDirectTextureImage(android::GraphicBuffer* aBuffer, GLenum aWrapMode)
|
2012-07-30 14:20:58 +00:00
|
|
|
{ return nullptr; }
|
2012-07-23 23:58:37 +00:00
|
|
|
|
2010-07-19 05:01:14 +00:00
|
|
|
/*
|
|
|
|
* Offscreen support API
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Bind aOffscreen's color buffer as a texture to the TEXTURE_2D
|
|
|
|
* target. Returns TRUE on success, otherwise FALSE. If
|
|
|
|
* aOffscreen is not an offscreen context, returns FALSE. If
|
|
|
|
* BindOffscreenNeedsTexture() returns TRUE, then you should have
|
|
|
|
* a 2D texture name bound whose image will be replaced by the
|
|
|
|
* contents of the offscreen context. If it returns FALSE,
|
|
|
|
* the current 2D texture binding will be replaced.
|
|
|
|
*
|
|
|
|
* After a successul call to BindTex2DOffscreen, UnbindTex2DOffscreen
|
|
|
|
* *must* be called once rendering is complete.
|
|
|
|
*
|
|
|
|
* The same texture unit must be active for Bind/Unbind of a given
|
|
|
|
* context.
|
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
virtual bool BindOffscreenNeedsTexture(GLContext *aOffscreen) {
|
2010-07-19 05:01:14 +00:00
|
|
|
return aOffscreen->mOffscreenTexture == 0;
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
virtual bool BindTex2DOffscreen(GLContext *aOffscreen) {
|
2010-07-19 05:01:14 +00:00
|
|
|
if (aOffscreen->GetContextType() != GetContextType()) {
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2010-07-19 05:01:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!aOffscreen->mSharedContext ||
|
|
|
|
aOffscreen->mSharedContext != mSharedContext)
|
|
|
|
{
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2010-07-19 05:01:14 +00:00
|
|
|
}
|
|
|
|
|
2011-12-19 23:47:54 +00:00
|
|
|
if (!aOffscreen->mOffscreenTexture) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-07-19 05:01:14 +00:00
|
|
|
fBindTexture(LOCAL_GL_TEXTURE_2D, aOffscreen->mOffscreenTexture);
|
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2010-07-19 05:01:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void UnbindTex2DOffscreen(GLContext *aOffscreen) { }
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsOffscreen() {
|
2010-07-19 05:01:14 +00:00
|
|
|
return mIsOffscreen;
|
|
|
|
}
|
2011-12-19 23:47:54 +00:00
|
|
|
|
|
|
|
// Before reads from offscreen texture
|
2011-12-16 22:24:46 +00:00
|
|
|
void GuaranteeResolve() {
|
2012-07-06 23:38:16 +00:00
|
|
|
BlitDirtyFBOs();
|
|
|
|
fFinish();
|
2011-12-16 22:24:46 +00:00
|
|
|
}
|
|
|
|
|
2012-08-22 03:30:20 +00:00
|
|
|
protected:
|
|
|
|
GLuint mTexBlit_Buffer;
|
|
|
|
GLuint mTexBlit_VertShader;
|
|
|
|
GLuint mTexBlit_FragShader;
|
|
|
|
GLuint mTexBlit_Program;
|
|
|
|
|
|
|
|
bool mTexBlit_UseDrawNotCopy;
|
|
|
|
|
|
|
|
bool UseTexQuadProgram();
|
|
|
|
void DeleteTexBlitProgram();
|
|
|
|
|
|
|
|
public:
|
|
|
|
void BlitFramebufferToFramebuffer(GLuint srcFB, GLuint destFB,
|
|
|
|
const gfxIntSize& srcSize,
|
|
|
|
const gfxIntSize& destSize);
|
|
|
|
void BlitTextureToFramebuffer(GLuint srcTex, GLuint destFB,
|
|
|
|
const gfxIntSize& srcSize,
|
|
|
|
const gfxIntSize& destSize);
|
|
|
|
void BlitFramebufferToTexture(GLuint srcFB, GLuint destTex,
|
|
|
|
const gfxIntSize& srcSize,
|
|
|
|
const gfxIntSize& destSize);
|
|
|
|
void BlitTextureToTexture(GLuint srcTex, GLuint destTex,
|
|
|
|
const gfxIntSize& srcSize,
|
|
|
|
const gfxIntSize& destSize);
|
|
|
|
|
2010-07-19 05:01:14 +00: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.
|
2010-09-21 19:41:24 +00:00
|
|
|
*
|
|
|
|
* Only valid if IsOffscreen() returns true.
|
2010-07-19 05:01:14 +00:00
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
virtual bool ResizeOffscreen(const gfxIntSize& aNewSize) {
|
2011-10-19 19:09:57 +00:00
|
|
|
if (mOffscreenDrawFBO || mOffscreenReadFBO)
|
2012-04-25 14:10:43 +00:00
|
|
|
return ResizeOffscreenFBOs(aNewSize, mOffscreenReadFBO != 0);
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2010-07-19 05:01:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return size of this offscreen context.
|
2010-09-21 19:41:24 +00:00
|
|
|
*
|
|
|
|
* Only valid if IsOffscreen() returns true.
|
2010-07-19 05:01:14 +00:00
|
|
|
*/
|
|
|
|
gfxIntSize OffscreenSize() {
|
|
|
|
return mOffscreenSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* In some cases, we have to allocate a bigger offscreen buffer
|
|
|
|
* than what's requested. This is the bigger size.
|
2010-09-21 19:41:24 +00:00
|
|
|
*
|
|
|
|
* Only valid if IsOffscreen() returns true.
|
2010-07-19 05:01:14 +00:00
|
|
|
*/
|
|
|
|
gfxIntSize OffscreenActualSize() {
|
|
|
|
return mOffscreenActualSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If this context is FBO-backed, return the FBO or the color
|
|
|
|
* buffer texture. If the context is not FBO-backed, 0 is
|
|
|
|
* returned (which is also a valid FBO binding).
|
2010-09-21 19:41:24 +00:00
|
|
|
*
|
|
|
|
* Only valid if IsOffscreen() returns true.
|
2010-07-19 05:01:14 +00:00
|
|
|
*/
|
|
|
|
GLuint GetOffscreenFBO() {
|
2011-10-19 19:09:57 +00:00
|
|
|
// 0 is interpreted as (off)screen, whether for read or draw operations
|
|
|
|
return 0;
|
2010-07-19 05:01:14 +00:00
|
|
|
}
|
2011-10-19 19:09:57 +00:00
|
|
|
|
2010-07-19 05:01:14 +00:00
|
|
|
GLuint GetOffscreenTexture() {
|
|
|
|
return mOffscreenTexture;
|
|
|
|
}
|
|
|
|
|
2011-10-19 19:09:57 +00:00
|
|
|
virtual bool SupportsFramebufferMultisample() {
|
|
|
|
return IsExtensionSupported(EXT_framebuffer_multisample) || IsExtensionSupported(ANGLE_framebuffer_multisample);
|
|
|
|
}
|
|
|
|
|
2011-10-19 19:09:57 +00:00
|
|
|
virtual bool SupportsOffscreenSplit() {
|
|
|
|
return IsExtensionSupported(EXT_framebuffer_blit) || IsExtensionSupported(ANGLE_framebuffer_blit);
|
|
|
|
}
|
|
|
|
|
2012-11-26 22:23:27 +00:00
|
|
|
|
|
|
|
enum SharedTextureShareType {
|
|
|
|
SameProcess = 0,
|
|
|
|
CrossProcess
|
|
|
|
};
|
|
|
|
|
2012-07-20 19:20:51 +00:00
|
|
|
enum SharedTextureBufferType {
|
|
|
|
TextureID
|
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
, SurfaceTexture
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2012-06-01 01:30:08 +00:00
|
|
|
/**
|
|
|
|
* Create new shared GLContext content handle, must be released by ReleaseSharedHandle.
|
|
|
|
*/
|
2012-11-26 22:23:27 +00:00
|
|
|
virtual SharedTextureHandle CreateSharedHandle(SharedTextureShareType shareType)
|
|
|
|
{ return 0; }
|
2012-07-20 19:20:51 +00: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.
|
|
|
|
*/
|
2012-11-26 22:23:27 +00:00
|
|
|
virtual SharedTextureHandle CreateSharedHandle(SharedTextureShareType shareType,
|
|
|
|
void* buffer,
|
|
|
|
SharedTextureBufferType bufferType)
|
|
|
|
{ return 0; }
|
2012-06-01 01:30:08 +00:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2012-11-26 22:23:27 +00:00
|
|
|
virtual void UpdateSharedHandle(SharedTextureShareType shareType,
|
|
|
|
SharedTextureHandle sharedHandle)
|
|
|
|
{ }
|
2012-06-01 01:30:08 +00:00
|
|
|
/**
|
|
|
|
* - 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).
|
|
|
|
*/
|
2012-11-26 22:23:27 +00:00
|
|
|
virtual void ReleaseSharedHandle(SharedTextureShareType shareType,
|
|
|
|
SharedTextureHandle sharedHandle)
|
|
|
|
{ }
|
2012-07-20 19:20:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
GLenum mTarget;
|
|
|
|
ShaderProgramType mProgramType;
|
|
|
|
gfx3DMatrix mTextureTransform;
|
|
|
|
} SharedHandleDetails;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns information necessary for rendering a shared handle.
|
|
|
|
* These values change depending on what sharing mechanism is in use
|
|
|
|
*/
|
2012-11-26 22:23:27 +00:00
|
|
|
virtual bool GetSharedHandleDetails(SharedTextureShareType shareType,
|
|
|
|
SharedTextureHandle sharedHandle,
|
|
|
|
SharedHandleDetails& details)
|
|
|
|
{ return false; }
|
2012-06-01 01:30:08 +00:00
|
|
|
/**
|
|
|
|
* Attach Shared GL Handle to GL_TEXTURE_2D target
|
|
|
|
* GLContext must be current before this call
|
|
|
|
*/
|
2012-11-26 22:23:27 +00:00
|
|
|
virtual bool AttachSharedHandle(SharedTextureShareType shareType,
|
|
|
|
SharedTextureHandle sharedHandle)
|
|
|
|
{ return false; }
|
2012-07-20 19:20:51 +00:00
|
|
|
|
2012-06-01 01:30:08 +00:00
|
|
|
/**
|
|
|
|
* Detach Shared GL Handle from GL_TEXTURE_2D target
|
|
|
|
*/
|
2012-11-26 22:23:27 +00:00
|
|
|
virtual void DetachSharedHandle(SharedTextureShareType shareType,
|
|
|
|
SharedTextureHandle sharedHandle)
|
|
|
|
{ }
|
2012-02-09 00:06:03 +00:00
|
|
|
|
|
|
|
private:
|
2012-02-10 01:57:26 +00:00
|
|
|
GLuint mUserBoundDrawFBO;
|
|
|
|
GLuint mUserBoundReadFBO;
|
|
|
|
GLuint mInternalBoundDrawFBO;
|
|
|
|
GLuint mInternalBoundReadFBO;
|
2012-02-09 00:06:03 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
void fBindFramebuffer(GLenum target, GLuint framebuffer) {
|
|
|
|
switch (target) {
|
|
|
|
case LOCAL_GL_DRAW_FRAMEBUFFER_EXT:
|
2012-02-10 01:57:26 +00:00
|
|
|
mUserBoundDrawFBO = framebuffer;
|
|
|
|
|
|
|
|
if (framebuffer == 0) {
|
|
|
|
mInternalBoundDrawFBO = mOffscreenDrawFBO;
|
|
|
|
} else {
|
|
|
|
mInternalBoundDrawFBO = mUserBoundDrawFBO;
|
|
|
|
}
|
|
|
|
|
|
|
|
raw_fBindFramebuffer(LOCAL_GL_DRAW_FRAMEBUFFER_EXT,
|
|
|
|
mInternalBoundDrawFBO);
|
2012-02-09 00:06:03 +00:00
|
|
|
break;
|
2012-02-10 01:57:26 +00:00
|
|
|
|
2012-02-09 00:06:03 +00:00
|
|
|
case LOCAL_GL_READ_FRAMEBUFFER_EXT:
|
2012-02-10 01:57:26 +00:00
|
|
|
mUserBoundReadFBO = framebuffer;
|
|
|
|
|
|
|
|
if (framebuffer == 0) {
|
|
|
|
mInternalBoundReadFBO = mOffscreenReadFBO;
|
|
|
|
} else {
|
|
|
|
mInternalBoundReadFBO = mUserBoundReadFBO;
|
|
|
|
}
|
|
|
|
|
|
|
|
raw_fBindFramebuffer(LOCAL_GL_READ_FRAMEBUFFER_EXT,
|
|
|
|
mInternalBoundReadFBO);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LOCAL_GL_FRAMEBUFFER:
|
|
|
|
mUserBoundDrawFBO = mUserBoundReadFBO = framebuffer;
|
|
|
|
|
|
|
|
if (framebuffer == 0) {
|
|
|
|
mInternalBoundDrawFBO = mOffscreenDrawFBO;
|
|
|
|
mInternalBoundReadFBO = mOffscreenReadFBO;
|
|
|
|
} else {
|
|
|
|
mInternalBoundDrawFBO = mUserBoundDrawFBO;
|
|
|
|
mInternalBoundReadFBO = mUserBoundReadFBO;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SupportsOffscreenSplit()) {
|
|
|
|
raw_fBindFramebuffer(LOCAL_GL_DRAW_FRAMEBUFFER_EXT,
|
|
|
|
mInternalBoundDrawFBO);
|
|
|
|
raw_fBindFramebuffer(LOCAL_GL_READ_FRAMEBUFFER_EXT,
|
|
|
|
mInternalBoundReadFBO);
|
|
|
|
} else {
|
|
|
|
raw_fBindFramebuffer(LOCAL_GL_FRAMEBUFFER,
|
|
|
|
mInternalBoundDrawFBO);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
raw_fBindFramebuffer(target, framebuffer);
|
2012-02-09 00:06:03 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-31 23:44:33 +00:00
|
|
|
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_FRAMEBUFFER_BINDING:
|
|
|
|
*params = GetUserBoundDrawFBO();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LOCAL_GL_READ_FRAMEBUFFER_BINDING_EXT:
|
|
|
|
*params = GetUserBoundReadFBO();
|
|
|
|
break;
|
|
|
|
|
2012-11-13 22:35:35 +00:00
|
|
|
case LOCAL_GL_MAX_TEXTURE_SIZE:
|
|
|
|
*params = mMaxTextureSize;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LOCAL_GL_MAX_CUBE_MAP_TEXTURE_SIZE:
|
|
|
|
*params = mMaxCubeMapTextureSize;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LOCAL_GL_MAX_RENDERBUFFER_SIZE:
|
|
|
|
*params = mMaxRenderbufferSize;
|
|
|
|
break;
|
|
|
|
|
2012-08-31 23:44:33 +00:00
|
|
|
default:
|
|
|
|
raw_fGetIntegerv(pname, params);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-12 22:10:38 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
// See comment near BindInternalDrawFBO()
|
|
|
|
bool mInInternalBindingMode_DrawFBO;
|
|
|
|
bool mInInternalBindingMode_ReadFBO;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
GLuint GetUserBoundDrawFBO() {
|
2012-02-09 00:06:03 +00:00
|
|
|
#ifdef DEBUG
|
2012-08-31 23:44:33 +00:00
|
|
|
MOZ_ASSERT(IsCurrent());
|
|
|
|
|
2011-10-19 19:09:57 +00:00
|
|
|
GLint ret = 0;
|
2012-02-09 00:06:03 +00:00
|
|
|
// Don't need a branch here, because:
|
|
|
|
// LOCAL_GL_DRAW_FRAMEBUFFER_BINDING_EXT == LOCAL_GL_FRAMEBUFFER_BINDING == 0x8CA6
|
2012-02-10 01:57:26 +00:00
|
|
|
// We use raw_ here because this is debug code and we need to see what
|
|
|
|
// the driver thinks.
|
|
|
|
raw_fGetIntegerv(LOCAL_GL_DRAW_FRAMEBUFFER_BINDING_EXT, &ret);
|
2012-02-09 00:06:03 +00:00
|
|
|
|
2012-03-12 22:10:38 +00:00
|
|
|
bool abort = false;
|
|
|
|
|
|
|
|
if (mInInternalBindingMode_DrawFBO) {
|
|
|
|
NS_ERROR("Draw FBO still bound internally!");
|
|
|
|
printf_stderr("Current internal draw FBO: %d, user: %d)\n", ret, mUserBoundDrawFBO);
|
|
|
|
abort = true;
|
|
|
|
}
|
|
|
|
|
2012-02-10 01:57:26 +00:00
|
|
|
if (mInternalBoundDrawFBO != (GLuint)ret) {
|
2012-03-12 22:10:38 +00:00
|
|
|
NS_ERROR("Draw FBO binding misprediction!");
|
|
|
|
printf_stderr("Bound draw FBO was: %d, Expected: %d\n", ret, mInternalBoundDrawFBO);
|
|
|
|
abort = true;
|
2012-02-09 00:06:03 +00:00
|
|
|
}
|
2012-03-12 22:10:38 +00:00
|
|
|
|
|
|
|
if (abort)
|
|
|
|
NS_ABORT();
|
2012-02-09 00:06:03 +00:00
|
|
|
#endif
|
|
|
|
|
2012-02-10 01:57:26 +00:00
|
|
|
// We only ever expose the user's bound FBOs
|
|
|
|
return mUserBoundDrawFBO;
|
2011-10-19 19:09:57 +00:00
|
|
|
}
|
|
|
|
|
2012-03-12 22:10:38 +00:00
|
|
|
GLuint GetUserBoundReadFBO() {
|
2012-02-09 00:06:03 +00:00
|
|
|
#ifdef DEBUG
|
2012-08-31 23:44:33 +00:00
|
|
|
MOZ_ASSERT(IsCurrent());
|
|
|
|
|
2011-10-19 19:09:57 +00:00
|
|
|
GLint ret = 0;
|
2012-02-10 01:57:26 +00:00
|
|
|
// We use raw_ here because this is debug code and we need to see what
|
|
|
|
// the driver thinks.
|
2011-10-19 19:09:57 +00:00
|
|
|
if (SupportsOffscreenSplit())
|
2012-02-10 01:57:26 +00:00
|
|
|
raw_fGetIntegerv(LOCAL_GL_READ_FRAMEBUFFER_BINDING_EXT, &ret);
|
2011-10-19 19:09:57 +00:00
|
|
|
else
|
2012-02-10 01:57:26 +00:00
|
|
|
raw_fGetIntegerv(LOCAL_GL_FRAMEBUFFER_BINDING, &ret);
|
2012-02-09 00:06:03 +00:00
|
|
|
|
2012-03-12 22:10:38 +00:00
|
|
|
bool abort = false;
|
|
|
|
|
|
|
|
if (mInInternalBindingMode_ReadFBO) {
|
|
|
|
NS_ERROR("Read FBO still bound internally!");
|
|
|
|
printf_stderr("Current internal read FBO: %d, user: %d)\n", ret, mUserBoundReadFBO);
|
|
|
|
abort = true;
|
|
|
|
}
|
|
|
|
|
2012-02-10 01:57:26 +00:00
|
|
|
if (mInternalBoundReadFBO != (GLuint)ret) {
|
2012-03-12 22:10:38 +00:00
|
|
|
NS_ERROR("Read FBO binding misprediction!");
|
|
|
|
printf_stderr("Bound read FBO was: %d, Expected: %d\n", ret, mInternalBoundReadFBO);
|
|
|
|
abort = true;
|
2012-02-09 00:06:03 +00:00
|
|
|
}
|
2012-03-12 22:10:38 +00:00
|
|
|
|
|
|
|
if (abort)
|
|
|
|
NS_ABORT();
|
2012-02-09 00:06:03 +00:00
|
|
|
#endif
|
|
|
|
|
2012-02-10 01:57:26 +00:00
|
|
|
// We only ever expose the user's bound FBOs
|
|
|
|
return mUserBoundReadFBO;
|
2011-10-19 19:09:57 +00:00
|
|
|
}
|
|
|
|
|
2012-03-12 22:10:38 +00:00
|
|
|
void BindUserDrawFBO(GLuint name) {
|
2011-10-19 19:09:57 +00:00
|
|
|
if (SupportsOffscreenSplit())
|
|
|
|
fBindFramebuffer(LOCAL_GL_DRAW_FRAMEBUFFER_EXT, name);
|
|
|
|
else
|
|
|
|
fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, name);
|
2012-03-12 22:10:38 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
mInInternalBindingMode_DrawFBO = false;
|
|
|
|
#endif
|
2011-10-19 19:09:57 +00:00
|
|
|
}
|
|
|
|
|
2012-03-12 22:10:38 +00:00
|
|
|
void BindUserReadFBO(GLuint name) {
|
2011-10-19 19:09:57 +00:00
|
|
|
if (SupportsOffscreenSplit())
|
|
|
|
fBindFramebuffer(LOCAL_GL_READ_FRAMEBUFFER_EXT, name);
|
|
|
|
else
|
|
|
|
fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, name);
|
2012-03-12 22:10:38 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
mInInternalBindingMode_ReadFBO = false;
|
|
|
|
#endif
|
2011-10-19 19:09:57 +00:00
|
|
|
}
|
|
|
|
|
2012-08-22 03:30:20 +00:00
|
|
|
GLuint GetUserBoundFBO() {
|
|
|
|
MOZ_ASSERT(GetUserBoundDrawFBO() == GetUserBoundReadFBO());
|
|
|
|
return GetUserBoundReadFBO();
|
|
|
|
}
|
|
|
|
|
|
|
|
void BindUserFBO(GLuint name) {
|
|
|
|
fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, name);
|
|
|
|
}
|
|
|
|
|
2012-03-12 22:10:38 +00:00
|
|
|
// BindInternalDraw/ReadFBO() switch us over into 'internal binding mode'
|
|
|
|
// for the corresponding Draw or Read binding.
|
|
|
|
// To exit internal binding mode, use BindUserDraw/ReadFBO().
|
|
|
|
// While in internal binding mode for Draw/Read, the corresponding
|
|
|
|
// GetBoundUserDraw/ReadFBO() is undefined, and will trigger ABORT in DEBUG builds.
|
|
|
|
void BindInternalDrawFBO(GLuint name) {
|
|
|
|
#ifdef DEBUG
|
2012-08-22 03:30:20 +00:00
|
|
|
mInInternalBindingMode_DrawFBO = true;
|
2012-03-12 22:10:38 +00:00
|
|
|
#endif
|
|
|
|
if (SupportsOffscreenSplit())
|
|
|
|
raw_fBindFramebuffer(LOCAL_GL_DRAW_FRAMEBUFFER_EXT, name);
|
|
|
|
else
|
|
|
|
raw_fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, name);
|
|
|
|
|
|
|
|
mInternalBoundDrawFBO = name;
|
2011-10-19 19:09:57 +00:00
|
|
|
}
|
|
|
|
|
2012-03-12 22:10:38 +00:00
|
|
|
void BindInternalReadFBO(GLuint name) {
|
|
|
|
#ifdef DEBUG
|
2012-08-22 03:30:20 +00:00
|
|
|
mInInternalBindingMode_ReadFBO = true;
|
2012-03-12 22:10:38 +00:00
|
|
|
#endif
|
|
|
|
if (SupportsOffscreenSplit())
|
|
|
|
raw_fBindFramebuffer(LOCAL_GL_READ_FRAMEBUFFER_EXT, name);
|
|
|
|
else
|
|
|
|
raw_fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, name);
|
|
|
|
|
|
|
|
mInternalBoundReadFBO = name;
|
2011-10-19 19:09:57 +00:00
|
|
|
}
|
|
|
|
|
2012-03-12 22:10:38 +00:00
|
|
|
void BindInternalFBO(GLuint name) {
|
|
|
|
BindInternalDrawFBO(name);
|
|
|
|
BindInternalReadFBO(name);
|
2011-10-19 19:09:57 +00:00
|
|
|
}
|
|
|
|
|
2012-03-12 22:10:38 +00:00
|
|
|
void InitFramebuffers() {
|
|
|
|
MakeCurrent();
|
|
|
|
BindUserDrawFBO(0);
|
|
|
|
BindUserReadFBO(0);
|
2011-10-19 19:09:57 +00:00
|
|
|
}
|
|
|
|
|
2012-03-12 22:10:38 +00:00
|
|
|
GLuint SwapUserDrawFBO(GLuint name) {
|
|
|
|
GLuint prev = GetUserBoundDrawFBO();
|
|
|
|
BindUserDrawFBO(name);
|
|
|
|
return prev;
|
|
|
|
}
|
|
|
|
|
|
|
|
GLuint SwapUserReadFBO(GLuint name) {
|
|
|
|
GLuint prev = GetUserBoundReadFBO();
|
|
|
|
BindUserReadFBO(name);
|
|
|
|
return prev;
|
2011-10-19 19:09:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool mOffscreenFBOsDirty;
|
|
|
|
|
2011-12-16 21:11:59 +00:00
|
|
|
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;
|
2012-05-24 19:10:49 +00:00
|
|
|
*precision = 23;
|
2011-12-16 21:11:59 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-10 01:57:26 +00:00
|
|
|
// Do whatever setup is necessary to draw to our offscreen FBO, if it's
|
|
|
|
// bound.
|
2011-10-19 19:09:57 +00:00
|
|
|
void BeforeGLDrawCall() {
|
2012-02-10 01:57:26 +00:00
|
|
|
if (mInternalBoundDrawFBO != mOffscreenDrawFBO)
|
2011-10-19 19:09:57 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (mOffscreenDrawFBO == mOffscreenReadFBO)
|
|
|
|
return;
|
|
|
|
|
|
|
|
mOffscreenFBOsDirty = true;
|
|
|
|
}
|
|
|
|
|
2012-02-10 01:57:26 +00:00
|
|
|
// Do whatever tear-down is necessary after drawing to our offscreen FBO,
|
|
|
|
// if it's bound.
|
2011-10-19 19:09:57 +00:00
|
|
|
void AfterGLDrawCall() {
|
|
|
|
}
|
|
|
|
|
2012-02-10 01:57:26 +00:00
|
|
|
// Do whatever setup is necessary to read from our offscreen FBO, if it's
|
|
|
|
// bound.
|
2011-10-19 19:09:57 +00:00
|
|
|
void BeforeGLReadCall() {
|
2012-02-10 01:57:26 +00:00
|
|
|
if (mInternalBoundReadFBO != mOffscreenReadFBO)
|
2011-10-19 19:09:57 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (mOffscreenDrawFBO == mOffscreenReadFBO)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// If we're not dirty, there's no need to blit
|
|
|
|
if (!mOffscreenFBOsDirty)
|
|
|
|
return;
|
|
|
|
|
|
|
|
const bool scissor = fIsEnabled(LOCAL_GL_SCISSOR_TEST);
|
|
|
|
if (scissor)
|
|
|
|
fDisable(LOCAL_GL_SCISSOR_TEST);
|
|
|
|
|
2012-03-12 22:10:38 +00:00
|
|
|
// Store current bindings for restoring later
|
|
|
|
GLuint prevDraw = GetUserBoundDrawFBO();
|
|
|
|
GLuint prevRead = GetUserBoundReadFBO();
|
|
|
|
|
|
|
|
NS_ABORT_IF_FALSE(SupportsOffscreenSplit(), "Doesn't support offscreen split?");
|
|
|
|
|
|
|
|
// Manually setting internal bindings, entering internal mode
|
|
|
|
// Flip read/draw for blitting
|
|
|
|
BindInternalDrawFBO(mOffscreenReadFBO);
|
|
|
|
BindInternalReadFBO(mOffscreenDrawFBO);
|
2011-10-19 19:09:57 +00:00
|
|
|
|
|
|
|
GLint width = mOffscreenActualSize.width;
|
|
|
|
GLint height = mOffscreenActualSize.height;
|
|
|
|
raw_fBlitFramebuffer(0, 0, width, height,
|
|
|
|
0, 0, width, height,
|
|
|
|
LOCAL_GL_COLOR_BUFFER_BIT,
|
|
|
|
LOCAL_GL_NEAREST);
|
|
|
|
|
2012-03-12 22:10:38 +00:00
|
|
|
// Reset to emulated user binding, exiting internal mode
|
|
|
|
BindUserDrawFBO(prevDraw);
|
|
|
|
BindUserReadFBO(prevRead);
|
2011-10-19 19:09:57 +00:00
|
|
|
|
|
|
|
if (scissor)
|
|
|
|
fEnable(LOCAL_GL_SCISSOR_TEST);
|
|
|
|
|
|
|
|
mOffscreenFBOsDirty = false;
|
|
|
|
}
|
|
|
|
|
2012-02-10 01:57:26 +00:00
|
|
|
// Do whatever tear-down is necessary after reading from our offscreen FBO,
|
|
|
|
// if it's bound.
|
2011-10-19 19:09:57 +00:00
|
|
|
void AfterGLReadCall() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
// Draw call hooks:
|
|
|
|
void fClear(GLbitfield mask) {
|
|
|
|
BeforeGLDrawCall();
|
|
|
|
raw_fClear(mask);
|
|
|
|
AfterGLDrawCall();
|
|
|
|
}
|
|
|
|
|
|
|
|
void fDrawArrays(GLenum mode, GLint first, GLsizei count) {
|
|
|
|
BeforeGLDrawCall();
|
|
|
|
raw_fDrawArrays(mode, first, count);
|
|
|
|
AfterGLDrawCall();
|
|
|
|
}
|
|
|
|
|
|
|
|
void fDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) {
|
|
|
|
BeforeGLDrawCall();
|
|
|
|
raw_fDrawElements(mode, count, type, indices);
|
|
|
|
AfterGLDrawCall();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Read call hooks:
|
|
|
|
void fReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) {
|
2012-12-19 07:16:01 +00:00
|
|
|
y = FixYValue(y, height);
|
|
|
|
|
2011-10-19 19:09:57 +00:00
|
|
|
BeforeGLReadCall();
|
|
|
|
raw_fReadPixels(x, y, width, height, format, type, pixels);
|
|
|
|
AfterGLReadCall();
|
|
|
|
}
|
|
|
|
|
|
|
|
void fCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) {
|
2012-12-19 07:16:01 +00: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 19:09:57 +00: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-19 07:16:01 +00:00
|
|
|
y = FixYValue(y, height);
|
|
|
|
|
2011-10-19 19:09:57 +00:00
|
|
|
BeforeGLReadCall();
|
|
|
|
raw_fCopyTexSubImage2D(target, level, xoffset, yoffset,
|
|
|
|
x, y, width, height);
|
|
|
|
AfterGLReadCall();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ForceDirtyFBOs() {
|
2012-03-12 22:10:38 +00:00
|
|
|
GLuint draw = SwapUserDrawFBO(0);
|
2011-10-19 19:09:57 +00:00
|
|
|
|
|
|
|
BeforeGLDrawCall();
|
|
|
|
// no-op; just pretend we did something
|
|
|
|
AfterGLDrawCall();
|
|
|
|
|
2012-03-12 22:10:38 +00:00
|
|
|
BindUserDrawFBO(draw);
|
2011-10-19 19:09:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BlitDirtyFBOs() {
|
2012-03-12 22:10:38 +00:00
|
|
|
GLuint read = SwapUserReadFBO(0);
|
2011-10-19 19:09:57 +00:00
|
|
|
|
|
|
|
BeforeGLReadCall();
|
|
|
|
// no-op; we just want to make sure the Read FBO is updated if it needs to be
|
|
|
|
AfterGLReadCall();
|
|
|
|
|
2012-03-12 22:10:38 +00:00
|
|
|
BindUserReadFBO(read);
|
2011-10-19 19:09:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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();
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
virtual bool TextureImageSupportsGetBackingSurface() {
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2010-09-21 19:41:24 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
virtual bool RenewSurface() { return false; }
|
2010-12-13 22:36:35 +00:00
|
|
|
|
2010-09-21 19:41:24 +00:00
|
|
|
/**`
|
2010-07-01 16:30:38 +00:00
|
|
|
* Return a valid, allocated TextureImage of |aSize| with
|
|
|
|
* |aContentType|. The TextureImage's texture is configured to
|
|
|
|
* use |aWrapMode| (usually GL_CLAMP_TO_EDGE or GL_REPEAT) and by
|
|
|
|
* default, GL_LINEAR filtering. Specify
|
2012-05-09 20:55:31 +00:00
|
|
|
* |aFlags=UseNearestFilter| for GL_NEAREST filtering. Specify
|
|
|
|
* |aFlags=NeedsYFlip| if the image is flipped. Return
|
2010-07-01 16:30:38 +00:00
|
|
|
* NULL 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,
|
2010-11-12 20:02:20 +00:00
|
|
|
GLenum aWrapMode,
|
2012-05-09 20:55:31 +00:00
|
|
|
TextureImage::Flags aFlags = TextureImage::NoFlags);
|
2010-07-01 16:30:38 +00:00
|
|
|
|
2011-07-06 18:00:47 +00: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,
|
2012-05-09 20:55:31 +00:00
|
|
|
TextureImage::Flags aFlags = TextureImage::NoFlags)
|
2011-07-06 18:00:47 +00:00
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2012-07-16 14:59:59 +00:00
|
|
|
}
|
2011-07-06 18:00:47 +00:00
|
|
|
|
2010-08-07 05:09:18 +00:00
|
|
|
/**
|
|
|
|
* Read the image data contained in aTexture, and return it as an ImageSurface.
|
|
|
|
* If GL_RGBA is given as the format, a ImageFormatARGB32 surface is returned.
|
|
|
|
* Not implemented yet:
|
|
|
|
* If GL_RGB is given as the format, a ImageFormatRGB24 surface is returned.
|
|
|
|
* If GL_LUMINANCE is given as the format, a ImageFormatA8 surface is returned.
|
|
|
|
*
|
|
|
|
* 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,
|
2012-03-05 18:09:05 +00:00
|
|
|
GLenum aTextureFormat,
|
|
|
|
bool aYInvert = false);
|
|
|
|
|
|
|
|
already_AddRefed<gfxImageSurface> GetTexImage(GLuint aTexture, bool aYInvert, ShaderProgramType aShader);
|
2010-08-07 05:09:18 +00:00
|
|
|
|
2010-08-07 05:09:18 +00:00
|
|
|
/**
|
2012-08-21 23:13:26 +00: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.
|
2010-08-07 05:09:18 +00:00
|
|
|
*/
|
2012-08-21 23:13:26 +00:00
|
|
|
void THEBES_API ReadPixelsIntoImageSurface(gfxImageSurface* dest);
|
2010-08-07 05:09:18 +00:00
|
|
|
|
2012-08-21 00:13:32 +00:00
|
|
|
// Similar to ReadPixelsIntoImageSurface, but pulls from the screen
|
2012-08-21 23:13:26 +00:00
|
|
|
// instead of the currently bound framebuffer.
|
2012-08-21 00:13:32 +00:00
|
|
|
void ReadScreenIntoImageSurface(gfxImageSurface* dest);
|
|
|
|
|
2010-09-21 19:41:24 +00: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-12-17 07:23:07 +00: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 aSurface Surface to upload.
|
2011-01-18 01:32:40 +00:00
|
|
|
* \param aDstRegion Region of texture to upload to.
|
2010-12-17 07:23:07 +00:00
|
|
|
* \param aTexture Texture to use, or 0 to have one created for you.
|
|
|
|
* \param aOverwrite Over an existing texture with a new one.
|
2011-01-18 01:32:40 +00:00
|
|
|
* \param aSrcPoint Offset into aSrc where the region's bound's
|
|
|
|
* TopLeft() sits.
|
2010-12-17 07:49:42 +00:00
|
|
|
* \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.
|
2012-04-04 05:56:22 +00:00
|
|
|
* \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.
|
2010-12-17 07:23:07 +00:00
|
|
|
* \return Shader program needed to render this texture.
|
|
|
|
*/
|
|
|
|
ShaderProgramType UploadSurfaceToTexture(gfxASurface *aSurface,
|
2011-01-18 01:32:40 +00:00
|
|
|
const nsIntRegion& aDstRegion,
|
2010-12-17 07:23:07 +00:00
|
|
|
GLuint& aTexture,
|
|
|
|
bool aOverwrite = false,
|
2011-01-18 01:32:40 +00:00
|
|
|
const nsIntPoint& aSrcPoint = nsIntPoint(0, 0),
|
2012-04-04 05:56:22 +00:00
|
|
|
bool aPixelBuffer = false,
|
|
|
|
GLenum aTextureUnit = LOCAL_GL_TEXTURE0);
|
2010-12-17 07:23:07 +00:00
|
|
|
|
2011-07-25 07:32:56 +00: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);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2011-11-08 15:51:44 +00: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);
|
|
|
|
|
|
|
|
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-11-12 20:02:17 +00:00
|
|
|
/** Helper for DecomposeIntoNoRepeatTriangles
|
|
|
|
*/
|
|
|
|
struct RectTriangles {
|
2011-05-19 10:53:02 +00:00
|
|
|
RectTriangles() { }
|
2010-11-12 20:02:17 +00:00
|
|
|
|
2012-02-29 22:15:12 +00: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.
|
2010-11-12 20:02:17 +00:00
|
|
|
void addRect(GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1,
|
2012-02-29 22:15:12 +00:00
|
|
|
GLfloat tx0, GLfloat ty0, GLfloat tx1, GLfloat ty1,
|
|
|
|
bool flip_y = false);
|
2010-11-12 20:02:17 +00:00
|
|
|
|
2011-05-19 10:53:02 +00:00
|
|
|
/**
|
|
|
|
* these return a float pointer to the start of each array respectively.
|
|
|
|
* Use it for glVertexAttribPointer calls.
|
|
|
|
* We can return NULL if we choose to use Vertex Buffer Objects here.
|
|
|
|
*/
|
|
|
|
float* vertexPointer() {
|
|
|
|
return &vertexCoords[0].x;
|
2012-07-16 14:59:59 +00:00
|
|
|
}
|
2011-05-19 10:53:02 +00:00
|
|
|
|
|
|
|
float* texCoordPointer() {
|
|
|
|
return &texCoords[0].u;
|
2012-07-16 14:59:59 +00:00
|
|
|
}
|
2011-05-19 10:53:02 +00:00
|
|
|
|
|
|
|
unsigned int elements() {
|
|
|
|
return vertexCoords.Length();
|
2012-07-16 14:59:59 +00:00
|
|
|
}
|
2011-05-19 10:53:02 +00: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-11-12 20:02:17 +00: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
|
2012-02-29 22:15:12 +00:00
|
|
|
* we don't have to use the REPEAT wrap mode. If aFlipY is true, the
|
|
|
|
* texture coordinates will be specified vertically flipped.
|
2010-11-12 20:02:17 +00:00
|
|
|
*
|
|
|
|
* 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,
|
2012-02-29 22:15:12 +00:00
|
|
|
RectTriangles& aRects,
|
|
|
|
bool aFlipY = false);
|
2010-11-12 20:02:17 +00:00
|
|
|
|
2012-06-12 21:39:18 +00:00
|
|
|
|
2010-08-07 05:09:18 +00: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.
|
|
|
|
*/
|
|
|
|
enum GLExtensions {
|
|
|
|
EXT_framebuffer_object,
|
|
|
|
ARB_framebuffer_object,
|
2010-08-07 05:09:18 +00:00
|
|
|
ARB_texture_rectangle,
|
2010-08-07 05:09:18 +00:00
|
|
|
EXT_bgra,
|
|
|
|
EXT_texture_format_BGRA8888,
|
|
|
|
OES_depth24,
|
|
|
|
OES_depth32,
|
|
|
|
OES_stencil8,
|
|
|
|
OES_texture_npot,
|
|
|
|
OES_depth_texture,
|
|
|
|
OES_packed_depth_stencil,
|
|
|
|
IMG_read_format,
|
|
|
|
EXT_read_format_bgra,
|
2010-11-11 20:31:23 +00:00
|
|
|
APPLE_client_storage,
|
2010-11-12 20:02:20 +00:00
|
|
|
ARB_texture_non_power_of_two,
|
2010-12-17 07:49:42 +00:00
|
|
|
ARB_pixel_buffer_object,
|
2011-02-11 23:11:30 +00:00
|
|
|
ARB_ES2_compatibility,
|
2011-08-15 19:53:02 +00:00
|
|
|
OES_texture_float,
|
|
|
|
ARB_texture_float,
|
2011-09-09 09:41:11 +00:00
|
|
|
EXT_unpack_subimage,
|
2011-10-01 04:45:50 +00:00
|
|
|
OES_standard_derivatives,
|
2012-02-23 13:43:57 +00:00
|
|
|
EXT_texture_filter_anisotropic,
|
2012-05-08 17:29:31 +00:00
|
|
|
EXT_texture_compression_s3tc,
|
2012-06-15 03:16:21 +00:00
|
|
|
EXT_texture_compression_dxt1,
|
|
|
|
ANGLE_texture_compression_dxt3,
|
|
|
|
ANGLE_texture_compression_dxt5,
|
2012-09-25 12:49:28 +00:00
|
|
|
AMD_compressed_ATC_texture,
|
2012-09-25 12:49:28 +00:00
|
|
|
IMG_texture_compression_pvrtc,
|
2011-10-19 19:09:57 +00:00
|
|
|
EXT_framebuffer_blit,
|
|
|
|
ANGLE_framebuffer_blit,
|
2011-10-19 19:09:57 +00:00
|
|
|
EXT_framebuffer_multisample,
|
|
|
|
ANGLE_framebuffer_multisample,
|
2011-10-19 19:09:57 +00:00
|
|
|
OES_rgb8_rgba8,
|
2011-10-26 20:00:44 +00:00
|
|
|
ARB_robustness,
|
2011-12-15 00:57:09 +00:00
|
|
|
EXT_robustness,
|
2012-04-06 23:57:55 +00:00
|
|
|
ARB_sync,
|
2012-06-12 21:36:10 +00:00
|
|
|
OES_EGL_image,
|
2012-06-12 21:39:43 +00:00
|
|
|
OES_EGL_sync,
|
2012-07-20 04:14:14 +00:00
|
|
|
OES_EGL_image_external,
|
2012-08-14 01:17:55 +00:00
|
|
|
EXT_packed_depth_stencil,
|
2010-08-07 05:09:18 +00:00
|
|
|
Extensions_Max
|
|
|
|
};
|
|
|
|
|
2012-10-03 21:13:05 +00:00
|
|
|
bool IsExtensionSupported(GLExtensions aKnownExtension) const {
|
2010-08-07 05:09:18 +00:00
|
|
|
return mAvailableExtensions[aKnownExtension];
|
|
|
|
}
|
|
|
|
|
2012-04-05 01:44:55 +00:00
|
|
|
void MarkExtensionUnsupported(GLExtensions aKnownExtension) {
|
|
|
|
mAvailableExtensions[aKnownExtension] = 0;
|
|
|
|
}
|
2011-05-20 19:53:53 +00:00
|
|
|
|
2010-11-10 15:49:52 +00:00
|
|
|
// Shared code for GL extensions and GLX extensions.
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool ListHasExtension(const GLubyte *extensions,
|
2012-04-05 01:44:55 +00:00
|
|
|
const char *extension);
|
2010-11-10 15:49:52 +00:00
|
|
|
|
2011-10-26 21:36:18 +00:00
|
|
|
GLint GetMaxTextureImageSize() { return mMaxTextureImageSize; }
|
2011-09-29 06:19:26 +00:00
|
|
|
void SetFlipped(bool aFlipped) { mFlipped = aFlipped; }
|
2010-12-17 07:19:28 +00:00
|
|
|
|
2011-05-20 19:53:53 +00:00
|
|
|
// this should just be a std::bitset, but that ended up breaking
|
|
|
|
// MacOS X builds; see bug 584919. We can replace this with one
|
|
|
|
// later on. This is handy to use in WebGL contexts as well,
|
|
|
|
// so making it public.
|
2012-06-12 21:39:18 +00:00
|
|
|
template<size_t Size>
|
2011-05-20 19:53:53 +00:00
|
|
|
struct ExtensionBitset {
|
|
|
|
ExtensionBitset() {
|
2012-06-12 21:39:18 +00:00
|
|
|
for (size_t i = 0; i < Size; ++i)
|
|
|
|
extensions[i] = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Load(const char* extStr, const char** extList, bool verbose = false) {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; extList[i]; ++i) {
|
|
|
|
if (strcmp(cur, extList[i]) == 0) {
|
|
|
|
if (verbose)
|
|
|
|
printf_stderr("Found extension %s\n", cur);
|
|
|
|
extensions[i] = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
cur = space + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
free(exts);
|
2011-05-20 19:53:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool& operator[](size_t index) {
|
2012-06-12 21:39:18 +00:00
|
|
|
MOZ_ASSERT(index < Size, "out of range");
|
|
|
|
return extensions[index];
|
2011-05-20 19:53:53 +00:00
|
|
|
}
|
|
|
|
|
2012-10-03 21:13:05 +00:00
|
|
|
const bool& operator[](size_t index) const {
|
|
|
|
MOZ_ASSERT(index < Size, "out of range");
|
|
|
|
return extensions[index];
|
|
|
|
}
|
|
|
|
|
2012-06-12 21:39:18 +00:00
|
|
|
bool extensions[Size];
|
2011-05-20 19:53:53 +00:00
|
|
|
};
|
|
|
|
|
2012-06-12 21:39:18 +00:00
|
|
|
protected:
|
|
|
|
ExtensionBitset<Extensions_Max> mAvailableExtensions;
|
|
|
|
|
|
|
|
public:
|
2011-10-26 20:00:44 +00:00
|
|
|
/**
|
|
|
|
* 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,
|
2011-11-29 14:10:44 +00:00
|
|
|
CONTEXT_UNKNOWN_CONTEXT_RESET_ARB = 0x8255
|
2011-10-26 20:00:44 +00:00
|
|
|
};
|
|
|
|
|
2011-11-19 03:57:29 +00:00
|
|
|
bool HasRobustness() {
|
|
|
|
return mHasRobustness;
|
|
|
|
}
|
|
|
|
|
2010-04-27 02:09:44 +00:00
|
|
|
protected:
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mInitialized;
|
|
|
|
bool mIsOffscreen;
|
|
|
|
bool mIsGLES2;
|
|
|
|
bool mIsGlobalSharedContext;
|
2011-10-26 20:00:44 +00:00
|
|
|
bool mHasRobustness;
|
2011-12-03 07:52:35 +00:00
|
|
|
bool mContextLost;
|
2010-09-21 19:41:24 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t mVendor;
|
|
|
|
int32_t mRenderer;
|
2010-10-06 20:43:14 +00:00
|
|
|
|
2012-02-09 19:05:11 +00:00
|
|
|
public:
|
2010-10-12 21:01:59 +00:00
|
|
|
enum {
|
|
|
|
DebugEnabled = 1 << 0,
|
|
|
|
DebugTrace = 1 << 1,
|
|
|
|
DebugAbortOnError = 1 << 2
|
|
|
|
};
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
static uint32_t sDebugMode;
|
2010-10-12 21:01:59 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
static uint32_t DebugMode() {
|
2011-12-16 22:24:46 +00:00
|
|
|
#ifdef DEBUG
|
2012-02-09 19:05:11 +00:00
|
|
|
return sDebugMode;
|
2011-12-16 22:24:46 +00:00
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2012-02-09 19:05:11 +00:00
|
|
|
protected:
|
|
|
|
|
2010-07-28 21:24:09 +00:00
|
|
|
ContextFormat mCreationFormat;
|
2010-07-19 05:01:14 +00:00
|
|
|
nsRefPtr<GLContext> mSharedContext;
|
|
|
|
|
2012-04-10 20:20:02 +00:00
|
|
|
// The thread on which this context was created.
|
|
|
|
nsCOMPtr<nsIThread> mOwningThread;
|
|
|
|
|
2010-10-12 21:01:59 +00:00
|
|
|
GLContextSymbols mSymbols;
|
|
|
|
|
2012-05-12 23:23:56 +00: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.
|
2012-08-22 15:56:38 +00:00
|
|
|
static unsigned sCurrentGLContextTLS;
|
2012-05-12 23:23:56 +00:00
|
|
|
#endif
|
|
|
|
|
2010-07-19 05:01:14 +00:00
|
|
|
void UpdateActualFormat();
|
|
|
|
ContextFormat mActualFormat;
|
|
|
|
|
|
|
|
gfxIntSize mOffscreenSize;
|
|
|
|
gfxIntSize mOffscreenActualSize;
|
|
|
|
GLuint mOffscreenTexture;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mFlipped;
|
2010-07-19 05:01:14 +00:00
|
|
|
|
2010-09-21 19:41:24 +00:00
|
|
|
// lazy-initialized things
|
|
|
|
GLuint mBlitProgram, mBlitFramebuffer;
|
|
|
|
void UseBlitProgram();
|
|
|
|
void SetBlitFramebufferForDestTexture(GLuint aTexture);
|
|
|
|
|
2011-12-19 23:47:54 +00:00
|
|
|
// Helper to create/resize an offscreen FBO,
|
2010-07-19 05:01:14 +00:00
|
|
|
// for offscreen implementations that use FBOs.
|
2011-12-19 23:47:54 +00:00
|
|
|
// Note that it does -not- clear the resized buffers.
|
2012-04-25 14:10:43 +00:00
|
|
|
bool ResizeOffscreenFBOs(const ContextFormat& aCF, const gfxIntSize& aSize, const bool aNeedsReadBuffer);
|
|
|
|
bool ResizeOffscreenFBOs(const gfxIntSize& aSize, const bool aNeedsReadBuffer) {
|
|
|
|
if (!IsOffscreenSizeAllowed(aSize))
|
2011-10-19 19:09:57 +00:00
|
|
|
return false;
|
2011-10-21 03:41:02 +00:00
|
|
|
|
2012-04-25 14:10:43 +00:00
|
|
|
ContextFormat format(mCreationFormat);
|
|
|
|
|
|
|
|
if (format.samples) {
|
|
|
|
// AA path
|
|
|
|
if (ResizeOffscreenFBOs(format, aSize, aNeedsReadBuffer))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
NS_WARNING("ResizeOffscreenFBOs failed to resize an AA context! Falling back to no AA...");
|
|
|
|
format.samples = 0;
|
2011-10-21 03:41:02 +00:00
|
|
|
}
|
|
|
|
|
2012-04-25 14:10:43 +00:00
|
|
|
if (ResizeOffscreenFBOs(format, aSize, aNeedsReadBuffer))
|
2012-03-12 22:10:38 +00:00
|
|
|
return true;
|
|
|
|
|
2012-04-25 14:10:43 +00:00
|
|
|
NS_WARNING("ResizeOffscreenFBOs failed to resize non-AA context!");
|
2012-03-12 22:10:38 +00:00
|
|
|
return false;
|
2011-10-19 19:09:57 +00:00
|
|
|
}
|
2012-03-12 22:10:38 +00:00
|
|
|
|
2012-04-25 14:10:43 +00:00
|
|
|
struct GLFormats {
|
|
|
|
GLFormats()
|
|
|
|
: texColor(0)
|
|
|
|
, texColorType(0)
|
|
|
|
, rbColor(0)
|
|
|
|
, depthStencil(0)
|
|
|
|
, depth(0)
|
|
|
|
, stencil(0)
|
|
|
|
, samples(0)
|
|
|
|
{}
|
|
|
|
|
|
|
|
GLenum texColor;
|
|
|
|
GLenum texColorType;
|
|
|
|
GLenum rbColor;
|
|
|
|
GLenum depthStencil;
|
|
|
|
GLenum depth;
|
|
|
|
GLenum stencil;
|
|
|
|
GLsizei samples;
|
|
|
|
};
|
|
|
|
|
2012-07-15 15:11:17 +00:00
|
|
|
enum ColorByteOrder {
|
|
|
|
ForceRGBA,
|
|
|
|
DefaultByteOrder
|
|
|
|
};
|
|
|
|
|
|
|
|
GLFormats ChooseGLFormats(ContextFormat& aCF, GLContext::ColorByteOrder aByteOrder = GLContext::DefaultByteOrder);
|
2012-04-25 14:10:43 +00:00
|
|
|
void CreateTextureForOffscreen(const GLFormats& aFormats, const gfxIntSize& aSize,
|
|
|
|
GLuint& texture);
|
|
|
|
void CreateRenderbuffersForOffscreen(const GLContext::GLFormats& aFormats, const gfxIntSize& aSize,
|
|
|
|
GLuint& colorMSRB, GLuint& depthRB, GLuint& stencilRB);
|
|
|
|
bool AssembleOffscreenFBOs(const GLuint colorMSRB,
|
|
|
|
const GLuint depthRB,
|
|
|
|
const GLuint stencilRB,
|
|
|
|
const GLuint texture,
|
|
|
|
GLuint& drawFBO,
|
|
|
|
GLuint& readFBO);
|
|
|
|
|
|
|
|
void DeleteOffscreenFBOs();
|
2012-03-12 22:10:38 +00:00
|
|
|
|
2011-10-19 19:09:57 +00:00
|
|
|
GLuint mOffscreenDrawFBO;
|
|
|
|
GLuint mOffscreenReadFBO;
|
2011-10-19 19:09:57 +00:00
|
|
|
GLuint mOffscreenColorRB;
|
2010-07-19 05:01:14 +00:00
|
|
|
GLuint mOffscreenDepthRB;
|
|
|
|
GLuint mOffscreenStencilRB;
|
|
|
|
|
|
|
|
// Clear to transparent black, with 0 depth and stencil,
|
|
|
|
// while preserving current ClearColor etc. values.
|
|
|
|
// Useful for resizing offscreen buffers.
|
2011-12-19 23:47:54 +00:00
|
|
|
public:
|
2010-07-19 05:01:14 +00:00
|
|
|
void ClearSafely();
|
2010-04-27 02:09:44 +00:00
|
|
|
|
2012-04-10 15:49:10 +00:00
|
|
|
bool WorkAroundDriverBugs() const { return mWorkAroundDriverBugs; }
|
|
|
|
|
2011-12-19 23:47:54 +00:00
|
|
|
protected:
|
|
|
|
|
2012-03-21 18:07:31 +00:00
|
|
|
nsDataHashtable<nsPtrHashKey<void>, void*> mUserData;
|
2010-04-27 02:09:44 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
void SetIsGLES2(bool aIsGLES2) {
|
2010-07-28 21:24:09 +00:00
|
|
|
NS_ASSERTION(!mInitialized, "SetIsGLES2 can only be called before initialization!");
|
|
|
|
mIsGLES2 = aIsGLES2;
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool InitWithPrefix(const char *prefix, bool trygl);
|
2010-04-27 02:09:44 +00:00
|
|
|
|
2010-08-07 05:09:18 +00:00
|
|
|
void InitExtensions();
|
2010-06-15 06:55:08 +00:00
|
|
|
|
2010-07-01 16:30:38 +00:00
|
|
|
virtual already_AddRefed<TextureImage>
|
|
|
|
CreateBasicTextureImage(GLuint aTexture,
|
|
|
|
const nsIntSize& aSize,
|
2010-11-12 20:02:20 +00:00
|
|
|
GLenum aWrapMode,
|
2010-07-01 16:30:38 +00:00
|
|
|
TextureImage::ContentType aContentType,
|
2012-05-09 20:55:31 +00:00
|
|
|
GLContext* aContext,
|
2012-11-26 22:23:27 +00:00
|
|
|
TextureImage::Flags aFlags = TextureImage::NoFlags);
|
2010-07-01 16:30:38 +00:00
|
|
|
|
2011-05-20 19:53:53 +00:00
|
|
|
bool IsOffscreenSizeAllowed(const gfxIntSize& aSize) const {
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t biggerDimension = NS_MAX(aSize.width, aSize.height);
|
|
|
|
int32_t maxAllowed = NS_MIN(mMaxRenderbufferSize, mMaxTextureSize);
|
2011-05-20 19:53:53 +00:00
|
|
|
return biggerDimension <= maxAllowed;
|
|
|
|
}
|
|
|
|
|
2010-10-12 21:01:59 +00:00
|
|
|
nsTArray<nsIntRect> mViewportStack;
|
|
|
|
nsTArray<nsIntRect> mScissorStack;
|
|
|
|
|
2010-12-17 07:19:28 +00:00
|
|
|
GLint mMaxTextureSize;
|
2012-03-26 16:15:53 +00:00
|
|
|
GLint mMaxCubeMapTextureSize;
|
2011-10-26 21:36:18 +00:00
|
|
|
GLint mMaxTextureImageSize;
|
2011-05-20 19:53:53 +00:00
|
|
|
GLint mMaxRenderbufferSize;
|
2012-11-26 23:21:39 +00:00
|
|
|
bool mNeedsTextureSizeChecks;
|
2012-04-10 15:49:10 +00:00
|
|
|
bool mWorkAroundDriverBugs;
|
2010-12-17 07:19:28 +00:00
|
|
|
|
2012-03-26 16:15:53 +00:00
|
|
|
bool IsTextureSizeSafeToPassToDriver(GLenum target, GLsizei width, GLsizei height) const {
|
2012-11-26 23:21:39 +00:00
|
|
|
if (mNeedsTextureSizeChecks) {
|
|
|
|
// some drivers incorrectly handle some large texture sizes that are below the
|
2012-03-26 16:15:53 +00:00
|
|
|
// max texture size that they report. So we check ourselves against our own values
|
|
|
|
// (mMax[CubeMap]TextureSize).
|
2012-11-26 23:21:39 +00:00
|
|
|
// see bug 737182 for Mac Intel 2D textures
|
|
|
|
// see bug 684882 for Mac Intel cube map textures
|
|
|
|
// see bug 814716 for Mesa Nouveau
|
2012-03-26 16:15:53 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2010-04-27 02:09:44 +00:00
|
|
|
public:
|
2011-07-08 00:01:16 +00: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();
|
|
|
|
|
|
|
|
if (error) {
|
|
|
|
// clear all pending errors
|
|
|
|
while(fGetError()) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
2010-08-07 05:09:18 +00:00
|
|
|
|
2010-10-12 21:01:59 +00: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
|
|
|
|
|
|
|
|
protected:
|
|
|
|
GLenum mGLError;
|
|
|
|
|
|
|
|
public:
|
2011-07-08 00:01:16 +00:00
|
|
|
|
2010-10-12 21:01:59 +00:00
|
|
|
void BeforeGLCall(const char* glFunction) {
|
2011-12-16 22:24:46 +00:00
|
|
|
if (DebugMode()) {
|
2012-05-12 23:23:56 +00:00
|
|
|
GLContext *currentGLContext = NULL;
|
|
|
|
|
|
|
|
currentGLContext = (GLContext*)PR_GetThreadPrivate(sCurrentGLContextTLS);
|
|
|
|
|
2011-12-16 22:24:46 +00:00
|
|
|
if (DebugMode() & DebugTrace)
|
2010-10-12 21:01:59 +00:00
|
|
|
printf_stderr("[gl:%p] > %s\n", this, glFunction);
|
2012-05-12 23:23:56 +00:00
|
|
|
if (this != currentGLContext) {
|
2010-10-12 21:01:59 +00:00
|
|
|
printf_stderr("Fatal: %s called on non-current context %p. "
|
|
|
|
"The current context for this thread is %p.\n",
|
2012-05-12 23:23:56 +00:00
|
|
|
glFunction, this, currentGLContext);
|
2010-10-12 21:01:59 +00:00
|
|
|
NS_ABORT();
|
|
|
|
}
|
2010-07-28 21:24:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-12 21:01:59 +00:00
|
|
|
void AfterGLCall(const char* glFunction) {
|
2011-12-16 22:24:46 +00:00
|
|
|
if (DebugMode()) {
|
2010-10-12 21:01:59 +00:00
|
|
|
// 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();
|
2011-12-16 22:24:46 +00:00
|
|
|
if (DebugMode() & DebugTrace)
|
2010-10-12 21:01:59 +00:00
|
|
|
printf_stderr("[gl:%p] < %s [0x%04x]\n", this, glFunction, mGLError);
|
|
|
|
if (mGLError != LOCAL_GL_NO_ERROR) {
|
2011-04-18 22:47:40 +00:00
|
|
|
printf_stderr("GL ERROR: %s generated GL error %s(0x%04x)\n",
|
|
|
|
glFunction,
|
|
|
|
GLErrorToString(mGLError),
|
|
|
|
mGLError);
|
2011-12-16 22:24:46 +00:00
|
|
|
if (DebugMode() & DebugAbortOnError)
|
2010-10-12 21:01:59 +00:00
|
|
|
NS_ABORT();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-18 22:47:40 +00:00
|
|
|
const char* GLErrorToString(GLenum aError)
|
|
|
|
{
|
|
|
|
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";
|
|
|
|
default:
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-12 21:01:59 +00:00
|
|
|
#define BEFORE_GL_CALL do { \
|
|
|
|
BeforeGLCall(MOZ_FUNCTION_NAME); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define AFTER_GL_CALL do { \
|
|
|
|
AfterGLCall(MOZ_FUNCTION_NAME); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define BEFORE_GL_CALL do { } while (0)
|
|
|
|
#define AFTER_GL_CALL do { } while (0)
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2012-12-19 07:16:01 +00:00
|
|
|
#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)
|
|
|
|
|
2010-10-12 21:01:59 +00:00
|
|
|
/*** In GL debug mode, we completely override glGetError ***/
|
|
|
|
|
|
|
|
GLenum fGetError() {
|
|
|
|
#ifdef DEBUG
|
|
|
|
// debug mode ends up eating the error in AFTER_GL_CALL
|
2011-12-16 22:24:46 +00:00
|
|
|
if (DebugMode()) {
|
2010-10-12 21:01:59 +00:00
|
|
|
GLenum err = mGLError;
|
|
|
|
mGLError = LOCAL_GL_NO_ERROR;
|
|
|
|
return err;
|
2010-07-28 21:24:09 +00:00
|
|
|
}
|
2010-10-12 21:01:59 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return mSymbols.fGetError();
|
2010-07-28 21:24:09 +00:00
|
|
|
}
|
|
|
|
|
2010-10-12 21:01:59 +00:00
|
|
|
|
|
|
|
/*** Scissor functions ***/
|
|
|
|
|
|
|
|
protected:
|
2011-02-25 07:44:18 +00:00
|
|
|
GLint FixYValue(GLint y, GLint height)
|
|
|
|
{
|
2012-12-19 07:16:01 +00:00
|
|
|
MOZ_ASSERT( !(mIsOffscreen && mFlipped) );
|
2011-02-25 07:44:18 +00:00
|
|
|
return mFlipped ? ViewportRect().height - (height + y) : y;
|
|
|
|
}
|
|
|
|
|
2010-10-12 21:01:59 +00:00
|
|
|
public:
|
2010-09-21 19:41:24 +00:00
|
|
|
void fScissor(GLint x, GLint y, GLsizei width, GLsizei height) {
|
|
|
|
ScissorRect().SetRect(x, y, width, height);
|
2012-12-19 07:16:01 +00: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);
|
2010-10-12 21:01:59 +00:00
|
|
|
raw_fScissor(x, y, width, height);
|
2010-09-21 19:41:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsIntRect& ScissorRect() {
|
|
|
|
return mScissorStack[mScissorStack.Length()-1];
|
|
|
|
}
|
|
|
|
|
|
|
|
void PushScissorRect() {
|
2010-10-15 19:32:51 +00:00
|
|
|
nsIntRect copy(ScissorRect());
|
|
|
|
mScissorStack.AppendElement(copy);
|
2010-09-21 19:41:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PushScissorRect(const nsIntRect& aRect) {
|
|
|
|
mScissorStack.AppendElement(aRect);
|
2013-01-03 02:11:54 +00:00
|
|
|
fScissor(aRect.x, aRect.y, aRect.width, aRect.height);
|
2010-09-21 19:41:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PopScissorRect() {
|
|
|
|
if (mScissorStack.Length() < 2) {
|
|
|
|
NS_WARNING("PopScissorRect with Length < 2!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIntRect thisRect = ScissorRect();
|
|
|
|
mScissorStack.TruncateLength(mScissorStack.Length() - 1);
|
2011-04-19 03:07:23 +00:00
|
|
|
if (!thisRect.IsEqualInterior(ScissorRect())) {
|
2013-01-03 02:11:54 +00:00
|
|
|
fScissor(ScissorRect().x, ScissorRect().y,
|
|
|
|
ScissorRect().width, ScissorRect().height);
|
2010-09-21 19:41:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-12 21:01:59 +00:00
|
|
|
/*** Viewport functions ***/
|
|
|
|
|
2012-12-19 07:16:01 +00:00
|
|
|
private:
|
2010-10-12 21:01:59 +00:00
|
|
|
// only does the glViewport call, no ViewportRect business
|
|
|
|
void raw_fViewport(GLint x, GLint y, GLsizei width, GLsizei height) {
|
|
|
|
BEFORE_GL_CALL;
|
2011-02-25 07:44:18 +00: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");
|
2010-10-12 21:01:59 +00:00
|
|
|
mSymbols.fViewport(x, y, width, height);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2010-09-21 19:41:24 +00:00
|
|
|
void fViewport(GLint x, GLint y, GLsizei width, GLsizei height) {
|
|
|
|
ViewportRect().SetRect(x, y, width, height);
|
2010-10-12 21:01:59 +00:00
|
|
|
raw_fViewport(x, y, width, height);
|
2010-09-21 19:41:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsIntRect& ViewportRect() {
|
|
|
|
return mViewportStack[mViewportStack.Length()-1];
|
|
|
|
}
|
|
|
|
|
|
|
|
void PushViewportRect() {
|
2010-10-15 19:32:51 +00:00
|
|
|
nsIntRect copy(ViewportRect());
|
|
|
|
mViewportStack.AppendElement(copy);
|
2010-09-21 19:41:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PushViewportRect(const nsIntRect& aRect) {
|
|
|
|
mViewportStack.AppendElement(aRect);
|
2010-10-12 21:01:59 +00:00
|
|
|
raw_fViewport(aRect.x, aRect.y, aRect.width, aRect.height);
|
2010-09-21 19:41:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PopViewportRect() {
|
|
|
|
if (mViewportStack.Length() < 2) {
|
|
|
|
NS_WARNING("PopViewportRect with Length < 2!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIntRect thisRect = ViewportRect();
|
|
|
|
mViewportStack.TruncateLength(mViewportStack.Length() - 1);
|
2011-04-19 03:07:23 +00:00
|
|
|
if (!thisRect.IsEqualInterior(ViewportRect())) {
|
2010-10-12 21:01:59 +00:00
|
|
|
raw_fViewport(ViewportRect().x, ViewportRect().y,
|
|
|
|
ViewportRect().width, ViewportRect().height);
|
2010-09-21 19:41:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-12 21:01:59 +00:00
|
|
|
/*** other GL functions ***/
|
2010-09-21 19:41:24 +00:00
|
|
|
|
2010-10-12 21:01:59 +00:00
|
|
|
void fActiveTexture(GLenum texture) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fActiveTexture(texture);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-09-21 19:41:24 +00:00
|
|
|
|
2010-10-12 21:01:59 +00:00
|
|
|
void fAttachShader(GLuint program, GLuint shader) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fAttachShader(program, shader);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-09-21 19:41:24 +00:00
|
|
|
|
2010-10-12 21:01:59 +00:00
|
|
|
void fBindAttribLocation(GLuint program, GLuint index, const GLchar* name) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fBindAttribLocation(program, index, name);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-09-21 19:41:24 +00:00
|
|
|
|
2010-10-12 21:01:59 +00:00
|
|
|
void fBindBuffer(GLenum target, GLuint buffer) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fBindBuffer(target, buffer);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-07-19 05:01:14 +00:00
|
|
|
|
2010-10-12 21:01:59 +00:00
|
|
|
void fBindTexture(GLenum target, GLuint texture) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fBindTexture(target, texture);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-07-19 05:01:14 +00:00
|
|
|
|
2010-10-12 21:01:59 +00:00
|
|
|
void fBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fBlendColor(red, green, blue, alpha);
|
|
|
|
AFTER_GL_CALL;
|
2010-07-19 05:01:14 +00:00
|
|
|
}
|
|
|
|
|
2010-10-12 21:01:59 +00:00
|
|
|
void fBlendEquation(GLenum mode) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fBlendEquation(mode);
|
|
|
|
AFTER_GL_CALL;
|
2010-07-19 05:01:14 +00:00
|
|
|
}
|
|
|
|
|
2010-10-12 21:01:59 +00:00
|
|
|
void fBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fBlendEquationSeparate(modeRGB, modeAlpha);
|
|
|
|
AFTER_GL_CALL;
|
2010-07-19 05:01:14 +00:00
|
|
|
}
|
|
|
|
|
2010-10-12 21:01:59 +00:00
|
|
|
void fBlendFunc(GLenum sfactor, GLenum dfactor) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fBlendFunc(sfactor, dfactor);
|
|
|
|
AFTER_GL_CALL;
|
2010-07-19 05:01:14 +00:00
|
|
|
}
|
|
|
|
|
2010-10-12 21:01:59 +00:00
|
|
|
void fBlendFuncSeparate(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fBlendFuncSeparate(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha);
|
|
|
|
AFTER_GL_CALL;
|
2010-07-19 05:01:14 +00:00
|
|
|
}
|
|
|
|
|
2012-12-19 07:16:01 +00:00
|
|
|
private:
|
|
|
|
void raw_fBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage) {
|
2010-10-12 21:01:59 +00:00
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fBufferData(target, size, data, usage);
|
2012-12-19 07:16:01 +00:00
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
void fBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage) {
|
|
|
|
raw_fBufferData(target, size, data, usage);
|
2012-04-16 19:56:12 +00:00
|
|
|
|
|
|
|
// bug 744888
|
|
|
|
if (WorkAroundDriverBugs() &&
|
|
|
|
!data &&
|
|
|
|
Vendor() == VendorNVIDIA)
|
|
|
|
{
|
|
|
|
char c = 0;
|
2012-12-19 07:16:01 +00:00
|
|
|
fBufferSubData(target, size-1, 1, &c);
|
2012-04-16 19:56:12 +00:00
|
|
|
}
|
2010-07-19 05:01:14 +00:00
|
|
|
}
|
|
|
|
|
2010-10-12 21:01:59 +00:00
|
|
|
void fBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fBufferSubData(target, offset, size, data);
|
|
|
|
AFTER_GL_CALL;
|
2010-07-19 05:01:14 +00:00
|
|
|
}
|
|
|
|
|
2012-12-19 07:16:01 +00:00
|
|
|
private:
|
2011-10-19 19:09:57 +00:00
|
|
|
void raw_fClear(GLbitfield mask) {
|
2010-10-12 21:01:59 +00:00
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fClear(mask);
|
|
|
|
AFTER_GL_CALL;
|
2010-07-19 05:01:14 +00:00
|
|
|
}
|
|
|
|
|
2012-12-19 07:16:01 +00:00
|
|
|
public:
|
2010-10-12 21:01:59 +00:00
|
|
|
void fClearColor(GLclampf r, GLclampf g, GLclampf b, GLclampf a) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fClearColor(r, g, b, a);
|
|
|
|
AFTER_GL_CALL;
|
2010-07-19 05:01:14 +00:00
|
|
|
}
|
|
|
|
|
2010-10-12 21:01:59 +00:00
|
|
|
void fClearStencil(GLint s) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fClearStencil(s);
|
|
|
|
AFTER_GL_CALL;
|
2010-07-19 05:01:14 +00:00
|
|
|
}
|
|
|
|
|
2010-10-12 21:01:59 +00:00
|
|
|
void fColorMask(realGLboolean red, realGLboolean green, realGLboolean blue, realGLboolean alpha) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fColorMask(red, green, blue, alpha);
|
2012-05-08 17:29:31 +00:00
|
|
|
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);
|
2010-10-12 21:01:59 +00:00
|
|
|
AFTER_GL_CALL;
|
2010-07-19 05:01:14 +00:00
|
|
|
}
|
|
|
|
|
2010-10-12 21:01:59 +00:00
|
|
|
void fCullFace(GLenum mode) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fCullFace(mode);
|
|
|
|
AFTER_GL_CALL;
|
2010-07-19 05:01:14 +00:00
|
|
|
}
|
2010-10-12 21:01:59 +00:00
|
|
|
|
|
|
|
void fDetachShader(GLuint program, GLuint shader) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fDetachShader(program, shader);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fDepthFunc(GLenum func) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fDepthFunc(func);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fDepthMask(realGLboolean flag) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fDepthMask(flag);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fDisable(GLenum capability) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fDisable(capability);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fDisableVertexAttribArray(GLuint index) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fDisableVertexAttribArray(index);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
2012-12-19 07:16:01 +00:00
|
|
|
private:
|
2011-10-19 19:09:57 +00:00
|
|
|
void raw_fDrawArrays(GLenum mode, GLint first, GLsizei count) {
|
2010-10-12 21:01:59 +00:00
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fDrawArrays(mode, first, count);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
2011-10-19 19:09:57 +00:00
|
|
|
void raw_fDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) {
|
2010-10-12 21:01:59 +00:00
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fDrawElements(mode, count, type, indices);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
2012-12-19 07:16:01 +00:00
|
|
|
public:
|
2010-10-12 21:01:59 +00:00
|
|
|
void fEnable(GLenum capability) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fEnable(capability);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fEnableVertexAttribArray(GLuint index) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fEnableVertexAttribArray(index);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
2012-07-06 23:38:16 +00:00
|
|
|
void fFinish() {
|
2010-10-12 21:01:59 +00:00
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fFinish();
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fFlush() {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fFlush();
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fFrontFace(GLenum face) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fFrontFace(face);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fGetAttachedShaders(GLuint program, GLsizei maxCount, GLsizei* count, GLuint* shaders) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fGetAttachedShaders(program, maxCount, count, shaders);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
GLint fGetAttribLocation (GLuint program, const GLchar* name) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
GLint retval = mSymbols.fGetAttribLocation(program, name);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2012-02-10 01:57:26 +00:00
|
|
|
private:
|
|
|
|
void raw_fGetIntegerv(GLenum pname, GLint *params) {
|
2010-10-12 21:01:59 +00:00
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fGetIntegerv(pname, params);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
2012-02-10 01:57:26 +00:00
|
|
|
public:
|
2012-08-22 03:30:20 +00:00
|
|
|
void GetUIntegerv(GLenum pname, GLuint *params) {
|
|
|
|
fGetIntegerv(pname, reinterpret_cast<GLint*>(params));
|
|
|
|
}
|
|
|
|
|
2010-10-12 21:01:59 +00:00
|
|
|
void fGetFloatv(GLenum pname, GLfloat *params) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fGetFloatv(pname, params);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fGetBooleanv(GLenum pname, realGLboolean *params) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fGetBooleanv(pname, params);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fGetBufferParameteriv(GLenum target, GLenum pname, GLint* params) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fGetBufferParameteriv(target, pname, params);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fGenerateMipmap(GLenum target) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fGenerateMipmap(target);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fGetProgramiv(GLuint program, GLenum pname, GLint* param) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fGetProgramiv(program, pname, param);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fGetProgramInfoLog(GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fGetProgramInfoLog(program, bufSize, length, infoLog);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fTexParameteri(GLenum target, GLenum pname, GLint param) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fTexParameteri(target, pname, param);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fTexParameterf(GLenum target, GLenum pname, GLfloat param) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fTexParameterf(target, pname, param);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
const GLubyte* fGetString(GLenum name) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
const GLubyte *result = mSymbols.fGetString(name);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-03-05 18:09:05 +00:00
|
|
|
void fGetTexImage(GLenum target, GLint level, GLenum format, GLenum type, GLvoid *img) {
|
|
|
|
BEFORE_GL_CALL;
|
2012-12-19 07:16:01 +00:00
|
|
|
ASSERT_SYMBOL_PRESENT(fGetTexImage);
|
2012-03-05 18:09:05 +00:00
|
|
|
mSymbols.fGetTexImage(target, level, format, type, img);
|
|
|
|
AFTER_GL_CALL;
|
2012-07-16 14:59:59 +00:00
|
|
|
}
|
2012-03-05 18:09:05 +00:00
|
|
|
|
|
|
|
void fGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint *params)
|
|
|
|
{
|
|
|
|
BEFORE_GL_CALL;
|
2012-12-19 07:16:01 +00:00
|
|
|
ASSERT_SYMBOL_PRESENT(fGetTexLevelParameteriv);
|
2012-03-05 18:09:05 +00:00
|
|
|
mSymbols.fGetTexLevelParameteriv(target, level, pname, params);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
2010-10-12 21:01:59 +00:00
|
|
|
void fGetTexParameterfv(GLenum target, GLenum pname, const GLfloat *params) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fGetTexParameterfv(target, pname, params);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fGetTexParameteriv(GLenum target, GLenum pname, const GLint *params) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fGetTexParameteriv(target, pname, params);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fGetUniformfv(GLuint program, GLint location, GLfloat* params) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fGetUniformfv(program, location, params);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fGetUniformiv(GLuint program, GLint location, GLint* params) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fGetUniformiv(program, location, params);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
GLint fGetUniformLocation (GLint programObj, const GLchar* name) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
GLint retval = mSymbols.fGetUniformLocation(programObj, name);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* retval) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fGetVertexAttribfv(index, pname, retval);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fGetVertexAttribiv(GLuint index, GLenum pname, GLint* retval) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fGetVertexAttribiv(index, pname, retval);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
2012-08-22 03:30:20 +00:00
|
|
|
void fGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** retval) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fGetVertexAttribPointerv(index, pname, retval);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
2010-10-12 21:01:59 +00:00
|
|
|
void fHint(GLenum target, GLenum mode) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fHint(target, mode);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
realGLboolean fIsBuffer(GLuint buffer) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
realGLboolean retval = mSymbols.fIsBuffer(buffer);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2012-12-19 07:16:01 +00:00
|
|
|
realGLboolean fIsEnabled(GLenum capability) {
|
2010-10-12 21:01:59 +00:00
|
|
|
BEFORE_GL_CALL;
|
|
|
|
realGLboolean retval = mSymbols.fIsEnabled(capability);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2012-12-19 07:16:01 +00:00
|
|
|
realGLboolean fIsProgram(GLuint program) {
|
2010-10-12 21:01:59 +00:00
|
|
|
BEFORE_GL_CALL;
|
|
|
|
realGLboolean retval = mSymbols.fIsProgram(program);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2012-12-19 07:16:01 +00:00
|
|
|
realGLboolean fIsShader(GLuint shader) {
|
2010-10-12 21:01:59 +00:00
|
|
|
BEFORE_GL_CALL;
|
|
|
|
realGLboolean retval = mSymbols.fIsShader(shader);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2012-12-19 07:16:01 +00:00
|
|
|
realGLboolean fIsTexture(GLuint texture) {
|
2010-10-12 21:01:59 +00:00
|
|
|
BEFORE_GL_CALL;
|
|
|
|
realGLboolean retval = mSymbols.fIsTexture(texture);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fLineWidth(GLfloat width) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fLineWidth(width);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fLinkProgram(GLuint program) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fLinkProgram(program);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fPixelStorei(GLenum pname, GLint param) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fPixelStorei(pname, param);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
2012-07-05 14:13:46 +00:00
|
|
|
void fPointParameterf(GLenum pname, GLfloat param) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fPointParameterf(pname, param);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
2010-10-12 21:01:59 +00:00
|
|
|
void fPolygonOffset(GLfloat factor, GLfloat bias) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fPolygonOffset(factor, bias);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fReadBuffer(GLenum mode) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fReadBuffer(mode);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
2012-12-19 07:16:01 +00:00
|
|
|
private:
|
2011-10-19 19:09:57 +00:00
|
|
|
void raw_fReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) {
|
2010-10-12 21:01:59 +00:00
|
|
|
BEFORE_GL_CALL;
|
2012-10-02 02:42:09 +00:00
|
|
|
mSymbols.fReadPixels(x, FixYValue(y, height), width, height, format, type, pixels);
|
2010-10-12 21:01:59 +00:00
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
2012-12-19 07:16:01 +00:00
|
|
|
public:
|
2010-10-12 21:01:59 +00:00
|
|
|
void fSampleCoverage(GLclampf value, realGLboolean invert) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fSampleCoverage(value, invert);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
2012-12-19 07:16:01 +00: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;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2010-10-12 21:01:59 +00:00
|
|
|
void fStencilFunc(GLenum func, GLint ref, GLuint mask) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fStencilFunc(func, ref, mask);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fStencilFuncSeparate(GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fStencilFuncSeparate(frontfunc, backfunc, ref, mask);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fStencilMask(GLuint mask) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fStencilMask(mask);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fStencilMaskSeparate(GLenum face, GLuint mask) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fStencilMaskSeparate(face, mask);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fStencilOp(GLenum fail, GLenum zfail, GLenum zpass) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fStencilOp(fail, zfail, zpass);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fStencilOpSeparate(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fStencilOpSeparate(face, sfail, dpfail, dppass);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
2012-12-19 07:16:01 +00:00
|
|
|
private:
|
|
|
|
void raw_fTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) {
|
2010-10-12 21:01:59 +00:00
|
|
|
BEFORE_GL_CALL;
|
2012-12-19 07:16:01 +00:00
|
|
|
mSymbols.fTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
|
2010-10-12 21:01:59 +00:00
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
2012-12-19 07:16:01 +00: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);
|
|
|
|
}
|
|
|
|
|
2010-10-12 21:01:59 +00: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;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fUniform1f(GLint location, GLfloat v0) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fUniform1f(location, v0);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fUniform1fv(GLint location, GLsizei count, const GLfloat* value) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fUniform1fv(location, count, value);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fUniform1i(GLint location, GLint v0) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fUniform1i(location, v0);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fUniform1iv(GLint location, GLsizei count, const GLint* value) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fUniform1iv(location, count, value);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fUniform2f(GLint location, GLfloat v0, GLfloat v1) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fUniform2f(location, v0, v1);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fUniform2fv(GLint location, GLsizei count, const GLfloat* value) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fUniform2fv(location, count, value);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fUniform2i(GLint location, GLint v0, GLint v1) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fUniform2i(location, v0, v1);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fUniform2iv(GLint location, GLsizei count, const GLint* value) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fUniform2iv(location, count, value);
|
|
|
|
AFTER_GL_CALL;
|
2010-08-07 05:09:18 +00:00
|
|
|
}
|
|
|
|
|
2010-10-12 21:01:59 +00:00
|
|
|
void fUniform3f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fUniform3f(location, v0, v1, v2);
|
|
|
|
AFTER_GL_CALL;
|
2010-07-19 05:01:14 +00:00
|
|
|
}
|
|
|
|
|
2010-10-12 21:01:59 +00:00
|
|
|
void fUniform3fv(GLint location, GLsizei count, const GLfloat* value) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fUniform3fv(location, count, value);
|
|
|
|
AFTER_GL_CALL;
|
2010-07-19 05:01:14 +00:00
|
|
|
}
|
|
|
|
|
2010-10-12 21:01:59 +00:00
|
|
|
void fUniform3i(GLint location, GLint v0, GLint v1, GLint v2) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fUniform3i(location, v0, v1, v2);
|
|
|
|
AFTER_GL_CALL;
|
2010-07-19 05:01:14 +00:00
|
|
|
}
|
|
|
|
|
2010-10-12 21:01:59 +00:00
|
|
|
void fUniform3iv(GLint location, GLsizei count, const GLint* value) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fUniform3iv(location, count, value);
|
|
|
|
AFTER_GL_CALL;
|
2010-07-19 05:01:14 +00:00
|
|
|
}
|
|
|
|
|
2010-10-12 21:01:59 +00:00
|
|
|
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;
|
2010-07-19 05:01:14 +00:00
|
|
|
}
|
|
|
|
|
2010-10-12 21:01:59 +00:00
|
|
|
void fUniform4fv(GLint location, GLsizei count, const GLfloat* value) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fUniform4fv(location, count, value);
|
|
|
|
AFTER_GL_CALL;
|
2010-07-19 05:01:14 +00:00
|
|
|
}
|
|
|
|
|
2010-10-12 21:01:59 +00: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;
|
2010-07-19 05:01:14 +00:00
|
|
|
}
|
|
|
|
|
2010-10-12 21:01:59 +00:00
|
|
|
void fUniform4iv(GLint location, GLsizei count, const GLint* value) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fUniform4iv(location, count, value);
|
|
|
|
AFTER_GL_CALL;
|
2010-07-19 05:01:14 +00:00
|
|
|
}
|
|
|
|
|
2010-10-12 21:01:59 +00: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-07-19 05:01:14 +00:00
|
|
|
}
|
|
|
|
|
2010-10-12 21:01:59 +00: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-07-19 05:01:14 +00:00
|
|
|
}
|
|
|
|
|
2010-10-12 21:01:59 +00: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-07-19 05:01:14 +00:00
|
|
|
}
|
|
|
|
|
2010-10-12 21:01:59 +00:00
|
|
|
void fUseProgram(GLuint program) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fUseProgram(program);
|
|
|
|
AFTER_GL_CALL;
|
2010-07-19 05:01:14 +00:00
|
|
|
}
|
|
|
|
|
2010-10-12 21:01:59 +00:00
|
|
|
void fValidateProgram(GLuint program) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fValidateProgram(program);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fVertexAttrib1f(GLuint index, GLfloat x) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fVertexAttrib1f(index, x);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fVertexAttrib2f(GLuint index, GLfloat x, GLfloat y) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fVertexAttrib2f(index, x, y);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fVertexAttrib3f(index, x, y, z);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fVertexAttrib1fv(GLuint index, const GLfloat* v) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fVertexAttrib1fv(index, v);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fVertexAttrib2fv(GLuint index, const GLfloat* v) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fVertexAttrib2fv(index, v);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fVertexAttrib3fv(GLuint index, const GLfloat* v) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fVertexAttrib3fv(index, v);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fVertexAttrib4fv(GLuint index, const GLfloat* v) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fVertexAttrib4fv(index, v);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fCompileShader(GLuint shader) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fCompileShader(shader);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
2012-12-19 07:16:01 +00:00
|
|
|
private:
|
2011-10-19 19:09:57 +00:00
|
|
|
void raw_fCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) {
|
2010-10-12 21:01:59 +00:00
|
|
|
BEFORE_GL_CALL;
|
2012-12-19 07:16:01 +00:00
|
|
|
mSymbols.fCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
|
2010-10-12 21:01:59 +00:00
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
2011-10-19 19:09:57 +00:00
|
|
|
void raw_fCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) {
|
2010-10-12 21:01:59 +00:00
|
|
|
BEFORE_GL_CALL;
|
2012-12-19 07:16:01 +00:00
|
|
|
mSymbols.fCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
|
2010-10-12 21:01:59 +00:00
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
2012-12-19 07:16:01 +00:00
|
|
|
public:
|
2010-10-12 21:01:59 +00:00
|
|
|
void fGetShaderiv(GLuint shader, GLenum pname, GLint* param) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fGetShaderiv(shader, pname, param);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fGetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fGetShaderInfoLog(shader, bufSize, length, infoLog);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
2012-12-19 07:16:01 +00:00
|
|
|
private:
|
|
|
|
void raw_fGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) {
|
|
|
|
MOZ_ASSERT(mIsGLES2);
|
|
|
|
|
2011-12-16 21:11:59 +00:00
|
|
|
BEFORE_GL_CALL;
|
2012-12-19 07:16:01 +00:00
|
|
|
ASSERT_SYMBOL_PRESENT(fGetShaderPrecisionFormat);
|
2012-12-19 07:16:01 +00:00
|
|
|
mSymbols.fGetShaderPrecisionFormat(shadertype, precisiontype, range, precision);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
void fGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) {
|
|
|
|
if (mIsGLES2) {
|
|
|
|
raw_fGetShaderPrecisionFormat(shadertype, precisiontype, range, precision);
|
2011-12-16 21:11:59 +00:00
|
|
|
} else {
|
|
|
|
// Fall back to automatic values because almost all desktop hardware supports the OpenGL standard precisions.
|
|
|
|
GetShaderPrecisionFormatNonES2(shadertype, precisiontype, range, precision);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-12 21:01:59 +00:00
|
|
|
void fGetShaderSource(GLint obj, GLsizei maxLength, GLsizei* length, GLchar* source) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fGetShaderSource(obj, maxLength, length, source);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fShaderSource(GLuint shader, GLsizei count, const GLchar** strings, const GLint* lengths) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fShaderSource(shader, count, strings, lengths);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
2012-02-09 00:06:03 +00:00
|
|
|
private:
|
|
|
|
void raw_fBindFramebuffer(GLenum target, GLuint framebuffer) {
|
2010-10-12 21:01:59 +00:00
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fBindFramebuffer(target, framebuffer);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
2012-02-09 00:06:03 +00:00
|
|
|
public:
|
2010-10-12 21:01:59 +00:00
|
|
|
void fBindRenderbuffer(GLenum target, GLuint renderbuffer) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fBindRenderbuffer(target, renderbuffer);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
GLenum fCheckFramebufferStatus (GLenum target) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
GLenum retval = mSymbols.fCheckFramebufferStatus(target);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fFramebufferRenderbuffer(GLenum target, GLenum attachmentPoint, GLenum renderbufferTarget, GLuint renderbuffer) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fFramebufferRenderbuffer(target, attachmentPoint, renderbufferTarget, renderbuffer);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* value) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fGetFramebufferAttachmentParameteriv(target, attachment, pname, value);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* value) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fGetRenderbufferParameteriv(target, pname, value);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
realGLboolean fIsFramebuffer (GLuint framebuffer) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
realGLboolean retval = mSymbols.fIsFramebuffer(framebuffer);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2012-12-19 07:16:01 +00:00
|
|
|
private:
|
2011-10-19 19:09:57 +00:00
|
|
|
void raw_fBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) {
|
|
|
|
BEFORE_GL_CALL;
|
2012-12-19 07:16:01 +00:00
|
|
|
ASSERT_SYMBOL_PRESENT(fBlitFramebuffer);
|
2011-10-19 19:09:57 +00:00
|
|
|
mSymbols.fBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
2012-12-19 07:16:01 +00:00
|
|
|
public:
|
2010-10-12 21:01:59 +00:00
|
|
|
realGLboolean fIsRenderbuffer (GLuint renderbuffer) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
realGLboolean retval = mSymbols.fIsRenderbuffer(renderbuffer);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fRenderbufferStorage(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fRenderbufferStorage(target, internalFormat, width, height);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
2011-10-19 19:09:57 +00:00
|
|
|
void fRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height) {
|
|
|
|
BEFORE_GL_CALL;
|
2012-12-19 07:16:01 +00:00
|
|
|
ASSERT_SYMBOL_PRESENT(fRenderbufferStorageMultisample);
|
2011-10-19 19:09:57 +00:00
|
|
|
mSymbols.fRenderbufferStorageMultisample(target, samples, internalFormat, width, height);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
2012-12-19 07:16:01 +00:00
|
|
|
private:
|
|
|
|
void raw_fDepthRange(GLclampf a, GLclampf b) {
|
|
|
|
MOZ_ASSERT(!mIsGLES2);
|
|
|
|
|
|
|
|
BEFORE_GL_CALL;
|
2012-12-19 07:16:01 +00:00
|
|
|
ASSERT_SYMBOL_PRESENT(fDepthRange);
|
2012-12-19 07:16:01 +00:00
|
|
|
mSymbols.fDepthRange(a, b);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void raw_fDepthRangef(GLclampf a, GLclampf b) {
|
|
|
|
MOZ_ASSERT(mIsGLES2);
|
|
|
|
|
|
|
|
BEFORE_GL_CALL;
|
2012-12-19 07:16:01 +00:00
|
|
|
ASSERT_SYMBOL_PRESENT(fDepthRangef);
|
2012-12-19 07:16:01 +00:00
|
|
|
mSymbols.fDepthRangef(a, b);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void raw_fClearDepth(GLclampf v) {
|
|
|
|
MOZ_ASSERT(!mIsGLES2);
|
|
|
|
|
|
|
|
BEFORE_GL_CALL;
|
2012-12-19 07:16:01 +00:00
|
|
|
ASSERT_SYMBOL_PRESENT(fClearDepth);
|
2012-12-19 07:16:01 +00:00
|
|
|
mSymbols.fClearDepth(v);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void raw_fClearDepthf(GLclampf v) {
|
|
|
|
MOZ_ASSERT(mIsGLES2);
|
|
|
|
|
2010-10-12 21:01:59 +00:00
|
|
|
BEFORE_GL_CALL;
|
2012-12-19 07:16:01 +00:00
|
|
|
ASSERT_SYMBOL_PRESENT(fClearDepthf);
|
2012-12-19 07:16:01 +00:00
|
|
|
mSymbols.fClearDepthf(v);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
void fDepthRange(GLclampf a, GLclampf b) {
|
2010-10-12 21:01:59 +00:00
|
|
|
if (mIsGLES2) {
|
2012-12-19 07:16:01 +00:00
|
|
|
raw_fDepthRangef(a, b);
|
2010-10-12 21:01:59 +00:00
|
|
|
} else {
|
2012-12-19 07:16:01 +00:00
|
|
|
raw_fDepthRange(a, b);
|
2010-10-12 21:01:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void fClearDepth(GLclampf v) {
|
|
|
|
if (mIsGLES2) {
|
2012-12-19 07:16:01 +00:00
|
|
|
raw_fClearDepthf(v);
|
2010-10-12 21:01:59 +00:00
|
|
|
} else {
|
2012-12-19 07:16:01 +00:00
|
|
|
raw_fClearDepth(v);
|
2010-10-12 21:01:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-17 07:49:42 +00:00
|
|
|
void* fMapBuffer(GLenum target, GLenum access) {
|
|
|
|
BEFORE_GL_CALL;
|
2012-12-19 07:16:01 +00:00
|
|
|
ASSERT_SYMBOL_PRESENT(fMapBuffer);
|
2010-12-17 07:49:42 +00:00
|
|
|
void *ret = mSymbols.fMapBuffer(target, access);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
realGLboolean fUnmapBuffer(GLenum target) {
|
|
|
|
BEFORE_GL_CALL;
|
2012-12-19 07:16:01 +00:00
|
|
|
ASSERT_SYMBOL_PRESENT(fUnmapBuffer);
|
2010-12-17 07:49:42 +00:00
|
|
|
realGLboolean ret = mSymbols.fUnmapBuffer(target);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-10-12 21:01:59 +00:00
|
|
|
|
2012-12-19 07:16:01 +00:00
|
|
|
private:
|
2011-01-06 04:54:27 +00:00
|
|
|
#ifdef DEBUG
|
2012-12-18 01:58:44 +00:00
|
|
|
GLContext *TrackingContext() {
|
|
|
|
GLContext *tip = this;
|
|
|
|
while (tip->mSharedContext)
|
|
|
|
tip = tip->mSharedContext;
|
|
|
|
return tip;
|
|
|
|
}
|
2010-10-12 21:01:59 +00:00
|
|
|
|
2011-01-06 04:54:27 +00:00
|
|
|
#define TRACKING_CONTEXT(a) do { TrackingContext()->a; } while (0)
|
|
|
|
#else
|
|
|
|
#define TRACKING_CONTEXT(a) do {} while (0)
|
|
|
|
#endif
|
|
|
|
|
2012-12-19 07:16:01 +00:00
|
|
|
GLuint GLAPIENTRY raw_fCreateProgram() {
|
2012-12-18 01:58:44 +00:00
|
|
|
BEFORE_GL_CALL;
|
|
|
|
GLuint ret = mSymbols.fCreateProgram();
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
return ret;
|
|
|
|
}
|
2010-10-12 21:01:59 +00:00
|
|
|
|
2012-12-19 07:16:01 +00:00
|
|
|
GLuint GLAPIENTRY raw_fCreateShader(GLenum t) {
|
2012-12-18 01:58:44 +00:00
|
|
|
BEFORE_GL_CALL;
|
|
|
|
GLuint ret = mSymbols.fCreateShader(t);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
return ret;
|
|
|
|
}
|
2010-10-12 21:01:59 +00:00
|
|
|
|
2012-12-19 07:16:01 +00:00
|
|
|
void GLAPIENTRY raw_fGenBuffers(GLsizei n, GLuint* names) {
|
2012-12-18 01:58:44 +00:00
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fGenBuffers(n, names);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-10-12 21:01:59 +00:00
|
|
|
|
2012-12-19 07:16:01 +00:00
|
|
|
void GLAPIENTRY raw_fGenFramebuffers(GLsizei n, GLuint* names) {
|
2012-12-18 01:58:44 +00:00
|
|
|
BEFORE_GL_CALL;
|
2012-12-19 07:16:01 +00:00
|
|
|
mSymbols.fGenFramebuffers(n, names);
|
2012-12-18 01:58:44 +00:00
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-10-12 21:01:59 +00:00
|
|
|
|
2012-12-19 07:16:01 +00:00
|
|
|
void GLAPIENTRY raw_fGenRenderbuffers(GLsizei n, GLuint* names) {
|
2012-12-18 01:58:44 +00:00
|
|
|
BEFORE_GL_CALL;
|
2012-12-19 07:16:01 +00:00
|
|
|
mSymbols.fGenRenderbuffers(n, names);
|
2012-12-18 01:58:44 +00:00
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-10-12 21:01:59 +00:00
|
|
|
|
2012-12-19 07:16:01 +00:00
|
|
|
void GLAPIENTRY raw_fGenTextures(GLsizei n, GLuint* names) {
|
2012-12-18 01:58:44 +00:00
|
|
|
BEFORE_GL_CALL;
|
2012-12-19 07:16:01 +00:00
|
|
|
mSymbols.fGenTextures(n, names);
|
2012-12-18 01:58:44 +00:00
|
|
|
AFTER_GL_CALL;
|
2012-12-19 07:16:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
GLuint fCreateProgram() {
|
|
|
|
GLuint ret = raw_fCreateProgram();
|
|
|
|
TRACKING_CONTEXT(CreatedProgram(this, ret));
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
GLuint fCreateShader(GLenum t) {
|
|
|
|
GLuint ret = raw_fCreateShader(t);
|
|
|
|
TRACKING_CONTEXT(CreatedShader(this, ret));
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2012-12-18 01:58:44 +00:00
|
|
|
TRACKING_CONTEXT(CreatedRenderbuffers(this, n, names));
|
|
|
|
}
|
2010-10-12 21:01:59 +00:00
|
|
|
|
2012-12-19 07:16:01 +00:00
|
|
|
void fGenTextures(GLsizei n, GLuint* names) {
|
|
|
|
raw_fGenTextures(n, names);
|
|
|
|
TRACKING_CONTEXT(CreatedTextures(this, n, names));
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
void GLAPIENTRY raw_fDeleteProgram(GLuint program) {
|
2012-12-18 01:58:44 +00:00
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fDeleteProgram(program);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-10-12 21:01:59 +00:00
|
|
|
|
2012-12-19 07:16:01 +00:00
|
|
|
void GLAPIENTRY raw_fDeleteShader(GLuint shader) {
|
2012-12-18 01:58:44 +00:00
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fDeleteShader(shader);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-10-12 21:01:59 +00:00
|
|
|
|
2012-12-19 07:16:01 +00:00
|
|
|
void GLAPIENTRY raw_fDeleteBuffers(GLsizei n, GLuint *names) {
|
2012-12-18 01:58:44 +00:00
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fDeleteBuffers(n, names);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-10-12 21:01:59 +00:00
|
|
|
|
2012-12-19 07:16:01 +00:00
|
|
|
void GLAPIENTRY raw_fDeleteFramebuffers(GLsizei n, GLuint *names) {
|
2012-12-18 01:58:44 +00:00
|
|
|
BEFORE_GL_CALL;
|
2012-12-19 07:16:01 +00:00
|
|
|
mSymbols.fDeleteFramebuffers(n, names);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GLAPIENTRY raw_fDeleteRenderbuffers(GLsizei n, GLuint *names) {
|
|
|
|
BEFORE_GL_CALL;
|
|
|
|
mSymbols.fDeleteRenderbuffers(n, names);
|
2012-12-18 01:58:44 +00:00
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2010-10-12 21:01:59 +00:00
|
|
|
|
2012-12-19 07:16:01 +00:00
|
|
|
void GLAPIENTRY raw_fDeleteTextures(GLsizei n, GLuint *names) {
|
2012-12-18 01:58:44 +00:00
|
|
|
BEFORE_GL_CALL;
|
2012-12-19 07:16:01 +00:00
|
|
|
mSymbols.fDeleteTextures(n, names);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
2012-12-18 01:58:44 +00:00
|
|
|
if (n == 1 && *names == 0) {
|
2012-12-19 07:16:01 +00:00
|
|
|
// Deleting framebuffer 0 causes hangs on the DROID. See bug 623228.
|
2012-12-18 01:58:44 +00:00
|
|
|
} else {
|
2012-12-19 07:16:01 +00:00
|
|
|
raw_fDeleteFramebuffers(n, names);
|
2012-12-18 01:58:44 +00:00
|
|
|
}
|
|
|
|
TRACKING_CONTEXT(DeletedFramebuffers(this, n, names));
|
|
|
|
}
|
2010-10-12 21:01:59 +00:00
|
|
|
|
2012-12-19 07:16:01 +00:00
|
|
|
void fDeleteRenderbuffers(GLsizei n, GLuint *names) {
|
|
|
|
raw_fDeleteRenderbuffers(n, names);
|
2012-12-18 01:58:44 +00:00
|
|
|
TRACKING_CONTEXT(DeletedRenderbuffers(this, n, names));
|
|
|
|
}
|
2011-10-26 20:00:44 +00:00
|
|
|
|
2012-12-19 07:16:01 +00:00
|
|
|
void fDeleteTextures(GLsizei n, GLuint *names) {
|
|
|
|
raw_fDeleteTextures(n, names);
|
|
|
|
TRACKING_CONTEXT(DeletedTextures(this, n, names));
|
|
|
|
}
|
|
|
|
|
2011-10-26 20:00:44 +00:00
|
|
|
|
2012-12-18 01:58:44 +00:00
|
|
|
GLenum GLAPIENTRY fGetGraphicsResetStatus() {
|
2012-12-19 07:16:01 +00:00
|
|
|
MOZ_ASSERT(mHasRobustness);
|
|
|
|
|
2012-12-18 01:58:44 +00:00
|
|
|
BEFORE_GL_CALL;
|
2012-12-19 07:16:01 +00:00
|
|
|
ASSERT_SYMBOL_PRESENT(fGetGraphicsResetStatus);
|
|
|
|
GLenum ret = mSymbols.fGetGraphicsResetStatus();
|
2012-12-18 01:58:44 +00:00
|
|
|
AFTER_GL_CALL;
|
|
|
|
return ret;
|
|
|
|
}
|
2012-04-06 23:57:55 +00:00
|
|
|
|
2012-12-18 01:58:44 +00:00
|
|
|
GLsync GLAPIENTRY fFenceSync(GLenum condition, GLbitfield flags) {
|
|
|
|
BEFORE_GL_CALL;
|
2012-12-19 07:16:01 +00:00
|
|
|
ASSERT_SYMBOL_PRESENT(fFenceSync);
|
2012-12-18 01:58:44 +00:00
|
|
|
GLsync ret = mSymbols.fFenceSync(condition, flags);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
return ret;
|
|
|
|
}
|
2012-04-06 23:57:55 +00:00
|
|
|
|
2012-12-18 01:58:44 +00:00
|
|
|
realGLboolean GLAPIENTRY fIsSync(GLsync sync) {
|
|
|
|
BEFORE_GL_CALL;
|
2012-12-19 07:16:01 +00:00
|
|
|
ASSERT_SYMBOL_PRESENT(fIsSync);
|
2012-12-18 01:58:44 +00:00
|
|
|
realGLboolean ret = mSymbols.fIsSync(sync);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
return ret;
|
|
|
|
}
|
2012-04-06 23:57:55 +00:00
|
|
|
|
2012-12-18 01:58:44 +00:00
|
|
|
void GLAPIENTRY fDeleteSync(GLsync sync) {
|
|
|
|
BEFORE_GL_CALL;
|
2012-12-19 07:16:01 +00:00
|
|
|
ASSERT_SYMBOL_PRESENT(fDeleteSync);
|
2012-12-18 01:58:44 +00:00
|
|
|
mSymbols.fDeleteSync(sync);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2012-04-06 23:57:55 +00:00
|
|
|
|
2012-12-18 01:58:44 +00:00
|
|
|
GLenum GLAPIENTRY fClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) {
|
|
|
|
BEFORE_GL_CALL;
|
2012-12-19 07:16:01 +00:00
|
|
|
ASSERT_SYMBOL_PRESENT(fClientWaitSync);
|
2012-12-18 01:58:44 +00:00
|
|
|
GLenum ret = mSymbols.fClientWaitSync(sync, flags, timeout);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
return ret;
|
|
|
|
}
|
2012-04-06 23:57:55 +00:00
|
|
|
|
2012-12-18 01:58:44 +00:00
|
|
|
void GLAPIENTRY fWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) {
|
|
|
|
BEFORE_GL_CALL;
|
2012-12-19 07:16:01 +00:00
|
|
|
ASSERT_SYMBOL_PRESENT(fWaitSync);
|
2012-12-18 01:58:44 +00:00
|
|
|
mSymbols.fWaitSync(sync, flags, timeout);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2012-04-06 23:57:55 +00:00
|
|
|
|
2012-12-18 01:58:44 +00:00
|
|
|
void GLAPIENTRY fGetInteger64v(GLenum pname, GLint64 *params) {
|
|
|
|
BEFORE_GL_CALL;
|
2012-12-19 07:16:01 +00:00
|
|
|
ASSERT_SYMBOL_PRESENT(fGetInteger64v);
|
2012-12-18 01:58:44 +00:00
|
|
|
mSymbols.fGetInteger64v(pname, params);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2012-04-06 23:57:55 +00:00
|
|
|
|
2012-12-18 01:58:44 +00:00
|
|
|
void GLAPIENTRY fGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values) {
|
|
|
|
BEFORE_GL_CALL;
|
2012-12-19 07:16:01 +00:00
|
|
|
ASSERT_SYMBOL_PRESENT(fGetSynciv);
|
2012-12-18 01:58:44 +00:00
|
|
|
mSymbols.fGetSynciv(sync, pname, bufSize, length, values);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// OES_EGL_image (GLES)
|
2012-12-19 07:16:01 +00:00
|
|
|
void fEGLImageTargetTexture2D(GLenum target, GLeglImage image) {
|
2012-12-18 01:58:44 +00:00
|
|
|
BEFORE_GL_CALL;
|
2012-12-19 07:16:01 +00:00
|
|
|
ASSERT_SYMBOL_PRESENT(fEGLImageTargetTexture2D);
|
2012-12-18 01:58:44 +00:00
|
|
|
mSymbols.fEGLImageTargetTexture2D(target, image);
|
|
|
|
AFTER_GL_CALL;
|
|
|
|
}
|
2012-06-12 21:36:10 +00:00
|
|
|
|
2012-12-19 07:16:01 +00:00
|
|
|
#undef ASSERT_SYMBOL_PRESENT
|
|
|
|
|
2011-01-06 04:54:27 +00:00
|
|
|
#ifdef DEBUG
|
2010-07-19 22:19:15 +00:00
|
|
|
void THEBES_API CreatedProgram(GLContext *aOrigin, GLuint aName);
|
|
|
|
void THEBES_API CreatedShader(GLContext *aOrigin, GLuint aName);
|
|
|
|
void THEBES_API CreatedBuffers(GLContext *aOrigin, GLsizei aCount, GLuint *aNames);
|
|
|
|
void THEBES_API CreatedTextures(GLContext *aOrigin, GLsizei aCount, GLuint *aNames);
|
|
|
|
void THEBES_API CreatedFramebuffers(GLContext *aOrigin, GLsizei aCount, GLuint *aNames);
|
|
|
|
void THEBES_API CreatedRenderbuffers(GLContext *aOrigin, GLsizei aCount, GLuint *aNames);
|
|
|
|
void THEBES_API DeletedProgram(GLContext *aOrigin, GLuint aName);
|
|
|
|
void THEBES_API DeletedShader(GLContext *aOrigin, GLuint aName);
|
|
|
|
void THEBES_API DeletedBuffers(GLContext *aOrigin, GLsizei aCount, GLuint *aNames);
|
|
|
|
void THEBES_API DeletedTextures(GLContext *aOrigin, GLsizei aCount, GLuint *aNames);
|
|
|
|
void THEBES_API DeletedFramebuffers(GLContext *aOrigin, GLsizei aCount, GLuint *aNames);
|
|
|
|
void THEBES_API DeletedRenderbuffers(GLContext *aOrigin, GLsizei aCount, GLuint *aNames);
|
2010-07-19 05:01:14 +00:00
|
|
|
|
|
|
|
void SharedContextDestroyed(GLContext *aChild);
|
|
|
|
void ReportOutstandingNames();
|
|
|
|
|
|
|
|
struct NamedResource {
|
|
|
|
NamedResource()
|
2012-07-30 14:20:58 +00:00
|
|
|
: origin(nullptr), name(0), originDeleted(false)
|
2010-07-19 05:01:14 +00:00
|
|
|
{ }
|
|
|
|
|
|
|
|
NamedResource(GLContext *aOrigin, GLuint aName)
|
2011-10-17 14:59:28 +00:00
|
|
|
: origin(aOrigin), name(aName), originDeleted(false)
|
2010-07-19 05:01:14 +00:00
|
|
|
{ }
|
|
|
|
|
|
|
|
GLContext *origin;
|
|
|
|
GLuint name;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool originDeleted;
|
2010-07-19 05:01:14 +00: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;
|
|
|
|
#endif
|
2010-10-06 20:43:14 +00:00
|
|
|
|
2012-12-17 00:16:26 +00:00
|
|
|
public:
|
|
|
|
enum MemoryUse {
|
|
|
|
// when memory being allocated is reported to a memory reporter
|
|
|
|
MemoryAllocated,
|
|
|
|
// when memory being freed is reported to a memory reporter
|
|
|
|
MemoryFreed
|
|
|
|
};
|
|
|
|
|
|
|
|
// When memory is used/freed for tile textures, call this method
|
|
|
|
// to update the value reported by the memory reporter.
|
|
|
|
static void UpdateTextureMemoryUsage(MemoryUse action,
|
|
|
|
GLenum format,
|
|
|
|
GLenum type,
|
|
|
|
uint16_t tileSize);
|
2010-04-27 02:09:44 +00:00
|
|
|
};
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
inline bool
|
2012-01-30 20:09:02 +00:00
|
|
|
DoesStringMatch(const char* aString, const char *aWantedString)
|
2010-10-06 20:43:14 +00:00
|
|
|
{
|
2012-01-30 20:09:02 +00:00
|
|
|
if (!aString || !aWantedString)
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2011-03-09 10:17:00 +00:00
|
|
|
|
2012-01-30 20:09:02 +00:00
|
|
|
const char *occurrence = strstr(aString, aWantedString);
|
2010-10-06 20:43:14 +00:00
|
|
|
|
2012-01-30 20:09:02 +00:00
|
|
|
// aWanted not found
|
2010-10-06 20:43:14 +00:00
|
|
|
if (!occurrence)
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2010-10-06 20:43:14 +00:00
|
|
|
|
2012-01-30 20:09:02 +00:00
|
|
|
// aWantedString preceded by alpha character
|
|
|
|
if (occurrence != aString && isalpha(*(occurrence-1)))
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2010-10-06 20:43:14 +00:00
|
|
|
|
|
|
|
// aWantedVendor followed by alpha character
|
2012-01-30 20:09:02 +00:00
|
|
|
const char *afterOccurrence = occurrence + strlen(aWantedString);
|
2010-10-06 20:43:14 +00:00
|
|
|
if (isalpha(*afterOccurrence))
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2010-10-06 20:43:14 +00:00
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2010-10-06 20:43:14 +00:00
|
|
|
}
|
|
|
|
|
2012-08-22 03:30:20 +00: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;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ScopedFramebufferTexture
|
|
|
|
: public ScopedGLWrapper<ScopedFramebufferTexture>
|
|
|
|
{
|
2012-08-24 18:45:05 +00:00
|
|
|
friend struct ScopedGLWrapper<ScopedFramebufferTexture>;
|
2012-08-22 03:30:20 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
bool mComplete; // True if the framebuffer we create is complete.
|
|
|
|
GLuint mFB;
|
|
|
|
|
|
|
|
public:
|
|
|
|
ScopedFramebufferTexture(GLContext* gl, GLuint texture)
|
|
|
|
: ScopedGLWrapper<ScopedFramebufferTexture>(gl)
|
|
|
|
, mComplete(false)
|
|
|
|
, mFB(0)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mGL->IsCurrent());
|
|
|
|
GLuint boundFB = mGL->GetUserBoundFBO();
|
|
|
|
|
|
|
|
mGL->fGenFramebuffers(1, &mFB);
|
|
|
|
mGL->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, mFB);
|
|
|
|
mGL->fFramebufferTexture2D(LOCAL_GL_FRAMEBUFFER,
|
|
|
|
LOCAL_GL_COLOR_ATTACHMENT0,
|
|
|
|
LOCAL_GL_TEXTURE_2D,
|
|
|
|
texture,
|
|
|
|
0);
|
|
|
|
|
|
|
|
GLenum status = mGL->fCheckFramebufferStatus(LOCAL_GL_FRAMEBUFFER);
|
|
|
|
if (status == LOCAL_GL_FRAMEBUFFER_COMPLETE) {
|
|
|
|
mComplete = true;
|
|
|
|
} else {
|
|
|
|
mGL->fDeleteFramebuffers(1, &mFB);
|
|
|
|
mFB = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
mGL->BindUserFBO(boundFB);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void UnwrapImpl() {
|
|
|
|
if (!mFB)
|
|
|
|
return;
|
|
|
|
|
|
|
|
MOZ_ASSERT(mGL->IsCurrent());
|
|
|
|
mGL->fDeleteFramebuffers(1, &mFB);
|
|
|
|
mFB = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
GLuint FB() const {
|
|
|
|
return mFB;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsComplete() const {
|
|
|
|
return mComplete;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Wraps glEnable/Disable.
|
|
|
|
struct ScopedGLState
|
|
|
|
: public ScopedGLWrapper<ScopedGLState>
|
|
|
|
{
|
2012-08-24 18:45:05 +00:00
|
|
|
friend struct ScopedGLWrapper<ScopedGLState>;
|
2012-08-22 03:30:20 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mGL->IsCurrent());
|
|
|
|
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() {
|
|
|
|
MOZ_ASSERT(mGL->IsCurrent());
|
|
|
|
|
|
|
|
if (mOldState)
|
|
|
|
mGL->fEnable(mCapability);
|
|
|
|
else
|
|
|
|
mGL->fDisable(mCapability);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Saves and restores with GetUserBoundFBO and BindUserFBO.
|
|
|
|
struct ScopedFramebufferBinding
|
|
|
|
: public ScopedGLWrapper<ScopedFramebufferBinding>
|
|
|
|
{
|
2012-08-24 18:45:05 +00:00
|
|
|
friend struct ScopedGLWrapper<ScopedFramebufferBinding>;
|
2012-08-22 03:30:20 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
GLuint mOldState;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void Init() {
|
|
|
|
MOZ_ASSERT(mGL->IsCurrent());
|
|
|
|
mOldState = mGL->GetUserBoundFBO();
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
ScopedFramebufferBinding(GLContext* gl)
|
|
|
|
: ScopedGLWrapper<ScopedFramebufferBinding>(gl)
|
|
|
|
{
|
|
|
|
Init();
|
|
|
|
}
|
|
|
|
|
|
|
|
ScopedFramebufferBinding(GLContext* gl, GLuint newFB)
|
|
|
|
: ScopedGLWrapper<ScopedFramebufferBinding>(gl)
|
|
|
|
{
|
|
|
|
Init();
|
|
|
|
mGL->BindUserFBO(newFB);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void UnwrapImpl() {
|
|
|
|
MOZ_ASSERT(mGL->IsCurrent());
|
|
|
|
mGL->BindUserFBO(mOldState);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-12-17 00:16:26 +00:00
|
|
|
uint32_t GetBitsPerTexel(GLenum format, GLenum type);
|
|
|
|
|
2010-04-27 02:09:44 +00:00
|
|
|
} /* namespace gl */
|
|
|
|
} /* namespace mozilla */
|
|
|
|
|
2010-05-18 04:04:22 +00:00
|
|
|
#endif /* GLCONTEXT_H_ */
|