Bug 912042 - Avoid including GLContext.h in headers that don't need it - r=jrmuizel

This commit is contained in:
Benoit Jacob
2013-09-04 08:14:52 -04:00
parent 8be65bb83a
commit 8b1ffe319e
77 changed files with 501 additions and 396 deletions

View File

@@ -874,7 +874,7 @@ CanvasRenderingContext2D::EnsureTarget()
if (!mForceSoftware && CheckSizeForSkiaGL(size))
{
glContext = GLContextProvider::CreateOffscreen(gfxIntSize(size.width, size.height),
caps, GLContext::ContextFlagsNone);
caps, gl::ContextFlagsNone);
}
if (glContext) {

View File

@@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "WebGL2Context.h"
#include "GLContext.h"
#include "mozilla/dom/WebGL2RenderingContextBinding.h"
#include "mozilla/Telemetry.h"

View File

@@ -5,6 +5,7 @@
#include "WebGLBuffer.h"
#include "WebGLContext.h"
#include "GLContext.h"
#include "mozilla/dom/WebGLRenderingContextBinding.h"
using namespace mozilla;

View File

@@ -37,6 +37,7 @@
#include "nsDisplayList.h"
#include "GLContextProvider.h"
#include "GLContext.h"
#include "gfxCrashReporterUtils.h"
@@ -530,9 +531,9 @@ WebGLContext::SetDimensions(int32_t width, int32_t height)
// try the default provider, whatever that is
if (!gl && useOpenGL) {
GLContext::ContextFlags flag = useMesaLlvmPipe
? GLContext::ContextFlagsMesaLLVMPipe
: GLContext::ContextFlagsNone;
gl::ContextFlags flag = useMesaLlvmPipe
? gl::ContextFlagsMesaLLVMPipe
: gl::ContextFlagsNone;
gl = gl::GLContextProvider::CreateOffscreen(size, caps, flag);
if (gl && !InitAndValidateGL()) {
GenerateWarning("Error during %s initialization",
@@ -1243,7 +1244,7 @@ WebGLContext::MaybeRestoreContext()
if (mContextStatus != ContextNotLost || gl == nullptr)
return;
bool isEGL = gl->GetContextType() == GLContext::ContextTypeEGL,
bool isEGL = gl->GetContextType() == gl::ContextTypeEGL,
isANGLE = gl->IsANGLE();
GLContext::ContextResetARB resetStatus = GLContext::CONTEXT_NO_ERROR;
@@ -1311,6 +1312,9 @@ WebGLContext::ForceRestoreContext()
mContextStatus = ContextLostAwaitingRestore;
}
void
WebGLContext::MakeContextCurrent() const { gl->MakeCurrent(); }
//
// XPCOM goop
//

View File

@@ -951,7 +951,7 @@ protected:
void Invalidate();
void DestroyResourcesAndContext();
void MakeContextCurrent() const { gl->MakeCurrent(); }
void MakeContextCurrent() const;
// helpers
void TexImage2D_base(GLenum target, GLint level, GLenum internalformat,

View File

@@ -5,6 +5,7 @@
#include "WebGLContext.h"
#include "WebGLQuery.h"
#include "GLContext.h"
using namespace mozilla;

View File

@@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "WebGLContext.h"
#include "GLContext.h"
#include "WebGLBuffer.h"
#include "WebGLVertexArray.h"

View File

@@ -7,6 +7,7 @@
#include "WebGLTexture.h"
#include "WebGLRenderbuffer.h"
#include "WebGLFramebuffer.h"
#include "GLContext.h"
using namespace mozilla;

View File

@@ -23,6 +23,7 @@
#include "gfxImageSurface.h"
#include "gfxContext.h"
#include "gfxPlatform.h"
#include "GLContext.h"
#include "nsContentUtils.h"
#include "nsError.h"

View File

@@ -12,6 +12,7 @@
#include "WebGLRenderbuffer.h"
#include "WebGLTexture.h"
#include "WebGLVertexArray.h"
#include "GLContext.h"
using namespace mozilla;
using namespace dom;

View File

@@ -6,6 +6,7 @@
#include <stdarg.h>
#include "WebGLContext.h"
#include "GLContext.h"
#include "prprf.h"

View File

@@ -13,6 +13,7 @@
#include "WebGLRenderbuffer.h"
#include "WebGLTexture.h"
#include "WebGLVertexArray.h"
#include "GLContext.h"
#include "mozilla/CheckedInt.h"
#include "mozilla/Preferences.h"

View File

@@ -7,6 +7,7 @@
#include "WebGLBuffer.h"
#include "WebGLVertexAttribData.h"
#include "WebGLVertexArray.h"
#include "GLContext.h"
using namespace mozilla;

View File

@@ -13,6 +13,7 @@
#include "WebGLUniformInfo.h"
#include "WebGLShader.h"
#include "WebGLProgram.h"
#include "GLContext.h"
using namespace mozilla;
using namespace dom;

View File

@@ -8,6 +8,7 @@
#include "WebGLTexture.h"
#include "WebGLRenderbuffer.h"
#include "WebGLFramebuffer.h"
#include "GLContext.h"
#include <algorithm>

View File

@@ -6,6 +6,7 @@
#include "WebGLContext.h"
#include "WebGLExtensions.h"
#include "mozilla/dom/WebGLRenderingContextBinding.h"
#include "GLContext.h"
using namespace mozilla;

View File

@@ -8,6 +8,7 @@
#include "WebGLVertexArray.h"
#include "WebGLExtensions.h"
#include "mozilla/dom/WebGLRenderingContextBinding.h"
#include "GLContext.h"
using namespace mozilla;

View File

@@ -11,6 +11,7 @@
#include "mozilla/dom/WebGLRenderingContextBinding.h"
#include "WebGLTexture.h"
#include "WebGLRenderbuffer.h"
#include "GLContext.h"
using namespace mozilla;

View File

@@ -7,6 +7,7 @@
#include "WebGLShader.h"
#include "WebGLProgram.h"
#include "mozilla/dom/WebGLRenderingContextBinding.h"
#include "GLContext.h"
using namespace mozilla;

View File

@@ -12,6 +12,7 @@
#include "mozilla/LinkedList.h"
#include "mozilla/CheckedInt.h"
#include <map>
namespace mozilla {

View File

@@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "WebGLContext.h"
#include "GLContext.h"
#include "WebGLQuery.h"
#include "mozilla/dom/WebGL2RenderingContextBinding.h"
#include "nsContentUtils.h"
@@ -33,6 +34,15 @@ void WebGLQuery::Delete() {
LinkedListElement<WebGLQuery>::removeFrom(mContext->mQueries);
}
bool WebGLQuery::IsActive() const
{
WebGLRefPtr<WebGLQuery>* targetSlot = mContext->GetQueryTargetSlot(mType, "WebGLQuery::IsActive()");
MOZ_ASSERT(targetSlot, "unknown query object's type");
return *targetSlot == this;
}
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(WebGLQuery)

View File

@@ -7,7 +7,6 @@
#define WEBGLQUERY_H_
#include "WebGLObjectModel.h"
#include "WebGLContext.h"
#include "nsWrapperCache.h"
@@ -38,14 +37,7 @@ public:
// -------------------------------------------------------------------------
// MEMBER FUNCTIONS
bool IsActive() const
{
WebGLRefPtr<WebGLQuery>* targetSlot = mContext->GetQueryTargetSlot(mType, "WebGLQuery::IsActive()");
MOZ_ASSERT(targetSlot, "unknown query object's type");
return *targetSlot == this;
}
bool IsActive() const;
bool HasEverBeenActive()
{

View File

@@ -7,6 +7,7 @@
#include "WebGLRenderbuffer.h"
#include "WebGLTexture.h"
#include "mozilla/dom/WebGLRenderingContextBinding.h"
#include "GLContext.h"
using namespace mozilla;

View File

@@ -8,6 +8,7 @@
#include "WebGLContext.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/dom/WebGLRenderingContextBinding.h"
#include "GLContext.h"
using namespace mozilla;

View File

@@ -5,6 +5,7 @@
#include "WebGLContext.h"
#include "WebGLTexture.h"
#include "GLContext.h"
#include "mozilla/dom/WebGLRenderingContextBinding.h"
#include <algorithm>

View File

@@ -7,6 +7,7 @@
#include "WebGLBuffer.h"
#include "WebGLVertexArray.h"
#include "mozilla/dom/WebGLRenderingContextBinding.h"
#include "GLContext.h"
using namespace mozilla;

View File

@@ -12,6 +12,7 @@
#include "Blob.h"
#include "ContentChild.h"
#include "IndexedDBChild.h"
#include "mozilla/Preferences.h"
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/IntentionalCrash.h"
#include "mozilla/docshell/OfflineCacheUpdateChild.h"

View File

@@ -10,6 +10,7 @@
#include "nsNPAPIPluginInstance.h"
#include "nsPluginInstanceOwner.h"
#include "GLContextProvider.h"
#include "GLContext.h"
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args)
#define ASSIGN(obj, name) (obj)->name = anp_opengl_##name

View File

@@ -50,6 +50,7 @@ using namespace mozilla;
#include "mozilla/dom/ScreenOrientation.h"
#include "mozilla/Hal.h"
#include "GLContextProvider.h"
#include "GLContext.h"
#include "TexturePoolOGL.h"
using namespace mozilla::gl;
@@ -135,9 +136,9 @@ public:
return 0;
SharedTextureHandle handle =
sPluginContext->CreateSharedHandle(GLContext::SameProcess,
sPluginContext->CreateSharedHandle(gl::SameProcess,
(void*)mTextureInfo.mTexture,
GLContext::TextureID);
gl::TextureID);
// We want forget about this now, so delete the texture. Assigning it to zero
// ensures that we create a new one in Lock()
@@ -1013,9 +1014,9 @@ SharedTextureHandle nsNPAPIPluginInstance::CreateSharedHandle()
return mContentTexture->CreateSharedHandle();
} else if (mContentSurface) {
EnsureGLContext();
return sPluginContext->CreateSharedHandle(GLContext::SameProcess,
return sPluginContext->CreateSharedHandle(gl::SameProcess,
mContentSurface,
GLContext::SurfaceTexture);
gl::SurfaceTexture);
} else return 0;
}

View File

@@ -20,7 +20,7 @@
#ifdef MOZ_WIDGET_ANDROID
#include "nsAutoPtr.h"
#include "nsIRunnable.h"
#include "GLContext.h"
#include "GLContextTypes.h"
#include "nsSurfaceTexture.h"
#include "AndroidBridge.h"
#include <map>

View File

@@ -170,7 +170,7 @@ nsPluginInstanceOwner::GetImageContainer()
SharedTextureImage::Data data;
data.mHandle = mInstance->CreateSharedHandle();
data.mShareType = mozilla::gl::GLContext::SameProcess;
data.mShareType = mozilla::gl::SameProcess;
data.mInverted = mInstance->Inverted();
LayoutDeviceRect r = GetPluginRect();
@@ -1681,10 +1681,10 @@ already_AddRefed<ImageContainer> nsPluginInstanceOwner::GetImageContainerForVide
SharedTextureImage::Data data;
data.mShareType = gl::GLContext::SameProcess;
data.mShareType = gl::SameProcess;
data.mHandle = mInstance->GLContext()->CreateSharedHandle(data.mShareType,
aVideoInfo->mSurfaceTexture,
gl::GLContext::SurfaceTexture);
gl::SurfaceTexture);
// The logic below for Honeycomb is just a guess, but seems to work. We don't have a separate
// inverted flag for video.

View File

@@ -727,10 +727,10 @@ PluginInstanceParent::GetImageContainer(ImageContainer** aContainer)
NS_ASSERTION(image->GetFormat() == SHARED_TEXTURE, "Wrong format?");
SharedTextureImage::Data data;
data.mShareType = GLContext::SameProcess;
data.mShareType = gl::SameProcess;
data.mHandle = GLContextProviderCGL::CreateSharedHandle(data.mShareType,
ioSurface,
GLContext::IOSurface);
gl::IOSurface);
data.mInverted = false;
// Use the device pixel size of the IOSurface, since layers handles resolution scaling
// already.

View File

@@ -17,6 +17,7 @@
#include "nsAutoPtr.h"
#include "nsDataHashtable.h"
#include "nsHashKeys.h"
#include "nsIObserver.h"
#ifdef MOZ_CRASHREPORTER
#include "nsExceptionHandler.h"

View File

@@ -1034,7 +1034,7 @@ GLContext::InitExtensions()
const bool firstRun = false;
#endif
mAvailableExtensions.Load(extensions, sExtensionNames, firstRun && DebugMode());
InitializeExtensionsBitSet(mAvailableExtensions, extensions, sExtensionNames, firstRun && DebugMode());
if (WorkAroundDriverBugs() &&
Vendor() == VendorQualcomm) {

View File

@@ -17,6 +17,7 @@
#include <set>
#include <stack>
#include <map>
#include <bitset>
#ifdef WIN32
#include <windows.h>
@@ -118,8 +119,6 @@ namespace GLFeature {
};
}
typedef uintptr_t SharedTextureHandle;
MOZ_BEGIN_ENUM_CLASS(ContextProfile, uint8_t)
Unknown = 0,
OpenGL, // only for IsAtLeast's <profile> parameter
@@ -128,7 +127,6 @@ MOZ_BEGIN_ENUM_CLASS(ContextProfile, uint8_t)
OpenGLES
MOZ_END_ENUM_CLASS(ContextProfile)
class GLContext
: public GLLibraryLoader
, public GenericAtomicRefCounted
@@ -158,20 +156,6 @@ public:
RendererOther
};
enum ContextFlags {
ContextFlagsNone = 0x0,
ContextFlagsGlobal = 0x1,
ContextFlagsMesaLLVMPipe = 0x2
};
enum GLContextType {
ContextTypeUnknown,
ContextTypeWGL,
ContextTypeCGL,
ContextTypeGLX,
ContextTypeEGL
};
// -----------------------------------------------------------------------------
// basic getters
@@ -438,66 +422,41 @@ public:
public:
// 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.
template<size_t Size>
struct ExtensionBitset
template<size_t N>
static void InitializeExtensionsBitSet(std::bitset<N>& extensionsBitset, const char* extStr, const char** extList, bool verbose = false)
{
ExtensionBitset()
{
for (size_t i = 0; i < Size; ++i)
extensions[i] = false;
}
char* exts = strdup(extStr);
void Load(const char* extStr, const char** extList, bool verbose = false)
{
char* exts = strdup(extStr);
if (verbose)
printf_stderr("Extensions: %s\n", exts);
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 (PL_strcasecmp(cur, extList[i]) == 0) {
if (verbose)
printf_stderr("Found extension %s\n", cur);
extensions[i] = 1;
}
}
cur = space + 1;
char* cur = exts;
bool done = false;
while (!done) {
char* space = strchr(cur, ' ');
if (space) {
*space = '\0';
} else {
done = true;
}
free(exts);
for (int i = 0; extList[i]; ++i) {
if (PL_strcasecmp(cur, extList[i]) == 0) {
if (verbose)
printf_stderr("Found extension %s\n", cur);
extensionsBitset[i] = true;
}
}
cur = space + 1;
}
bool& operator[](size_t index) {
MOZ_ASSERT(index < Size, "out of range");
return extensions[index];
}
const bool& operator[](size_t index) const {
MOZ_ASSERT(index < Size, "out of range");
return extensions[index];
}
bool extensions[Size];
};
free(exts);
}
protected:
ExtensionBitset<Extensions_Max> mAvailableExtensions;
std::bitset<Extensions_Max> mAvailableExtensions;
// -----------------------------------------------------------------------------
@@ -516,7 +475,7 @@ public:
private:
ExtensionBitset<GLFeature::EnumMax> mAvailableFeatures;
std::bitset<GLFeature::EnumMax> mAvailableFeatures;
/**
* Init features regarding OpenGL extension and context version and profile
@@ -621,6 +580,9 @@ private:
// MOZ_GL_DEBUG implementation
private:
#undef BEFORE_GL_CALL
#undef AFTER_GL_CALL
#ifdef DEBUG
#ifndef MOZ_FUNCTION_NAME
@@ -2591,22 +2553,6 @@ public:
*/
const gfxIntSize& OffscreenSize() const;
enum SharedTextureShareType {
SameProcess = 0,
CrossProcess
};
enum SharedTextureBufferType {
TextureID
#ifdef MOZ_WIDGET_ANDROID
, SurfaceTexture
#endif
#ifdef XP_MACOSX
, IOSurface
#endif
};
/*
* Create a new shared GLContext content handle, using the passed buffer as a source.
* Must be released by ReleaseSharedHandle. UpdateSharedHandle will have no effect

View File

@@ -6,7 +6,7 @@
#ifndef GLCONTEXTPROVIDER_H_
#define GLCONTEXTPROVIDER_H_
#include "GLContext.h"
#include "GLContextTypes.h"
#include "gfxTypes.h"
#include "gfxPoint.h"
#include "nsAutoPtr.h"

View File

@@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "GLContextProvider.h"
#include "GLContext.h"
#include "nsDebug.h"
#include "nsIWidget.h"
#include "OpenGL/OpenGL.h"
@@ -518,12 +519,12 @@ GLContextProviderCGL::GetGlobalContext(const ContextFlags)
}
SharedTextureHandle
GLContextProviderCGL::CreateSharedHandle(GLContext::SharedTextureShareType shareType,
GLContextProviderCGL::CreateSharedHandle(SharedTextureShareType shareType,
void* buffer,
GLContext::SharedTextureBufferType bufferType)
SharedTextureBufferType bufferType)
{
if (shareType != GLContext::SameProcess ||
bufferType != GLContext::IOSurface) {
if (shareType != SameProcess ||
bufferType != gl::IOSurface) {
return 0;
}
@@ -534,7 +535,7 @@ GLContextProviderCGL::CreateSharedHandle(GLContext::SharedTextureShareType share
}
already_AddRefed<gfxASurface>
GLContextProviderCGL::GetSharedHandleAsSurface(GLContext::SharedTextureShareType shareType,
GLContextProviderCGL::GetSharedHandleAsSurface(SharedTextureShareType shareType,
SharedTextureHandle sharedHandle)
{
MacIOSurface* surf = reinterpret_cast<MacIOSurface*>(sharedHandle);

View File

@@ -3,6 +3,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "GLContext.h"
#include "mozilla/Util.h"
// please add new includes below Qt, otherwise it break Qt build due malloc wrapper conflicts
@@ -736,12 +737,12 @@ protected:
};
typedef enum {
Image
enum SharedHandleType {
SharedHandleType_Image
#ifdef MOZ_WIDGET_ANDROID
, SurfaceTexture
, SharedHandleType_SurfaceTexture
#endif
} SharedHandleType;
};
class SharedTextureHandleWrapper
{
@@ -765,7 +766,7 @@ class SurfaceTextureWrapper: public SharedTextureHandleWrapper
{
public:
SurfaceTextureWrapper(nsSurfaceTexture* aSurfaceTexture) :
SharedTextureHandleWrapper(SharedHandleType::SurfaceTexture)
SharedTextureHandleWrapper(SharedHandleType_SurfaceTexture)
, mSurfaceTexture(aSurfaceTexture)
{
}
@@ -785,7 +786,7 @@ class EGLTextureWrapper : public SharedTextureHandleWrapper
{
public:
EGLTextureWrapper() :
SharedTextureHandleWrapper(SharedHandleType::Image)
SharedTextureHandleWrapper(SharedHandleType_Image)
, mEGLImage(nullptr)
, mSyncObject(nullptr)
{
@@ -876,7 +877,7 @@ GLContextEGL::UpdateSharedHandle(SharedTextureShareType shareType,
SharedTextureHandleWrapper* wrapper = reinterpret_cast<SharedTextureHandleWrapper*>(sharedHandle);
NS_ASSERTION(wrapper->Type() == SharedHandleType::Image, "Expected EGLImage shared handle");
NS_ASSERTION(wrapper->Type() == SharedHandleType_Image, "Expected EGLImage shared handle");
NS_ASSERTION(mShareWithEGLImage, "EGLImage not supported or disabled in runtime");
EGLTextureWrapper* wrap = reinterpret_cast<EGLTextureWrapper*>(wrapper);
@@ -950,12 +951,12 @@ void GLContextEGL::ReleaseSharedHandle(SharedTextureShareType shareType,
switch (wrapper->Type()) {
#ifdef MOZ_WIDGET_ANDROID
case SharedHandleType::SurfaceTexture:
case SharedHandleType_SurfaceTexture:
delete wrapper;
break;
#endif
case SharedHandleType::Image: {
case SharedHandleType_Image: {
NS_ASSERTION(mShareWithEGLImage, "EGLImage not supported or disabled in runtime");
EGLTextureWrapper* wrap = (EGLTextureWrapper*)sharedHandle;
@@ -980,7 +981,7 @@ bool GLContextEGL::GetSharedHandleDetails(SharedTextureShareType shareType,
switch (wrapper->Type()) {
#ifdef MOZ_WIDGET_ANDROID
case SharedHandleType::SurfaceTexture: {
case SharedHandleType_SurfaceTexture: {
SurfaceTextureWrapper* surfaceWrapper = reinterpret_cast<SurfaceTextureWrapper*>(wrapper);
details.mTarget = LOCAL_GL_TEXTURE_EXTERNAL;
@@ -990,7 +991,7 @@ bool GLContextEGL::GetSharedHandleDetails(SharedTextureShareType shareType,
}
#endif
case SharedHandleType::Image:
case SharedHandleType_Image:
details.mTarget = LOCAL_GL_TEXTURE_2D;
details.mTextureFormat = FORMAT_R8G8B8A8;
break;
@@ -1013,7 +1014,7 @@ bool GLContextEGL::AttachSharedHandle(SharedTextureShareType shareType,
switch (wrapper->Type()) {
#ifdef MOZ_WIDGET_ANDROID
case SharedHandleType::SurfaceTexture: {
case SharedHandleType_SurfaceTexture: {
#ifndef DEBUG
/**
* NOTE: SurfaceTexture spams us if there are any existing GL errors, so we'll clear
@@ -1031,7 +1032,7 @@ bool GLContextEGL::AttachSharedHandle(SharedTextureShareType shareType,
}
#endif // MOZ_WIDGET_ANDROID
case SharedHandleType::Image: {
case SharedHandleType_Image: {
NS_ASSERTION(mShareWithEGLImage, "EGLImage not supported or disabled in runtime");
EGLTextureWrapper* wrap = (EGLTextureWrapper*)sharedHandle;
@@ -2012,7 +2013,7 @@ GLContextProviderEGL::CreateOffscreen(const gfxIntSize& size,
if (!glContext)
return nullptr;
if (flags & GLContext::ContextFlagsGlobal)
if (flags & ContextFlagsGlobal)
return glContext.forget();
if (!glContext->InitOffscreen(size, caps))
@@ -2022,15 +2023,15 @@ GLContextProviderEGL::CreateOffscreen(const gfxIntSize& size,
}
SharedTextureHandle
GLContextProviderEGL::CreateSharedHandle(GLContext::SharedTextureShareType shareType,
GLContextProviderEGL::CreateSharedHandle(SharedTextureShareType shareType,
void* buffer,
GLContext::SharedTextureBufferType bufferType)
SharedTextureBufferType bufferType)
{
return 0;
}
already_AddRefed<gfxASurface>
GLContextProviderEGL::GetSharedHandleAsSurface(GLContext::SharedTextureShareType shareType,
GLContextProviderEGL::GetSharedHandleAsSurface(SharedTextureShareType shareType,
SharedTextureHandle sharedHandle)
{
return nullptr;

View File

@@ -50,9 +50,9 @@ typedef GLXLibrary::LibraryType LibType;
static LibType gCurrLib = GLXLibrary::OPENGL_LIB;
LibType
GLXLibrary::SelectLibrary(const GLContext::ContextFlags& aFlags)
GLXLibrary::SelectLibrary(const ContextFlags& aFlags)
{
return (aFlags & GLContext::ContextFlagsMesaLLVMPipe)
return (aFlags & ContextFlagsMesaLLVMPipe)
? GLXLibrary::MESA_LLVMPIPE_LIB
: GLXLibrary::OPENGL_LIB;
}
@@ -1160,7 +1160,7 @@ GLContextGLX::CreateTextureImage(const nsIntSize& aSize,
}
static GLContextGLX *
GetGlobalContextGLX(const GLContext::ContextFlags aFlags = GLContext::ContextFlagsNone)
GetGlobalContextGLX(const ContextFlags aFlags = ContextFlagsNone)
{
return static_cast<GLContextGLX*>(GLContextProviderGLX::GetGlobalContext(aFlags));
}
@@ -1384,9 +1384,9 @@ DONE_CREATING_PIXMAP:
if (!error && // earlier recorded error
!serverError)
{
GLContext::ContextFlags flag = libToUse == GLXLibrary::MESA_LLVMPIPE_LIB
? GLContext::ContextFlagsMesaLLVMPipe
: GLContext::ContextFlagsNone;
ContextFlags flag = libToUse == GLXLibrary::MESA_LLVMPIPE_LIB
? ContextFlagsMesaLLVMPipe
: ContextFlagsNone;
// We might have an alpha channel, but it doesn't matter.
SurfaceCaps dummyCaps = SurfaceCaps::Any();
GLContextGLX* shareContext = GetGlobalContextGLX(flag);
@@ -1427,15 +1427,15 @@ GLContextProviderGLX::CreateOffscreen(const gfxIntSize& size,
}
SharedTextureHandle
GLContextProviderGLX::CreateSharedHandle(GLContext::SharedTextureShareType shareType,
GLContextProviderGLX::CreateSharedHandle(SharedTextureShareType shareType,
void* buffer,
GLContext::SharedTextureBufferType bufferType)
SharedTextureBufferType bufferType)
{
return 0;
}
already_AddRefed<gfxASurface>
GLContextProviderGLX::GetSharedHandleAsSurface(GLContext::SharedTextureShareType shareType,
GLContextProviderGLX::GetSharedHandleAsSurface(SharedTextureShareType shareType,
SharedTextureHandle sharedHandle)
{
return nullptr;

View File

@@ -14,7 +14,6 @@
class GL_CONTEXT_PROVIDER_NAME
{
public:
typedef GLContext::ContextFlags ContextFlags;
typedef gfx::SurfaceCaps SurfaceCaps;
/**
* Create a context that renders to the surface of the widget that is
@@ -61,13 +60,13 @@ public:
static already_AddRefed<GLContext>
CreateOffscreen(const gfxIntSize& size,
const SurfaceCaps& caps,
ContextFlags flags = GLContext::ContextFlagsNone);
ContextFlags flags = ContextFlagsNone);
/**
* Get a pointer to the global context, creating it if it doesn't exist.
*/
static GLContext*
GetGlobalContext(ContextFlags flags = GLContext::ContextFlagsNone);
GetGlobalContext(ContextFlags flags = ContextFlagsNone);
/*
* Create a new shared GLContext content handle, using the passed buffer as a source.
@@ -75,11 +74,11 @@ public:
* on handles created with this method, as the caller owns the source (the passed buffer)
* and is responsible for updating it accordingly.
*/
static SharedTextureHandle CreateSharedHandle(GLContext::SharedTextureShareType shareType,
static SharedTextureHandle CreateSharedHandle(SharedTextureShareType shareType,
void* buffer,
GLContext::SharedTextureBufferType bufferType);
SharedTextureBufferType bufferType);
static already_AddRefed<gfxASurface> GetSharedHandleAsSurface(GLContext::SharedTextureShareType shareType,
static already_AddRefed<gfxASurface> GetSharedHandleAsSurface(SharedTextureShareType shareType,
SharedTextureHandle sharedHandle);
/**

View File

@@ -23,15 +23,15 @@ GLContextProviderNull::CreateOffscreen(const gfxIntSize&,
}
SharedTextureHandle
GLContextProviderNull::CreateSharedHandle(GLContext::SharedTextureShareType shareType,
GLContextProviderNull::CreateSharedHandle(SharedTextureShareType shareType,
void* buffer,
GLContext::SharedTextureBufferType bufferType)
SharedTextureBufferType bufferType)
{
return 0;
}
already_AddRefed<gfxASurface>
GLContextProviderNull::GetSharedHandleAsSurface(GLContext::SharedTextureShareType shareType,
GLContextProviderNull::GetSharedHandleAsSurface(SharedTextureShareType shareType,
SharedTextureHandle sharedHandle)
{
return nullptr;

View File

@@ -30,9 +30,9 @@ typedef WGLLibrary::LibraryType LibType;
WGLLibrary sWGLLib[WGLLibrary::LIBS_MAX];
LibType
WGLLibrary::SelectLibrary(const GLContext::ContextFlags& aFlags)
WGLLibrary::SelectLibrary(const ContextFlags& aFlags)
{
return (aFlags & GLContext::ContextFlagsMesaLLVMPipe)
return (aFlags & ContextFlagsMesaLLVMPipe)
? WGLLibrary::MESA_LLVMPIPE_LIB
: WGLLibrary::OPENGL_LIB;
}
@@ -234,10 +234,10 @@ WGLLibrary::EnsureInitialized(bool aUseMesaLlvmPipe)
mInitialized = true;
GLContext::ContextFlags flag = GLContext::ContextFlagsNone;
ContextFlags flag = ContextFlagsNone;
if (aUseMesaLlvmPipe) {
mLibType = WGLLibrary::MESA_LLVMPIPE_LIB;
flag = GLContext::ContextFlagsMesaLLVMPipe;
flag = ContextFlagsMesaLLVMPipe;
}
// Call this to create the global GLContext instance,
@@ -439,7 +439,7 @@ GLContextWGL::ResizeOffscreen(const gfxIntSize& aNewSize)
}
static GLContextWGL *
GetGlobalContextWGL(const GLContext::ContextFlags aFlags = GLContext::ContextFlagsNone)
GetGlobalContextWGL(const ContextFlags aFlags = ContextFlagsNone)
{
return static_cast<GLContextWGL*>(GLContextProviderWGL::GetGlobalContext(aFlags));
}
@@ -603,7 +603,7 @@ CreatePBufferOffscreenContext(const gfxIntSize& aSize,
}
static already_AddRefed<GLContextWGL>
CreateWindowOffscreenContext(GLContext::ContextFlags aFlags)
CreateWindowOffscreenContext(ContextFlags aFlags)
{
// CreateWindowOffscreenContext must return a global-shared context
GLContextWGL *shareContext = GetGlobalContextWGL(aFlags);
@@ -693,15 +693,15 @@ GLContextProviderWGL::CreateOffscreen(const gfxIntSize& size,
}
SharedTextureHandle
GLContextProviderWGL::CreateSharedHandle(GLContext::SharedTextureShareType shareType,
GLContextProviderWGL::CreateSharedHandle(SharedTextureShareType shareType,
void* buffer,
GLContext::SharedTextureBufferType bufferType)
SharedTextureBufferType bufferType)
{
return 0;
}
already_AddRefed<gfxASurface>
GLContextProviderWGL::GetSharedHandleAsSurface(GLContext::SharedTextureShareType shareType,
GLContextProviderWGL::GetSharedHandleAsSurface(SharedTextureShareType shareType,
SharedTextureHandle sharedHandle)
{
return nullptr;

View File

@@ -6,15 +6,44 @@
#ifndef GLCONTEXT_TYPES_H_
#define GLCONTEXT_TYPES_H_
typedef unsigned int GLenum;
typedef unsigned int GLbitfield;
typedef unsigned int GLuint;
typedef int GLint;
typedef int GLsizei;
#include "GLTypes.h"
namespace mozilla {
namespace gl {
class GLContext;
typedef uintptr_t SharedTextureHandle;
enum SharedTextureShareType {
SameProcess = 0,
CrossProcess
};
enum SharedTextureBufferType {
TextureID
#ifdef MOZ_WIDGET_ANDROID
, SurfaceTexture
#endif
#ifdef XP_MACOSX
, IOSurface
#endif
};
enum ContextFlags {
ContextFlagsNone = 0x0,
ContextFlagsGlobal = 0x1,
ContextFlagsMesaLLVMPipe = 0x2
};
enum GLContextType {
ContextTypeUnknown,
ContextTypeWGL,
ContextTypeCGL,
ContextTypeGLX,
ContextTypeEGL
};
struct GLFormats
{
// Constructs a zeroed object:

View File

@@ -319,7 +319,7 @@ GLLibraryEGL::InitExtensions()
const bool firstRun = false;
#endif
mAvailableExtensions.Load(extensions, sExtensionNames, firstRun && debugMode);
GLContext::InitializeExtensionsBitSet(mAvailableExtensions, extensions, sExtensionNames, firstRun && debugMode);
#ifdef DEBUG
firstRun = false;
@@ -396,6 +396,25 @@ GLLibraryEGL::DumpEGLConfigs()
delete [] ec;
}
#ifdef DEBUG
/*static*/ void
GLLibraryEGL::BeforeGLCall(const char* glFunction)
{
if (GLContext::DebugMode()) {
if (GLContext::DebugMode() & GLContext::DebugTrace)
printf_stderr("[egl] > %s\n", glFunction);
}
}
/*static*/ void
GLLibraryEGL::AfterGLCall(const char* glFunction)
{
if (GLContext::DebugMode() & GLContext::DebugTrace) {
printf_stderr("[egl] < %s\n", glFunction);
}
}
#endif
} /* namespace gl */
} /* namespace mozilla */

