mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-27 00:09:46 +00:00
1c5959ee6e
- Bug 1125750 - Check the overflow region direction to avoid unnecesary reflow for scrollable frame. (6b5067631) - Bug 1125750 - Add auto test to detect error when using mOuter to check overflow area of a scrollable frame. (4e9c43e31) - override -> MOZ_OVERRIDE (ed1ecc151) - Bug 990907 - Don't add text-overflow markers while being actively scrolled by APZ. (523bc5a3e) - Bug 945584: Part 6 - Implementation of scroll snapping (v10 Patch) (bf64eb0f3) - Bug 945584: Part 7 - Implement Scroll Snapping for Autoscroll, - Triggering scroll snapping at the end of an autoscroll. - This enables text selection to be unencumbered by scroll snapping, while restoring the scroll position to a valid snapping position when the drag operation is completed. (db9ce9811) - Bug 945584: Part 8 - Implement Scroll Snapping for Middle Mouse Button Scrolls (v2 Patch) (06d1b733d) - some MacOS 10.5 Leopard support (6a37f6745) - Bug 945584: Part 9 - Tests for scroll snapping (v4 Patch) (f67175387) - Bug 1102427 - Ensure scroll parents of an active scrollframe are layerized. (910d43ec5) - Bug 1142731 followup. Check isInterpreted() before we call environment(), because of the asmjs lambdas. (29b2acdc7) - Bug 1161627 - part 1 - add move constructor and assignment operator for already_AddRefed&& to RefPtr; This change is prep work for future mass rewriting. (98416d45c) - Bug 1161627 - part 2 - machine-convert TemporaryRef<T> to already_AddRefed<T>; (336e96af7) - Bug 1161627 - part 3 - remove TemporaryRef<T> from RefPtr.h (6c3acdaed) - Bug 940273 - Part 3 - Service Worker Cache webidl. (4b6803d0a) - Bug 940273 - Part 4 - Initial implementation of Service Worker Cache. (74498c108) - Bug 1133861 - Bustage fix. (4a81437c2)
153 lines
4.2 KiB
C++
153 lines
4.2 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;
|
|
}
|
|
gfxContentType contentType = ContentForFormat(mFormat);
|
|
nsRefPtr<gfxASurface> surface = gfxPlatform::GetPlatform()->CreateOffscreenSurface(aSize, contentType);
|
|
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 = ToIntSize(mSurface->GetSize());
|
|
mDrawTarget = Factory::CreateDrawTargetForCairoSurface(mSurface->CairoSurface(), size);
|
|
}
|
|
|
|
return mDrawTarget;
|
|
}
|