Skip to content

Commit

Permalink
Sync with latest bug 994856 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tmeshkova committed Apr 13, 2014
1 parent 09ae605 commit f80416a
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 93 deletions.
39 changes: 35 additions & 4 deletions embedding/embedlite/embedthread/EmbedLiteCompositorParent.cpp
Expand Up @@ -66,10 +66,41 @@ EmbedLiteCompositorParent::AllocPLayerTransactionParent(const nsTArray<LayersBac
if (listener) {
listener->CompositorCreated();
}
return CompositorParent::AllocPLayerTransactionParent(aBackendHints,
aId,
aTextureFactoryIdentifier,
aSuccess);

PLayerTransactionParent* parent =
CompositorParent::AllocPLayerTransactionParent(aBackendHints,
aId,
aTextureFactoryIdentifier,
aSuccess);

const CompositorParent::LayerTreeState* state = CompositorParent::GetIndirectShadowTree(RootLayerTreeId());
NS_ENSURE_TRUE(state && state->mLayerManager, parent);

GLContext* context = static_cast<CompositorOGL*>(state->mLayerManager->GetCompositor())->gl();
NS_ENSURE_TRUE(context, parent);

if (context->IsOffscreen()) {
GLScreenBuffer* screen = context->Screen();
if (screen) {
SurfaceStreamType streamType =
SurfaceStream::ChooseGLStreamType(SurfaceStream::OffMainThread,
screen->PreserveBuffer());
SurfaceFactory_GL* factory = nullptr;
if (context->GetContextType() == GLContextType::EGL && sEGLLibrary.HasKHRImageTexture2D()) {
// [Basic/OGL Layers, OMTC] WebGL layer init.
factory = SurfaceFactory_EGLImage::Create(context, screen->Caps());
} else {
// [Basic Layers, OMTC] WebGL layer init.
// Well, this *should* work...
factory = new SurfaceFactory_GLTexture(context, nullptr, screen->Caps());
}
if (factory) {
screen->Morph(factory, streamType);
}
}
}

return parent;
}

bool
Expand Down
22 changes: 1 addition & 21 deletions gfx/gl/GLContextProviderCGL.mm
Expand Up @@ -192,27 +192,7 @@ bool EnsureInitialized()
already_AddRefed<GLContext>
GLContextProviderCGL::CreateWrappingExisting(void* aContext, void* aSurface)
{
if (!sCGLLibrary.EnsureInitialized()) {
return nullptr;
}

NSOpenGLContext* context = (NSOpenGLContext)aContext;
if (!context) {
return nullptr;
}

GLContextCGL* shareContext = GetGlobalContextCGL();

// make the context transparent
GLint opaque = 0;
[context setValues:&opaque forParameter:NSOpenGLCPSurfaceOpacity];

SurfaceCaps caps = SurfaceCaps::ForRGBA();
nsRefPtr<GLContextCGL> glContext = new GLContextCGL(caps,
shareContext,
context);

return glContext.forget();
return nullptr;
}