View File

@@ -9,11 +9,11 @@
#include "mozilla/X11Util.h"
#endif
#include "GLContext.h"
#include "GLLibraryLoader.h"
#include "nsIFile.h"
#include <bitset>
#if defined(XP_WIN)
@@ -60,10 +60,21 @@ typedef void *EGLNativeWindowType;
namespace mozilla {
namespace gl {
#ifdef DEBUG
#undef BEFORE_GL_CALL
#undef AFTER_GL_CALL
#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
#define BEFORE_GL_CALL do { \
BeforeGLCall(MOZ_FUNCTION_NAME); \
} while (0)
@@ -73,23 +84,11 @@ namespace gl {
} while (0)
// We rely on the fact that GLLibraryEGL.h #defines BEFORE_GL_CALL and
// AFTER_GL_CALL to nothing if !defined(DEBUG).
#else
#define BEFORE_GL_CALL
#define AFTER_GL_CALL
#endif
static inline void BeforeGLCall(const char* glFunction)
{
if (GLContext::DebugMode()) {
if (GLContext::DebugMode() & GLContext::DebugTrace)
printf_stderr("[egl] > %s\n", glFunction);
}
}
static inline void AfterGLCall(const char* glFunction)
{
if (GLContext::DebugMode() & GLContext::DebugTrace) {
printf_stderr("[egl] < %s\n", glFunction);
}
}
class GLLibraryEGL
{
public:
@@ -126,11 +125,11 @@ public:
}
void MarkExtensionUnsupported(EGLExtensions aKnownExtension) {
mAvailableExtensions[aKnownExtension] = 0;
mAvailableExtensions[aKnownExtension] = false;
}
protected:
GLContext::ExtensionBitset<Extensions_Max> mAvailableExtensions;
std::bitset<Extensions_Max> mAvailableExtensions;
public:
@@ -518,6 +517,11 @@ public:
pfnGetSyncAttrib fGetSyncAttrib;
} mSymbols;
#ifdef DEBUG
static void BeforeGLCall(const char* glFunction);
static void AfterGLCall(const char* glFunction);
#endif
private:
bool mInitialized;
PRLibrary* mEGLLibrary;

