mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1560157 - Remove EGLUtils.h. r=lsalzman
EGLImageWrapper was completely unused. Differential Revision: https://phabricator.services.mozilla.com/D35349 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
62e9d98923
commit
32cc8bf833
@ -46,7 +46,6 @@ using mozilla::DefaultXDisplay;
|
||||
#include "nsIDocShell.h"
|
||||
#include "ImageContainer.h"
|
||||
#include "GLContext.h"
|
||||
#include "EGLUtils.h"
|
||||
#include "nsIContentInlines.h"
|
||||
#include "mozilla/MiscEvents.h"
|
||||
#include "mozilla/MouseEvents.h"
|
||||
|
@ -1,104 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "EGLUtils.h"
|
||||
|
||||
#include "GLContextEGL.h"
|
||||
#include "GLLibraryEGL.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace gl {
|
||||
|
||||
bool DoesEGLContextSupportSharingWithEGLImage(GLContext* gl) {
|
||||
const auto& gle = GLContextEGL::Cast(gl);
|
||||
const auto& egl = gle->mEgl;
|
||||
|
||||
return egl->HasKHRImageBase() && egl->HasKHRImageTexture2D() &&
|
||||
gl->IsExtensionSupported(GLContext::OES_EGL_image);
|
||||
}
|
||||
|
||||
EGLImage CreateEGLImage(GLContext* gl, GLuint tex) {
|
||||
MOZ_ASSERT(DoesEGLContextSupportSharingWithEGLImage(gl));
|
||||
|
||||
const auto& gle = GLContextEGL::Cast(gl);
|
||||
const auto& egl = gle->mEgl;
|
||||
EGLClientBuffer clientBuffer = (EGLClientBuffer)((uint64_t)tex);
|
||||
EGLImage image =
|
||||
egl->fCreateImage(egl->Display(), gle->mContext, LOCAL_EGL_GL_TEXTURE_2D,
|
||||
clientBuffer, nullptr);
|
||||
return image;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// EGLImageWrapper
|
||||
|
||||
/*static*/
|
||||
EGLImageWrapper* EGLImageWrapper::Create(GLContext* gl, GLuint tex) {
|
||||
MOZ_ASSERT(DoesEGLContextSupportSharingWithEGLImage(gl));
|
||||
|
||||
const auto& gle = GLContextEGL::Cast(gl);
|
||||
const auto& egl = gle->mEgl;
|
||||
const auto& display = egl->Display();
|
||||
EGLClientBuffer clientBuffer = (EGLClientBuffer)((uint64_t)tex);
|
||||
EGLImage image = egl->fCreateImage(
|
||||
display, gle->mContext, LOCAL_EGL_GL_TEXTURE_2D, clientBuffer, nullptr);
|
||||
if (!image) {
|
||||
#ifdef DEBUG
|
||||
printf_stderr("Could not create EGL images: ERROR (0x%04x)\n",
|
||||
egl->fGetError());
|
||||
#endif
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new EGLImageWrapper(egl, display, image);
|
||||
}
|
||||
|
||||
EGLImageWrapper::EGLImageWrapper(GLLibraryEGL* library, EGLDisplay display,
|
||||
EGLImage image)
|
||||
: mLibrary(library), mDisplay(display), mImage(image), mSync(0) {
|
||||
MOZ_ASSERT(mImage);
|
||||
}
|
||||
|
||||
EGLImageWrapper::~EGLImageWrapper() {
|
||||
mLibrary->fDestroyImage(mDisplay, mImage);
|
||||
}
|
||||
|
||||
bool EGLImageWrapper::FenceSync(GLContext* gl) {
|
||||
MOZ_ASSERT(!mSync);
|
||||
|
||||
if (mLibrary->IsExtensionSupported(GLLibraryEGL::KHR_fence_sync)) {
|
||||
mSync = mLibrary->fCreateSync(mDisplay, LOCAL_EGL_SYNC_FENCE, nullptr);
|
||||
// We need to flush to make sure the sync object enters the command stream;
|
||||
// we can't use EGL_SYNC_FLUSH_COMMANDS_BIT at wait time, because the wait
|
||||
// happens on a different thread/context.
|
||||
gl->fFlush();
|
||||
}
|
||||
|
||||
if (!mSync) {
|
||||
// we failed to create one, so just do a finish
|
||||
gl->fFinish();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EGLImageWrapper::ClientWaitSync() {
|
||||
if (!mSync) {
|
||||
// if we have no sync object, then we did a Finish() earlier
|
||||
return true;
|
||||
}
|
||||
|
||||
// wait at most 1 second; this should really be never/rarely hit
|
||||
const uint64_t ns_per_ms = 1000 * 1000;
|
||||
EGLTime timeout = 1000 * ns_per_ms;
|
||||
|
||||
EGLint result = mLibrary->fClientWaitSync(mDisplay, mSync, 0, timeout);
|
||||
mLibrary->fDestroySync(mDisplay, mSync);
|
||||
mSync = nullptr;
|
||||
|
||||
return result == LOCAL_EGL_CONDITION_SATISFIED;
|
||||
}
|
||||
|
||||
} // namespace gl
|
||||
} // namespace mozilla
|
@ -1,52 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef EGLUTILS_H_
|
||||
#define EGLUTILS_H_
|
||||
|
||||
#include "GLContextTypes.h"
|
||||
#include "GLTypes.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace gl {
|
||||
|
||||
class GLLibraryEGL;
|
||||
|
||||
bool DoesEGLContextSupportSharingWithEGLImage(GLContext* gl);
|
||||
EGLImage CreateEGLImage(GLContext* gl, GLuint tex);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// EGLImageWrapper
|
||||
|
||||
class EGLImageWrapper {
|
||||
public:
|
||||
static EGLImageWrapper* Create(GLContext* gl, GLuint tex);
|
||||
|
||||
private:
|
||||
const RefPtr<GLLibraryEGL> mLibrary;
|
||||
const EGLDisplay mDisplay;
|
||||
|
||||
public:
|
||||
const EGLImage mImage;
|
||||
|
||||
private:
|
||||
EGLSync mSync;
|
||||
|
||||
EGLImageWrapper(GLLibraryEGL* library, EGLDisplay display, EGLImage image);
|
||||
|
||||
public:
|
||||
~EGLImageWrapper();
|
||||
|
||||
// Insert a sync point on the given context, which should be the current
|
||||
// active context.
|
||||
bool FenceSync(GLContext* gl);
|
||||
|
||||
bool ClientWaitSync();
|
||||
};
|
||||
|
||||
} // namespace gl
|
||||
} // namespace mozilla
|
||||
|
||||
#endif
|
@ -542,6 +542,8 @@ class GLLibraryEGL final {
|
||||
static StaticRefPtr<GLLibraryEGL> sEGLLibrary;
|
||||
};
|
||||
|
||||
bool DoesEGLContextSupportSharingWithEGLImage(GLContext* gl);
|
||||
|
||||
} /* namespace gl */
|
||||
} /* namespace mozilla */
|
||||
|
||||
|
@ -27,7 +27,6 @@ EXPORTS += [
|
||||
'AndroidNativeWindow.h',
|
||||
'AndroidSurfaceTexture.h',
|
||||
'DecomposeIntoNoRepeatTriangles.h',
|
||||
'EGLUtils.h',
|
||||
'ForceDiscreteGPUHelperCGL.h',
|
||||
'GfxTexturesReporter.h',
|
||||
'GLBlitHelper.h',
|
||||
@ -119,7 +118,6 @@ if CONFIG['MOZ_WAYLAND']:
|
||||
UNIFIED_SOURCES += [
|
||||
'AndroidSurfaceTexture.cpp',
|
||||
'DecomposeIntoNoRepeatTriangles.cpp',
|
||||
'EGLUtils.cpp',
|
||||
'GfxTexturesReporter.cpp',
|
||||
'GLBlitHelper.cpp',
|
||||
'GLContext.cpp',
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
#include "TextureHostOGL.h"
|
||||
|
||||
#include "EGLUtils.h"
|
||||
#include "GLContext.h" // for GLContext, etc
|
||||
#include "GLLibraryEGL.h" // for GLLibraryEGL
|
||||
#include "GLUploadHelpers.h"
|
||||
@ -711,8 +710,17 @@ void EGLImageTextureSource::BindTexture(GLenum aTextureUnit,
|
||||
return;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(DoesEGLContextSupportSharingWithEGLImage(gl),
|
||||
#ifdef DEBUG
|
||||
const bool supportsEglImage = [&]() {
|
||||
const auto& gle = GLContextEGL::Cast(gl);
|
||||
const auto& egl = gle->mEgl;
|
||||
|
||||
return egl->HasKHRImageBase() && egl->HasKHRImageTexture2D() &&
|
||||
gl->IsExtensionSupported(GLContext::OES_EGL_image);
|
||||
}();
|
||||
MOZ_ASSERT(supportsEglImage,
|
||||
"EGLImage not supported or disabled in runtime");
|
||||
#endif
|
||||
|
||||
GLuint tex = mCompositor->GetTemporaryTexture(mTextureTarget, aTextureUnit);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user