Skip to content

Commit

Permalink
Bug 1536515 - Part 2: Add constructors that take GLContext to GLTextu…
Browse files Browse the repository at this point in the history
…reSource and DirectMapTextureSource r=nical

Differential Revision: https://phabricator.services.mozilla.com/D80505
  • Loading branch information
mikokm committed Jul 7, 2020
1 parent 0969459 commit 26bb4c4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
16 changes: 13 additions & 3 deletions gfx/layers/opengl/TextureHostOGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,13 @@ void TextureImageTextureSourceOGL::BindTexture(
GLTextureSource::GLTextureSource(TextureSourceProvider* aProvider,
GLuint aTextureHandle, GLenum aTarget,
gfx::IntSize aSize, gfx::SurfaceFormat aFormat)
: mGL(aProvider->GetGLContext()),
: GLTextureSource(aProvider->GetGLContext(), aTextureHandle, aTarget, aSize,
aFormat) {}

GLTextureSource::GLTextureSource(GLContext* aGL, GLuint aTextureHandle,
GLenum aTarget, gfx::IntSize aSize,
gfx::SurfaceFormat aFormat)
: mGL(aGL),
mTextureHandle(aTextureHandle),
mTextureTarget(aTarget),
mSize(aSize),
Expand Down Expand Up @@ -339,16 +345,20 @@ bool GLTextureSource::IsValid() const { return !!gl() && mTextureHandle != 0; }
////////////////////////////////////////////////////////////////////////
// DirectMapTextureSource

DirectMapTextureSource::DirectMapTextureSource(TextureSourceProvider* aProvider,
DirectMapTextureSource::DirectMapTextureSource(gl::GLContext* aContext,
gfx::DataSourceSurface* aSurface)
: GLTextureSource(aProvider, 0, LOCAL_GL_TEXTURE_RECTANGLE_ARB,
: GLTextureSource(aContext, 0, LOCAL_GL_TEXTURE_RECTANGLE_ARB,
aSurface->GetSize(), aSurface->GetFormat()),
mSync(0) {
MOZ_ASSERT(aSurface);

UpdateInternal(aSurface, nullptr, nullptr, true);
}

DirectMapTextureSource::DirectMapTextureSource(TextureSourceProvider* aProvider,
gfx::DataSourceSurface* aSurface)
: DirectMapTextureSource(aProvider->GetGLContext(), aSurface) {}

DirectMapTextureSource::~DirectMapTextureSource() {
if (!mSync || !gl() || !gl()->MakeCurrent() || gl()->IsDestroyed()) {
return;
Expand Down
5 changes: 5 additions & 0 deletions gfx/layers/opengl/TextureHostOGL.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ class GLTextureSource : public DataTextureSource, public TextureSourceOGL {
GLenum aTarget, gfx::IntSize aSize,
gfx::SurfaceFormat aFormat);

GLTextureSource(gl::GLContext* aGL, GLuint aTextureHandle, GLenum aTarget,
gfx::IntSize aSize, gfx::SurfaceFormat aFormat);

virtual ~GLTextureSource();

const char* Name() const override { return "GLTextureSource"; }
Expand Down Expand Up @@ -276,6 +279,8 @@ class GLTextureSource : public DataTextureSource, public TextureSourceOGL {
// the surface is not used by compositor.
class DirectMapTextureSource : public GLTextureSource {
public:
DirectMapTextureSource(gl::GLContext* aContext,
gfx::DataSourceSurface* aSurface);
DirectMapTextureSource(TextureSourceProvider* aProvider,
gfx::DataSourceSurface* aSurface);
~DirectMapTextureSource();
Expand Down

0 comments on commit 26bb4c4

Please sign in to comment.