gecko-dev/gfx/gl/SharedSurfaceGLX.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

105 строки
3.4 KiB
C++
Исходник Обычный вид История

/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 4; -*- */
/* 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 "MozFramebuffer.h"
#include "mozilla/gfx/SourceSurfaceCairo.h"
#include "mozilla/layers/LayersSurfaces.h"
#include "mozilla/layers/ShadowLayerUtilsX11.h"
#include "mozilla/layers/ISurfaceAllocator.h"
#include "mozilla/layers/TextureForwarder.h"
#include "mozilla/X11Util.h"
namespace mozilla::gl {
UniquePtr<SharedSurface> SurfaceFactory_GLXDrawable::CreateSharedImpl(
const SharedSurfaceDesc& desc) {
return SharedSurface_GLXDrawable::Create(desc);
}
/* static */
UniquePtr<SharedSurface_GLXDrawable> SharedSurface_GLXDrawable::Create(
const SharedSurfaceDesc& desc) {
Display* display = DefaultXDisplay();
Screen* screen = XDefaultScreenOfDisplay(display);
Visual* visual =
gfxXlibSurface::FindVisual(screen, gfx::SurfaceFormat::A8R8G8B8_UINT32);
const RefPtr<gfxXlibSurface> surf =
gfxXlibSurface::Create(screen, visual, desc.size);
surf->ReleasePixmap();
return AsUnique(new SharedSurface_GLXDrawable(desc, surf));
}
SharedSurface_GLXDrawable::SharedSurface_GLXDrawable(
const SharedSurfaceDesc& desc, const RefPtr<gfxXlibSurface>& xlibSurface)
: SharedSurface(desc, nullptr), mXlibSurface(xlibSurface) {}
SharedSurface_GLXDrawable::~SharedSurface_GLXDrawable() = default;
void SharedSurface_GLXDrawable::ProducerReleaseImpl() {
mDesc.gl->MakeCurrent();
mDesc.gl->fFlush();
}
void SharedSurface_GLXDrawable::LockProdImpl() {
GLContextGLX::Cast(mDesc.gl)->OverrideDrawable(mXlibSurface->GetGLXPixmap());
}
void SharedSurface_GLXDrawable::UnlockProdImpl() {
GLContextGLX::Cast(mDesc.gl)->RestoreDrawable();
}
Maybe<layers::SurfaceDescriptor>
SharedSurface_GLXDrawable::ToSurfaceDescriptor() {
if (!mXlibSurface) return {};
const bool sameProcess = false;
return Some(layers::SurfaceDescriptorX11(mXlibSurface, sameProcess));
}
bool SharedSurface_GLXDrawable::ReadbackBySharedHandle(
gfx::DataSourceSurface* out_surface) {
MOZ_ASSERT(out_surface);
Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat The bulk of this commit was generated with a script, executed at the top level of a typical source code checkout. The only non-machine-generated part was modifying MFBT's moz.build to reflect the new naming. CLOSED TREE makes big refactorings like this a piece of cake. # The main substitution. find . -name '*.cpp' -o -name '*.cc' -o -name '*.h' -o -name '*.mm' -o -name '*.idl'| \ xargs perl -p -i -e ' s/nsRefPtr\.h/RefPtr\.h/g; # handle includes s/nsRefPtr ?</RefPtr</g; # handle declarations and variables ' # Handle a special friend declaration in gfx/layers/AtomicRefCountedWithFinalize.h. perl -p -i -e 's/::nsRefPtr;/::RefPtr;/' gfx/layers/AtomicRefCountedWithFinalize.h # Handle nsRefPtr.h itself, a couple places that define constructors # from nsRefPtr, and code generators specially. We do this here, rather # than indiscriminantly s/nsRefPtr/RefPtr/, because that would rename # things like nsRefPtrHashtable. perl -p -i -e 's/nsRefPtr/RefPtr/g' \ mfbt/nsRefPtr.h \ xpcom/glue/nsCOMPtr.h \ xpcom/base/OwningNonNull.h \ ipc/ipdl/ipdl/lower.py \ ipc/ipdl/ipdl/builtin.py \ dom/bindings/Codegen.py \ python/lldbutils/lldbutils/utils.py # In our indiscriminate substitution above, we renamed # nsRefPtrGetterAddRefs, the class behind getter_AddRefs. Fix that up. find . -name '*.cpp' -o -name '*.h' -o -name '*.idl' | \ xargs perl -p -i -e 's/nsRefPtrGetterAddRefs/RefPtrGetterAddRefs/g' if [ -d .git ]; then git mv mfbt/nsRefPtr.h mfbt/RefPtr.h else hg mv mfbt/nsRefPtr.h mfbt/RefPtr.h fi --HG-- rename : mfbt/nsRefPtr.h => mfbt/RefPtr.h
2015-10-18 08:24:48 +03:00
RefPtr<gfx::DataSourceSurface> dataSurf =
new gfx::DataSourceSurfaceCairo(mXlibSurface->CairoSurface());
gfx::DataSourceSurface::ScopedMap mapSrc(dataSurf,
gfx::DataSourceSurface::READ);
if (!mapSrc.IsMapped()) {
return false;
}
gfx::DataSourceSurface::ScopedMap mapDest(out_surface,
gfx::DataSourceSurface::WRITE);
if (!mapDest.IsMapped()) {
return false;
}
if (mapDest.GetStride() == mapSrc.GetStride()) {
memcpy(mapDest.GetData(), mapSrc.GetData(),
out_surface->GetSize().height * mapDest.GetStride());
} else {
for (int32_t i = 0; i < dataSurf->GetSize().height; i++) {
memcpy(mapDest.GetData() + i * mapDest.GetStride(),
mapSrc.GetData() + i * mapSrc.GetStride(),
std::min(mapSrc.GetStride(), mapDest.GetStride()));
}
}
return true;
}
SurfaceFactory_GLXDrawable::SurfaceFactory_GLXDrawable(GLContext& gl)
: SurfaceFactory({&gl, SharedSurfaceType::GLXDrawable,
layers::TextureType::X11, true}) {}
} // namespace mozilla::gl