mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
8d1a041130
- Bug 1209252: add buttons to clear session and signaling logs. r=jib, r=sicking (39d0a4b57d)
- Bug 1197673 - Use float type for SetAudioOutputVolume. r=eitan (75eae2f441)
- Bug 1188099 - (Part 4) Introduce mochitest coverage for speech global queue. r=smaug r=kdavis (fd4c804c72)
- Bug 1226015 - Have child send __delete__ in speech synth request protocol, fixes race. r=smaug (c46532745a)
- Bug 1230533 - Cancel speech when controlling window goes away. r=smaug (3dae89ffaf)
- Bug 1237176 - skip dom/media/webspeech/synth/test/test_bfcache.html on Linux and Android for frequent timeouts (0d1eabb6fb)
- Bug 1237176 - actually disable test_bfcache.html on Android (1558e0bf39)
- Bug 1240871 - Don't allow implicit "async" in IPDL (r=mccr8,billm) (1db25ace3c)
- Bug 1000040 - Part 2: Implement EthernetManager; r=vicamo (82c01ca9a7)
- Bug 1000040 - Part 3: Test cases; r=vicamo (6a967cc5d9)
- Bug 1245241 - part 2 - remove TYPE_SYSV Shmems from IPDL. r=billm (6d6a4570ca)
- Bug 1245241 - part 3 - remove unused AdoptShmem from IPDL. r=billm (2762a13841)
- Bug 1107792: Don't ask for similar if the surface has an error, and more data in crash reports. r=milan (ead5108a93)
- Bug 1231881 - Remove NativeSurfaceType::CAIRO_SURFACE. r=bas. (c0f03e02f6)
- Bug 1241163 - Replace DrawTarget::CreateSourceSurfaceFromNativeSurface(CAIRO_CONTEXT) with Factory::CreateSourceSurfaceForCairoSurface. r=jrmuizel (06a96cdce6)
- Bug 1240177 - part 1 - add helper function to make Skia image info, r=jrmuizel (6a7d05aeb7)
- Bug 1240177 - part 2 - cleanups of DrawTargetSkia and SourceSurfaceSkia creation for GPU contexts, r=jrmuizel (3211ea9c0e)
- Bug 1240177 - part 3 - make DrawTargetSkia::OptimizeSourceSurface directly upload to GPU textures, r=jrmuizel (743d57a46c)
- Bug 1240177 - part 4 - avoid GPU readbacks in SourceSurfaceSkia::DrawTargetWillChange, r=jrmuizel (f568754717)
- Bug 1240177 - fix SourceSurfaceSkia::DrawTargetWillChange deepCopyTo usage. r=mattwoodrow (2e53d13ba3)
- Bug 1239152 Memset RGBX surfaces to opaque white. r=nical (977c7d5ede)
- Bug 1245241 - part 4 - move SharedMemorySysV details into nsShmImage. r=nical (0015d3caac)
- Bug 1245241 - Force the main thread to sync with the compositor when it tries to allocate insane amounts of shmems. r=lsalzman (7683d2afa7)
- Bug 1245241 - fix SharedMemoryBasic_android CloseHandle to null out handle. r=billm a=kwierso (9fa3f93233)
- Bug 1239152 - skip memset since XShm is already initialized to zero. r=mchang (477ecf2d9a)
- Bug 1227927 Part 1 - Make nsIFrame::PrincipalChildList a const function. r=bz (d9b690a1bc)
- Bug 1214377 - Hack to solve Thunderbird's need to detect style pre-wrap. r=roc a=me (a481ba9020)
- Bug 1214377 - Hack to solve Thunderbird's need to detect style pre-wrap. rs=ehsan on a CLOSED TREE (a15dfcaeb3)
- Bug 1240372 - Don't OOM crash in nsDocumentEncoder::EncodeToStringWithMaxLength() when the string buffer allocation fails; r=bzbarsky (76bed6a40a)
- Bug 1143570 - Part 1: Use an nsBlockInFlowLineIterator to determine whether a BR frame is visible or not; r=roc (99609f6fcd)
- Bug 1064843 part 2 - Make nsSubDocumentFrame inherit nsContainerFrame. r=dholbert (070202e396)
- Bug 1064843 part 3 - Make nsFormControlFrame inherit nsContainerFrame. r=dholbert (cee5125993)
- Bug 1064843 part 4 - Add a placeholder type for top layer. r=roc (e4e564b05b)
- Bug 1064843 part 5 - Ensure frames behave properly for unknown child list id passed into SetInitialChildList. r=dholbert (540f3da6a1)
- Bug 1064843 part 6 - Add backdrop frame list. r=dholbert (79f91fc815)
- Bug 1215365 - Update ua style sheet of fullscreen element. r=heycam (b44060a518)
- Bug 1235969 - Unprefix uses of -moz-transform, -moz-transform-origin and -moz-backface-visibility in UA style sheets. r=xidorn (c7a83cdcae)
- Bug 1064843 part 7 - Add backdrop pseudo-element and add related UA stylesheet. r=heycam (1d89afa54a)
- Bug 1064843 part 8 - Add frame class for backdrop frame. r=dbaron (9146be0073)
- Bug 1064843 part 9 - Change nsCSSFrameConstructor::CreatePlaceholderFrameFor to accept parent style context. r=dbaron (bc860e67f8)
- Bug 1064843 part 10 - Create and render backdrop frame for top layer frames. r=dbaron (1c6f165769)
- Bug 1064843 part 11 - Move checkWindowPureColor helper function from top-layer test to WindowSnapshot.js. r=roc (ef274dec50)
- Bug 1064843 part 12 - Add test for ::backdrop of fullscreen. r=dholbert (b978209868)
- Bug 1227927 Part 2 - Remove nsIFrame::GetFirstPrincipalChild(). r=mats (3f4ba2ef58)
- Bug 1227927 Part 3 - Use ranged-based for-loop to rewrite some simple loops in part 2. r=mats (6b22236653)
- Bug 1227927 Part 4 - Add comment to nsFrameList::GetLength() to warn it's O(n). r=mats (a08aa9185e)
- Bug 1101817 - Part 1: Remove usages of WeakMap.prototype.clear from Gecko. r=yzen,mak,yoric,gijs,jlongster (a992931bfe)
- Bug 1101817 - Part 3: Remove WeakMap.prototype.clear usages from Addons SDK. r=mossop (e81a8c3477)
- Bug 1101817 - Part 4: Remove WeakMap.prototype.clear from web-platform test. r=Ms2ger (1be3f645a2)
- Bug 1101817 - Part 6: Remove Weak{Map,Set}.prototype.clear. r=evilpie (7a0dbffdc9)
- Bug 1235152 - [css-break] Don't apply border/padding twice on inlines with box-decoration-break:clone and direction:rtl. r=roc (e6446262c1)
264 lines
6.8 KiB
C++
264 lines
6.8 KiB
C++
/* -*- Mode: C++; tab-width: 2; 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/. */
|
|
|
|
#if defined(MOZ_WIDGET_GTK)
|
|
#include <gtk/gtk.h>
|
|
#include <gdk/gdkx.h>
|
|
#elif defined(MOZ_WIDGET_QT)
|
|
#include <QWindow>
|
|
#endif
|
|
|
|
#include "nsShmImage.h"
|
|
#ifdef MOZ_WIDGET_GTK
|
|
#include "gfxPlatformGtk.h"
|
|
#endif
|
|
|
|
#ifdef MOZ_HAVE_SHMIMAGE
|
|
#include "mozilla/X11Util.h"
|
|
|
|
#include "mozilla/ipc/SharedMemory.h"
|
|
|
|
#include <errno.h>
|
|
#include <string.h>
|
|
#include <sys/ipc.h>
|
|
#include <sys/shm.h>
|
|
|
|
using namespace mozilla::ipc;
|
|
using namespace mozilla::gfx;
|
|
|
|
// If XShm isn't available to our client, we'll try XShm once, fail,
|
|
// set this to false and then never try again.
|
|
static bool gShmAvailable = true;
|
|
bool nsShmImage::UseShm()
|
|
{
|
|
#ifdef MOZ_WIDGET_GTK
|
|
return (gShmAvailable && !gfxPlatformGtk::GetPlatform()->UseXRender());
|
|
#else
|
|
return gShmAvailable;
|
|
#endif
|
|
}
|
|
|
|
#ifdef MOZ_WIDGET_GTK
|
|
static int gShmError = 0;
|
|
|
|
static int
|
|
TrapShmError(Display* aDisplay, XErrorEvent* aEvent)
|
|
{
|
|
// store the error code and ignore the error
|
|
gShmError = aEvent->error_code;
|
|
return 0;
|
|
}
|
|
#endif
|
|
|
|
bool
|
|
nsShmImage::CreateShmSegment()
|
|
{
|
|
if (!mImage) {
|
|
return false;
|
|
}
|
|
|
|
size_t size = SharedMemory::PageAlignedSize(mImage->bytes_per_line * mImage->height);
|
|
|
|
mInfo.shmid = shmget(IPC_PRIVATE, size, IPC_CREAT | 0600);
|
|
if (mInfo.shmid == -1) {
|
|
return false;
|
|
}
|
|
|
|
mInfo.shmaddr = (char *)shmat(mInfo.shmid, nullptr, 0);
|
|
if (mInfo.shmaddr == (void *)-1) {
|
|
nsPrintfCString warning("shmat(): %s (%d)\n", strerror(errno), errno);
|
|
NS_WARNING(warning.get());
|
|
return false;
|
|
}
|
|
|
|
// Mark the handle as deleted so that, should this process go away, the
|
|
// segment is cleaned up.
|
|
shmctl(mInfo.shmid, IPC_RMID, 0);
|
|
|
|
#ifdef DEBUG
|
|
struct shmid_ds info;
|
|
if (shmctl(mInfo.shmid, IPC_STAT, &info) < 0) {
|
|
return false;
|
|
}
|
|
|
|
MOZ_ASSERT(size <= info.shm_segsz,
|
|
"Segment doesn't have enough space!");
|
|
#endif
|
|
|
|
mInfo.readOnly = False;
|
|
|
|
mImage->data = mInfo.shmaddr;
|
|
|
|
return true;
|
|
}
|
|
|
|
void
|
|
nsShmImage::DestroyShmSegment()
|
|
{
|
|
if (mInfo.shmid != -1) {
|
|
shmdt(mInfo.shmaddr);
|
|
mInfo.shmid = -1;
|
|
}
|
|
}
|
|
|
|
bool
|
|
nsShmImage::CreateImage(const LayoutDeviceIntSize& aSize,
|
|
Display* aDisplay, Visual* aVisual, unsigned int aDepth)
|
|
{
|
|
mDisplay = aDisplay;
|
|
mImage = XShmCreateImage(aDisplay, aVisual, aDepth,
|
|
ZPixmap, nullptr,
|
|
&mInfo,
|
|
aSize.width, aSize.height);
|
|
if (!mImage || !CreateShmSegment()) {
|
|
return false;
|
|
}
|
|
|
|
#if defined(MOZ_WIDGET_GTK)
|
|
gShmError = 0;
|
|
XErrorHandler previousHandler = XSetErrorHandler(TrapShmError);
|
|
Status attachOk = XShmAttach(aDisplay, &mInfo);
|
|
XSync(aDisplay, False);
|
|
XSetErrorHandler(previousHandler);
|
|
if (gShmError) {
|
|
attachOk = 0;
|
|
}
|
|
#elif defined(MOZ_WIDGET_QT)
|
|
Status attachOk = XShmAttach(aDisplay, &mInfo);
|
|
#endif
|
|
|
|
if (!attachOk) {
|
|
// Assume XShm isn't available, and don't attempt to use it
|
|
// again.
|
|
gShmAvailable = false;
|
|
return false;
|
|
}
|
|
|
|
mXAttached = true;
|
|
mSize = aSize;
|
|
mFormat = SurfaceFormat::UNKNOWN;
|
|
switch (mImage->depth) {
|
|
case 32:
|
|
if ((mImage->red_mask == 0xff0000) &&
|
|
(mImage->green_mask == 0xff00) &&
|
|
(mImage->blue_mask == 0xff)) {
|
|
mFormat = SurfaceFormat::B8G8R8A8;
|
|
}
|
|
break;
|
|
case 24:
|
|
// Only support the BGRX layout, and report it as BGRA to the compositor.
|
|
// The alpha channel will be discarded when we put the image.
|
|
if ((mImage->red_mask == 0xff0000) &&
|
|
(mImage->green_mask == 0xff00) &&
|
|
(mImage->blue_mask == 0xff)) {
|
|
mFormat = SurfaceFormat::B8G8R8A8;
|
|
}
|
|
break;
|
|
case 16:
|
|
mFormat = SurfaceFormat::R5G6B5_UINT16;
|
|
break;
|
|
}
|
|
|
|
if (mFormat == SurfaceFormat::UNKNOWN) {
|
|
NS_WARNING("Unsupported XShm Image format!");
|
|
gShmAvailable = false;
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
nsShmImage::~nsShmImage()
|
|
{
|
|
if (mImage) {
|
|
mozilla::FinishX(mDisplay);
|
|
if (mXAttached) {
|
|
XShmDetach(mDisplay, &mInfo);
|
|
}
|
|
XDestroyImage(mImage);
|
|
}
|
|
DestroyShmSegment();
|
|
}
|
|
|
|
already_AddRefed<DrawTarget>
|
|
nsShmImage::CreateDrawTarget()
|
|
{
|
|
return gfxPlatform::GetPlatform()->CreateDrawTargetForData(
|
|
reinterpret_cast<unsigned char*>(mImage->data),
|
|
mSize.ToUnknownSize(),
|
|
mImage->bytes_per_line,
|
|
mFormat);
|
|
}
|
|
|
|
#ifdef MOZ_WIDGET_GTK
|
|
void
|
|
nsShmImage::Put(Display* aDisplay, Drawable aWindow,
|
|
const LayoutDeviceIntRegion& aRegion)
|
|
{
|
|
GC gc = XCreateGC(aDisplay, aWindow, 0, nullptr);
|
|
LayoutDeviceIntRegion bounded;
|
|
bounded.And(aRegion,
|
|
LayoutDeviceIntRect(0, 0, mImage->width, mImage->height));
|
|
for (auto iter = bounded.RectIter(); !iter.Done(); iter.Next()) {
|
|
const LayoutDeviceIntRect& r = iter.Get();
|
|
XShmPutImage(aDisplay, aWindow, gc, mImage,
|
|
r.x, r.y,
|
|
r.x, r.y,
|
|
r.width, r.height,
|
|
False);
|
|
}
|
|
|
|
XFreeGC(aDisplay, gc);
|
|
|
|
// FIXME/bug 597336: we need to ensure that the shm image isn't
|
|
// scribbled over before all its pending XShmPutImage()s complete.
|
|
// However, XSync() is an unnecessarily heavyweight
|
|
// synchronization mechanism; other options are possible. If this
|
|
// XSync is shown to hurt responsiveness, we need to explore the
|
|
// other options.
|
|
XSync(aDisplay, False);
|
|
}
|
|
|
|
#elif defined(MOZ_WIDGET_QT)
|
|
void
|
|
nsShmImage::Put(QWindow* aWindow, QRect& aRect)
|
|
{
|
|
Display* dpy = gfxQtPlatform::GetXDisplay(aWindow);
|
|
Drawable d = aWindow->winId();
|
|
|
|
GC gc = XCreateGC(dpy, d, 0, nullptr);
|
|
// Avoid out of bounds painting
|
|
QRect inter = aRect.intersected(aWindow->geometry());
|
|
XShmPutImage(dpy, d, gc, mImage,
|
|
inter.x(), inter.y(),
|
|
inter.x(), inter.y(),
|
|
inter.width(), inter.height(),
|
|
False);
|
|
XFreeGC(dpy, gc);
|
|
}
|
|
#endif
|
|
|
|
already_AddRefed<DrawTarget>
|
|
nsShmImage::EnsureShmImage(const LayoutDeviceIntSize& aSize,
|
|
Display* aDisplay, Visual* aVisual, unsigned int aDepth,
|
|
RefPtr<nsShmImage>& aImage)
|
|
{
|
|
if (!aImage || aImage->Size() != aSize) {
|
|
// Because we XSync() after XShmAttach() to trap errors, we
|
|
// know that the X server has the old image's memory mapped
|
|
// into its address space, so it's OK to destroy the old image
|
|
// here even if there are outstanding Puts. The Detach is
|
|
// ordered after the Puts.
|
|
aImage = new nsShmImage;
|
|
if (!aImage->CreateImage(aSize, aDisplay, aVisual, aDepth)) {
|
|
aImage = nullptr;
|
|
}
|
|
}
|
|
return !aImage ? nullptr : aImage->CreateDrawTarget();
|
|
}
|
|
|
|
#endif // MOZ_HAVE_SHMIMAGE
|