summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2022-08-31 11:46:12 +0000
committerMoonchild <moonchild@palemoon.org>2022-08-31 11:46:12 +0000
commit6638cc1e6d64dcba9c46bce48080fc17f1405f1e (patch)
treea1ff714e1bbd2d29421c17c6cbb8f557a853bce2
parentea31efd98eeafeb8b31733f025e1c349e70e0efb (diff)
downloaduxp-6638cc1e6d64dcba9c46bce48080fc17f1405f1e.tar.gz
[No issue] Don't use gfxXlibSurface in GLContextGLX.
-rw-r--r--gfx/gl/GLContextGLX.h18
-rw-r--r--gfx/gl/GLContextProviderGLX.cpp49
-rw-r--r--gfx/thebes/gfxPlatformGtk.cpp3
3 files changed, 31 insertions, 39 deletions
diff --git a/gfx/gl/GLContextGLX.h b/gfx/gl/GLContextGLX.h
index f7dd90c2b5..d431116756 100644
--- a/gfx/gl/GLContextGLX.h
+++ b/gfx/gl/GLContextGLX.h
@@ -25,8 +25,7 @@ public:
Display* display,
GLXDrawable drawable,
GLXFBConfig cfg,
- bool deleteDrawable,
- gfxXlibSurface* pixmap = nullptr,
+ Drawable ownedPixmap = X11None,
ContextProfile profile = ContextProfile::OpenGLCompatibility);
// Finds a GLXFBConfig compatible with the provided window.
@@ -77,25 +76,26 @@ private:
Display* aDisplay,
GLXDrawable aDrawable,
GLXContext aContext,
- bool aDeleteDrawable,
bool aDoubleBuffered,
- gfxXlibSurface* aPixmap,
- ContextProfile profile);
+ ContextProfile profile,
+ Drawable aOwnedPixmap = X11None);
GLXContext mContext;
Display* mDisplay;
GLXDrawable mDrawable;
Maybe<GLXDrawable> mOverrideDrawable;
- bool mDeleteDrawable;
+ // The X pixmap associated with the GLX pixmap. If this is provided, then
+ // this class assumes responsibility for freeing both. Otherwise, the
+ // user of this class is responsibile for freeing the drawables.
+ const Drawable mOwnedPixmap;
bool mDoubleBuffered;
GLXLibrary* mGLX;
- RefPtr<gfxXlibSurface> mPixmap;
bool mOwnsContext;
};
-}
-}
+} // namespace gl
+} // namespace mozilla
#endif // GLCONTEXTGLX_H_
diff --git a/gfx/gl/GLContextProviderGLX.cpp b/gfx/gl/GLContextProviderGLX.cpp
index c44b1a9f06..27d07e391d 100644
--- a/gfx/gl/GLContextProviderGLX.cpp
+++ b/gfx/gl/GLContextProviderGLX.cpp
@@ -327,7 +327,7 @@ GLXLibrary::CreatePixmap(gfxASurface* aSurface)
X11None };
int numConfigs = 0;
- Display* display = xs->XDisplay();
+ Display *display = xs->XDisplay();
int xscreen = DefaultScreen(display);
ScopedXFree<GLXFBConfig> cfgs(xChooseFBConfig(display,
@@ -800,7 +800,7 @@ already_AddRefed<GLContextGLX>
GLContextGLX::CreateGLContext(CreateContextFlags flags, const SurfaceCaps& caps,
GLContextGLX* shareContext, bool isOffscreen,
Display* display, GLXDrawable drawable, GLXFBConfig cfg,
- bool deleteDrawable, gfxXlibSurface* pixmap,
+ Drawable ownedPixmap,
ContextProfile profile)
{
GLXLibrary& glx = sGLXLibrary;
@@ -860,8 +860,7 @@ GLContextGLX::CreateGLContext(CreateContextFlags flags, const SurfaceCaps& caps,
if (context) {
glContext = new GLContextGLX(flags, caps, shareContext, isOffscreen, display,
- drawable, context, deleteDrawable, db, pixmap,
- profile);
+ drawable, context, db, profile, ownedPixmap);
if (!glContext->Init())
error = true;
} else {
@@ -896,8 +895,9 @@ GLContextGLX::~GLContextGLX()
mGLX->xDestroyContext(mDisplay, mContext);
- if (mDeleteDrawable) {
+ if (mOwnedPixmap) {
mGLX->xDestroyPixmap(mDisplay, mDrawable);
+ XFreePixmap(mDisplay, mOwnedPixmap);
}
MOZ_ASSERT(!mOverrideDrawable);
}
@@ -1035,18 +1035,16 @@ GLContextGLX::GLContextGLX(
Display* aDisplay,
GLXDrawable aDrawable,
GLXContext aContext,
- bool aDeleteDrawable,
bool aDoubleBuffered,
- gfxXlibSurface* aPixmap,
- ContextProfile profile)
+ ContextProfile profile,
+ Drawable aOwnedPixmap)
: GLContext(flags, caps, shareContext, isOffscreen),
mContext(aContext),
mDisplay(aDisplay),
mDrawable(aDrawable),
- mDeleteDrawable(aDeleteDrawable),
+ mOwnedPixmap(aOwnedPixmap),
mDoubleBuffered(aDoubleBuffered),
mGLX(&sGLXLibrary),
- mPixmap(aPixmap),
mOwnsContext(true)
{
MOZ_ASSERT(mGLX);
@@ -1098,10 +1096,9 @@ GLContextProviderGLX::CreateWrappingExisting(void* aContext, void* aSurface)
false, // Offscreen
(Display*)DefaultXDisplay(), // Display
(GLXDrawable)aSurface, (GLXContext)aContext,
- false, // aDeleteDrawable,
true,
- (gfxXlibSurface*)nullptr,
- ContextProfile::OpenGLCompatibility);
+ ContextProfile::OpenGLCompatibility,
+ (Drawable)nullptr);
glContext->mOwnsContext = false;
gGlobalContext = glContext;
@@ -1146,8 +1143,7 @@ CreateForWidget(Display* aXDisplay, Window aXWindow, bool aForceAccelerated)
GLContextGLX* shareContext = GetGlobalContextGLX();
RefPtr<GLContextGLX> gl = GLContextGLX::CreateGLContext(CreateContextFlags::NONE,
caps, shareContext, false,
- aXDisplay, aXWindow, config,
- false);
+ aXDisplay, aXWindow, config);
return gl.forget();
}
@@ -1326,24 +1322,20 @@ CreateOffscreenPixmapContext(CreateContextFlags flags, const IntSize& size,
FindVisualAndDepth(display, visid, &visual, &depth);
OffMainThreadScopedXErrorHandler xErrorHandler;
- bool error = false;
- Drawable drawable;
GLXPixmap pixmap = 0;
gfx::IntSize dummySize(16, 16);
- RefPtr<gfxXlibSurface> surface = gfxXlibSurface::Create(DefaultScreenOfDisplay(display),
- visual,
- dummySize);
- if (surface->CairoStatus() != 0) {
- mozilla::Unused << xErrorHandler.SyncAndGetError(display);
- return nullptr;
+ const auto drawable =
+ XCreatePixmap(display, DefaultRootWindow(display),
+ dummySize.width, dummySize.height, depth);
+ if (!drawable) {
+ mozilla::Unused << xErrorHandler.SyncAndGetError(display);
+ return nullptr;
}
-
// Handle slightly different signature between glXCreatePixmap and
// its pre-GLX-1.3 extension equivalent (though given the ABI, we
// might not need to).
- drawable = surface->XDrawable();
if (glx->GLXVersionCheck(1, 3)) {
pixmap = glx->xCreatePixmap(display, config, drawable, nullptr);
} else {
@@ -1351,16 +1343,17 @@ CreateOffscreenPixmapContext(CreateContextFlags flags, const IntSize& size,
}
if (pixmap == 0) {
- error = true;
+ XFreePixmap(display, drawable);
+ return nullptr;
}
bool serverError = xErrorHandler.SyncAndGetError(display);
- if (error || serverError)
+ if (serverError)
return nullptr;
GLContextGLX* shareContext = GetGlobalContextGLX();
return GLContextGLX::CreateGLContext(flags, minCaps, shareContext, true, display,
- pixmap, config, true, surface, profile);
+ pixmap, config, drawable, profile);
}
/*static*/ already_AddRefed<GLContext>
diff --git a/gfx/thebes/gfxPlatformGtk.cpp b/gfx/thebes/gfxPlatformGtk.cpp
index 6b55935248..73d1741922 100644
--- a/gfx/thebes/gfxPlatformGtk.cpp
+++ b/gfx/thebes/gfxPlatformGtk.cpp
@@ -731,8 +731,7 @@ public:
false,
mXDisplay,
root,
- config,
- false);
+ config);
if (!mGLContext) {
lock.NotifyAll();