Bug 1288860 - Change GLContextProvider to use CompositorWidget. r=jrmuizel
This commit is contained in:
@@ -14,6 +14,9 @@
|
||||
class nsIWidget;
|
||||
|
||||
namespace mozilla {
|
||||
namespace widget {
|
||||
class CompositorWidget;
|
||||
}
|
||||
namespace gl {
|
||||
|
||||
#define IN_GL_CONTEXT_PROVIDER_H
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "prenv.h"
|
||||
#include "GeckoProfiler.h"
|
||||
#include "mozilla/gfx/MacIOSurface.h"
|
||||
#include "mozilla/widget/CompositorWidget.h"
|
||||
|
||||
#include <OpenGL/OpenGL.h>
|
||||
|
||||
@@ -25,6 +26,7 @@ namespace mozilla {
|
||||
namespace gl {
|
||||
|
||||
using namespace mozilla::gfx;
|
||||
using namespace mozilla::widget;
|
||||
|
||||
class CGLLibrary
|
||||
{
|
||||
@@ -234,6 +236,12 @@ CreateWithFormat(const NSOpenGLPixelFormatAttribute* attribs)
|
||||
return context;
|
||||
}
|
||||
|
||||
already_AddRefed<GLContext>
|
||||
GLContextProviderCGL::CreateForCompositorWidget(CompositorWidget* aCompositorWidget, bool aForceAccelerated)
|
||||
{
|
||||
return CreateForWindow(aCompositorWidget->RealWidget(), aForceAccelerated);
|
||||
}
|
||||
|
||||
already_AddRefed<GLContext>
|
||||
GLContextProviderCGL::CreateForWindow(nsIWidget* aWidget, bool aForceAccelerated)
|
||||
{
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "gfxFailure.h"
|
||||
#include "prenv.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/widget/CompositorWidget.h"
|
||||
#include "GeckoProfiler.h"
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
@@ -18,6 +19,8 @@
|
||||
namespace mozilla {
|
||||
namespace gl {
|
||||
|
||||
using namespace mozilla::widget;
|
||||
|
||||
GLContextEAGL::GLContextEAGL(CreateContextFlags flags, const SurfaceCaps& caps,
|
||||
EAGLContext* context, GLContext* sharedContext,
|
||||
bool isOffscreen, ContextProfile profile)
|
||||
@@ -204,6 +207,12 @@ CreateEAGLContext(CreateContextFlags flags, bool aOffscreen, GLContextEAGL* shar
|
||||
return glContext.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<GLContext>
|
||||
GLContextProviderEAGL::CreateForCompositorWidget(CompositorWidget* aCompositorWidget, bool aForceAccelerated)
|
||||
{
|
||||
return CreateForWindow(aCompositorWidget->RealWidget(), aForceAccelerated);
|
||||
}
|
||||
|
||||
already_AddRefed<GLContext>
|
||||
GLContextProviderEAGL::CreateForWindow(nsIWidget* aWidget, bool aForceAccelerated)
|
||||
{
|
||||
|
||||
@@ -101,6 +101,7 @@
|
||||
#include "GLLibraryEGL.h"
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/widget/CompositorWidget.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsThreadUtils.h"
|
||||
@@ -112,6 +113,8 @@ using namespace mozilla::gfx;
|
||||
namespace mozilla {
|
||||
namespace gl {
|
||||
|
||||
using namespace mozilla::widget;
|
||||
|
||||
#define ADD_ATTR_2(_array, _k, _v) do { \
|
||||
(_array).AppendElement(_k); \
|
||||
(_array).AppendElement(_v); \
|
||||
@@ -757,6 +760,12 @@ GLContextProviderEGL::CreateWrappingExisting(void* aContext, void* aSurface)
|
||||
return gl.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<GLContext>
|
||||
GLContextProviderEGL::CreateForCompositorWidget(CompositorWidget* aCompositorWidget, bool aForceAccelerated)
|
||||
{
|
||||
return CreateForWindow(aCompositorWidget->RealWidget(), aForceAccelerated);
|
||||
}
|
||||
|
||||
already_AddRefed<GLContext>
|
||||
GLContextProviderEGL::CreateForWindow(nsIWidget* aWidget, bool aForceAccelerated)
|
||||
{
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "mozilla/MathAlgorithms.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "mozilla/widget/CompositorWidget.h"
|
||||
|
||||
#include "prenv.h"
|
||||
#include "GLContextProvider.h"
|
||||
@@ -41,6 +42,7 @@ namespace mozilla {
|
||||
namespace gl {
|
||||
|
||||
using namespace mozilla::gfx;
|
||||
using namespace mozilla::widget;
|
||||
|
||||
GLXLibrary sGLXLibrary;
|
||||
|
||||
@@ -1087,6 +1089,12 @@ GLContextProviderGLX::CreateWrappingExisting(void* aContext, void* aSurface)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
already_AddRefed<GLContext>
|
||||
GLContextProviderGLX::CreateForCompositorWidget(CompositorWidget* aCompositorWidget, bool aForceAccelerated)
|
||||
{
|
||||
return CreateForWindow(aCompositorWidget->RealWidget(), aForceAccelerated);
|
||||
}
|
||||
|
||||
already_AddRefed<GLContext>
|
||||
GLContextProviderGLX::CreateForWindow(nsIWidget* aWidget, bool aForceAccelerated)
|
||||
{
|
||||
|
||||
@@ -17,6 +17,32 @@ typedef void* EGLSurface;
|
||||
class GL_CONTEXT_PROVIDER_NAME
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Create a context that renders to the surface of the widget represented by
|
||||
* the compositor widget that is passed in. The context is always created
|
||||
* with an RGB pixel format, with no alpha, depth or stencil.
|
||||
* If any of those features are needed, either use a framebuffer, or
|
||||
* use CreateOffscreen.
|
||||
*
|
||||
* This context will attempt to share resources with all other window
|
||||
* contexts. As such, it's critical that resources allocated that are not
|
||||
* needed by other contexts be deleted before the context is destroyed.
|
||||
*
|
||||
* The GetSharedContext() method will return non-null if sharing
|
||||
* was successful.
|
||||
*
|
||||
* Note: a context created for a widget /must not/ hold a strong
|
||||
* reference to the widget; otherwise a cycle can be created through
|
||||
* a GL layer manager.
|
||||
*
|
||||
* @param aCompositorWidget Widget whose surface to create a context for
|
||||
* @param aForceAccelerated true if only accelerated contexts are allowed
|
||||
*
|
||||
* @return Context to use for the window
|
||||
*/
|
||||
static already_AddRefed<GLContext>
|
||||
CreateForCompositorWidget(mozilla::widget::CompositorWidget* aCompositorWidget, bool aForceAccelerated);
|
||||
|
||||
/**
|
||||
* Create a context that renders to the surface of the widget that is
|
||||
* passed in. The context is always created with an RGB pixel format,
|
||||
@@ -40,7 +66,7 @@ public:
|
||||
* @return Context to use for the window
|
||||
*/
|
||||
static already_AddRefed<GLContext>
|
||||
CreateForWindow(nsIWidget* widget, bool aForceAccelerated);
|
||||
CreateForWindow(nsIWidget* aWidget, bool aForceAccelerated);
|
||||
|
||||
/**
|
||||
* Create a context for offscreen rendering. The target of this
|
||||
|
||||
@@ -8,8 +8,16 @@
|
||||
namespace mozilla {
|
||||
namespace gl {
|
||||
|
||||
using namespace mozilla::widget;
|
||||
|
||||
already_AddRefed<GLContext>
|
||||
GLContextProviderNull::CreateForWindow(nsIWidget*, bool aForceAccelerated)
|
||||
GLContextProviderNull::CreateForCompositorWidget(CompositorWidget* aCompositorWidget, bool aForceAccelerated)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
already_AddRefed<GLContext>
|
||||
GLContextProviderNull::CreateForWindow(nsIWidget* aWidget, bool aForceAccelerated)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -17,11 +17,13 @@
|
||||
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "mozilla/widget/CompositorWidget.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace gl {
|
||||
|
||||
using namespace mozilla::gfx;
|
||||
using namespace mozilla::widget;
|
||||
|
||||
WGLLibrary sWGLLib;
|
||||
|
||||
@@ -429,6 +431,12 @@ GLContextProviderWGL::CreateWrappingExisting(void*, void*)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
already_AddRefed<GLContext>
|
||||
GLContextProviderWGL::CreateForCompositorWidget(CompositorWidget* aCompositorWidget, bool aForceAccelerated)
|
||||
{
|
||||
return CreateForWindow(aCompositorWidget->RealWidget(), aForceAccelerated);
|
||||
}
|
||||
|
||||
already_AddRefed<GLContext>
|
||||
GLContextProviderWGL::CreateForWindow(nsIWidget* aWidget, bool aForceAccelerated)
|
||||
{
|
||||
|
||||
@@ -117,7 +117,7 @@ CompositorOGL::CreateContext()
|
||||
#ifdef XP_WIN
|
||||
if (gfxEnv::LayersPreferEGL()) {
|
||||
printf_stderr("Trying GL layers...\n");
|
||||
context = gl::GLContextProviderEGL::CreateForWindow(mWidget->RealWidget(), false);
|
||||
context = gl::GLContextProviderEGL::CreateForCompositorWidget(mWidget, false);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -134,7 +134,7 @@ CompositorOGL::CreateContext()
|
||||
}
|
||||
|
||||
if (!context) {
|
||||
context = gl::GLContextProvider::CreateForWindow(mWidget->RealWidget(),
|
||||
context = gl::GLContextProvider::CreateForCompositorWidget(mWidget,
|
||||
gfxPlatform::GetPlatform()->RequiresAcceleratedGLContextForCompositorOGL());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user