gecko/gfx/gl/SharedSurfaceGLX.cpp
Wes Kocher 6482c81f9b Backed out 13 changesets (bug 709490) for android webgl-color-test.html failures
Backed out changeset 5be7514914b6 (bug 709490)
Backed out changeset 04b6f94fbe8a (bug 709490)
Backed out changeset 00c0e85dd8cd (bug 709490)
Backed out changeset 221385b7b81a (bug 709490)
Backed out changeset ecc38c18734f (bug 709490)
Backed out changeset 22878c936384 (bug 709490)
Backed out changeset 0edcbb60eee3 (bug 709490)
Backed out changeset 5feceec2014b (bug 709490)
Backed out changeset 835b655cb873 (bug 709490)
Backed out changeset 6fbb4a3f8cf7 (bug 709490)
Backed out changeset a5f8646fa156 (bug 709490)
Backed out changeset 2ae1386916b3 (bug 709490)
Backed out changeset 6b29a2a0a8fb (bug 709490)
2015-09-29 08:57:36 -07:00

111 lines
3.6 KiB
C++

/* -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40; -*- */
/* 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 "SharedSurfaceGLX.h"
#include "gfxXlibSurface.h"
#include "GLXLibrary.h"
#include "GLContextProvider.h"
#include "GLContextGLX.h"
#include "GLScreenBuffer.h"
#include "mozilla/layers/LayersSurfaces.h"
#include "mozilla/layers/ShadowLayerUtilsX11.h"
#include "mozilla/layers/ISurfaceAllocator.h"
#include "mozilla/X11Util.h"
namespace mozilla {
namespace gl {
/* static */
UniquePtr<SharedSurface_GLXDrawable>
SharedSurface_GLXDrawable::Create(GLContext* prodGL,
const SurfaceCaps& caps,
const gfx::IntSize& size,
bool deallocateClient,
bool inSameProcess)
{
UniquePtr<SharedSurface_GLXDrawable> ret;
Display* display = DefaultXDisplay();
Screen* screen = XDefaultScreenOfDisplay(display);
Visual* visual = gfxXlibSurface::FindVisual(screen, gfxImageFormat::ARGB32);
RefPtr<gfxXlibSurface> surf = gfxXlibSurface::Create(screen, visual, size);
if (!deallocateClient)
surf->ReleasePixmap();
ret.reset(new SharedSurface_GLXDrawable(prodGL, size, inSameProcess, surf));
return Move(ret);
}
SharedSurface_GLXDrawable::SharedSurface_GLXDrawable(GLContext* gl,
const gfx::IntSize& size,
bool inSameProcess,
const RefPtr<gfxXlibSurface>& xlibSurface)
: SharedSurface(SharedSurfaceType::GLXDrawable,
AttachmentType::Screen,
gl,
size,
true,
true)
, mXlibSurface(xlibSurface)
, mInSameProcess(inSameProcess)
{}
void
SharedSurface_GLXDrawable::Fence()
{
mGL->MakeCurrent();
mGL->fFlush();
}
void
SharedSurface_GLXDrawable::LockProdImpl()
{
mGL->Screen()->SetReadBuffer(LOCAL_GL_FRONT);
GLContextGLX::Cast(mGL)->OverrideDrawable(mXlibSurface->GetGLXPixmap());
}
void
SharedSurface_GLXDrawable::UnlockProdImpl()
{
GLContextGLX::Cast(mGL)->RestoreDrawable();
}
bool
SharedSurface_GLXDrawable::ToSurfaceDescriptor(layers::SurfaceDescriptor* const out_descriptor)
{
if (!mXlibSurface)
return false;
*out_descriptor = layers::SurfaceDescriptorX11(mXlibSurface, mInSameProcess);
return true;
}
/* static */
UniquePtr<SurfaceFactory_GLXDrawable>
SurfaceFactory_GLXDrawable::Create(GLContext* prodGL,
const SurfaceCaps& caps,
const RefPtr<layers::ISurfaceAllocator>& allocator,
const layers::TextureFlags& flags)
{
MOZ_ASSERT(caps.alpha, "GLX surfaces require an alpha channel!");
typedef SurfaceFactory_GLXDrawable ptrT;
UniquePtr<ptrT> ret(new ptrT(prodGL, caps, allocator,
flags & ~layers::TextureFlags::ORIGIN_BOTTOM_LEFT));
return Move(ret);
}
UniquePtr<SharedSurface>
SurfaceFactory_GLXDrawable::CreateShared(const gfx::IntSize& size)
{
bool deallocateClient = !!(mFlags & layers::TextureFlags::DEALLOCATE_CLIENT);
return SharedSurface_GLXDrawable::Create(mGL, mCaps, size, deallocateClient,
mAllocator->IsSameProcess());
}
} // namespace gl
} // namespace mozilla