Bug 1278403 - Misc code cleanup. - r=jrmuizel

MozReview-Commit-ID: 3ccHiLQM6lm
This commit is contained in:
Jeff Gilbert 2016-06-06 17:31:53 -07:00
Родитель 6b0581243f
Коммит 87e8222d4d
3 изменённых файлов: 55 добавлений и 96 удалений

Просмотреть файл

@ -193,14 +193,9 @@ CreateSurfaceForWindow(nsIWidget* widget, const EGLConfig& config) {
return newSurface;
}
GLContextEGL::GLContextEGL(
CreateContextFlags flags,
const SurfaceCaps& caps,
GLContext* shareContext,
bool isOffscreen,
EGLConfig config,
EGLSurface surface,
EGLContext context)
GLContextEGL::GLContextEGL(CreateContextFlags flags, const SurfaceCaps& caps,
GLContext* shareContext, bool isOffscreen, EGLConfig config,
EGLSurface surface, EGLContext context)
: GLContext(flags, caps, shareContext, isOffscreen)
, mConfig(config)
, mSurface(surface)
@ -529,10 +524,8 @@ GLContextEGL::CreateGLContext(CreateContextFlags flags,
contextAttribs.Elements());
if (!context && shareContext) {
shareContext = nullptr;
context = sEGLLibrary.fCreateContext(EGL_DISPLAY(),
config,
EGL_NO_CONTEXT,
contextAttribs.Elements());
context = sEGLLibrary.fCreateContext(EGL_DISPLAY(), config, EGL_NO_CONTEXT,
contextAttribs.Elements());
}
if (!context) {
aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_CREATE");
@ -540,12 +533,9 @@ GLContextEGL::CreateGLContext(CreateContextFlags flags,
return nullptr;
}
RefPtr<GLContextEGL> glContext = new GLContextEGL(flags, caps,
shareContext,
isOffscreen,
config,
surface,
context);
RefPtr<GLContextEGL> glContext = new GLContextEGL(flags, caps, shareContext,
isOffscreen, config, surface,
context);
if (!glContext->Init()) {
aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_INIT");
@ -755,21 +745,18 @@ GLContextProviderEGL::CreateWrappingExisting(void* aContext, void* aSurface)
return nullptr;
}
if (aContext && aSurface) {
SurfaceCaps caps = SurfaceCaps::Any();
EGLConfig config = EGL_NO_CONFIG;
RefPtr<GLContextEGL> glContext =
new GLContextEGL(CreateContextFlags::NONE, caps,
nullptr, false,
config, (EGLSurface)aSurface, (EGLContext)aContext);
if (!aContext || !aSurface)
return nullptr;
glContext->SetIsDoubleBuffered(true);
glContext->mOwnsContext = false;
SurfaceCaps caps = SurfaceCaps::Any();
EGLConfig config = EGL_NO_CONFIG;
RefPtr<GLContextEGL> gl = new GLContextEGL(CreateContextFlags::NONE, caps, nullptr,
false, config, (EGLSurface)aSurface,
(EGLContext)aContext);
gl->SetIsDoubleBuffered(true);
gl->mOwnsContext = false;
return glContext.forget();
}
return nullptr;
return gl.forget();
}
already_AddRefed<GLContext>
@ -796,21 +783,19 @@ GLContextProviderEGL::CreateForWindow(nsIWidget *aWidget, bool aForceAccelerated
}
SurfaceCaps caps = SurfaceCaps::Any();
RefPtr<GLContextEGL> glContext =
GLContextEGL::CreateGLContext(CreateContextFlags::NONE, caps,
nullptr, false,
config, surface, discardFailureId);
if (!glContext) {
RefPtr<GLContextEGL> gl = GLContextEGL::CreateGLContext(CreateContextFlags::NONE,
caps, nullptr, false, config,
surface, discardFailureId);
if (!gl) {
MOZ_CRASH("GFX: Failed to create EGLContext!\n");
mozilla::gl::DestroySurface(surface);
return nullptr;
}
glContext->MakeCurrent();
glContext->SetIsDoubleBuffered(doubleBuffered);
gl->MakeCurrent();
gl->SetIsDoubleBuffered(doubleBuffered);
return glContext.forget();
return gl.forget();
}
#if defined(ANDROID)
@ -829,8 +814,8 @@ GLContextProviderEGL::CreateEGLSurface(void* aWindow)
MOZ_ASSERT(aWindow);
EGLSurface surface = sEGLLibrary.fCreateWindowSurface(EGL_DISPLAY(), config, aWindow, 0);
EGLSurface surface = sEGLLibrary.fCreateWindowSurface(EGL_DISPLAY(), config, aWindow,
0);
if (surface == EGL_NO_SURFACE) {
MOZ_CRASH("GFX: Failed to create EGLSurface 2!\n");
}
@ -983,8 +968,9 @@ GLContextEGL::CreateEGLPBufferOffscreenContext(CreateContextFlags flags,
return nullptr;
}
RefPtr<GLContextEGL> gl = GLContextEGL::CreateGLContext(flags, configCaps, nullptr, true,
config, surface, aFailureId);
RefPtr<GLContextEGL> gl = GLContextEGL::CreateGLContext(flags, configCaps, nullptr,
true, config, surface,
aFailureId);
if (!gl) {
NS_WARNING("Failed to create GLContext from PBuffer");
sEGLLibrary.fDestroySurface(sEGLLibrary.Display(), surface);
@ -1039,11 +1025,11 @@ GLContextProviderEGL::CreateOffscreen(const mozilla::gfx::IntSize& size,
minBackbufferCaps.stencil = false;
}
gl = GLContextEGL::CreateEGLPBufferOffscreenContext(flags, size, minBackbufferCaps,
gl = GLContextEGL::CreateEGLPBufferOffscreenContext(flags, size,
minBackbufferCaps,
aFailureId);
if (!gl) {
if (!gl)
return nullptr;
}
// Pull the actual resulting caps to ensure that our offscreen matches our
// backbuffer.

Просмотреть файл

@ -779,16 +779,11 @@ GLXLibrary::xWaitVideoSync(int divisor, int remainder, unsigned int* count)
}
already_AddRefed<GLContextGLX>
GLContextGLX::CreateGLContext(CreateContextFlags flags,
const SurfaceCaps& caps,
GLContextGLX* shareContext,
bool isOffscreen,
Display* display,
GLXDrawable drawable,
GLXFBConfig cfg,
bool deleteDrawable,
gfxXlibSurface* pixmap,
ContextProfile profile)
GLContextGLX::CreateGLContext(CreateContextFlags flags, const SurfaceCaps& caps,
GLContextGLX* shareContext, bool isOffscreen,
Display* display, GLXDrawable drawable, GLXFBConfig cfg,
bool deleteDrawable, gfxXlibSurface* pixmap,
ContextProfile profile)
{
GLXLibrary& glx = sGLXLibrary;
@ -847,16 +842,9 @@ TRY_AGAIN_NO_SHARING:
}
if (context) {
glContext = new GLContextGLX(flags, caps,
shareContext,
isOffscreen,
display,
drawable,
context,
deleteDrawable,
db,
pixmap,
profile);
glContext = new GLContextGLX(flags, caps, shareContext, isOffscreen, display,
drawable, context, deleteDrawable, db, pixmap,
profile);
if (!glContext->Init())
error = true;
} else {
@ -1120,19 +1108,13 @@ GLContextProviderGLX::CreateForWindow(nsIWidget *aWidget, bool aForceAccelerated
return nullptr;
}
GLContextGLX *shareContext = GetGlobalContextGLX();
SurfaceCaps caps = SurfaceCaps::Any();
RefPtr<GLContextGLX> glContext = GLContextGLX::CreateGLContext(CreateContextFlags::NONE,
caps,
shareContext,
false,
display,
window,
config,
false);
return glContext.forget();
GLContextGLX* shareContext = GetGlobalContextGLX();
RefPtr<GLContextGLX> gl = GLContextGLX::CreateGLContext(CreateContextFlags::NONE,
caps, shareContext, false,
display, window, config,
false);
return gl.forget();
}
static bool

Просмотреть файл

@ -266,13 +266,9 @@ WGLLibrary::EnsureInitialized()
return true;
}
GLContextWGL::GLContextWGL(CreateContextFlags flags,
const SurfaceCaps& caps,
GLContext* sharedContext,
bool isOffscreen,
HDC aDC,
HGLRC aContext,
HWND aWindow)
GLContextWGL::GLContextWGL(CreateContextFlags flags, const SurfaceCaps& caps,
GLContext* sharedContext, bool isOffscreen, HDC aDC,
HGLRC aContext, HWND aWindow)
: GLContext(flags, caps, sharedContext, isOffscreen),
mDC(aDC),
mContext(aContext),
@ -285,14 +281,9 @@ GLContextWGL::GLContextWGL(CreateContextFlags flags,
SetProfileVersion(ContextProfile::OpenGLCompatibility, 200);
}
GLContextWGL::GLContextWGL(CreateContextFlags flags,
const SurfaceCaps& caps,
GLContext* sharedContext,
bool isOffscreen,
HANDLE aPbuffer,
HDC aDC,
HGLRC aContext,
int aPixelFormat)
GLContextWGL::GLContextWGL(CreateContextFlags flags, const SurfaceCaps& caps,
GLContext* sharedContext, bool isOffscreen, HANDLE aPbuffer,
HDC aDC, HGLRC aContext, int aPixelFormat)
: GLContext(flags, caps, sharedContext, isOffscreen),
mDC(aDC),
mContext(aContext),
@ -635,8 +626,8 @@ CreateWindowOffscreenContext()
SurfaceCaps caps = SurfaceCaps::ForRGBA();
RefPtr<GLContextWGL> glContext = new GLContextWGL(CreateContextFlags::NONE, caps,
shareContext, true,
dc, context, win);
shareContext, true, dc, context,
win);
return glContext.forget();
}