mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
05670874b5
- Bug 1262361 - Use gfxCriticalError to collect useful info when device reset. r=milan (a565047753)
- Bug 1265282 - Annotate reports instead of crashing when setting an incompatible compositor (D3D11). r=dvander (ed04e9e8eb)
- Bug 1235407 - Part 3: Force a reset when OpenSharedHandle fails. r=milan (a2f5c656eb)
- Bug 1264142 - Add ImageLayerComposite::GetFullyRenderedRegion() r=mattwoodrow (3a5f479820)
- Bug 1224199 - Remove some unused code in TiledLayerBufferComposite - r=nical (b3c60126ce)
- Bug 1262328 - Add Add ClientLayer::HandleMemoryPressure() r=nical (31bb89613d)
- Bug 1224833 - Check explicitly if image has TextureClient r=nical (34044dc195)
- Bug 1240867 - Add missing include. r=nical (abd9a8876e)
- Bug 1240800: When we've reallocated our buffer client side and fail to track the proper invalid region always upload the bounds of the visible region. r=mattwoodrow (7a7cc1928c)
- Bug 1253386 - Double buffer in CanvasClient2D - r=nical (a0fe10f1a6)
- Bug 1266380 - fix offset of untransformed surface when 3d transforming in BasicLayerManager. r=jrmuizel (3d3931346f)
- Bug 1257288 - Fix a bug in APZCTM logging code. r=kats (3c73c99077)
- Bug 1265424 - Record if the target was confirmed via a timeout or not. r=botond (e25c0c016d)
- Bug 1265424 - Ensure that HasReceivedAllContentNotifications doesn't start returning true if the target APZC was confirmed by timeout. r=botond (6c4e57cb8f)
- Bug 1229039 - If a PanGesture input block gets interrupted, just start a new block instead of not sending the rest of the events through the APZ. r=mstange (534b6691f7)
- Bug 1056356 - Remove the hand-rolled mechanism used to get nsRefPtr<const OverscrollHandoffChaiin> to work. r=kats (9d692fa32f)
- Bug 1253617 - Fix non-unified build bustage in OverscrollHandoffStat.cpp r=BenWa (38a53f7521)
- Bug 1262432 - Remove assertion that may be legitimately false sometimes. r=tnikkel (36bbb36476)
- Bug 1169802 - Temporary workaround for a deeper bug, to prevent an assertion from firing. r=botond (b1edd69e49)
- bits of Bug 1223296 (182a1ee34e)
- move around (bug 1014691) and align some more tests (19db30010c)
- Bug 944164 - Update jorendb to current function names, and much else: (b96a636c60)
- Bug 1244222 - Tests. r=bz (9cfbe54859)
- Bug 888969 - Make XPCJSID instanceof comparisons work correctly when [[GetPrototypeOf]] on the [[Prototype]] chain of the instance being tested throws an exception. r=bz (ff450de2ef)
- Bug 1256306 - Bump the Windows stack limit. r=bholley (5f4f0c3b1c)
- Bug 1257234 - Detect main thread's stack size at runtime, on Windows. r=ted (108608ce73)
- bug 1264651 - remove dom.max_child_script_run_time pref r=billm (443bc36d84)
- Bug 1266630 - Make fallible the orphan node table used during memory reporting. r=mccr8. (b7c6da934c)
- Bug 1259699 - Adjust Windows stack limits to account for large PGO stack frames. r=bholley (87ff9dbef9)
- bug 1250486 - get rid of the static ctor for XPCShellImpl.cpp r=bz (748def73ea)
- Bug 1231309 - guard sz with assert. r=bobbyholley (34080a1022)
- Bug 1255817 part 5. Remove the now-unused xpc::SystemErrorReporter. r=bholley (c014f7fa7f)
- Bug 1257888 - Link chromium mutex-based atomics implementation to webrtc signaling tests. r=froydnj (fadb9764b2)
- Bug 1253123 - Remove ipc_sync_message (r=jld) a=kwierso (7cc8a8fe0e)
- Bug 1253123 - Remove ipc_channel_proxy (r=jld) (4000ea80f3)
- Bug 1253123 - Remove message_router (r=jld) a=kwierso (8b41859a17)
- Bug 1235633 - IPC OOM mitigation by eliminating buffer copying (r=jld) (ecd6c12bec)
- Bug 1263314: Remove NonThreadSafe. r=jld (06a6331dee)
- Bug 1261567 - Include compat dir in libevent include path. r=billm (b496d2ad1f)
- Bug 1258312 - Add crash annotation to EnumSerializer r=jld (7face45d63)
- Bug 1262463 - part 1 - turn NS_RUNTIMEABORTs in protocols into FatalErrors; r=jld (731b35dc68)
- Bug 1262463 - part 2 - don't pass the other process pid into FatalError; r=jld (6f54c58494)
- Bug 1262463 - part 3 - out-of-line NS_RUNTIMEABORT calls in IPDL-generated code; r=jld (0728f61a5f)
- Bug 1259428 - part 1 - don't call Log methods of generated method classes; r=jld (938c6ff705)
- Bug 1259428 - part 2 - remove dodgy static_cast downcasts from logging statements; r=jld (4fa0a5228d)
- Bug 1259428 - part 3 - remove Log() methods from generated message subclasses; r=jld (964a0c2487)
- Bug 1259428 - part 4 - remove prtime.h from generated protocol headers; r=jld (8548b37b91)
- Bug 1259428 - part 5 - convert Message subclasses to constructor functions; r=jld (63f195ffce)
- Bug 1259428 - part 6 - remove unneeded MessageDecl methods; r=jld (fc8cd72bd7)
- Bug 1262458 - rename {msg,reply}Class-related things to reflect new functional reality; r=jld (8122887df4)
- Bug 1258663 - Crash annotate system call failures in the IPC transport. r=gabor (5f483a17a5)
- Bug 1258317 - Part 1: Annotate the crash report with process information on failure to transfer an IPC transport to another process. r=krizsa (107947c7c3)
- Bug 1258317 - cross compilation fixup. (534c214182)
- Bug 1258317 - Part 2: Remove unused privilege in mozilla::ipc::TransferHandleTorProcess(). r=krizsa (82fc8ca4cc)
- Bug 1252246 - Try to use PTHREAD_PROCESS_SHARED for CrossProcessMutex on more Unices. r=glandium f=kats (195742a508)
- now we can add crashreporter (2cbb6f2d1a)
- Bug 1251226 - Avoid passing a std::wstring through the variadic method; r=bobowen (80b2dd8034)
- Bug 1260736 - Let the client to filter out its interested messages to lower the number of times entering the monitor in PeekMessages(). r=dvander (3aea1ed77a)
- Bug 1264662 - Record IPC message capacity instead of size. r=billm (fbfff4e5b8)
- Bug 1261099 - Avoid two Message copies in MaybeUndeferIncall. r=billm (ebb7fe2b47)
659 lines
22 KiB
C++
659 lines
22 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/ContentClient.h"
|
|
#include "BasicLayers.h" // for BasicLayerManager
|
|
#include "gfxContext.h" // for gfxContext, etc
|
|
#include "gfxPlatform.h" // for gfxPlatform
|
|
#include "gfxEnv.h" // for gfxEnv
|
|
#include "gfxPrefs.h" // for gfxPrefs
|
|
#include "gfxPoint.h" // for IntSize, gfxPoint
|
|
#include "gfxTeeSurface.h" // for gfxTeeSurface
|
|
#include "gfxUtils.h" // for gfxUtils
|
|
#include "ipc/ShadowLayers.h" // for ShadowLayerForwarder
|
|
#include "mozilla/ArrayUtils.h" // for ArrayLength
|
|
#include "mozilla/Maybe.h"
|
|
#include "mozilla/gfx/2D.h" // for DrawTarget, Factory
|
|
#include "mozilla/gfx/BasePoint.h" // for BasePoint
|
|
#include "mozilla/gfx/BaseSize.h" // for BaseSize
|
|
#include "mozilla/gfx/Rect.h" // for Rect
|
|
#include "mozilla/gfx/Types.h"
|
|
#include "mozilla/layers/CompositorBridgeChild.h" // for CompositorBridgeChild
|
|
#include "mozilla/layers/LayerManagerComposite.h"
|
|
#include "mozilla/layers/LayersMessages.h" // for ThebesBufferData
|
|
#include "mozilla/layers/LayersTypes.h"
|
|
#include "nsAutoPtr.h" // for nsRefPtr
|
|
#include "nsDebug.h" // for NS_ASSERTION, NS_WARNING, etc
|
|
#include "nsISupportsImpl.h" // for gfxContext::Release, etc
|
|
#include "nsIWidget.h" // for nsIWidget
|
|
#include "nsLayoutUtils.h"
|
|
#ifdef XP_WIN
|
|
#include "gfxWindowsPlatform.h"
|
|
#endif
|
|
#ifdef MOZ_WIDGET_GTK
|
|
#include "gfxPlatformGtk.h"
|
|
#endif
|
|
#include "ReadbackLayer.h"
|
|
|
|
#include <vector>
|
|
|
|
using namespace std;
|
|
|
|
namespace mozilla {
|
|
|
|
using namespace gfx;
|
|
|
|
namespace layers {
|
|
|
|
static TextureFlags TextureFlagsForRotatedContentBufferFlags(uint32_t aBufferFlags)
|
|
{
|
|
TextureFlags result = TextureFlags::NO_FLAGS;
|
|
|
|
if (aBufferFlags & RotatedContentBuffer::BUFFER_COMPONENT_ALPHA) {
|
|
result |= TextureFlags::COMPONENT_ALPHA;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
/* static */ already_AddRefed<ContentClient>
|
|
ContentClient::CreateContentClient(CompositableForwarder* aForwarder)
|
|
{
|
|
LayersBackend backend = aForwarder->GetCompositorBackendType();
|
|
if (backend != LayersBackend::LAYERS_OPENGL &&
|
|
backend != LayersBackend::LAYERS_D3D9 &&
|
|
backend != LayersBackend::LAYERS_D3D11 &&
|
|
backend != LayersBackend::LAYERS_BASIC) {
|
|
return nullptr;
|
|
}
|
|
|
|
bool useDoubleBuffering = false;
|
|
|
|
#ifdef XP_WIN
|
|
if (backend == LayersBackend::LAYERS_D3D11) {
|
|
useDoubleBuffering = gfxWindowsPlatform::GetPlatform()->GetRenderMode() == gfxWindowsPlatform::RENDER_DIRECT2D;
|
|
} else
|
|
#endif
|
|
#ifdef MOZ_WIDGET_GTK
|
|
// We can't use double buffering when using image content with
|
|
// Xrender support on Linux, as ContentHostDoubleBuffered is not
|
|
// suited for direct uploads to the server.
|
|
if (!gfxPlatformGtk::GetPlatform()->UseImageOffscreenSurfaces() ||
|
|
!gfxPlatformGtk::GetPlatform()->UseXRender())
|
|
#endif
|
|
{
|
|
useDoubleBuffering = (LayerManagerComposite::SupportsDirectTexturing() &&
|
|
backend != LayersBackend::LAYERS_D3D9) ||
|
|
backend == LayersBackend::LAYERS_BASIC;
|
|
}
|
|
|
|
if (useDoubleBuffering || gfxEnv::ForceDoubleBuffering()) {
|
|
return MakeAndAddRef<ContentClientDoubleBuffered>(aForwarder);
|
|
}
|
|
return MakeAndAddRef<ContentClientSingleBuffered>(aForwarder);
|
|
}
|
|
|
|
void
|
|
ContentClient::EndPaint(nsTArray<ReadbackProcessor::Update>* aReadbackUpdates)
|
|
{
|
|
}
|
|
|
|
void
|
|
ContentClient::PrintInfo(std::stringstream& aStream, const char* aPrefix)
|
|
{
|
|
aStream << aPrefix;
|
|
aStream << nsPrintfCString("ContentClient (0x%p)", this).get();
|
|
|
|
if (profiler_feature_active("displaylistdump")) {
|
|
nsAutoCString pfx(aPrefix);
|
|
pfx += " ";
|
|
|
|
Dump(aStream, pfx.get(), false);
|
|
}
|
|
}
|
|
|
|
// We pass a null pointer for the ContentClient Forwarder argument, which means
|
|
// this client will not have a ContentHost on the other side.
|
|
ContentClientBasic::ContentClientBasic()
|
|
: ContentClient(nullptr)
|
|
, RotatedContentBuffer(ContainsVisibleBounds)
|
|
{}
|
|
|
|
void
|
|
ContentClientBasic::CreateBuffer(ContentType aType,
|
|
const IntRect& aRect,
|
|
uint32_t aFlags,
|
|
RefPtr<gfx::DrawTarget>* aBlackDT,
|
|
RefPtr<gfx::DrawTarget>* aWhiteDT)
|
|
{
|
|
MOZ_ASSERT(!(aFlags & BUFFER_COMPONENT_ALPHA));
|
|
|
|
*aBlackDT = gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(
|
|
IntSize(aRect.width, aRect.height),
|
|
gfxPlatform::GetPlatform()->Optimal2DFormatForContent(aType));
|
|
}
|
|
|
|
void
|
|
ContentClientRemoteBuffer::DestroyBuffers()
|
|
{
|
|
if (!mTextureClient) {
|
|
return;
|
|
}
|
|
|
|
mOldTextures.AppendElement(mTextureClient);
|
|
mTextureClient = nullptr;
|
|
if (mTextureClientOnWhite) {
|
|
mOldTextures.AppendElement(mTextureClientOnWhite);
|
|
mTextureClientOnWhite = nullptr;
|
|
}
|
|
|
|
DestroyFrontBuffer();
|
|
}
|
|
|
|
class RemoteBufferReadbackProcessor : public TextureReadbackSink
|
|
{
|
|
public:
|
|
RemoteBufferReadbackProcessor(nsTArray<ReadbackProcessor::Update>* aReadbackUpdates,
|
|
const IntRect& aBufferRect, const nsIntPoint& aBufferRotation)
|
|
: mReadbackUpdates(*aReadbackUpdates)
|
|
, mBufferRect(aBufferRect)
|
|
, mBufferRotation(aBufferRotation)
|
|
{
|
|
for (uint32_t i = 0; i < mReadbackUpdates.Length(); ++i) {
|
|
mLayerRefs.push_back(mReadbackUpdates[i].mLayer);
|
|
}
|
|
}
|
|
|
|
virtual void ProcessReadback(gfx::DataSourceSurface *aSourceSurface)
|
|
{
|
|
SourceRotatedBuffer rotBuffer(aSourceSurface, nullptr, mBufferRect, mBufferRotation);
|
|
|
|
for (uint32_t i = 0; i < mReadbackUpdates.Length(); ++i) {
|
|
ReadbackProcessor::Update& update = mReadbackUpdates[i];
|
|
nsIntPoint offset = update.mLayer->GetBackgroundLayerOffset();
|
|
|
|
ReadbackSink* sink = update.mLayer->GetSink();
|
|
|
|
if (!sink) {
|
|
continue;
|
|
}
|
|
|
|
if (!aSourceSurface) {
|
|
sink->SetUnknown(update.mSequenceCounter);
|
|
continue;
|
|
}
|
|
|
|
RefPtr<DrawTarget> dt =
|
|
sink->BeginUpdate(update.mUpdateRect + offset, update.mSequenceCounter);
|
|
if (!dt) {
|
|
continue;
|
|
}
|
|
|
|
dt->SetTransform(Matrix::Translation(offset.x, offset.y));
|
|
|
|
rotBuffer.DrawBufferWithRotation(dt, RotatedBuffer::BUFFER_BLACK);
|
|
|
|
update.mLayer->GetSink()->EndUpdate(update.mUpdateRect + offset);
|
|
}
|
|
}
|
|
|
|
private:
|
|
nsTArray<ReadbackProcessor::Update> mReadbackUpdates;
|
|
// This array is used to keep the layers alive until the callback.
|
|
vector<RefPtr<Layer>> mLayerRefs;
|
|
|
|
IntRect mBufferRect;
|
|
nsIntPoint mBufferRotation;
|
|
};
|
|
|
|
void
|
|
ContentClientRemoteBuffer::BeginPaint()
|
|
{
|
|
EnsureBackBufferIfFrontBuffer();
|
|
|
|
// XXX: So we might not have a TextureClient yet.. because it will
|
|
// only be created by CreateBuffer.. which will deliver a locked surface!.
|
|
if (mTextureClient) {
|
|
SetBufferProvider(mTextureClient);
|
|
}
|
|
if (mTextureClientOnWhite) {
|
|
SetBufferProviderOnWhite(mTextureClientOnWhite);
|
|
}
|
|
}
|
|
|
|
void
|
|
ContentClientRemoteBuffer::EndPaint(nsTArray<ReadbackProcessor::Update>* aReadbackUpdates)
|
|
{
|
|
MOZ_ASSERT(!mTextureClientOnWhite || !aReadbackUpdates || aReadbackUpdates->Length() == 0);
|
|
|
|
// XXX: We might still not have a texture client if PaintThebes
|
|
// decided we didn't need one yet because the region to draw was empty.
|
|
SetBufferProvider(nullptr);
|
|
SetBufferProviderOnWhite(nullptr);
|
|
for (unsigned i = 0; i< mOldTextures.Length(); ++i) {
|
|
if (mOldTextures[i]->IsLocked()) {
|
|
mOldTextures[i]->Unlock();
|
|
}
|
|
}
|
|
mOldTextures.Clear();
|
|
|
|
if (mTextureClient && mTextureClient->IsLocked()) {
|
|
if (aReadbackUpdates->Length() > 0) {
|
|
RefPtr<TextureReadbackSink> readbackSink = new RemoteBufferReadbackProcessor(aReadbackUpdates, mBufferRect, mBufferRotation);
|
|
|
|
mTextureClient->SetReadbackSink(readbackSink);
|
|
}
|
|
|
|
mTextureClient->Unlock();
|
|
mTextureClient->SyncWithObject(mForwarder->GetSyncObject());
|
|
}
|
|
if (mTextureClientOnWhite && mTextureClientOnWhite->IsLocked()) {
|
|
mTextureClientOnWhite->Unlock();
|
|
mTextureClientOnWhite->SyncWithObject(mForwarder->GetSyncObject());
|
|
}
|
|
|
|
ContentClientRemote::EndPaint(aReadbackUpdates);
|
|
}
|
|
|
|
void
|
|
ContentClientRemoteBuffer::BuildTextureClients(SurfaceFormat aFormat,
|
|
const IntRect& aRect,
|
|
uint32_t aFlags)
|
|
{
|
|
// If we hit this assertion, then it might be due to an empty transaction
|
|
// followed by a real transaction. Our buffers should be created (but not
|
|
// painted in the empty transaction) and then painted (but not created) in the
|
|
// real transaction. That is kind of fragile, and this assert will catch
|
|
// circumstances where we screw that up, e.g., by unnecessarily recreating our
|
|
// buffers.
|
|
MOZ_ASSERT(!mIsNewBuffer,
|
|
"Bad! Did we create a buffer twice without painting?");
|
|
|
|
mIsNewBuffer = true;
|
|
|
|
DestroyBuffers();
|
|
|
|
mSurfaceFormat = aFormat;
|
|
mSize = IntSize(aRect.width, aRect.height);
|
|
mTextureFlags = TextureFlagsForRotatedContentBufferFlags(aFlags);
|
|
|
|
if (aFlags & BUFFER_COMPONENT_ALPHA) {
|
|
mTextureFlags |= TextureFlags::COMPONENT_ALPHA;
|
|
}
|
|
|
|
CreateBackBuffer(mBufferRect);
|
|
}
|
|
|
|
void
|
|
ContentClientRemoteBuffer::CreateBackBuffer(const IntRect& aBufferRect)
|
|
{
|
|
// gfx::BackendType::NONE means fallback to the content backend
|
|
TextureAllocationFlags textureAllocFlags
|
|
= (mTextureFlags & TextureFlags::COMPONENT_ALPHA) ?
|
|
TextureAllocationFlags::ALLOC_CLEAR_BUFFER_BLACK :
|
|
TextureAllocationFlags::ALLOC_CLEAR_BUFFER;
|
|
|
|
mTextureClient = CreateTextureClientForDrawing(
|
|
mSurfaceFormat, mSize, BackendSelector::Content,
|
|
mTextureFlags | ExtraTextureFlags(),
|
|
textureAllocFlags
|
|
);
|
|
if (!mTextureClient || !AddTextureClient(mTextureClient)) {
|
|
AbortTextureClientCreation();
|
|
return;
|
|
}
|
|
|
|
if (mTextureFlags & TextureFlags::COMPONENT_ALPHA) {
|
|
mTextureClientOnWhite = mTextureClient->CreateSimilar(
|
|
mTextureFlags | ExtraTextureFlags(),
|
|
TextureAllocationFlags::ALLOC_CLEAR_BUFFER_WHITE
|
|
);
|
|
if (!mTextureClientOnWhite || !AddTextureClient(mTextureClientOnWhite)) {
|
|
AbortTextureClientCreation();
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
void
|
|
ContentClientRemoteBuffer::CreateBuffer(ContentType aType,
|
|
const IntRect& aRect,
|
|
uint32_t aFlags,
|
|
RefPtr<gfx::DrawTarget>* aBlackDT,
|
|
RefPtr<gfx::DrawTarget>* aWhiteDT)
|
|
{
|
|
BuildTextureClients(gfxPlatform::GetPlatform()->Optimal2DFormatForContent(aType), aRect, aFlags);
|
|
if (!mTextureClient) {
|
|
return;
|
|
}
|
|
|
|
// We just created the textures and we are about to get their draw targets
|
|
// so we have to lock them here.
|
|
DebugOnly<bool> locked = mTextureClient->Lock(OpenMode::OPEN_READ_WRITE);
|
|
MOZ_ASSERT(locked, "Could not lock the TextureClient");
|
|
|
|
*aBlackDT = mTextureClient->BorrowDrawTarget();
|
|
if (aFlags & BUFFER_COMPONENT_ALPHA) {
|
|
locked = mTextureClientOnWhite->Lock(OpenMode::OPEN_READ_WRITE);
|
|
MOZ_ASSERT(locked, "Could not lock the second TextureClient for component alpha");
|
|
|
|
*aWhiteDT = mTextureClientOnWhite->BorrowDrawTarget();
|
|
}
|
|
}
|
|
|
|
nsIntRegion
|
|
ContentClientRemoteBuffer::GetUpdatedRegion(const nsIntRegion& aRegionToDraw,
|
|
const nsIntRegion& aVisibleRegion,
|
|
bool aDidSelfCopy)
|
|
{
|
|
nsIntRegion updatedRegion;
|
|
if (mIsNewBuffer || aDidSelfCopy) {
|
|
// A buffer reallocation clears both buffers. The front buffer has all the
|
|
// content by now, but the back buffer is still clear. Here, in effect, we
|
|
// are saying to copy all of the pixels of the front buffer to the back.
|
|
// Also when we self-copied in the buffer, the buffer space
|
|
// changes and some changed buffer content isn't reflected in the
|
|
// draw or invalidate region (on purpose!). When this happens, we
|
|
// need to read back the entire buffer too.
|
|
updatedRegion = aVisibleRegion.GetBounds();
|
|
mIsNewBuffer = false;
|
|
} else {
|
|
updatedRegion = aRegionToDraw;
|
|
}
|
|
|
|
NS_ASSERTION(BufferRect().Contains(aRegionToDraw.GetBounds()),
|
|
"Update outside of buffer rect!");
|
|
MOZ_ASSERT(mTextureClient, "should have a back buffer by now");
|
|
|
|
return updatedRegion;
|
|
}
|
|
|
|
void
|
|
ContentClientRemoteBuffer::Updated(const nsIntRegion& aRegionToDraw,
|
|
const nsIntRegion& aVisibleRegion,
|
|
bool aDidSelfCopy)
|
|
{
|
|
nsIntRegion updatedRegion = GetUpdatedRegion(aRegionToDraw,
|
|
aVisibleRegion,
|
|
aDidSelfCopy);
|
|
|
|
MOZ_ASSERT(mTextureClient);
|
|
if (mTextureClientOnWhite) {
|
|
mForwarder->UseComponentAlphaTextures(this, mTextureClient,
|
|
mTextureClientOnWhite);
|
|
} else {
|
|
AutoTArray<CompositableForwarder::TimedTextureClient,1> textures;
|
|
CompositableForwarder::TimedTextureClient* t = textures.AppendElement();
|
|
t->mTextureClient = mTextureClient;
|
|
IntSize size = mTextureClient->GetSize();
|
|
t->mPictureRect = nsIntRect(0, 0, size.width, size.height);
|
|
GetForwarder()->UseTextures(this, textures);
|
|
}
|
|
mForwarder->UpdateTextureRegion(this,
|
|
ThebesBufferData(BufferRect(),
|
|
BufferRotation()),
|
|
updatedRegion);
|
|
}
|
|
|
|
void
|
|
ContentClientRemoteBuffer::SwapBuffers(const nsIntRegion& aFrontUpdatedRegion)
|
|
{
|
|
mFrontAndBackBufferDiffer = true;
|
|
}
|
|
|
|
void
|
|
ContentClientRemoteBuffer::Dump(std::stringstream& aStream,
|
|
const char* aPrefix,
|
|
bool aDumpHtml, TextureDumpMode aCompress)
|
|
{
|
|
// TODO We should combine the OnWhite/OnBlack here an just output a single image.
|
|
if (!aDumpHtml) {
|
|
aStream << "\n" << aPrefix << "Surface: ";
|
|
}
|
|
CompositableClient::DumpTextureClient(aStream, mTextureClient, aCompress);
|
|
}
|
|
|
|
void
|
|
ContentClientDoubleBuffered::Dump(std::stringstream& aStream,
|
|
const char* aPrefix,
|
|
bool aDumpHtml, TextureDumpMode aCompress)
|
|
{
|
|
// TODO We should combine the OnWhite/OnBlack here an just output a single image.
|
|
if (!aDumpHtml) {
|
|
aStream << "\n" << aPrefix << "Surface: ";
|
|
}
|
|
CompositableClient::DumpTextureClient(aStream, mFrontClient, aCompress);
|
|
}
|
|
|
|
void
|
|
ContentClientDoubleBuffered::DestroyFrontBuffer()
|
|
{
|
|
if (mFrontClient) {
|
|
mOldTextures.AppendElement(mFrontClient);
|
|
mFrontClient = nullptr;
|
|
}
|
|
|
|
if (mFrontClientOnWhite) {
|
|
mOldTextures.AppendElement(mFrontClientOnWhite);
|
|
mFrontClientOnWhite = nullptr;
|
|
}
|
|
}
|
|
|
|
void
|
|
ContentClientDoubleBuffered::Updated(const nsIntRegion& aRegionToDraw,
|
|
const nsIntRegion& aVisibleRegion,
|
|
bool aDidSelfCopy)
|
|
{
|
|
ContentClientRemoteBuffer::Updated(aRegionToDraw, aVisibleRegion, aDidSelfCopy);
|
|
|
|
if (mFrontClient) {
|
|
mFrontClient->RemoveFromCompositable(this);
|
|
}
|
|
|
|
if (mFrontClientOnWhite) {
|
|
mFrontClientOnWhite->RemoveFromCompositable(this);
|
|
}
|
|
}
|
|
|
|
void
|
|
ContentClientDoubleBuffered::SwapBuffers(const nsIntRegion& aFrontUpdatedRegion)
|
|
{
|
|
mFrontUpdatedRegion = aFrontUpdatedRegion;
|
|
|
|
RefPtr<TextureClient> oldBack = mTextureClient;
|
|
mTextureClient = mFrontClient;
|
|
mFrontClient = oldBack;
|
|
|
|
oldBack = mTextureClientOnWhite;
|
|
mTextureClientOnWhite = mFrontClientOnWhite;
|
|
mFrontClientOnWhite = oldBack;
|
|
|
|
IntRect oldBufferRect = mBufferRect;
|
|
mBufferRect = mFrontBufferRect;
|
|
mFrontBufferRect = oldBufferRect;
|
|
|
|
nsIntPoint oldBufferRotation = mBufferRotation;
|
|
mBufferRotation = mFrontBufferRotation;
|
|
mFrontBufferRotation = oldBufferRotation;
|
|
|
|
MOZ_ASSERT(mFrontClient);
|
|
|
|
ContentClientRemoteBuffer::SwapBuffers(aFrontUpdatedRegion);
|
|
}
|
|
|
|
void
|
|
ContentClientDoubleBuffered::BeginPaint()
|
|
{
|
|
ContentClientRemoteBuffer::BeginPaint();
|
|
|
|
mIsNewBuffer = false;
|
|
|
|
if (!mFrontAndBackBufferDiffer) {
|
|
return;
|
|
}
|
|
|
|
if (mDidSelfCopy) {
|
|
// We can't easily draw our front buffer into us, since we're going to be
|
|
// copying stuff around anyway it's easiest if we just move our situation
|
|
// to non-rotated while we're at it. If this situation occurs we'll have
|
|
// hit a self-copy path in PaintThebes before as well anyway.
|
|
mBufferRect.MoveTo(mFrontBufferRect.TopLeft());
|
|
mBufferRotation = nsIntPoint();
|
|
return;
|
|
}
|
|
mBufferRect = mFrontBufferRect;
|
|
mBufferRotation = mFrontBufferRotation;
|
|
}
|
|
|
|
// Sync front/back buffers content
|
|
// After executing, the new back buffer has the same (interesting) pixels as
|
|
// the new front buffer, and mValidRegion et al. are correct wrt the new
|
|
// back buffer (i.e. as they were for the old back buffer)
|
|
void
|
|
ContentClientDoubleBuffered::FinalizeFrame(const nsIntRegion& aRegionToDraw)
|
|
{
|
|
if (mTextureClient) {
|
|
DebugOnly<bool> locked = mTextureClient->Lock(OpenMode::OPEN_READ_WRITE);
|
|
MOZ_ASSERT(locked);
|
|
}
|
|
if (mTextureClientOnWhite) {
|
|
DebugOnly<bool> locked = mTextureClientOnWhite->Lock(OpenMode::OPEN_READ_WRITE);
|
|
MOZ_ASSERT(locked);
|
|
}
|
|
|
|
if (!mFrontAndBackBufferDiffer) {
|
|
MOZ_ASSERT(!mDidSelfCopy, "If we have to copy the world, then our buffers are different, right?");
|
|
return;
|
|
}
|
|
MOZ_ASSERT(mFrontClient);
|
|
if (!mFrontClient) {
|
|
return;
|
|
}
|
|
|
|
MOZ_LAYERS_LOG(("BasicShadowableThebes(%p): reading back <x=%d,y=%d,w=%d,h=%d>",
|
|
this,
|
|
mFrontUpdatedRegion.GetBounds().x,
|
|
mFrontUpdatedRegion.GetBounds().y,
|
|
mFrontUpdatedRegion.GetBounds().width,
|
|
mFrontUpdatedRegion.GetBounds().height));
|
|
|
|
mFrontAndBackBufferDiffer = false;
|
|
|
|
nsIntRegion updateRegion = mFrontUpdatedRegion;
|
|
if (mDidSelfCopy) {
|
|
mDidSelfCopy = false;
|
|
updateRegion = mBufferRect;
|
|
}
|
|
|
|
// No point in sync'ing what we are going to draw over anyway. And if there is
|
|
// nothing to sync at all, there is nothing to do and we can go home early.
|
|
updateRegion.Sub(updateRegion, aRegionToDraw);
|
|
if (updateRegion.IsEmpty()) {
|
|
return;
|
|
}
|
|
|
|
// We need to ensure that we lock these two buffers in the same
|
|
// order as the compositor to prevent deadlocks.
|
|
TextureClientAutoLock frontLock(mFrontClient, OpenMode::OPEN_READ_ONLY);
|
|
if (!frontLock.Succeeded()) {
|
|
return;
|
|
}
|
|
Maybe<TextureClientAutoLock> frontOnWhiteLock;
|
|
if (mFrontClientOnWhite) {
|
|
frontOnWhiteLock.emplace(mFrontClientOnWhite, OpenMode::OPEN_READ_ONLY);
|
|
if (!frontOnWhiteLock->Succeeded()) {
|
|
return;
|
|
}
|
|
}
|
|
|
|
// Restrict the DrawTargets and frontBuffer to a scope to make
|
|
// sure there is no more external references to the DrawTargets
|
|
// when we Unlock the TextureClients.
|
|
gfx::DrawTarget* dt = mFrontClient->BorrowDrawTarget();
|
|
gfx::DrawTarget* dtw = mFrontClientOnWhite ? mFrontClientOnWhite->BorrowDrawTarget() : nullptr;
|
|
if (dt && dt->IsValid()) {
|
|
RefPtr<SourceSurface> surf = dt->Snapshot();
|
|
RefPtr<SourceSurface> surfOnWhite = dtw ? dtw->Snapshot() : nullptr;
|
|
SourceRotatedBuffer frontBuffer(surf,
|
|
surfOnWhite,
|
|
mFrontBufferRect,
|
|
mFrontBufferRotation);
|
|
UpdateDestinationFrom(frontBuffer, updateRegion);
|
|
} else {
|
|
// We know this can happen, but we want to track it somewhat, in case it leads
|
|
// to other problems.
|
|
gfxCriticalNote << "Invalid draw target(s) " << hexa(dt) << " and " << hexa(dtw);
|
|
}
|
|
}
|
|
|
|
void
|
|
ContentClientDoubleBuffered::EnsureBackBufferIfFrontBuffer()
|
|
{
|
|
if (!mTextureClient && mFrontClient) {
|
|
CreateBackBuffer(mFrontBufferRect);
|
|
|
|
mBufferRect = mFrontBufferRect;
|
|
mBufferRotation = mFrontBufferRotation;
|
|
}
|
|
}
|
|
|
|
void
|
|
ContentClientDoubleBuffered::UpdateDestinationFrom(const RotatedBuffer& aSource,
|
|
const nsIntRegion& aUpdateRegion)
|
|
{
|
|
DrawIterator iter;
|
|
while (DrawTarget* destDT =
|
|
BorrowDrawTargetForQuadrantUpdate(aUpdateRegion.GetBounds(), BUFFER_BLACK, &iter)) {
|
|
bool isClippingCheap = IsClippingCheap(destDT, iter.mDrawRegion);
|
|
if (isClippingCheap) {
|
|
gfxUtils::ClipToRegion(destDT, iter.mDrawRegion);
|
|
}
|
|
|
|
aSource.DrawBufferWithRotation(destDT, BUFFER_BLACK, 1.0, CompositionOp::OP_SOURCE);
|
|
if (isClippingCheap) {
|
|
destDT->PopClip();
|
|
}
|
|
// Flush the destination before the sources become inaccessible (Unlock).
|
|
destDT->Flush();
|
|
ReturnDrawTargetToBuffer(destDT);
|
|
}
|
|
|
|
if (aSource.HaveBufferOnWhite()) {
|
|
MOZ_ASSERT(HaveBufferOnWhite());
|
|
DrawIterator whiteIter;
|
|
while (DrawTarget* destDT =
|
|
BorrowDrawTargetForQuadrantUpdate(aUpdateRegion.GetBounds(), BUFFER_WHITE, &whiteIter)) {
|
|
bool isClippingCheap = IsClippingCheap(destDT, whiteIter.mDrawRegion);
|
|
if (isClippingCheap) {
|
|
gfxUtils::ClipToRegion(destDT, whiteIter.mDrawRegion);
|
|
}
|
|
|
|
aSource.DrawBufferWithRotation(destDT, BUFFER_WHITE, 1.0, CompositionOp::OP_SOURCE);
|
|
if (isClippingCheap) {
|
|
destDT->PopClip();
|
|
}
|
|
// Flush the destination before the sources become inaccessible (Unlock).
|
|
destDT->Flush();
|
|
ReturnDrawTargetToBuffer(destDT);
|
|
}
|
|
}
|
|
}
|
|
|
|
void
|
|
ContentClientSingleBuffered::FinalizeFrame(const nsIntRegion& aRegionToDraw)
|
|
{
|
|
if (mTextureClient) {
|
|
DebugOnly<bool> locked = mTextureClient->Lock(OpenMode::OPEN_READ_WRITE);
|
|
MOZ_ASSERT(locked);
|
|
}
|
|
if (mTextureClientOnWhite) {
|
|
DebugOnly<bool> locked = mTextureClientOnWhite->Lock(OpenMode::OPEN_READ_WRITE);
|
|
MOZ_ASSERT(locked);
|
|
}
|
|
}
|
|
|
|
} // namespace layers
|
|
} // namespace mozilla
|