Files
basilisk55/gfx/layers/composite/X11TextureHost.cpp
T
roytam1 5959ed8aa3 Cherry-picking upstream changes (part 2):
Bug 1430557. r=longsonr, a=lizzard (d2012d4)
Bug 1416529. r=mcmanus, a=ritu (6c616d7)
Bug 1324042 - Fix trimmedOffsets arithmetic in GetRenderedText(). r=mats, a=RyanVM (0625e66)
Bug 1428947 - Check plane width & stride constraints. r=mattwoodrow, a=ritu (af26fd8)
Bug 1334465 - Set mIPCClosed to true before calling SendDeleteSelf in order to avoid race. r=bagder, a=ritu (48000c3)
Bug 1334465 - Make HttpChannelParent::mIPCClosed atomic. r=bagder, a=ritu (40f3b6c)
Bug 1398021 - Update lz4 to version 1.8.0. r=froydnj, a=RyanVM (9324e57)
Bug 1388020. r=nical, a=RyanVM (25eb3e4)
Bug 1437087 - Call Disconnect on Unlink of cycle collector. r=masayuki, a=RyanVM (439bf2f)
Bug 1437507 - Fix JSObject::setFlags to call ensureShape before checking for dictionary mode. r=jandem, a=RyanVM (fd3a371)
Bug 1440926 - Use overflow-checking math when computing Big5 max length. r=emk, a=RyanVM (72ee25b)
Bug 1440775 - Make fetch API force-cache and only-if-cached use VALIDATE_NEVER instead of LOAD_FROM_CACHE. r=mayhemer, a=RyanVM (322d7d2)
Bug 1425520. r=smaug, a=abillings (112a59e)
Bug 1437450 - Disable Ion no-clone optimization for regexps if the graph contains try blocks. r=nbp, a=RyanVM (c78bbff)
2018-03-17 08:14:37 +08:00

113 lines
2.6 KiB
C++

/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* 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 "X11TextureHost.h"
#include "mozilla/layers/BasicCompositor.h"
#include "mozilla/layers/X11TextureSourceBasic.h"
#ifdef GL_PROVIDER_GLX
#include "mozilla/layers/CompositorOGL.h"
#include "mozilla/layers/X11TextureSourceOGL.h"
#endif
#include "gfxXlibSurface.h"
#include "gfx2DGlue.h"
namespace mozilla {
namespace layers {
using namespace mozilla::gfx;
X11TextureHost::X11TextureHost(TextureFlags aFlags,
const SurfaceDescriptorX11& aDescriptor)
: TextureHost(aFlags)
{
mSurface = aDescriptor.OpenForeign();
if (mSurface && !(aFlags & TextureFlags::DEALLOCATE_CLIENT)) {
mSurface->TakePixmap();
}
}
bool
X11TextureHost::Lock()
{
if (!mCompositor || !mSurface) {
return false;
}
if (!mTextureSource) {
switch (mCompositor->GetBackendType()) {
case LayersBackend::LAYERS_BASIC:
mTextureSource =
new X11TextureSourceBasic(mCompositor->AsBasicCompositor(), mSurface);
break;
#ifdef GL_PROVIDER_GLX
case LayersBackend::LAYERS_OPENGL:
mTextureSource =
new X11TextureSourceOGL(mCompositor->AsCompositorOGL(), mSurface);
break;
#endif
default:
return false;
}
}
return true;
}
void
X11TextureHost::SetCompositor(Compositor* aCompositor)
{
mCompositor = aCompositor;
if (mTextureSource) {
mTextureSource->SetCompositor(aCompositor);
}
}
SurfaceFormat
X11TextureHost::GetFormat() const
{
if (!mSurface) {
return SurfaceFormat::UNKNOWN;
}
gfxContentType type = mSurface->GetContentType();
#ifdef GL_PROVIDER_GLX
if (mCompositor->GetBackendType() == LayersBackend::LAYERS_OPENGL) {
return X11TextureSourceOGL::ContentTypeToSurfaceFormat(type);
}
#endif
return X11TextureSourceBasic::ContentTypeToSurfaceFormat(type);
}
IntSize
X11TextureHost::GetSize() const
{
if (!mSurface) {
return IntSize();
}
return mSurface->GetSize();
}
already_AddRefed<gfx::DataSourceSurface>
X11TextureHost::GetAsSurface()
{
if (!mTextureSource || !mTextureSource->AsSourceBasic()) {
return nullptr;
}
RefPtr<DrawTarget> tempDT =
gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(
GetSize(), GetFormat());
if (!tempDT) {
return nullptr;
}
RefPtr<SourceSurface> surf = mTextureSource->AsSourceBasic()->GetSurface(tempDT);
if (!surf) {
return nullptr;
}
return surf->GetDataSurface();
}
}
}