already_AddRefed<GLContext>
Expand Down
8 changes: 2 additions & 6 deletions gfx/gl/GLContextProviderEGL.cpp
Expand Up @@ -259,7 +259,7 @@ GLContextEGL::~GLContextEGL()
{
MarkDestroyed();

// Wrapping GLContext cannot be destroyed
// Wrapped context should not destroy eglContext/Surface
if (!mOwnsContext) {
return;
}
Expand All @@ -275,10 +275,6 @@ GLContextEGL::~GLContextEGL()
bool
GLContextEGL::Init()
{
if (mInitialized) {
return true;
}

#if defined(ANDROID)
// We can't use LoadApitraceLibrary here because the GLContext
// expects its own handle to the GL library
Expand Down Expand Up @@ -444,7 +440,7 @@ GLContextEGL::SetupLookupFunction()
bool
GLContextEGL::SwapBuffers()
{
if (mSurface && mOwnsContext) {
if (mSurface) {
#ifdef MOZ_WIDGET_GONK
if (!mIsOffscreen) {
if (mHwc) {
Expand Down
6 changes: 1 addition & 5 deletions gfx/gl/GLContextProviderGLX.cpp
Expand Up @@ -846,10 +846,6 @@ GLContextGLX::~GLContextGLX()
bool
GLContextGLX::Init()
{
if (mInitialized) {
return true;
}

SetupLookupFunction();
if (!InitWithPrefix("gl", true)) {
return false;
Expand Down Expand Up @@ -907,7 +903,7 @@ GLContextGLX::SupportsRobustness() const
bool
GLContextGLX::SwapBuffers()
{
if (!mDoubleBuffered || !mOwnsContext)
if (!mDoubleBuffered)
return false;
mGLX->xSwapBuffers(mDisplay, mDrawable);
mGLX->xWaitGL();
Expand Down
27 changes: 1 addition & 26 deletions gfx/gl/GLContextProviderWGL.cpp
Expand Up @@ -403,32 +403,7 @@ GetGlobalContextWGL()
already_AddRefed<GLContext>
GLContextProviderWGL::CreateWrappingExisting(void* aContext, void* aSurface)
{
if (!sWGLLib.EnsureInitialized()) {
return nullptr;
}

/**
* We need to make sure we call SetPixelFormat -after- calling
* EnsureInitialized, otherwise it can load/unload the dll and
* wglCreateContext will fail.
*/

if (!aContext) {
return nullptr;
}

GLContextWGL *shareContext = GetGlobalContextWGL();

SurfaceCaps caps = SurfaceCaps::ForRGBA();
nsRefPtr<GLContextWGL> glContext = new GLContextWGL(caps,
shareContext,
false,
(HDC)aSurface,
(HGLRC)aContext);

glContext->SetIsDoubleBuffered(true);

return glContext.forget();
return nullptr;
}

already_AddRefed<GLContext>
Expand Down
10 changes: 0 additions & 10 deletions gfx/gl/GLScreenBuffer.cpp
Expand Up @@ -58,16 +58,6 @@ GLScreenBuffer::Create(GLContext* gl,
}
#endif

if (gl->GetContextType() == GLContextType::EGL) {
bool isCrossProcess = !(XRE_GetProcessType() == GeckoProcessType_Default);
if (!isCrossProcess) {
// [Basic/OGL Layers, OMTC] WebGL layer init.
factory = SurfaceFactory_EGLImage::Create(gl, caps);
}
} else {
factory = new SurfaceFactory_GLTexture(gl, nullptr, caps);
}

if (!factory) {
factory = new SurfaceFactory_Basic(gl, caps);
}
Expand Down
21 changes: 0 additions & 21 deletions gfx/layers/opengl/CompositorOGL.cpp
Expand Up @@ -281,27 +281,6 @@ CompositorOGL::Initialize()

MakeCurrent();

if (mGLContext->IsOffscreen()) {
GLScreenBuffer* screen = mGLContext->Screen();
if (screen) {
SurfaceStreamType streamType =
SurfaceStream::ChooseGLStreamType(SurfaceStream::OffMainThread,
screen->PreserveBuffer());
SurfaceFactory_GL* factory = nullptr;
if (mGLContext->GetContextType() == GLContextType::EGL && sEGLLibrary.HasKHRImageTexture2D()) {
// [Basic/OGL Layers, OMTC] WebGL layer init.
factory = SurfaceFactory_EGLImage::Create(mGLContext, screen->Caps());
} else {
// [Basic Layers, OMTC] WebGL layer init.
// Well, this *should* work...
factory = new SurfaceFactory_GLTexture(mGLContext, nullptr, screen->Caps());
}
if (factory) {
screen->Morph(factory, streamType);
}
}
}

mHasBGRA =
mGLContext->IsExtensionSupported(gl::GLContext::EXT_texture_format_BGRA8888) ||
mGLContext->IsExtensionSupported(gl::GLContext::EXT_bgra);
Expand Down

0 comments on commit f80416a

Please sign in to comment.