View File

@@ -5,19 +5,20 @@
#if !defined(GLTYPES_H_)
#define GLTYPES_H_
#include <stddef.h>
#include <stdint.h>
typedef int8_t realGLboolean;
#if !defined(__gltypes_h_) && !defined(__gl_h_)
#define __gltypes_h_
#define __gl_h_
#include <stddef.h>
#include <stdint.h>
typedef uint32_t GLenum;
typedef uint32_t GLbitfield;
typedef uint32_t GLuint;
typedef int32_t GLint;
typedef int32_t GLsizei;
typedef int8_t realGLboolean;
typedef int8_t GLbyte;
typedef int16_t GLshort;
typedef uint8_t GLubyte;

View File

@@ -6,10 +6,12 @@
#ifndef GFX_GLXLIBRARY_H
#define GFX_GLXLIBRARY_H
#include "GLContext.h"
#include "GLContextTypes.h"
typedef realGLboolean GLboolean;
#include <GL/glx.h>
struct PRLibrary;
namespace mozilla {
namespace gl {
@@ -99,7 +101,7 @@ public:
bool SupportsTextureFromPixmap(gfxASurface* aSurface);
bool IsATI() { return mIsATI; }
bool GLXVersionCheck(int aMajor, int aMinor);
static LibraryType SelectLibrary(const GLContext::ContextFlags& aFlags);
static LibraryType SelectLibrary(const ContextFlags& aFlags);
private:

View File

@@ -17,6 +17,7 @@ namespace mozilla {
namespace gl {
class GLContext;
class TextureGarbageBin;
class SharedSurface_EGLImage
: public SharedSurface_GL

View File

@@ -12,9 +12,13 @@
#include "mozilla/Attributes.h"
#include "gfxPoint.h"
#include "SurfaceTypes.h"
#include "GLContext.h"
namespace mozilla {
namespace gl {
class GLContext;
}
namespace gfx {
class SharedSurface;
class SurfaceFactory;

View File

@@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "VBOArena.h"
#include "GLContext.h"
using namespace mozilla::gl;

View File

@@ -6,12 +6,14 @@
#ifndef VBOARENA_H_
#define VBOARENA_H_
#include "GLContext.h"
#include "GLTypes.h"
#include <vector>
namespace mozilla {
namespace gl {
class GLContext;
class VBOArena {
public:
// Allocate a new VBO.

View File

@@ -3,7 +3,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "GLContext.h"
#include "GLContextTypes.h"
struct PRLibrary;
namespace mozilla {
namespace gl {
@@ -79,7 +80,7 @@ public:
int GetWindowPixelFormat() const { return mWindowPixelFormat; }
bool UseDoubleBufferedWindows() const { return mUseDoubleBufferedWindows; }
LibraryType GetLibraryType() const { return mLibType; }
static LibraryType SelectLibrary(const GLContext::ContextFlags& aFlags);
static LibraryType SelectLibrary(const ContextFlags& aFlags);
private:
bool mInitialized;

View File

@@ -61,7 +61,6 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
]
CPP_SOURCES += [
'GLContextProviderEGL.cpp',
'GLLibraryEGL.cpp',
'SharedSurfaceANGLE.cpp',
]
if CONFIG['MOZ_ENABLE_SKIA_GPU']:
@@ -89,11 +88,6 @@ else:
'GLContextProvider%s.cpp' % gl_provider,
]
if gl_provider == 'EGL':
CPP_SOURCES += [
'GLLibraryEGL.cpp',
]
CPP_SOURCES += [
'GLContext.cpp',
'GLContextFeatures.cpp',
@@ -103,6 +97,7 @@ CPP_SOURCES += [
'GLScreenBuffer.cpp',
'GLTextureImage.cpp',
'SharedSurface.cpp',
'GLLibraryEGL.cpp',
'SharedSurfaceEGL.cpp',
'SharedSurfaceGL.cpp',
'SurfaceFactory.cpp',

View File

@@ -27,7 +27,7 @@ class SharedTextureImage : public Image {
public:
struct Data {
gl::SharedTextureHandle mHandle;
gl::GLContext::SharedTextureShareType mShareType;
gl::SharedTextureShareType mShareType;
gfxIntSize mSize;
bool mInverted;
};

View File

@@ -8,7 +8,7 @@
#include <stddef.h> // for size_t
#include <stdint.h> // for uint32_t, uint8_t, uint64_t
#include "GLContext.h" // for GLContext (ptr only), etc
#include "GLContextTypes.h" // for GLContext (ptr only), etc
#include "GLTextureImage.h" // for TextureImage
#include "ImageContainer.h" // for PlanarYCbCrImage, etc
#include "ImageTypes.h" // for StereoMode

View File

@@ -12,6 +12,7 @@
#include "SurfaceStream.h"
#include "SharedSurfaceANGLE.h"
#include "gfxContext.h"
#include "GLContext.h"
using namespace mozilla::gl;
using namespace mozilla::gfx;
@@ -19,6 +20,17 @@ using namespace mozilla::gfx;
namespace mozilla {
namespace layers {
CanvasLayerD3D10::CanvasLayerD3D10(LayerManagerD3D10 *aManager)
: CanvasLayer(aManager, nullptr)
, LayerD3D10(aManager)
, mDataIsPremultiplied(false)
, mNeedsYFlip(false)
, mHasAlpha(true)
{
mImplData = static_cast<LayerD3D10*>(this);
mForceReadback = Preferences::GetBool("webgl.force-layers-readback", false);
}
CanvasLayerD3D10::~CanvasLayerD3D10()
{
}

View File

@@ -7,29 +7,23 @@
#define GFX_CANVASLAYERD3D10_H
#include "LayerManagerD3D10.h"
#include "GLContext.h"
#include "gfxASurface.h"
#include "mozilla/Preferences.h"
namespace mozilla {
namespace gl {
class GLContext;
}
namespace layers {
class CanvasLayerD3D10 : public CanvasLayer,
public LayerD3D10
{
public:
CanvasLayerD3D10(LayerManagerD3D10 *aManager)
: CanvasLayer(aManager, nullptr)
, LayerD3D10(aManager)
, mDataIsPremultiplied(false)
, mNeedsYFlip(false)
, mHasAlpha(true)
{
mImplData = static_cast<LayerD3D10*>(this);
mForceReadback = Preferences::GetBool("webgl.force-layers-readback", false);
}
CanvasLayerD3D10(LayerManagerD3D10 *aManager);
~CanvasLayerD3D10();
// CanvasLayer implementation

View File

@@ -6,6 +6,7 @@ include protocol PGrallocBuffer;
include "gfxipc/ShadowLayerUtils.h";
include "mozilla/gfx/Types.h";
include "nsRegion.h";
using gfx3DMatrix;
using gfxIntSize;
@@ -23,7 +24,7 @@ using mozilla::layers::SurfaceDescriptorX11;
using mozilla::null_t;
using mozilla::WindowsHandle;
using mozilla::gl::SharedTextureHandle;
using mozilla::gl::GLContext::SharedTextureShareType;
using mozilla::gl::SharedTextureShareType;
using mozilla::gfx::SurfaceStreamHandle;
using mozilla::gfx::SurfaceFormat;
using mozilla::gfx::IntSize;

View File

@@ -9,7 +9,8 @@
#define IPC_ShadowLayerUtils_h
#include "ipc/IPCMessageUtils.h"
#include "GLContext.h"
#include "GLContextTypes.h"
#include "SurfaceTypes.h"
#include "mozilla/WidgetUtils.h"
#if defined(MOZ_ENABLE_D3D10_LAYER)
@@ -52,9 +53,9 @@ struct ParamTraits<mozilla::layers::SurfaceDescriptorX11> {
#endif // !defined(MOZ_HAVE_XSURFACEDESCRIPTORX11)
template<>
struct ParamTraits<mozilla::gl::GLContext::SharedTextureShareType>
struct ParamTraits<mozilla::gl::SharedTextureShareType>
{
typedef mozilla::gl::GLContext::SharedTextureShareType paramType;
typedef mozilla::gl::SharedTextureShareType paramType;
static void Write(Message* msg, const paramType& param)
{

View File

@@ -22,6 +22,7 @@
#include "gfxImageSurface.h"
#include "gfxPlatform.h"
#include "GLContext.h"
#include "GeckoProfiler.h"

View File

@@ -209,6 +209,7 @@ CPP_SOURCES += [
'CompositableClient.cpp',
'CompositableHost.cpp',
'CompositableTransactionParent.cpp',
'CompositingRenderTargetOGL.cpp',
'Compositor.cpp',
'CompositorChild.cpp',
'CompositorCocoaWidgetHelper.cpp',

View File

@@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "CanvasLayerOGL.h"
#include "GLContext.h" // for GLContext
#include "GLScreenBuffer.h" // for GLScreenBuffer
#include "SharedSurface.h" // for SharedSurface
#include "SharedSurfaceGL.h" // for SharedSurface_Basic, etc

View File

@@ -6,9 +6,8 @@
#ifndef GFX_CANVASLAYEROGL_H
#define GFX_CANVASLAYEROGL_H
#include "GLContext.h" // for GLContext
#include "GLContextTypes.h" // for GLuint, GLenum
#include "GLDefs.h" // for LOCAL_GL_TEXTURE_2D
#include "GLContextTypes.h" // for GLContext
#include "GLDefs.h" // for GLuint, LOCAL_GL_TEXTURE_2D
#include "LayerManagerOGL.h" // for LayerOGL::GLContext, etc
#include "Layers.h" // for CanvasLayer, etc
#include "gfxASurface.h" // for gfxASurface, etc

View File

@@ -0,0 +1,87 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "CompositingRenderTargetOGL.h"
#include "GLContext.h"
using namespace mozilla;
using namespace mozilla::layers;
CompositingRenderTargetOGL::~CompositingRenderTargetOGL()
{
mGL->fDeleteTextures(1, &mTextureHandle);
mGL->fDeleteFramebuffers(1, &mFBO);
}
void
CompositingRenderTargetOGL::BindTexture(GLenum aTextureUnit, GLenum aTextureTarget)
{
MOZ_ASSERT(mInitParams.mStatus == InitParams::INITIALIZED);
MOZ_ASSERT(mTextureHandle != 0);
mGL->fActiveTexture(aTextureUnit);
mGL->fBindTexture(aTextureTarget, mTextureHandle);
}
void
CompositingRenderTargetOGL::BindRenderTarget()
{
if (mInitParams.mStatus != InitParams::INITIALIZED) {
InitializeImpl();
} else {
MOZ_ASSERT(mInitParams.mStatus == InitParams::INITIALIZED);
mGL->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, mFBO);
GLenum result = mGL->fCheckFramebufferStatus(LOCAL_GL_FRAMEBUFFER);
if (result != LOCAL_GL_FRAMEBUFFER_COMPLETE) {
nsAutoCString msg;
msg.AppendPrintf("Framebuffer not complete -- error 0x%x, aFBOTextureTarget 0x%x, aRect.width %d, aRect.height %d",
result, mInitParams.mFBOTextureTarget, mInitParams.mSize.width, mInitParams.mSize.height);
NS_WARNING(msg.get());
}
mCompositor->PrepareViewport(mInitParams.mSize, mTransform);
}
}
#ifdef MOZ_DUMP_PAINTING
already_AddRefed<gfxImageSurface>
CompositingRenderTargetOGL::Dump(Compositor* aCompositor)
{
MOZ_ASSERT(mInitParams.mStatus == InitParams::INITIALIZED);
CompositorOGL* compositorOGL = static_cast<CompositorOGL*>(aCompositor);
return mGL->GetTexImage(mTextureHandle, true, compositorOGL->GetFBOFormat());
}
#endif
void
CompositingRenderTargetOGL::InitializeImpl()
{
MOZ_ASSERT(mInitParams.mStatus == InitParams::READY);
mGL->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, mFBO);
mGL->fFramebufferTexture2D(LOCAL_GL_FRAMEBUFFER,
LOCAL_GL_COLOR_ATTACHMENT0,
mInitParams.mFBOTextureTarget,
mTextureHandle,
0);
// Making this call to fCheckFramebufferStatus prevents a crash on
// PowerVR. See bug 695246.
GLenum result = mGL->fCheckFramebufferStatus(LOCAL_GL_FRAMEBUFFER);
if (result != LOCAL_GL_FRAMEBUFFER_COMPLETE) {
nsAutoCString msg;
msg.AppendPrintf("Framebuffer not complete -- error 0x%x, aFBOTextureTarget 0x%x, mFBO %d, mTextureHandle %d, aRect.width %d, aRect.height %d",
result, mInitParams.mFBOTextureTarget, mFBO, mTextureHandle, mInitParams.mSize.width, mInitParams.mSize.height);
NS_ERROR(msg.get());
}
mCompositor->PrepareViewport(mInitParams.mSize, mTransform);
mGL->fScissor(0, 0, mInitParams.mSize.width, mInitParams.mSize.height);
if (mInitParams.mInit == INIT_MODE_CLEAR) {
mGL->fClearColor(0.0, 0.0, 0.0, 0.0);
mGL->fClear(LOCAL_GL_COLOR_BUFFER_BIT);
}
mInitParams.mStatus = InitParams::INITIALIZED;
}

View File

@@ -7,9 +7,8 @@
#define MOZILLA_GFX_COMPOSITINGRENDERTARGETOGL_H
#include "mozilla-config.h" // for MOZ_DUMP_PAINTING
#include "GLContext.h" // for GLContext
#include "GLContextTypes.h" // for GLenum, GLuint
#include "GLDefs.h" // for LOCAL_GL_FRAMEBUFFER, etc
#include "GLContextTypes.h" // for GLContext
#include "GLDefs.h" // for GLenum, LOCAL_GL_FRAMEBUFFER, etc
#include "gfxMatrix.h" // for gfxMatrix
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
#include "mozilla/Attributes.h" // for MOZ_OVERRIDE
@@ -73,11 +72,7 @@ public:
, mFBO(aFBO)
{}
~CompositingRenderTargetOGL()
{
mGL->fDeleteTextures(1, &mTextureHandle);
mGL->fDeleteFramebuffers(1, &mFBO);
}
~CompositingRenderTargetOGL();
/**
* Create a render target around the default FBO, for rendering straight to
@@ -111,35 +106,12 @@ public:
mInitParams = InitParams(aSize, aFBOTextureTarget, aInit);
}
void BindTexture(GLenum aTextureUnit, GLenum aTextureTarget)
{
MOZ_ASSERT(mInitParams.mStatus == InitParams::INITIALIZED);
MOZ_ASSERT(mTextureHandle != 0);
mGL->fActiveTexture(aTextureUnit);
mGL->fBindTexture(aTextureTarget, mTextureHandle);
}
void BindTexture(GLenum aTextureUnit, GLenum aTextureTarget);
/**
* Call when we want to draw into our FBO
*/
void BindRenderTarget()
{
if (mInitParams.mStatus != InitParams::INITIALIZED) {
InitializeImpl();
} else {
MOZ_ASSERT(mInitParams.mStatus == InitParams::INITIALIZED);
mGL->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, mFBO);
GLenum result = mGL->fCheckFramebufferStatus(LOCAL_GL_FRAMEBUFFER);
if (result != LOCAL_GL_FRAMEBUFFER_COMPLETE) {
nsAutoCString msg;
msg.AppendPrintf("Framebuffer not complete -- error 0x%x, aFBOTextureTarget 0x%x, aRect.width %d, aRect.height %d",
result, mInitParams.mFBOTextureTarget, mInitParams.mSize.width, mInitParams.mSize.height);
NS_WARNING(msg.get());
}
mCompositor->PrepareViewport(mInitParams.mSize, mTransform);
}
}
void BindRenderTarget();
GLuint GetFBO() const
{
@@ -179,12 +151,7 @@ public:
}
#ifdef MOZ_DUMP_PAINTING
virtual already_AddRefed<gfxImageSurface> Dump(Compositor* aCompositor)
{
MOZ_ASSERT(mInitParams.mStatus == InitParams::INITIALIZED);
CompositorOGL* compositorOGL = static_cast<CompositorOGL*>(aCompositor);
return mGL->GetTexImage(mTextureHandle, true, compositorOGL->GetFBOFormat());
}
virtual already_AddRefed<gfxImageSurface> Dump(Compositor* aCompositor);
#endif
private:
@@ -192,36 +159,7 @@ private:
* Actually do the initialisation. Note that we leave our FBO bound, and so
* calling this method is only suitable when about to use this render target.
*/
void InitializeImpl()
{
MOZ_ASSERT(mInitParams.mStatus == InitParams::READY);
mGL->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, mFBO);
mGL->fFramebufferTexture2D(LOCAL_GL_FRAMEBUFFER,
LOCAL_GL_COLOR_ATTACHMENT0,
mInitParams.mFBOTextureTarget,
mTextureHandle,
0);
// Making this call to fCheckFramebufferStatus prevents a crash on
// PowerVR. See bug 695246.
GLenum result = mGL->fCheckFramebufferStatus(LOCAL_GL_FRAMEBUFFER);
if (result != LOCAL_GL_FRAMEBUFFER_COMPLETE) {
nsAutoCString msg;
msg.AppendPrintf("Framebuffer not complete -- error 0x%x, aFBOTextureTarget 0x%x, mFBO %d, mTextureHandle %d, aRect.width %d, aRect.height %d",
result, mInitParams.mFBOTextureTarget, mFBO, mTextureHandle, mInitParams.mSize.width, mInitParams.mSize.height);
NS_ERROR(msg.get());
}
mCompositor->PrepareViewport(mInitParams.mSize, mTransform);
mGL->fScissor(0, 0, mInitParams.mSize.width, mInitParams.mSize.height);
if (mInitParams.mInit == INIT_MODE_CLEAR) {
mGL->fClearColor(0.0, 0.0, 0.0, 0.0);
mGL->fClear(LOCAL_GL_COLOR_BUFFER_BIT);
}
mInitParams.mStatus = InitParams::INITIALIZED;
}
void InitializeImpl();
InitParams mInitParams;
gfxMatrix mTransform;

View File

@@ -9,6 +9,7 @@
#include <stdlib.h> // for free, malloc
#include "FPSCounter.h" // for FPSState, FPSCounter
#include "GLContextProvider.h" // for GLContextProvider
#include "GLContext.h" // for GLContext
#include "LayerManagerOGL.h" // for BUFFER_OFFSET
#include "Layers.h" // for WriteSnapshotToDumpFile
#include "gfx2DGlue.h" // for ThebesFilter
@@ -1446,5 +1447,94 @@ CompositorOGL::CreateDataTextureSource(TextureFlags aFlags)
return result;
}
bool
CompositorOGL::SupportsPartialTextureUpdate()
{
return mGLContext->CanUploadSubTextures();
}
int32_t
CompositorOGL::GetMaxTextureSize() const
{
MOZ_ASSERT(mGLContext);
GLint texSize = 0;
mGLContext->fGetIntegerv(LOCAL_GL_MAX_TEXTURE_SIZE,
&texSize);
MOZ_ASSERT(texSize != 0);
return texSize;
}
void
CompositorOGL::MakeCurrent(MakeCurrentFlags aFlags) {
if (mDestroyed) {
NS_WARNING("Call on destroyed layer manager");
return;
}
mGLContext->MakeCurrent(aFlags & ForceMakeCurrent);
}
void
CompositorOGL::BindQuadVBO() {
mGLContext->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, mQuadVBO);
}
void
CompositorOGL::QuadVBOVerticesAttrib(GLuint aAttribIndex) {
mGLContext->fVertexAttribPointer(aAttribIndex, 2,
LOCAL_GL_FLOAT, LOCAL_GL_FALSE, 0,
(GLvoid*) QuadVBOVertexOffset());
}
void
CompositorOGL::QuadVBOTexCoordsAttrib(GLuint aAttribIndex) {
mGLContext->fVertexAttribPointer(aAttribIndex, 2,
LOCAL_GL_FLOAT, LOCAL_GL_FALSE, 0,
(GLvoid*) QuadVBOTexCoordOffset());
}
void
CompositorOGL::QuadVBOFlippedTexCoordsAttrib(GLuint aAttribIndex) {
mGLContext->fVertexAttribPointer(aAttribIndex, 2,
LOCAL_GL_FLOAT, LOCAL_GL_FALSE, 0,
(GLvoid*) QuadVBOFlippedTexCoordOffset());
}
void
CompositorOGL::BindAndDrawQuad(GLuint aVertAttribIndex,
GLuint aTexCoordAttribIndex,
bool aFlipped)
{
BindQuadVBO();
QuadVBOVerticesAttrib(aVertAttribIndex);
if (aTexCoordAttribIndex != GLuint(-1)) {
if (aFlipped)
QuadVBOFlippedTexCoordsAttrib(aTexCoordAttribIndex);
else
QuadVBOTexCoordsAttrib(aTexCoordAttribIndex);
mGLContext->fEnableVertexAttribArray(aTexCoordAttribIndex);
}
mGLContext->fEnableVertexAttribArray(aVertAttribIndex);
mGLContext->fDrawArrays(LOCAL_GL_TRIANGLE_STRIP, 0, 4);
mGLContext->fDisableVertexAttribArray(aVertAttribIndex);
if (aTexCoordAttribIndex != GLuint(-1)) {
mGLContext->fDisableVertexAttribArray(aTexCoordAttribIndex);
}
}
void
CompositorOGL::BindAndDrawQuad(ShaderProgramOGL *aProg,
bool aFlipped)
{
NS_ASSERTION(aProg->HasInitialized(), "Shader program not correctly initialized");
BindAndDrawQuad(aProg->AttribLocation(ShaderProgramOGL::VertexCoordAttrib),
aProg->AttribLocation(ShaderProgramOGL::TexCoordAttrib),
aFlipped);
}
} /* layers */
} /* mozilla */

View File

@@ -7,9 +7,8 @@
#define MOZILLA_GFX_COMPOSITOROGL_H
#include "./../mozilla-config.h" // for MOZ_DUMP_PAINTING
#include "GLContext.h" // for GLContext
#include "GLContextTypes.h" // for GLuint, GLenum, GLint
#include "GLDefs.h" // for GLintptr, GLvoid, etc
#include "GLContextTypes.h" // for GLContext, etc
#include "GLDefs.h" // for GLuint, LOCAL_GL_TEXTURE_2D, etc
#include "LayerManagerOGLProgram.h" // for ShaderProgramOGL, etc
#include "Units.h" // for ScreenPoint
#include "gfxContext.h" // for gfxContext
@@ -106,10 +105,7 @@ public:
virtual void EndFrameForExternalComposition(const gfxMatrix& aTransform) MOZ_OVERRIDE;
virtual void AbortFrame() MOZ_OVERRIDE;
virtual bool SupportsPartialTextureUpdate() MOZ_OVERRIDE
{
return mGLContext->CanUploadSubTextures();
}
virtual bool SupportsPartialTextureUpdate() MOZ_OVERRIDE;
virtual bool CanUseCanvasLayerForSize(const gfxIntSize &aSize) MOZ_OVERRIDE
{
@@ -119,15 +115,7 @@ public:
return aSize <= gfxIntSize(maxSize, maxSize);
}
virtual int32_t GetMaxTextureSize() const MOZ_OVERRIDE
{
MOZ_ASSERT(mGLContext);
GLint texSize = 0;
mGLContext->fGetIntegerv(LOCAL_GL_MAX_TEXTURE_SIZE,
&texSize);
MOZ_ASSERT(texSize != 0);
return texSize;
}
virtual int32_t GetMaxTextureSize() const MOZ_OVERRIDE;
/**
* Set the size of the EGL surface we're rendering to, if we're rendering to
@@ -139,13 +127,7 @@ public:
mRenderOffset = aOffset;
}
virtual void MakeCurrent(MakeCurrentFlags aFlags = 0) MOZ_OVERRIDE {
if (mDestroyed) {
NS_WARNING("Call on destroyed layer manager");
return;
}
mGLContext->MakeCurrent(aFlags & ForceMakeCurrent);
}
virtual void MakeCurrent(MakeCurrentFlags aFlags = 0) MOZ_OVERRIDE;
virtual void SetTargetContext(gfxContext* aTarget) MOZ_OVERRIDE
{
@@ -300,62 +282,15 @@ private:
GLintptr QuadVBOTexCoordOffset() { return sizeof(float)*4*2; }
GLintptr QuadVBOFlippedTexCoordOffset() { return sizeof(float)*8*2; }
void BindQuadVBO() {
mGLContext->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, mQuadVBO);
}
void QuadVBOVerticesAttrib(GLuint aAttribIndex) {
mGLContext->fVertexAttribPointer(aAttribIndex, 2,
LOCAL_GL_FLOAT, LOCAL_GL_FALSE, 0,
(GLvoid*) QuadVBOVertexOffset());
}
void QuadVBOTexCoordsAttrib(GLuint aAttribIndex) {
mGLContext->fVertexAttribPointer(aAttribIndex, 2,
LOCAL_GL_FLOAT, LOCAL_GL_FALSE, 0,
(GLvoid*) QuadVBOTexCoordOffset());
}
void QuadVBOFlippedTexCoordsAttrib(GLuint aAttribIndex) {
mGLContext->fVertexAttribPointer(aAttribIndex, 2,
LOCAL_GL_FLOAT, LOCAL_GL_FALSE, 0,
(GLvoid*) QuadVBOFlippedTexCoordOffset());
}
void BindQuadVBO();
void QuadVBOVerticesAttrib(GLuint aAttribIndex);
void QuadVBOTexCoordsAttrib(GLuint aAttribIndex);
void QuadVBOFlippedTexCoordsAttrib(GLuint aAttribIndex);
void BindAndDrawQuad(GLuint aVertAttribIndex,
GLuint aTexCoordAttribIndex,
bool aFlipped = false)
{
BindQuadVBO();
QuadVBOVerticesAttrib(aVertAttribIndex);
if (aTexCoordAttribIndex != GLuint(-1)) {
if (aFlipped)
QuadVBOFlippedTexCoordsAttrib(aTexCoordAttribIndex);
else
QuadVBOTexCoordsAttrib(aTexCoordAttribIndex);
mGLContext->fEnableVertexAttribArray(aTexCoordAttribIndex);
}
mGLContext->fEnableVertexAttribArray(aVertAttribIndex);
mGLContext->fDrawArrays(LOCAL_GL_TRIANGLE_STRIP, 0, 4);
mGLContext->fDisableVertexAttribArray(aVertAttribIndex);
if (aTexCoordAttribIndex != GLuint(-1)) {
mGLContext->fDisableVertexAttribArray(aTexCoordAttribIndex);
}
}
bool aFlipped = false);
void BindAndDrawQuad(ShaderProgramOGL *aProg,
bool aFlipped = false)
{
NS_ASSERTION(aProg->HasInitialized(), "Shader program not correctly initialized");
BindAndDrawQuad(aProg->AttribLocation(ShaderProgramOGL::VertexCoordAttrib),
aProg->AttribLocation(ShaderProgramOGL::TexCoordAttrib),
aFlipped);
}
bool aFlipped = false);
void BindAndDrawQuadWithTextureRect(ShaderProgramOGL *aProg,
const gfx::Rect& aTexCoordRect,
TextureSource *aTexture);

View File

@@ -6,8 +6,7 @@
#ifndef GFX_IMAGELAYEROGL_H
#define GFX_IMAGELAYEROGL_H
#include "GLContext.h" // for GLContext
#include "GLContextTypes.h" // for GLuint
#include "GLContextTypes.h" // for GLContext, GLuint
#include "ImageContainer.h" // for ImageBackendData, etc
#include "ImageLayers.h" // for ImageLayer
#include "LayerManagerOGL.h" // for LayerOGL

View File

@@ -45,7 +45,7 @@ SharedTextureClientOGL::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
void
SharedTextureClientOGL::InitWith(gl::SharedTextureHandle aHandle,
gfx::IntSize aSize,
gl::GLContext::SharedTextureShareType aShareType,
gl::SharedTextureShareType aShareType,
bool aInverted)
{
MOZ_ASSERT(!IsAllocated());

View File

@@ -6,7 +6,7 @@
#ifndef MOZILLA_GFX_TEXTURECLIENTOGL_H
#define MOZILLA_GFX_TEXTURECLIENTOGL_H
#include "GLContext.h" // for SharedTextureHandle, etc
#include "GLContextTypes.h" // for SharedTextureHandle, etc
#include "gfxASurface.h" // for gfxASurface, etc
#include "mozilla/Attributes.h" // for MOZ_OVERRIDE
#include "mozilla/gfx/Point.h" // for IntSize
@@ -36,7 +36,7 @@ public:
void InitWith(gl::SharedTextureHandle aHandle,
gfx::IntSize aSize,
gl::GLContext::SharedTextureShareType aShareType,
gl::SharedTextureShareType aShareType,
bool aInverted = false);
virtual gfx::IntSize GetSize() const { return mSize; }
@@ -44,7 +44,7 @@ public:
protected:
gl::SharedTextureHandle mHandle;
gfx::IntSize mSize;
gl::GLContext::SharedTextureShareType mShareType;
gl::SharedTextureShareType mShareType;
bool mInverted;
};

View File

@@ -292,7 +292,7 @@ SharedTextureSourceOGL::gl() const
SharedTextureHostOGL::SharedTextureHostOGL(uint64_t aID,
TextureFlags aFlags,
gl::GLContext::SharedTextureShareType aShareType,
gl::SharedTextureShareType aShareType,
gl::SharedTextureHandle aSharedHandle,
gfx::IntSize aSize,
bool inverted)
@@ -741,6 +741,14 @@ SurfaceStreamHostOGL::Lock()
return true;
}
void
SurfaceStreamHostOGL::BindTexture(GLenum activetex)
{
MOZ_ASSERT(mGL);
mGL->fActiveTexture(activetex);
mGL->fBindTexture(mTextureTarget, mTextureHandle);
}
void
YCbCrDeprecatedTextureHostOGL::SetCompositor(Compositor* aCompositor)
@@ -826,6 +834,13 @@ TiledDeprecatedTextureHostOGL::~TiledDeprecatedTextureHostOGL()
DeleteTextures();
}
void
TiledDeprecatedTextureHostOGL::BindTexture(GLenum aTextureUnit)
{
mGL->fActiveTexture(aTextureUnit);
mGL->fBindTexture(LOCAL_GL_TEXTURE_2D, mTextureHandle);
}
static void
GetFormatAndTileForImageFormat(gfxASurface::gfxImageFormat aFormat,
GLenum& aOutFormat,

View File

@@ -8,9 +8,8 @@
#include <stddef.h> // for size_t
#include <stdint.h> // for uint64_t
#include "GLContext.h" // for GLContext, etc
#include "GLContextTypes.h" // for GLenum, GLuint
#include "GLDefs.h" // for LOCAL_GL_CLAMP_TO_EDGE, etc
#include "GLContextTypes.h" // for GLContext
#include "GLDefs.h" // for GLenum, LOCAL_GL_CLAMP_TO_EDGE, etc
#include "GLTextureImage.h" // for TextureImage
#include "gfx3DMatrix.h" // for gfx3DMatrix
#include "gfxASurface.h" // for gfxASurface, etc
@@ -219,7 +218,7 @@ class SharedTextureSourceOGL : public NewTextureSource
, public TextureSourceOGL
{
public:
typedef gl::GLContext::SharedTextureShareType SharedTextureShareType;
typedef gl::SharedTextureShareType SharedTextureShareType;
SharedTextureSourceOGL(CompositorOGL* aCompositor,
gl::SharedTextureHandle aHandle,
@@ -278,7 +277,7 @@ class SharedTextureHostOGL : public TextureHost
public:
SharedTextureHostOGL(uint64_t aID,
TextureFlags aFlags,
gl::GLContext::SharedTextureShareType aShareType,
gl::SharedTextureShareType aShareType,
gl::SharedTextureHandle aSharedhandle,
gfx::IntSize aSize,
bool inverted);
@@ -318,7 +317,7 @@ protected:
gfx::IntSize mSize;
CompositorOGL* mCompositor;
gl::SharedTextureHandle mSharedHandle;
gl::GLContext::SharedTextureShareType mShareType;
gl::SharedTextureShareType mShareType;
RefPtr<SharedTextureSourceOGL> mTextureSource;
};
@@ -581,7 +580,7 @@ public:
, mTextureHandle(0)
, mWrapMode(LOCAL_GL_CLAMP_TO_EDGE)
, mSharedHandle(0)
, mShareType(GLContext::SameProcess)
, mShareType(gl::SameProcess)
{}
virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE;
@@ -661,7 +660,7 @@ protected:
GLenum mWrapMode;
GLenum mTextureTarget;
gl::SharedTextureHandle mSharedHandle;
gl::GLContext::SharedTextureShareType mShareType;
gl::SharedTextureShareType mShareType;
};
class SurfaceStreamHostOGL : public DeprecatedTextureHost
@@ -716,11 +715,7 @@ public:
return mTextureTarget;
}
void BindTexture(GLenum activetex) MOZ_OVERRIDE {
MOZ_ASSERT(mGL);
mGL->fActiveTexture(activetex);
mGL->fBindTexture(mTextureTarget, mTextureHandle);
}
void BindTexture(GLenum activetex) MOZ_OVERRIDE;
void UnbindTexture() MOZ_OVERRIDE {}
@@ -784,11 +779,7 @@ public:
virtual TextureSourceOGL* AsSourceOGL() MOZ_OVERRIDE { return this; }
virtual bool IsValid() const MOZ_OVERRIDE { return true; }
virtual GLenum GetWrapMode() const MOZ_OVERRIDE { return LOCAL_GL_CLAMP_TO_EDGE; }
virtual void BindTexture(GLenum aTextureUnit) MOZ_OVERRIDE
{
mGL->fActiveTexture(aTextureUnit);
mGL->fBindTexture(LOCAL_GL_TEXTURE_2D, mTextureHandle);
}
virtual void BindTexture(GLenum aTextureUnit);
virtual void UnbindTexture() MOZ_OVERRIDE {}
virtual gfx::IntSize GetSize() const MOZ_OVERRIDE
{

View File

@@ -5,13 +5,11 @@
#ifndef GFX_TEXTUREPOOLOGL_H
#define GFX_TEXTUREPOOLOGL_H
#include "GLContextTypes.h" // for GLuint
#include "GLContextTypes.h" // for GLContext, GLuint
namespace mozilla {
namespace gl {
class GLContext;
// A texture pool for for the on-screen GLContext. The main purpose of this class
// is to provide the ability to easily allocate an on-screen texture from the
// content thread. The unfortunate nature of the SurfaceTexture API (see nsSurfaceTexture)

View File

@@ -22,7 +22,9 @@
#include "TextInputHandler.h"
#include "nsCocoaUtils.h"
#include "gfxQuartzSurface.h"
#include "GLContext.h"
#include "GLContextTypes.h"
#include "mozilla/Mutex.h"
#include "nsRegion.h"
#include "nsString.h"
#include "nsIDragService.h"

View File

@@ -56,6 +56,7 @@
#include "mozilla/layers/LayerManagerComposite.h"
#include "GLTextureImage.h"
#include "GLContextProvider.h"
#include "GLContext.h"
#include "mozilla/layers/GLManager.h"
#include "mozilla/layers/CompositorCocoaWidgetHelper.h"
#include "mozilla/layers/CompositorOGL.h"

View File

@@ -29,6 +29,7 @@
#include "gfxPlatform.h"
#include "gfxUtils.h"
#include "GLContextProvider.h"
#include "GLContext.h"
#include "LayerManagerOGL.h"
#include "nsAutoPtr.h"
#include "nsAppShell.h"

View File

@@ -67,6 +67,7 @@
#include "mozilla/layers/LayersTypes.h"
#include "nsIIdleServiceInternal.h"
#include "nsIPropertyBag2.h"
#include "GLContext.h"
#ifdef ACCESSIBILITY
#include "mozilla/a11y/Accessible.h"