Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
/* -*- 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"
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "BasicLayers.h" // for BasicLayerManager
|
|
|
|
#include "gfxContext.h" // for gfxContext, etc
|
|
|
|
#include "gfxPlatform.h" // for gfxPlatform
|
2015-10-28 16:31:00 +03:00
|
|
|
#include "gfxEnv.h" // for gfxEnv
|
2014-02-27 06:53:27 +04:00
|
|
|
#include "gfxPrefs.h" // for gfxPrefs
|
2015-05-29 18:01:46 +03:00
|
|
|
#include "gfxPoint.h" // for IntSize, gfxPoint
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "gfxUtils.h" // for gfxUtils
|
|
|
|
#include "ipc/ShadowLayers.h" // for ShadowLayerForwarder
|
2013-12-09 06:52:54 +04:00
|
|
|
#include "mozilla/ArrayUtils.h" // for ArrayLength
|
2015-11-11 10:58:29 +03:00
|
|
|
#include "mozilla/Maybe.h"
|
2013-08-12 03:17:23 +04:00
|
|
|
#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"
|
2016-03-22 21:08:38 +03:00
|
|
|
#include "mozilla/layers/CompositorBridgeChild.h" // for CompositorBridgeChild
|
2013-04-26 02:25:33 +04:00
|
|
|
#include "mozilla/layers/LayerManagerComposite.h"
|
2013-09-06 19:41:00 +04:00
|
|
|
#include "mozilla/layers/LayersMessages.h" // for ThebesBufferData
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "mozilla/layers/LayersTypes.h"
|
|
|
|
#include "nsDebug.h" // for NS_ASSERTION, NS_WARNING, etc
|
|
|
|
#include "nsISupportsImpl.h" // for gfxContext::Release, etc
|
|
|
|
#include "nsIWidget.h" // for nsIWidget
|
2014-05-05 12:24:56 +04:00
|
|
|
#include "nsLayoutUtils.h"
|
2013-05-03 21:34:29 +04:00
|
|
|
#ifdef XP_WIN
|
|
|
|
#include "gfxWindowsPlatform.h"
|
|
|
|
#endif
|
2014-07-23 03:02:25 +04:00
|
|
|
#ifdef MOZ_WIDGET_GTK
|
|
|
|
#include "gfxPlatformGtk.h"
|
|
|
|
#endif
|
2014-07-30 17:38:47 +04:00
|
|
|
#include "ReadbackLayer.h"
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
using namespace std;
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
using namespace gfx;
|
|
|
|
|
|
|
|
namespace layers {
|
|
|
|
|
2014-03-31 13:10:49 +04:00
|
|
|
static TextureFlags TextureFlagsForRotatedContentBufferFlags(uint32_t aBufferFlags)
|
|
|
|
{
|
2014-04-26 06:34:05 +04:00
|
|
|
TextureFlags result = TextureFlags::NO_FLAGS;
|
2014-03-31 13:10:49 +04:00
|
|
|
|
|
|
|
if (aBufferFlags & RotatedContentBuffer::BUFFER_COMPONENT_ALPHA) {
|
2014-04-26 06:34:05 +04:00
|
|
|
result |= TextureFlags::COMPONENT_ALPHA;
|
2014-03-31 13:10:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2015-06-17 17:00:52 +03:00
|
|
|
/* static */ already_AddRefed<ContentClient>
|
2013-04-17 01:36:06 +04:00
|
|
|
ContentClient::CreateContentClient(CompositableForwarder* aForwarder)
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
{
|
2013-07-04 00:35:51 +04:00
|
|
|
LayersBackend backend = aForwarder->GetCompositorBackendType();
|
2014-01-23 22:26:41 +04:00
|
|
|
if (backend != LayersBackend::LAYERS_OPENGL &&
|
|
|
|
backend != LayersBackend::LAYERS_D3D9 &&
|
|
|
|
backend != LayersBackend::LAYERS_D3D11 &&
|
|
|
|
backend != LayersBackend::LAYERS_BASIC) {
|
2013-08-04 11:46:17 +04:00
|
|
|
return nullptr;
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
}
|
2013-05-03 21:34:29 +04:00
|
|
|
|
|
|
|
bool useDoubleBuffering = false;
|
|
|
|
|
|
|
|
#ifdef XP_WIN
|
2014-01-23 22:26:41 +04:00
|
|
|
if (backend == LayersBackend::LAYERS_D3D11) {
|
2016-04-22 00:35:13 +03:00
|
|
|
useDoubleBuffering = gfxWindowsPlatform::GetPlatform()->IsDirect2DBackend();
|
2013-05-03 21:34:29 +04:00
|
|
|
} else
|
2014-07-23 03:02:25 +04:00
|
|
|
#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() ||
|
2016-08-04 21:33:44 +03:00
|
|
|
!gfxVars::UseXRender())
|
2013-05-03 21:34:29 +04:00
|
|
|
#endif
|
|
|
|
{
|
2014-02-07 17:30:01 +04:00
|
|
|
useDoubleBuffering = (LayerManagerComposite::SupportsDirectTexturing() &&
|
|
|
|
backend != LayersBackend::LAYERS_D3D9) ||
|
2014-01-23 22:26:41 +04:00
|
|
|
backend == LayersBackend::LAYERS_BASIC;
|
2013-05-03 21:34:29 +04:00
|
|
|
}
|
|
|
|
|
2015-10-28 16:31:00 +03:00
|
|
|
if (useDoubleBuffering || gfxEnv::ForceDoubleBuffering()) {
|
2015-04-30 22:20:30 +03:00
|
|
|
return MakeAndAddRef<ContentClientDoubleBuffered>(aForwarder);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
}
|
2015-04-30 22:20:30 +03:00
|
|
|
return MakeAndAddRef<ContentClientSingleBuffered>(aForwarder);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
}
|
|
|
|
|
2014-04-09 13:15:19 +04:00
|
|
|
void
|
2014-07-30 17:38:47 +04:00
|
|
|
ContentClient::EndPaint(nsTArray<ReadbackProcessor::Update>* aReadbackUpdates)
|
2014-04-09 13:15:19 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-12-18 21:32:45 +03:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-28 07:19:56 +04:00
|
|
|
// 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)
|
2013-11-27 04:29:46 +04:00
|
|
|
, RotatedContentBuffer(ContainsVisibleBounds)
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
{}
|
|
|
|
|
2013-09-12 08:53:46 +04:00
|
|
|
void
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
ContentClientBasic::CreateBuffer(ContentType aType,
|
2015-05-07 12:07:47 +03:00
|
|
|
const IntRect& aRect,
|
2013-04-22 06:40:52 +04:00
|
|
|
uint32_t aFlags,
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<gfx::DrawTarget>* aBlackDT,
|
|
|
|
RefPtr<gfx::DrawTarget>* aWhiteDT)
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
{
|
2013-08-23 10:13:55 +04:00
|
|
|
MOZ_ASSERT(!(aFlags & BUFFER_COMPONENT_ALPHA));
|
2016-07-20 17:26:02 +03:00
|
|
|
if (aFlags & BUFFER_COMPONENT_ALPHA) {
|
|
|
|
gfxDevCrash(LogReason::AlphaWithBasicClient) << "Asking basic content client for component alpha";
|
|
|
|
}
|
2013-09-12 08:53:46 +04:00
|
|
|
|
2013-11-27 04:29:45 +04:00
|
|
|
*aBlackDT = gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(
|
|
|
|
IntSize(aRect.width, aRect.height),
|
2015-07-07 05:27:19 +03:00
|
|
|
gfxPlatform::GetPlatform()->Optimal2DFormatForContent(aType));
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
}
|
|
|
|
|
2013-11-28 01:16:34 +04:00
|
|
|
void
|
2013-11-28 01:16:35 +04:00
|
|
|
ContentClientRemoteBuffer::DestroyBuffers()
|
2013-12-05 22:39:22 +04:00
|
|
|
{
|
|
|
|
if (!mTextureClient) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mOldTextures.AppendElement(mTextureClient);
|
|
|
|
mTextureClient = nullptr;
|
|
|
|
if (mTextureClientOnWhite) {
|
|
|
|
mOldTextures.AppendElement(mTextureClientOnWhite);
|
|
|
|
mTextureClientOnWhite = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
DestroyFrontBuffer();
|
|
|
|
}
|
|
|
|
|
2014-07-30 17:38:47 +04:00
|
|
|
class RemoteBufferReadbackProcessor : public TextureReadbackSink
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RemoteBufferReadbackProcessor(nsTArray<ReadbackProcessor::Update>* aReadbackUpdates,
|
2015-05-07 12:07:47 +03:00
|
|
|
const IntRect& aBufferRect, const nsIntPoint& aBufferRotation)
|
2014-07-30 17:38:47 +04:00
|
|
|
: 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;
|
|
|
|
}
|
|
|
|
|
2015-12-18 06:39:10 +03:00
|
|
|
RefPtr<DrawTarget> dt =
|
2014-07-30 17:38:47 +04:00
|
|
|
sink->BeginUpdate(update.mUpdateRect + offset, update.mSequenceCounter);
|
2015-12-18 06:39:10 +03:00
|
|
|
if (!dt) {
|
2014-07-30 17:38:47 +04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
dt->SetTransform(Matrix::Translation(offset.x, offset.y));
|
|
|
|
|
|
|
|
rotBuffer.DrawBufferWithRotation(dt, RotatedBuffer::BUFFER_BLACK);
|
|
|
|
|
2015-12-18 06:39:09 +03:00
|
|
|
update.mLayer->GetSink()->EndUpdate(update.mUpdateRect + offset);
|
2014-07-30 17:38:47 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsTArray<ReadbackProcessor::Update> mReadbackUpdates;
|
|
|
|
// This array is used to keep the layers alive until the callback.
|
2015-10-18 08:24:48 +03:00
|
|
|
vector<RefPtr<Layer>> mLayerRefs;
|
2014-07-30 17:38:47 +04:00
|
|
|
|
2015-05-07 12:07:47 +03:00
|
|
|
IntRect mBufferRect;
|
2014-07-30 17:38:47 +04:00
|
|
|
nsIntPoint mBufferRotation;
|
|
|
|
};
|
|
|
|
|
2013-12-05 22:39:22 +04:00
|
|
|
void
|
|
|
|
ContentClientRemoteBuffer::BeginPaint()
|
|
|
|
{
|
2014-05-15 02:31:22 +04:00
|
|
|
EnsureBackBufferIfFrontBuffer();
|
|
|
|
|
2014-04-01 10:28:05 +04:00
|
|
|
// XXX: So we might not have a TextureClient yet.. because it will
|
2013-12-05 22:39:22 +04:00
|
|
|
// only be created by CreateBuffer.. which will deliver a locked surface!.
|
|
|
|
if (mTextureClient) {
|
|
|
|
SetBufferProvider(mTextureClient);
|
|
|
|
}
|
|
|
|
if (mTextureClientOnWhite) {
|
|
|
|
SetBufferProviderOnWhite(mTextureClientOnWhite);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-07-30 17:38:47 +04:00
|
|
|
ContentClientRemoteBuffer::EndPaint(nsTArray<ReadbackProcessor::Update>* aReadbackUpdates)
|
2013-12-05 22:39:22 +04:00
|
|
|
{
|
2014-07-30 17:38:47 +04:00
|
|
|
MOZ_ASSERT(!mTextureClientOnWhite || !aReadbackUpdates || aReadbackUpdates->Length() == 0);
|
|
|
|
|
2013-12-05 22:39:22 +04:00
|
|
|
// 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);
|
2014-01-23 18:26:59 +04:00
|
|
|
for (unsigned i = 0; i< mOldTextures.Length(); ++i) {
|
2014-01-24 18:25:04 +04:00
|
|
|
if (mOldTextures[i]->IsLocked()) {
|
|
|
|
mOldTextures[i]->Unlock();
|
|
|
|
}
|
2014-01-23 18:26:59 +04:00
|
|
|
}
|
2013-12-05 22:39:22 +04:00
|
|
|
mOldTextures.Clear();
|
|
|
|
|
2014-04-09 13:15:18 +04:00
|
|
|
if (mTextureClient && mTextureClient->IsLocked()) {
|
2014-07-30 17:38:47 +04:00
|
|
|
if (aReadbackUpdates->Length() > 0) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<TextureReadbackSink> readbackSink = new RemoteBufferReadbackProcessor(aReadbackUpdates, mBufferRect, mBufferRotation);
|
2014-07-30 17:38:47 +04:00
|
|
|
|
|
|
|
mTextureClient->SetReadbackSink(readbackSink);
|
|
|
|
}
|
|
|
|
|
2013-12-05 22:39:22 +04:00
|
|
|
mTextureClient->Unlock();
|
2014-12-13 04:50:47 +03:00
|
|
|
mTextureClient->SyncWithObject(mForwarder->GetSyncObject());
|
2013-12-05 22:39:22 +04:00
|
|
|
}
|
2014-04-09 13:15:18 +04:00
|
|
|
if (mTextureClientOnWhite && mTextureClientOnWhite->IsLocked()) {
|
2013-12-05 22:39:22 +04:00
|
|
|
mTextureClientOnWhite->Unlock();
|
2014-12-13 04:50:47 +03:00
|
|
|
mTextureClientOnWhite->SyncWithObject(mForwarder->GetSyncObject());
|
2013-12-05 22:39:22 +04:00
|
|
|
}
|
2014-12-13 04:50:47 +03:00
|
|
|
|
2014-07-30 17:38:47 +04:00
|
|
|
ContentClientRemote::EndPaint(aReadbackUpdates);
|
2013-12-05 22:39:22 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ContentClientRemoteBuffer::BuildTextureClients(SurfaceFormat aFormat,
|
2015-05-07 12:07:47 +03:00
|
|
|
const IntRect& aRect,
|
2013-12-05 22:39:22 +04:00
|
|
|
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.
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(!mIsNewBuffer,
|
|
|
|
"Bad! Did we create a buffer twice without painting?");
|
2013-12-05 22:39:22 +04:00
|
|
|
|
|
|
|
mIsNewBuffer = true;
|
|
|
|
|
|
|
|
DestroyBuffers();
|
|
|
|
|
|
|
|
mSurfaceFormat = aFormat;
|
2015-05-28 12:59:15 +03:00
|
|
|
mSize = IntSize(aRect.width, aRect.height);
|
2014-11-25 22:19:13 +03:00
|
|
|
mTextureFlags = TextureFlagsForRotatedContentBufferFlags(aFlags);
|
2013-12-05 22:39:22 +04:00
|
|
|
|
2014-05-15 02:31:22 +04:00
|
|
|
if (aFlags & BUFFER_COMPONENT_ALPHA) {
|
2014-11-25 22:19:13 +03:00
|
|
|
mTextureFlags |= TextureFlags::COMPONENT_ALPHA;
|
2014-05-15 02:31:22 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
CreateBackBuffer(mBufferRect);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-05-07 12:07:47 +03:00
|
|
|
ContentClientRemoteBuffer::CreateBackBuffer(const IntRect& aBufferRect)
|
2014-05-15 02:31:22 +04:00
|
|
|
{
|
2014-07-25 13:24:46 +04:00
|
|
|
// gfx::BackendType::NONE means fallback to the content backend
|
2016-02-17 18:34:37 +03:00
|
|
|
TextureAllocationFlags textureAllocFlags
|
|
|
|
= (mTextureFlags & TextureFlags::COMPONENT_ALPHA) ?
|
|
|
|
TextureAllocationFlags::ALLOC_CLEAR_BUFFER_BLACK :
|
|
|
|
TextureAllocationFlags::ALLOC_CLEAR_BUFFER;
|
|
|
|
|
2014-07-25 13:24:46 +04:00
|
|
|
mTextureClient = CreateTextureClientForDrawing(
|
2015-08-07 03:27:36 +03:00
|
|
|
mSurfaceFormat, mSize, BackendSelector::Content,
|
2015-05-29 22:53:57 +03:00
|
|
|
mTextureFlags | ExtraTextureFlags(),
|
2016-02-17 18:34:37 +03:00
|
|
|
textureAllocFlags
|
2014-07-25 13:24:46 +04:00
|
|
|
);
|
|
|
|
if (!mTextureClient || !AddTextureClient(mTextureClient)) {
|
2013-12-05 22:39:22 +04:00
|
|
|
AbortTextureClientCreation();
|
|
|
|
return;
|
|
|
|
}
|
2014-07-25 13:24:46 +04:00
|
|
|
|
2014-11-25 22:19:13 +03:00
|
|
|
if (mTextureFlags & TextureFlags::COMPONENT_ALPHA) {
|
2014-07-25 13:24:46 +04:00
|
|
|
mTextureClientOnWhite = mTextureClient->CreateSimilar(
|
2015-05-29 22:53:57 +03:00
|
|
|
mTextureFlags | ExtraTextureFlags(),
|
2014-07-25 13:24:46 +04:00
|
|
|
TextureAllocationFlags::ALLOC_CLEAR_BUFFER_WHITE
|
|
|
|
);
|
|
|
|
if (!mTextureClientOnWhite || !AddTextureClient(mTextureClientOnWhite)) {
|
2013-12-05 22:39:22 +04:00
|
|
|
AbortTextureClientCreation();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ContentClientRemoteBuffer::CreateBuffer(ContentType aType,
|
2015-05-07 12:07:47 +03:00
|
|
|
const IntRect& aRect,
|
2013-12-05 22:39:22 +04:00
|
|
|
uint32_t aFlags,
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<gfx::DrawTarget>* aBlackDT,
|
|
|
|
RefPtr<gfx::DrawTarget>* aWhiteDT)
|
2013-12-05 22:39:22 +04:00
|
|
|
{
|
|
|
|
BuildTextureClients(gfxPlatform::GetPlatform()->Optimal2DFormatForContent(aType), aRect, aFlags);
|
|
|
|
if (!mTextureClient) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-01-23 18:26:59 +04:00
|
|
|
// We just created the textures and we are about to get their draw targets
|
|
|
|
// so we have to lock them here.
|
2014-04-26 06:34:06 +04:00
|
|
|
DebugOnly<bool> locked = mTextureClient->Lock(OpenMode::OPEN_READ_WRITE);
|
2014-01-23 18:26:59 +04:00
|
|
|
MOZ_ASSERT(locked, "Could not lock the TextureClient");
|
|
|
|
|
2014-06-11 22:57:58 +04:00
|
|
|
*aBlackDT = mTextureClient->BorrowDrawTarget();
|
2013-12-05 22:39:22 +04:00
|
|
|
if (aFlags & BUFFER_COMPONENT_ALPHA) {
|
2014-04-26 06:34:06 +04:00
|
|
|
locked = mTextureClientOnWhite->Lock(OpenMode::OPEN_READ_WRITE);
|
2014-01-23 18:26:59 +04:00
|
|
|
MOZ_ASSERT(locked, "Could not lock the second TextureClient for component alpha");
|
|
|
|
|
2014-06-11 22:57:58 +04:00
|
|
|
*aWhiteDT = mTextureClientOnWhite->BorrowDrawTarget();
|
2013-12-05 22:39:22 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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.
|
2016-02-09 08:07:30 +03:00
|
|
|
updatedRegion = aVisibleRegion.GetBounds();
|
2013-12-05 22:39:22 +04:00
|
|
|
mIsNewBuffer = false;
|
|
|
|
} else {
|
|
|
|
updatedRegion = aRegionToDraw;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_ASSERTION(BufferRect().Contains(aRegionToDraw.GetBounds()),
|
|
|
|
"Update outside of buffer rect!");
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(mTextureClient, "should have a back buffer by now");
|
2013-12-05 22:39:22 +04:00
|
|
|
|
|
|
|
return updatedRegion;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ContentClientRemoteBuffer::Updated(const nsIntRegion& aRegionToDraw,
|
|
|
|
const nsIntRegion& aVisibleRegion,
|
|
|
|
bool aDidSelfCopy)
|
|
|
|
{
|
|
|
|
nsIntRegion updatedRegion = GetUpdatedRegion(aRegionToDraw,
|
|
|
|
aVisibleRegion,
|
|
|
|
aDidSelfCopy);
|
|
|
|
|
|
|
|
MOZ_ASSERT(mTextureClient);
|
2014-01-23 18:14:58 +04:00
|
|
|
if (mTextureClientOnWhite) {
|
2014-02-06 15:28:29 +04:00
|
|
|
mForwarder->UseComponentAlphaTextures(this, mTextureClient,
|
|
|
|
mTextureClientOnWhite);
|
|
|
|
} else {
|
2016-02-02 18:36:30 +03:00
|
|
|
AutoTArray<CompositableForwarder::TimedTextureClient,1> textures;
|
2015-07-03 13:37:03 +03:00
|
|
|
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);
|
2014-01-23 18:14:58 +04:00
|
|
|
}
|
2013-12-05 22:39:22 +04:00
|
|
|
mForwarder->UpdateTextureRegion(this,
|
|
|
|
ThebesBufferData(BufferRect(),
|
|
|
|
BufferRotation()),
|
|
|
|
updatedRegion);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ContentClientRemoteBuffer::SwapBuffers(const nsIntRegion& aFrontUpdatedRegion)
|
|
|
|
{
|
|
|
|
mFrontAndBackBufferDiffer = true;
|
|
|
|
}
|
|
|
|
|
2014-12-18 21:32:45 +03:00
|
|
|
void
|
|
|
|
ContentClientRemoteBuffer::Dump(std::stringstream& aStream,
|
|
|
|
const char* aPrefix,
|
2015-09-29 01:51:37 +03:00
|
|
|
bool aDumpHtml, TextureDumpMode aCompress)
|
2014-12-18 21:32:45 +03:00
|
|
|
{
|
|
|
|
// TODO We should combine the OnWhite/OnBlack here an just output a single image.
|
2015-09-29 01:51:37 +03:00
|
|
|
if (!aDumpHtml) {
|
|
|
|
aStream << "\n" << aPrefix << "Surface: ";
|
|
|
|
}
|
|
|
|
CompositableClient::DumpTextureClient(aStream, mTextureClient, aCompress);
|
2014-12-18 21:32:45 +03:00
|
|
|
}
|
|
|
|
|
2015-01-13 00:51:02 +03:00
|
|
|
void
|
|
|
|
ContentClientDoubleBuffered::Dump(std::stringstream& aStream,
|
2015-09-29 01:51:37 +03:00
|
|
|
const char* aPrefix,
|
|
|
|
bool aDumpHtml, TextureDumpMode aCompress)
|
2015-01-13 00:51:02 +03:00
|
|
|
{
|
|
|
|
// TODO We should combine the OnWhite/OnBlack here an just output a single image.
|
2015-09-26 02:19:04 +03:00
|
|
|
if (!aDumpHtml) {
|
|
|
|
aStream << "\n" << aPrefix << "Surface: ";
|
|
|
|
}
|
2015-09-29 01:51:37 +03:00
|
|
|
CompositableClient::DumpTextureClient(aStream, mFrontClient, aCompress);
|
2015-01-13 00:51:02 +03:00
|
|
|
}
|
|
|
|
|
2013-12-05 22:39:22 +04:00
|
|
|
void
|
|
|
|
ContentClientDoubleBuffered::DestroyFrontBuffer()
|
|
|
|
{
|
2014-06-04 21:45:00 +04:00
|
|
|
if (mFrontClient) {
|
|
|
|
mOldTextures.AppendElement(mFrontClient);
|
|
|
|
mFrontClient = nullptr;
|
|
|
|
}
|
2013-12-05 22:39:22 +04:00
|
|
|
|
|
|
|
if (mFrontClientOnWhite) {
|
|
|
|
mOldTextures.AppendElement(mFrontClientOnWhite);
|
|
|
|
mFrontClientOnWhite = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-24 20:14:45 +04:00
|
|
|
void
|
|
|
|
ContentClientDoubleBuffered::Updated(const nsIntRegion& aRegionToDraw,
|
|
|
|
const nsIntRegion& aVisibleRegion,
|
|
|
|
bool aDidSelfCopy)
|
|
|
|
{
|
|
|
|
ContentClientRemoteBuffer::Updated(aRegionToDraw, aVisibleRegion, aDidSelfCopy);
|
|
|
|
}
|
|
|
|
|
2013-12-05 22:39:22 +04:00
|
|
|
void
|
|
|
|
ContentClientDoubleBuffered::SwapBuffers(const nsIntRegion& aFrontUpdatedRegion)
|
|
|
|
{
|
|
|
|
mFrontUpdatedRegion = aFrontUpdatedRegion;
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<TextureClient> oldBack = mTextureClient;
|
2013-12-05 22:39:22 +04:00
|
|
|
mTextureClient = mFrontClient;
|
|
|
|
mFrontClient = oldBack;
|
|
|
|
|
|
|
|
oldBack = mTextureClientOnWhite;
|
|
|
|
mTextureClientOnWhite = mFrontClientOnWhite;
|
|
|
|
mFrontClientOnWhite = oldBack;
|
|
|
|
|
2015-05-07 12:07:47 +03:00
|
|
|
IntRect oldBufferRect = mBufferRect;
|
2013-12-05 22:39:22 +04:00
|
|
|
mBufferRect = mFrontBufferRect;
|
|
|
|
mFrontBufferRect = oldBufferRect;
|
|
|
|
|
|
|
|
nsIntPoint oldBufferRotation = mBufferRotation;
|
|
|
|
mBufferRotation = mFrontBufferRotation;
|
|
|
|
mFrontBufferRotation = oldBufferRotation;
|
|
|
|
|
|
|
|
MOZ_ASSERT(mFrontClient);
|
|
|
|
|
|
|
|
ContentClientRemoteBuffer::SwapBuffers(aFrontUpdatedRegion);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-04-09 13:15:19 +04:00
|
|
|
ContentClientDoubleBuffered::BeginPaint()
|
2013-12-05 22:39:22 +04:00
|
|
|
{
|
2014-04-09 13:15:19 +04:00
|
|
|
ContentClientRemoteBuffer::BeginPaint();
|
|
|
|
|
2014-01-12 23:54:40 +04:00
|
|
|
mIsNewBuffer = false;
|
|
|
|
|
2013-12-05 22:39:22 +04:00
|
|
|
if (!mFrontAndBackBufferDiffer) {
|
|
|
|
return;
|
|
|
|
}
|
2014-01-12 23:54:40 +04:00
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2014-04-09 13:15:18 +04:00
|
|
|
if (mTextureClient) {
|
2014-04-26 06:34:06 +04:00
|
|
|
DebugOnly<bool> locked = mTextureClient->Lock(OpenMode::OPEN_READ_WRITE);
|
2014-04-09 13:15:18 +04:00
|
|
|
MOZ_ASSERT(locked);
|
|
|
|
}
|
|
|
|
if (mTextureClientOnWhite) {
|
2014-04-26 06:34:06 +04:00
|
|
|
DebugOnly<bool> locked = mTextureClientOnWhite->Lock(OpenMode::OPEN_READ_WRITE);
|
2014-04-09 13:15:18 +04:00
|
|
|
MOZ_ASSERT(locked);
|
|
|
|
}
|
|
|
|
|
2014-01-12 23:54:40 +04:00
|
|
|
if (!mFrontAndBackBufferDiffer) {
|
|
|
|
MOZ_ASSERT(!mDidSelfCopy, "If we have to copy the world, then our buffers are different, right?");
|
|
|
|
return;
|
|
|
|
}
|
2013-12-05 22:39:22 +04:00
|
|
|
MOZ_ASSERT(mFrontClient);
|
2014-06-04 19:21:50 +04:00
|
|
|
if (!mFrontClient) {
|
|
|
|
return;
|
|
|
|
}
|
2013-12-05 22:39:22 +04:00
|
|
|
|
|
|
|
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));
|
|
|
|
|
2014-01-12 23:54:40 +04:00
|
|
|
mFrontAndBackBufferDiffer = false;
|
2013-12-05 22:39:22 +04:00
|
|
|
|
2014-01-12 23:54:40 +04:00
|
|
|
nsIntRegion updateRegion = mFrontUpdatedRegion;
|
2013-12-05 22:39:22 +04:00
|
|
|
if (mDidSelfCopy) {
|
|
|
|
mDidSelfCopy = false;
|
|
|
|
updateRegion = mBufferRect;
|
|
|
|
}
|
|
|
|
|
2014-01-12 23:54:40 +04:00
|
|
|
// 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;
|
|
|
|
}
|
2013-12-05 22:39:22 +04:00
|
|
|
|
|
|
|
// We need to ensure that we lock these two buffers in the same
|
|
|
|
// order as the compositor to prevent deadlocks.
|
2015-11-11 10:58:29 +03:00
|
|
|
TextureClientAutoLock frontLock(mFrontClient, OpenMode::OPEN_READ_ONLY);
|
|
|
|
if (!frontLock.Succeeded()) {
|
2013-12-05 22:39:22 +04:00
|
|
|
return;
|
|
|
|
}
|
2015-11-11 10:58:29 +03:00
|
|
|
Maybe<TextureClientAutoLock> frontOnWhiteLock;
|
2013-12-05 22:39:22 +04:00
|
|
|
if (mFrontClientOnWhite) {
|
2015-11-11 10:58:29 +03:00
|
|
|
frontOnWhiteLock.emplace(mFrontClientOnWhite, OpenMode::OPEN_READ_ONLY);
|
|
|
|
if (!frontOnWhiteLock->Succeeded()) {
|
|
|
|
return;
|
|
|
|
}
|
2013-12-05 22:39:22 +04:00
|
|
|
}
|
2015-11-11 10:58:29 +03:00
|
|
|
|
|
|
|
// 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.
|
2015-12-04 21:43:00 +03:00
|
|
|
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);
|
|
|
|
}
|
2013-12-05 22:39:22 +04:00
|
|
|
}
|
2013-11-28 01:16:34 +04:00
|
|
|
|
2014-05-15 02:31:22 +04:00
|
|
|
void
|
|
|
|
ContentClientDoubleBuffered::EnsureBackBufferIfFrontBuffer()
|
|
|
|
{
|
|
|
|
if (!mTextureClient && mFrontClient) {
|
|
|
|
CreateBackBuffer(mFrontBufferRect);
|
2014-05-31 04:16:35 +04:00
|
|
|
|
|
|
|
mBufferRect = mFrontBufferRect;
|
|
|
|
mBufferRotation = mFrontBufferRotation;
|
2014-05-15 02:31:22 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-05 22:39:22 +04:00
|
|
|
void
|
|
|
|
ContentClientDoubleBuffered::UpdateDestinationFrom(const RotatedBuffer& aSource,
|
|
|
|
const nsIntRegion& aUpdateRegion)
|
|
|
|
{
|
2014-04-10 12:42:29 +04:00
|
|
|
DrawIterator iter;
|
|
|
|
while (DrawTarget* destDT =
|
|
|
|
BorrowDrawTargetForQuadrantUpdate(aUpdateRegion.GetBounds(), BUFFER_BLACK, &iter)) {
|
|
|
|
bool isClippingCheap = IsClippingCheap(destDT, iter.mDrawRegion);
|
2013-12-05 22:39:22 +04:00
|
|
|
if (isClippingCheap) {
|
2014-04-10 12:42:29 +04:00
|
|
|
gfxUtils::ClipToRegion(destDT, iter.mDrawRegion);
|
2013-12-05 22:39:22 +04:00
|
|
|
}
|
|
|
|
|
2014-04-10 12:42:29 +04:00
|
|
|
aSource.DrawBufferWithRotation(destDT, BUFFER_BLACK, 1.0, CompositionOp::OP_SOURCE);
|
2014-01-08 01:09:34 +04:00
|
|
|
if (isClippingCheap) {
|
|
|
|
destDT->PopClip();
|
|
|
|
}
|
2014-02-05 00:35:22 +04:00
|
|
|
// Flush the destination before the sources become inaccessible (Unlock).
|
|
|
|
destDT->Flush();
|
2014-01-24 10:58:33 +04:00
|
|
|
ReturnDrawTargetToBuffer(destDT);
|
2013-12-05 22:39:22 +04:00
|
|
|
}
|
2014-04-10 12:42:29 +04:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
2013-12-05 22:39:22 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-04-09 13:15:18 +04:00
|
|
|
ContentClientSingleBuffered::FinalizeFrame(const nsIntRegion& aRegionToDraw)
|
2013-12-05 22:39:22 +04:00
|
|
|
{
|
2014-04-09 13:15:18 +04:00
|
|
|
if (mTextureClient) {
|
2014-04-26 06:34:06 +04:00
|
|
|
DebugOnly<bool> locked = mTextureClient->Lock(OpenMode::OPEN_READ_WRITE);
|
2014-01-23 18:26:59 +04:00
|
|
|
MOZ_ASSERT(locked);
|
2013-12-05 22:39:22 +04:00
|
|
|
}
|
2014-04-09 13:15:18 +04:00
|
|
|
if (mTextureClientOnWhite) {
|
2014-04-26 06:34:06 +04:00
|
|
|
DebugOnly<bool> locked = mTextureClientOnWhite->Lock(OpenMode::OPEN_READ_WRITE);
|
2014-01-23 18:26:59 +04:00
|
|
|
MOZ_ASSERT(locked);
|
2013-12-05 22:39:22 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-07 12:07:47 +03:00
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|