Bug 874823 - Support unknown consumer for ShSurf_GLTex. - r=mattwoodrow

This commit is contained in:
Jeff Gilbert 2013-06-04 17:05:28 -07:00
Родитель f7319523f2
Коммит 6c9255e881
4 изменённых файлов: 30 добавлений и 5 удалений

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

@ -339,9 +339,10 @@ SharedSurface_GLTexture::~SharedSurface_GLTexture()
void
SharedSurface_GLTexture::Fence()
{
MutexAutoLock lock(mMutex);
mGL->MakeCurrent();
if (mGL->IsExtensionSupported(GLContext::ARB_sync)) {
if (mConsGL && mGL->IsExtensionSupported(GLContext::ARB_sync)) {
if (mSync) {
mGL->fDeleteSync(mSync);
mSync = 0;
@ -361,10 +362,13 @@ SharedSurface_GLTexture::Fence()
bool
SharedSurface_GLTexture::WaitSync()
{
MutexAutoLock lock(mMutex);
if (!mSync) {
// We must have used glFinish instead of glFenceSync.
return true;
}
MOZ_ASSERT(mConsGL, "Did you forget to call a deferred `SetConsumerGL()`?");
mConsGL->MakeCurrent();
MOZ_ASSERT(mConsGL->IsExtensionSupported(GLContext::ARB_sync));
@ -377,5 +381,13 @@ SharedSurface_GLTexture::WaitSync()
return true;
}
void
SharedSurface_GLTexture::SetConsumerGL(GLContext* consGL)
{
MutexAutoLock lock(mMutex);
MOZ_ASSERT(consGL);
mConsGL = consGL;
}
} /* namespace gfx */
} /* namespace mozilla */

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

@ -12,6 +12,7 @@
#include "GLContextTypes.h"
#include "nsAutoPtr.h"
#include "gfxASurface.h"
#include "mozilla/Mutex.h"
#include <queue>
@ -192,9 +193,10 @@ public:
}
protected:
GLContext* const mConsGL;
GLContext* mConsGL;
const GLuint mTex;
GLsync mSync;
mutable Mutex mMutex;
SharedSurface_GLTexture(GLContext* prodGL,
GLContext* consGL,
@ -209,6 +211,7 @@ protected:
, mConsGL(consGL)
, mTex(tex)
, mSync(0)
, mMutex("SharedSurface_GLTexture mutex")
{
}
@ -226,6 +229,9 @@ public:
virtual GLuint Texture() const {
return mTex;
}
// Custom:
void SetConsumerGL(GLContext* consGL);
};
class SurfaceFactory_GLTexture
@ -235,12 +241,17 @@ protected:
GLContext* const mConsGL;
public:
// If we don't know `consGL` at construction time, use `nullptr`, and call
// `SetConsumerGL()` on each `SharedSurface_GLTexture` before calling its
// `WaitSync()`.
SurfaceFactory_GLTexture(GLContext* prodGL,
GLContext* consGL,
const SurfaceCaps& caps)
: SurfaceFactory_GL(prodGL, SharedSurfaceType::GLTextureShare, caps)
, mConsGL(consGL)
{}
{
MOZ_ASSERT(consGL != prodGL);
}
virtual SharedSurface* CreateShared(const gfxIntSize& size) {
bool hasAlpha = mReadCaps.alpha;

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

@ -42,7 +42,7 @@ ClientCanvasLayer::Initialize(const Data& aData)
} else {
// [Basic Layers, OMTC] WebGL layer init.
// Well, this *should* work...
factory = new SurfaceFactory_GLTexture(mGLContext, mGLContext, screen->Caps());
factory = new SurfaceFactory_GLTexture(mGLContext, nullptr, screen->Caps());
}
}
}

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

@ -407,7 +407,9 @@ SurfaceStreamHostOGL::Lock()
gfxImageSurface* toUpload = nullptr;
switch (sharedSurf->Type()) {
case SharedSurfaceType::GLTextureShare: {
mTextureHandle = SharedSurface_GLTexture::Cast(sharedSurf)->Texture();
SharedSurface_GLTexture* glTexSurf = SharedSurface_GLTexture::Cast(sharedSurf);
glTexSurf->SetConsumerGL(mGL);
mTextureHandle = glTexSurf->Texture();
MOZ_ASSERT(mTextureHandle);
mShaderProgram = sharedSurf->HasAlpha() ? RGBALayerProgramType
: RGBXLayerProgramType;