mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:30:27 +00:00
14c77e53f5
- Bug 1161590 - Ignore blocklist preference in nightly and aurora. r=jrmuizelaar (47ec8bee6) - Bug 1162299 - Distinguish between all features and unrecognized feature. r=kats (e9705844f) - Add compositor, layers, and rendering info to nsIGfxInfo. (bug 1179051 part 5, r=mattwoodrow) (b4e6da05f) - Bug 1186002. Avoid testing for recreate on broken drivers. r=dvander (10506f4f2) - Bug 1156407 - part 1 - use static_assert instead of PR_STATIC_ASSERT; r=mccr8 (ff53e05ba) - Bug 1156407 - part 2 - make CALLBACK_TYPE enum a private implementation detail of nsTimerImpl; r=mccr8 (de0cc6527) - Bug 1156407 - part 3 - get rid of NS_NewTimer; r=mccr8 (c598b96e0) - Bug 1095433: fix the race condition in the Task Tracer that crashes processes forked from Nuwa. r=tlee (cffe07827) - Bug 1113562 - Expected delay time of tasks should not be the latency of those kind. r=sinker (f422ae04e) - Bug 1155059: Patch 1&2 - Convert Dispatch() and friends to already_AddRefed<> r=froydnj (2ca9850af) - Bug 1155059: Patch 4 - invoke NS_ASSERTION if DispatchToMainThread fails to get MainThread ptr r=froydnj (651903c22) - Bug 1155059: Patch 3&7 - fix leaks in Promise, ConsoleService and JS Finalize r=froydnj (b57cb08d9) - Bug 1155059: Patch 5 - clean up ServiceWorkers and avoid leaks r=nikhil (666245af8) - Bug 1155059: Patch 6 - fix problems with gfxFontInfoLoader shutdown sequence r=jdaggett (332e8bd76) - Bug 1155059: Patch 8 - Don't leak runnables when MediaCache/FileBlockCache get shut down after XPCOM is in final shutdown r=cpearce (18f36fa25) - Bug 1155059: Patch 9 - Modify DataChannel.cpp to use updated API r=froydnj (c5415703c) - Bug 1176446 - TextureClientD3D11 should take into account the layer backend when allocating a surface. r=bas (3c1b59296) - Bug 1176363 - Part 1: Stop using DrawTargets off the main thread. r=mattwoodrow (624e8107a) - Bug 1176363 - Part 2: Allow mapping of SourceSurfaceRawData from multiple threads. r=bas (38c8363cf) - Fix d3d11 texture sharing checks being preserved across device resets. (bug 1183910 part 6, r=mattwoodrow) (658121c50) - Clear the blur cache after device resets. (bug 1188032, r=bas) (c362b2ec6)
167 lines
4.5 KiB
C++
167 lines
4.5 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 "mozilla/layers/TextureClientX11.h"
|
|
#include "mozilla/layers/CompositableClient.h"
|
|
#include "mozilla/layers/CompositableForwarder.h"
|
|
#include "mozilla/layers/ISurfaceAllocator.h"
|
|
#include "mozilla/layers/ShadowLayerUtilsX11.h"
|
|
#include "mozilla/gfx/2D.h"
|
|
#include "mozilla/gfx/Logging.h"
|
|
#include "gfxXlibSurface.h"
|
|
#include "gfx2DGlue.h"
|
|
|
|
#include "mozilla/X11Util.h"
|
|
#include <X11/Xlib.h>
|
|
|
|
using namespace mozilla;
|
|
using namespace mozilla::gfx;
|
|
using namespace mozilla::layers;
|
|
|
|
TextureClientX11::TextureClientX11(ISurfaceAllocator* aAllocator,
|
|
SurfaceFormat aFormat,
|
|
TextureFlags aFlags)
|
|
: TextureClient(aAllocator, aFlags),
|
|
mFormat(aFormat),
|
|
mLocked(false)
|
|
{
|
|
MOZ_COUNT_CTOR(TextureClientX11);
|
|
}
|
|
|
|
TextureClientX11::~TextureClientX11()
|
|
{
|
|
MOZ_COUNT_DTOR(TextureClientX11);
|
|
}
|
|
|
|
already_AddRefed<TextureClient>
|
|
TextureClientX11::CreateSimilar(TextureFlags aFlags,
|
|
TextureAllocationFlags aAllocFlags) const
|
|
{
|
|
RefPtr<TextureClient> tex = new TextureClientX11(mAllocator, mFormat, mFlags);
|
|
|
|
// mSize is guaranteed to be non-negative
|
|
MOZ_ASSERT(mSize.width >= 0 && mSize.height >= 0);
|
|
if (!tex->AllocateForSurface(mSize, aAllocFlags)) {
|
|
return nullptr;
|
|
}
|
|
|
|
return tex.forget();
|
|
}
|
|
|
|
bool
|
|
TextureClientX11::IsAllocated() const
|
|
{
|
|
return !!mSurface;
|
|
}
|
|
|
|
bool
|
|
TextureClientX11::Lock(OpenMode aMode)
|
|
{
|
|
MOZ_ASSERT(!mLocked, "The TextureClient is already Locked!");
|
|
mLocked = IsValid() && IsAllocated();
|
|
return mLocked;
|
|
}
|
|
|
|
void
|
|
TextureClientX11::Unlock()
|
|
{
|
|
MOZ_ASSERT(mLocked, "The TextureClient is already Unlocked!");
|
|
mLocked = false;
|
|
|
|
if (mDrawTarget) {
|
|
// see the comment on TextureClient::BorrowDrawTarget.
|
|
// This DrawTarget is internal to the TextureClient and is only exposed to the
|
|
// outside world between Lock() and Unlock(). This assertion checks that no outside
|
|
// reference remains by the time Unlock() is called.
|
|
MOZ_ASSERT(mDrawTarget->refCount() == 1);
|
|
|
|
mDrawTarget->Flush();
|
|
mDrawTarget = nullptr;
|
|
}
|
|
|
|
if (mSurface && !mAllocator->IsSameProcess()) {
|
|
FinishX(DefaultXDisplay());
|
|
}
|
|
}
|
|
|
|
bool
|
|
TextureClientX11::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
|
|
{
|
|
MOZ_ASSERT(IsValid());
|
|
if (!mSurface) {
|
|
return false;
|
|
}
|
|
|
|
if (!(mFlags & TextureFlags::DEALLOCATE_CLIENT)) {
|
|
// Pass to the host the responsibility of freeing the pixmap. ReleasePixmap means
|
|
// the underlying pixmap will not be deallocated in mSurface's destructor.
|
|
// ToSurfaceDescriptor is at most called once per TextureClient.
|
|
mSurface->ReleasePixmap();
|
|
}
|
|
|
|
aOutDescriptor = SurfaceDescriptorX11(mSurface);
|
|
return true;
|
|
}
|
|
|
|
bool
|
|
TextureClientX11::AllocateForSurface(IntSize aSize, TextureAllocationFlags aTextureFlags)
|
|
{
|
|
MOZ_ASSERT(IsValid());
|
|
MOZ_ASSERT(!IsAllocated());
|
|
//MOZ_ASSERT(mFormat != gfx::FORMAT_YUV, "This TextureClient cannot use YCbCr data");
|
|
|
|
MOZ_ASSERT(aSize.width >= 0 && aSize.height >= 0);
|
|
if (aSize.width <= 0 || aSize.height <= 0) {
|
|
gfxDebug() << "Asking for X11 surface of invalid size " << aSize.width << "x" << aSize.height;
|
|
return false;
|
|
}
|
|
gfxImageFormat imageFormat = SurfaceFormatToImageFormat(mFormat);
|
|
nsRefPtr<gfxASurface> surface = gfxPlatform::GetPlatform()->CreateOffscreenSurface(aSize, imageFormat);
|
|
if (!surface || surface->GetType() != gfxSurfaceType::Xlib) {
|
|
NS_ERROR("creating Xlib surface failed!");
|
|
return false;
|
|
}
|
|
|
|
mSize = aSize;
|
|
mSurface = static_cast<gfxXlibSurface*>(surface.get());
|
|
|
|
if (!mAllocator->IsSameProcess()) {
|
|
FinishX(DefaultXDisplay());
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
DrawTarget*
|
|
TextureClientX11::BorrowDrawTarget()
|
|
{
|
|
MOZ_ASSERT(IsValid());
|
|
MOZ_ASSERT(mLocked);
|
|
|
|
if (!mSurface) {
|
|
return nullptr;
|
|
}
|
|
|
|
if (!mDrawTarget) {
|
|
IntSize size = mSurface->GetSize();
|
|
mDrawTarget = Factory::CreateDrawTargetForCairoSurface(mSurface->CairoSurface(), size);
|
|
}
|
|
|
|
return mDrawTarget;
|
|
}
|
|
|
|
void
|
|
TextureClientX11::UpdateFromSurface(gfx::DataSourceSurface* aSurface)
|
|
{
|
|
MOZ_ASSERT(CanExposeDrawTarget());
|
|
|
|
DrawTarget* dt = BorrowDrawTarget();
|
|
|
|
if (!dt) {
|
|
gfxCriticalError() << "Failed to borrow drawtarget for TextureClientX11::UpdateFromSurface";
|
|
return;
|
|
}
|
|
|
|
dt->CopySurface(aSurface, IntRect(IntPoint(), aSurface->GetSize()), IntPoint());
|
|
} |