Skip to content

Commit

Permalink
Prepare GL context changes for upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
tmeshkova committed Apr 9, 2014
1 parent 9c4020b commit 7432b0a
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 20 deletions.
2 changes: 1 addition & 1 deletion embedding/embedlite/EmbedLiteApp.cpp
Expand Up @@ -76,7 +76,7 @@ EmbedLiteApp::~EmbedLiteApp()
EmbedLiteRenderTarget*
EmbedLiteApp::CreateEmbedLiteRenderTarget()
{
return new EmbedLiteRenderTarget();
return new EmbedLiteRenderTarget(nullptr, nullptr);
}

void
Expand Down
4 changes: 2 additions & 2 deletions embedding/embedlite/EmbedLiteRenderTarget.cpp
Expand Up @@ -12,9 +12,9 @@
using namespace mozilla::gl;
using namespace mozilla::embedlite;

EmbedLiteRenderTarget::EmbedLiteRenderTarget()
EmbedLiteRenderTarget::EmbedLiteRenderTarget(void* aContext, void* aSurface)
{
nsRefPtr<GLContext> ctx = GLContextProvider::CreateForEmbedded();
nsRefPtr<GLContext> ctx = GLContextProvider::CreateWrappingExisting(aContext, aSurface);

MOZ_ASSERT(ctx);
mGLContext = ctx;
Expand Down
2 changes: 1 addition & 1 deletion embedding/embedlite/EmbedLiteRenderTarget.h
Expand Up @@ -26,7 +26,7 @@ class EmbedLiteRenderTarget
mozilla::gl::GLContext* GetConsumerContext() { return mGLContext.get(); }

friend class EmbedLiteApp;
EmbedLiteRenderTarget();
EmbedLiteRenderTarget(void* aContext, void* aSurface);

RefPtr<mozilla::gl::GLContext> mGLContext;
};
Expand Down
2 changes: 1 addition & 1 deletion gfx/gl/GLContextProviderCGL.mm
Expand Up @@ -190,7 +190,7 @@ bool EnsureInitialized()
}

already_AddRefed<GLContext>
GLContextProviderCGL::CreateForEmbedded()
GLContextProviderCGL::CreateWrappingExisting(void* aContext, void* aSurface)
{
return nullptr;
}
Expand Down
6 changes: 1 addition & 5 deletions gfx/gl/GLContextProviderEGL.cpp
Expand Up @@ -692,7 +692,7 @@ CreateConfig(EGLConfig* aConfig)
static nsRefPtr<GLContext> gGlobalContext;

already_AddRefed<GLContext>
GLContextProviderEGL::CreateForEmbedded()
GLContextProviderEGL::CreateWrappingExisting(void* aContext, void* aSurface)
{
if (!sEGLLibrary.EnsureInitialized()) {
MOZ_CRASH("Failed to load EGL library!\n");
Expand Down Expand Up @@ -731,10 +731,6 @@ GLContextProviderEGL::CreateForWindow(nsIWidget *aWidget)

bool doubleBuffered = true;

if (aWidget->HasGLContext()) {
return CreateForEmbedded();
}

EGLConfig config;
if (!CreateConfig(&config)) {
MOZ_CRASH("Failed to create EGLConfig!\n");
Expand Down
6 changes: 1 addition & 5 deletions gfx/gl/GLContextProviderGLX.cpp
Expand Up @@ -984,7 +984,7 @@ AreCompatibleVisuals(Visual *one, Visual *two)
static nsRefPtr<GLContext> gGlobalContext;

already_AddRefed<GLContext>
GLContextProviderGLX::CreateForEmbedded()
GLContextProviderGLX::CreateForEmbedded(void* aContext, void* aSurface)
{
if (!sGLXLibrary.EnsureInitialized()) {
return nullptr;
Expand Down Expand Up @@ -1021,10 +1021,6 @@ GLContextProviderGLX::CreateForWindow(nsIWidget *aWidget)
return nullptr;
}

if (aWidget->HasGLContext()) {
return CreateForEmbedded();
}

// Currently, we take whatever Visual the window already has, and
// try to create an fbconfig for that visual. This isn't
// necessarily what we want in the long run; an fbconfig may not
Expand Down
19 changes: 17 additions & 2 deletions gfx/gl/GLContextProviderImpl.h
Expand Up @@ -61,9 +61,24 @@ class GL_CONTEXT_PROVIDER_NAME
CreateOffscreen(const gfxIntSize& size,
const SurfaceCaps& caps);

static already_AddRefed<GLContext>
CreateForEmbedded();
/**
* Create the gecko context wrapper for existing context.
*
* The offscreen context returned by this method will always have
* the ability to be rendered into a context created by a window.
* It might or might not share resources with the global context;
* query GetSharedContext() for a non-null result to check. If
* resource sharing can be avoided on the target platform, it will
* be, in order to isolate the offscreen context.
*
* @param aContext The initial size of this offscreen context.
* @param aSurface The ContextFormat for this offscreen context.
*
* @return Context to use for offscreen rendering
*/

static already_AddRefed<GLContext>
CreateWrappingExisting(void* aContext, void* aSurface);

/**
* Get a pointer to the global context, creating it if it doesn't exist.
Expand Down
2 changes: 1 addition & 1 deletion gfx/gl/GLContextProviderNull.cpp
Expand Up @@ -15,7 +15,7 @@ GLContextProviderNull::CreateForWindow(nsIWidget*)
}

already_AddRefed<GLContext>
GLContextProviderNull::CreateForEmbedded()
GLContextProviderNull::CreateWrappingExisting(void* aContext, void* aSurface)
{
return nullptr;
}
Expand Down
2 changes: 1 addition & 1 deletion gfx/gl/GLContextProviderWGL.cpp
Expand Up @@ -401,7 +401,7 @@ GetGlobalContextWGL()
}

already_AddRefed<GLContext>
GLContextProviderWGL::CreateForEmbedded()
GLContextProviderWGL::CreateWrappingExisting(void* aContext, void* aSurface)
{
return nullptr;
}
Expand Down
2 changes: 1 addition & 1 deletion gfx/layers/opengl/CompositorOGL.cpp
Expand Up @@ -177,7 +177,7 @@ CompositorOGL::CreateContext()

// If widget has active GL context then we can try to wrap it into Moz GL Context
if (mWidget->HasGLContext()) {
context = GLContextProvider::CreateForEmbedded();
context = GLContextProvider::CreateWrappingExisting(nullptr, nullptr);
if (!context || !context->Init()) {
NS_WARNING("Failed to create embedded context");
context = nullptr;
Expand Down

0 comments on commit 7432b0a

Please sign in to comment.