forked from mirrors/gecko-dev
Backed out 8 changesets (bug 1265824) for bustage in /builds/worker/workspace/build/src/gfx/layers/opengl/CompositorOGL.cpp on a CLOSED TREE
Backed out changeset 1099d6f15f9f (bug 1265824) Backed out changeset b5ba15b1a70f (bug 1265824) Backed out changeset 51795de4adaf (bug 1265824) Backed out changeset be68741ff4ce (bug 1265824) Backed out changeset 4731dc56702d (bug 1265824) Backed out changeset 984133e9614b (bug 1265824) Backed out changeset efce316a4425 (bug 1265824) Backed out changeset 367abce30668 (bug 1265824)
This commit is contained in:
parent
aa98d8cbd6
commit
b1e7992b82
43 changed files with 115 additions and 1253 deletions
|
|
@ -81,7 +81,6 @@ static const char* const sExtensionNames[] = {
|
||||||
"GL_ANGLE_texture_compression_dxt5",
|
"GL_ANGLE_texture_compression_dxt5",
|
||||||
"GL_ANGLE_timer_query",
|
"GL_ANGLE_timer_query",
|
||||||
"GL_APPLE_client_storage",
|
"GL_APPLE_client_storage",
|
||||||
"GL_APPLE_fence",
|
|
||||||
"GL_APPLE_framebuffer_multisample",
|
"GL_APPLE_framebuffer_multisample",
|
||||||
"GL_APPLE_sync",
|
"GL_APPLE_sync",
|
||||||
"GL_APPLE_texture_range",
|
"GL_APPLE_texture_range",
|
||||||
|
|
@ -1081,15 +1080,6 @@ GLContext::LoadMoreSymbols(const char* prefix, bool trygl)
|
||||||
fnLoadForExt(symbols, APPLE_texture_range);
|
fnLoadForExt(symbols, APPLE_texture_range);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsExtensionSupported(APPLE_fence)) {
|
|
||||||
const SymLoadStruct symbols[] = {
|
|
||||||
{ (PRFuncPtr*) &mSymbols.fFinishObjectAPPLE, { "FinishObjectAPPLE", nullptr } },
|
|
||||||
{ (PRFuncPtr*) &mSymbols.fTestObjectAPPLE, { "TestObjectAPPLE", nullptr } },
|
|
||||||
END_SYMBOLS
|
|
||||||
};
|
|
||||||
fnLoadForExt(symbols, APPLE_fence);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsSupported(GLFeature::vertex_array_object)) {
|
if (IsSupported(GLFeature::vertex_array_object)) {
|
||||||
const SymLoadStruct coreSymbols[] = {
|
const SymLoadStruct coreSymbols[] = {
|
||||||
{ (PRFuncPtr*) &mSymbols.fIsVertexArray, { "IsVertexArray", nullptr } },
|
{ (PRFuncPtr*) &mSymbols.fIsVertexArray, { "IsVertexArray", nullptr } },
|
||||||
|
|
|
||||||
|
|
@ -380,7 +380,6 @@ public:
|
||||||
ANGLE_texture_compression_dxt5,
|
ANGLE_texture_compression_dxt5,
|
||||||
ANGLE_timer_query,
|
ANGLE_timer_query,
|
||||||
APPLE_client_storage,
|
APPLE_client_storage,
|
||||||
APPLE_fence,
|
|
||||||
APPLE_framebuffer_multisample,
|
APPLE_framebuffer_multisample,
|
||||||
APPLE_sync,
|
APPLE_sync,
|
||||||
APPLE_texture_range,
|
APPLE_texture_range,
|
||||||
|
|
@ -3303,25 +3302,6 @@ public:
|
||||||
AFTER_GL_CALL;
|
AFTER_GL_CALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// APPLE_fence
|
|
||||||
|
|
||||||
void fFinishObjectAPPLE(GLenum object, GLint name) {
|
|
||||||
BEFORE_GL_CALL;
|
|
||||||
ASSERT_SYMBOL_PRESENT(fFinishObjectAPPLE);
|
|
||||||
mSymbols.fFinishObjectAPPLE(object, name);
|
|
||||||
AFTER_GL_CALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
realGLboolean fTestObjectAPPLE(GLenum object, GLint name) {
|
|
||||||
realGLboolean ret = false;
|
|
||||||
BEFORE_GL_CALL;
|
|
||||||
ASSERT_SYMBOL_PRESENT(fTestObjectAPPLE);
|
|
||||||
ret = mSymbols.fTestObjectAPPLE(object, name);
|
|
||||||
AFTER_GL_CALL;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// prim_restart
|
// prim_restart
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -137,8 +137,6 @@ struct GLContextSymbols final
|
||||||
void (GLAPIENTRY * fTexSubImage2D)(GLenum, GLint, GLint, GLint, GLsizei,
|
void (GLAPIENTRY * fTexSubImage2D)(GLenum, GLint, GLint, GLint, GLsizei,
|
||||||
GLsizei, GLenum, GLenum, const void*);
|
GLsizei, GLenum, GLenum, const void*);
|
||||||
void (GLAPIENTRY * fTextureRangeAPPLE)(GLenum, GLsizei, GLvoid*);
|
void (GLAPIENTRY * fTextureRangeAPPLE)(GLenum, GLsizei, GLvoid*);
|
||||||
void (GLAPIENTRY * fFinishObjectAPPLE)(GLenum, GLint);
|
|
||||||
realGLboolean (GLAPIENTRY * fTestObjectAPPLE)(GLenum, GLint);
|
|
||||||
void (GLAPIENTRY * fUniform1f)(GLint, GLfloat);
|
void (GLAPIENTRY * fUniform1f)(GLint, GLfloat);
|
||||||
void (GLAPIENTRY * fUniform1fv)(GLint, GLsizei, const GLfloat*);
|
void (GLAPIENTRY * fUniform1fv)(GLint, GLsizei, const GLfloat*);
|
||||||
void (GLAPIENTRY * fUniform1i)(GLint, GLint);
|
void (GLAPIENTRY * fUniform1i)(GLint, GLint);
|
||||||
|
|
|
||||||
|
|
@ -105,13 +105,8 @@ static bool UsingX11Compositor()
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ComputeHasIntermediateBuffer(gfx::SurfaceFormat aFormat,
|
bool ComputeHasIntermediateBuffer(gfx::SurfaceFormat aFormat,
|
||||||
LayersBackend aLayersBackend,
|
LayersBackend aLayersBackend)
|
||||||
bool aSupportsTextureDirectMapping)
|
|
||||||
{
|
{
|
||||||
if (aSupportsTextureDirectMapping) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return aLayersBackend != LayersBackend::LAYERS_BASIC
|
return aLayersBackend != LayersBackend::LAYERS_BASIC
|
||||||
|| UsingX11Compositor()
|
|| UsingX11Compositor()
|
||||||
|| aFormat == gfx::SurfaceFormat::UNKNOWN;
|
|| aFormat == gfx::SurfaceFormat::UNKNOWN;
|
||||||
|
|
@ -173,8 +168,7 @@ BufferTextureData::CreateForYCbCrWithBufferSize(KnowsCompositor* aAllocator,
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasIntermediateBuffer = aAllocator ? ComputeHasIntermediateBuffer(gfx::SurfaceFormat::YUV,
|
bool hasIntermediateBuffer = aAllocator ? ComputeHasIntermediateBuffer(gfx::SurfaceFormat::YUV,
|
||||||
aAllocator->GetCompositorBackendType(),
|
aAllocator->GetCompositorBackendType())
|
||||||
aAllocator->SupportsTextureDirectMapping())
|
|
||||||
: true;
|
: true;
|
||||||
|
|
||||||
// Initialize the metadata with something, even if it will have to be rewritten
|
// Initialize the metadata with something, even if it will have to be rewritten
|
||||||
|
|
@ -216,8 +210,7 @@ BufferTextureData::CreateForYCbCr(KnowsCompositor* aAllocator,
|
||||||
bool hasIntermediateBuffer =
|
bool hasIntermediateBuffer =
|
||||||
aAllocator
|
aAllocator
|
||||||
? ComputeHasIntermediateBuffer(gfx::SurfaceFormat::YUV,
|
? ComputeHasIntermediateBuffer(gfx::SurfaceFormat::YUV,
|
||||||
aAllocator->GetCompositorBackendType(),
|
aAllocator->GetCompositorBackendType())
|
||||||
aAllocator->SupportsTextureDirectMapping())
|
|
||||||
: true;
|
: true;
|
||||||
|
|
||||||
YCbCrDescriptor descriptor = YCbCrDescriptor(aYSize, aYStride,
|
YCbCrDescriptor descriptor = YCbCrDescriptor(aYSize, aYStride,
|
||||||
|
|
@ -532,9 +525,7 @@ MemoryTextureData::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasIntermediateBuffer = ComputeHasIntermediateBuffer(aFormat,
|
bool hasIntermediateBuffer = ComputeHasIntermediateBuffer(aFormat, aLayersBackend);
|
||||||
aLayersBackend,
|
|
||||||
aAllocFlags & ALLOC_ALLOW_DIRECT_MAPPING);
|
|
||||||
|
|
||||||
GfxMemoryImageReporter::DidAlloc(buf);
|
GfxMemoryImageReporter::DidAlloc(buf);
|
||||||
|
|
||||||
|
|
@ -610,9 +601,7 @@ ShmemTextureData::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasIntermediateBuffer = ComputeHasIntermediateBuffer(aFormat,
|
bool hasIntermediateBuffer = ComputeHasIntermediateBuffer(aFormat, aLayersBackend);
|
||||||
aLayersBackend,
|
|
||||||
aAllocFlags & ALLOC_ALLOW_DIRECT_MAPPING);
|
|
||||||
|
|
||||||
BufferDescriptor descriptor = RGBDescriptor(aSize, aFormat, hasIntermediateBuffer);
|
BufferDescriptor descriptor = RGBDescriptor(aSize, aFormat, hasIntermediateBuffer);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,7 @@ namespace mozilla {
|
||||||
namespace layers {
|
namespace layers {
|
||||||
|
|
||||||
bool ComputeHasIntermediateBuffer(gfx::SurfaceFormat aFormat,
|
bool ComputeHasIntermediateBuffer(gfx::SurfaceFormat aFormat,
|
||||||
LayersBackend aLayersBackend,
|
LayersBackend aLayersBackend);
|
||||||
bool aSupportsTextureDirectMapping);
|
|
||||||
|
|
||||||
class BufferTextureData : public TextureData
|
class BufferTextureData : public TextureData
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -175,7 +175,6 @@ struct TextureFactoryIdentifier
|
||||||
LayersBackend mParentBackend;
|
LayersBackend mParentBackend;
|
||||||
GeckoProcessType mParentProcessType;
|
GeckoProcessType mParentProcessType;
|
||||||
int32_t mMaxTextureSize;
|
int32_t mMaxTextureSize;
|
||||||
bool mSupportsTextureDirectMapping;
|
|
||||||
bool mCompositorUseANGLE;
|
bool mCompositorUseANGLE;
|
||||||
bool mSupportsTextureBlitting;
|
bool mSupportsTextureBlitting;
|
||||||
bool mSupportsPartialUploads;
|
bool mSupportsPartialUploads;
|
||||||
|
|
@ -186,7 +185,6 @@ struct TextureFactoryIdentifier
|
||||||
explicit TextureFactoryIdentifier(LayersBackend aLayersBackend = LayersBackend::LAYERS_NONE,
|
explicit TextureFactoryIdentifier(LayersBackend aLayersBackend = LayersBackend::LAYERS_NONE,
|
||||||
GeckoProcessType aParentProcessType = GeckoProcessType_Default,
|
GeckoProcessType aParentProcessType = GeckoProcessType_Default,
|
||||||
int32_t aMaxTextureSize = 4096,
|
int32_t aMaxTextureSize = 4096,
|
||||||
bool aSupportsTextureDirectMapping = false,
|
|
||||||
bool aCompositorUseANGLE = false,
|
bool aCompositorUseANGLE = false,
|
||||||
bool aSupportsTextureBlitting = false,
|
bool aSupportsTextureBlitting = false,
|
||||||
bool aSupportsPartialUploads = false,
|
bool aSupportsPartialUploads = false,
|
||||||
|
|
@ -195,7 +193,6 @@ struct TextureFactoryIdentifier
|
||||||
: mParentBackend(aLayersBackend)
|
: mParentBackend(aLayersBackend)
|
||||||
, mParentProcessType(aParentProcessType)
|
, mParentProcessType(aParentProcessType)
|
||||||
, mMaxTextureSize(aMaxTextureSize)
|
, mMaxTextureSize(aMaxTextureSize)
|
||||||
, mSupportsTextureDirectMapping(aSupportsTextureDirectMapping)
|
|
||||||
, mCompositorUseANGLE(aCompositorUseANGLE)
|
, mCompositorUseANGLE(aCompositorUseANGLE)
|
||||||
, mSupportsTextureBlitting(aSupportsTextureBlitting)
|
, mSupportsTextureBlitting(aSupportsTextureBlitting)
|
||||||
, mSupportsPartialUploads(aSupportsPartialUploads)
|
, mSupportsPartialUploads(aSupportsPartialUploads)
|
||||||
|
|
@ -209,12 +206,10 @@ struct TextureFactoryIdentifier
|
||||||
mParentBackend == aOther.mParentBackend &&
|
mParentBackend == aOther.mParentBackend &&
|
||||||
mParentProcessType == aOther.mParentProcessType &&
|
mParentProcessType == aOther.mParentProcessType &&
|
||||||
mMaxTextureSize == aOther.mMaxTextureSize &&
|
mMaxTextureSize == aOther.mMaxTextureSize &&
|
||||||
mSupportsTextureDirectMapping == aOther.mSupportsTextureDirectMapping &&
|
|
||||||
mCompositorUseANGLE == aOther.mCompositorUseANGLE &&
|
mCompositorUseANGLE == aOther.mCompositorUseANGLE &&
|
||||||
mSupportsTextureBlitting == aOther.mSupportsTextureBlitting &&
|
mSupportsTextureBlitting == aOther.mSupportsTextureBlitting &&
|
||||||
mSupportsPartialUploads == aOther.mSupportsPartialUploads &&
|
mSupportsPartialUploads == aOther.mSupportsPartialUploads &&
|
||||||
mSupportsComponentAlpha == aOther.mSupportsComponentAlpha &&
|
mSupportsComponentAlpha == aOther.mSupportsComponentAlpha &&
|
||||||
mUsingAdvancedLayers == aOther.mUsingAdvancedLayers &&
|
|
||||||
mSyncHandle == aOther.mSyncHandle;
|
mSyncHandle == aOther.mSyncHandle;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,6 @@
|
||||||
|
|
||||||
#include "mozilla/layers/TextureSourceProvider.h"
|
#include "mozilla/layers/TextureSourceProvider.h"
|
||||||
#include "mozilla/layers/TextureHost.h"
|
#include "mozilla/layers/TextureHost.h"
|
||||||
#include "mozilla/layers/PTextureParent.h"
|
|
||||||
#ifdef XP_DARWIN
|
|
||||||
#include "mozilla/layers/TextureSync.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace layers {
|
namespace layers {
|
||||||
|
|
@ -22,30 +18,9 @@ TextureSourceProvider::~TextureSourceProvider()
|
||||||
void
|
void
|
||||||
TextureSourceProvider::ReadUnlockTextures()
|
TextureSourceProvider::ReadUnlockTextures()
|
||||||
{
|
{
|
||||||
#ifdef XP_DARWIN
|
|
||||||
nsClassHashtable<nsUint32HashKey, nsTArray<uint64_t>> texturesIdsToUnlockByPid;
|
|
||||||
for (auto& texture : mUnlockAfterComposition) {
|
|
||||||
auto bufferTexture = texture->AsBufferTextureHost();
|
|
||||||
if (bufferTexture && bufferTexture->IsDirectMap()) {
|
|
||||||
texture->ReadUnlock();
|
|
||||||
auto actor = texture->GetIPDLActor();
|
|
||||||
if (actor) {
|
|
||||||
base::ProcessId pid = actor->OtherPid();
|
|
||||||
nsTArray<uint64_t>* textureIds = texturesIdsToUnlockByPid.LookupOrAdd(pid);
|
|
||||||
textureIds->AppendElement(TextureHost::GetTextureSerial(actor));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
texture->ReadUnlock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (auto it = texturesIdsToUnlockByPid.ConstIter(); !it.Done(); it.Next()) {
|
|
||||||
TextureSync::SetTexturesUnlocked(it.Key(), *it.UserData());
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
for (auto& texture : mUnlockAfterComposition) {
|
for (auto& texture : mUnlockAfterComposition) {
|
||||||
texture->ReadUnlock();
|
texture->ReadUnlock();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
mUnlockAfterComposition.Clear();
|
mUnlockAfterComposition.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -74,9 +74,6 @@ public:
|
||||||
/// Returns true if notified, false otherwise.
|
/// Returns true if notified, false otherwise.
|
||||||
virtual bool NotifyNotUsedAfterComposition(TextureHost* aTextureHost);
|
virtual bool NotifyNotUsedAfterComposition(TextureHost* aTextureHost);
|
||||||
|
|
||||||
virtual void MaybeUnlockBeforeNextComposition(TextureHost* aTextureHost) {}
|
|
||||||
virtual void TryUnlockTextures() {}
|
|
||||||
|
|
||||||
// If overridden, make sure to call the base function.
|
// If overridden, make sure to call the base function.
|
||||||
virtual void Destroy();
|
virtual void Destroy();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,287 +0,0 @@
|
||||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
||||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
||||||
/* 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 "TextureSync.h"
|
|
||||||
|
|
||||||
#include <unordered_set>
|
|
||||||
|
|
||||||
#include "chrome/common/mach_ipc_mac.h"
|
|
||||||
#include "mozilla/ipc/SharedMemoryBasic.h"
|
|
||||||
#include "mozilla/layers/CompositorThread.h"
|
|
||||||
#include "mozilla/StaticMonitor.h"
|
|
||||||
#include "mozilla/StaticPtr.h"
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
#define LOG_ERROR(str, args...) \
|
|
||||||
PR_BEGIN_MACRO \
|
|
||||||
mozilla::SmprintfPointer msg = mozilla::Smprintf(str, ## args); \
|
|
||||||
NS_WARNING(msg.get()); \
|
|
||||||
PR_END_MACRO
|
|
||||||
#else
|
|
||||||
#define LOG_ERROR(str, args...) do { /* nothing */ } while(0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace mozilla {
|
|
||||||
|
|
||||||
namespace layers {
|
|
||||||
|
|
||||||
// Hold raw pointers and trust that TextureSourceProviders will be
|
|
||||||
// unregistered in their destructors - we don't want to keep these
|
|
||||||
// alive, and destroying them from the main thread will be an
|
|
||||||
// error anyway.
|
|
||||||
StaticAutoPtr<nsTArray<TextureSourceProvider*>> gTextureSourceProviders;
|
|
||||||
|
|
||||||
static std::map<pid_t, std::unordered_set<uint64_t>> gProcessTextureIds;
|
|
||||||
static StaticMonitor gTextureLockMonitor;
|
|
||||||
|
|
||||||
const int kSendMessageTimeout = 1000;
|
|
||||||
const int kTextureLockTimeout = 32; // We really don't want to wait more than
|
|
||||||
// two frames for a texture to unlock. This
|
|
||||||
// will in any case be very uncommon.
|
|
||||||
|
|
||||||
struct WaitForTexturesReply
|
|
||||||
{
|
|
||||||
bool success;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct WaitForTexturesRequest
|
|
||||||
{
|
|
||||||
pid_t pid;
|
|
||||||
};
|
|
||||||
|
|
||||||
std::unordered_set<uint64_t>*
|
|
||||||
GetLockedTextureIdsForProcess(pid_t pid)
|
|
||||||
{
|
|
||||||
gTextureLockMonitor.AssertCurrentThreadOwns();
|
|
||||||
|
|
||||||
if (gProcessTextureIds.find(pid) == gProcessTextureIds.end()) {
|
|
||||||
gProcessTextureIds[pid] = std::unordered_set<uint64_t>();
|
|
||||||
}
|
|
||||||
|
|
||||||
return &gProcessTextureIds.at(pid);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
WaitForTextureIdsToUnlock(pid_t pid, const Span<const uint64_t>& textureIds)
|
|
||||||
{
|
|
||||||
{
|
|
||||||
StaticMonitorAutoLock lock(gTextureLockMonitor);
|
|
||||||
std::unordered_set<uint64_t>* freedTextureIds = GetLockedTextureIdsForProcess(pid);
|
|
||||||
|
|
||||||
TimeStamp start = TimeStamp::Now();
|
|
||||||
while (true) {
|
|
||||||
bool allCleared = true;
|
|
||||||
for (uint64_t textureId : textureIds) {
|
|
||||||
if (freedTextureIds->find(textureId) != freedTextureIds->end()) {
|
|
||||||
allCleared = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (allCleared) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lock.Wait(TimeDuration::FromMilliseconds(kTextureLockTimeout)) == CVStatus::Timeout) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// In case the monitor gets signaled multiple times, each less than kTextureLockTimeout.
|
|
||||||
// This ensures that the total time we wait is < 2 * kTextureLockTimeout
|
|
||||||
if ((TimeStamp::Now() - start).ToMilliseconds() > (double)kTextureLockTimeout) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
CheckTexturesForUnlock()
|
|
||||||
{
|
|
||||||
if (gTextureSourceProviders) {
|
|
||||||
for (auto it = gTextureSourceProviders->begin(); it != gTextureSourceProviders->end(); ++it) {
|
|
||||||
(*it)->TryUnlockTextures();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
TextureSync::DispatchCheckTexturesForUnlock()
|
|
||||||
{
|
|
||||||
RefPtr<Runnable> task = NS_NewRunnableFunction(
|
|
||||||
"CheckTexturesForUnlock",
|
|
||||||
&CheckTexturesForUnlock);
|
|
||||||
CompositorThreadHolder::Loop()->PostTask(task.forget());
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
TextureSync::HandleWaitForTexturesMessage(MachReceiveMessage* rmsg, ipc::MemoryPorts* ports)
|
|
||||||
{
|
|
||||||
WaitForTexturesRequest* req = reinterpret_cast<WaitForTexturesRequest*>(rmsg->GetData());
|
|
||||||
uint64_t* textureIds = (uint64_t*)(req + 1);
|
|
||||||
uint32_t textureIdsLength = (rmsg->GetDataLength() - sizeof(WaitForTexturesRequest)) / sizeof(uint64_t);
|
|
||||||
|
|
||||||
bool success = WaitForTextureIdsToUnlock(req->pid, MakeSpan<uint64_t>(textureIds, textureIdsLength));
|
|
||||||
|
|
||||||
if (!success) {
|
|
||||||
LOG_ERROR("Waiting for textures to unlock failed.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
MachSendMessage msg(ipc::kReturnWaitForTexturesMsg);
|
|
||||||
WaitForTexturesReply replydata;
|
|
||||||
replydata.success = success;
|
|
||||||
msg.SetData(&replydata, sizeof(WaitForTexturesReply));
|
|
||||||
kern_return_t err = ports->mSender->SendMessage(msg, kSendMessageTimeout);
|
|
||||||
if (KERN_SUCCESS != err) {
|
|
||||||
LOG_ERROR("SendMessage failed 0x%x %s\n", err, mach_error_string(err));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
TextureSync::RegisterTextureSourceProvider(TextureSourceProvider* textureSourceProvider)
|
|
||||||
{
|
|
||||||
if (!gTextureSourceProviders) {
|
|
||||||
gTextureSourceProviders = new nsTArray<TextureSourceProvider*>();
|
|
||||||
}
|
|
||||||
MOZ_RELEASE_ASSERT(!gTextureSourceProviders->Contains(textureSourceProvider));
|
|
||||||
gTextureSourceProviders->AppendElement(textureSourceProvider);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
TextureSync::UnregisterTextureSourceProvider(TextureSourceProvider* textureSourceProvider)
|
|
||||||
{
|
|
||||||
if (gTextureSourceProviders) {
|
|
||||||
MOZ_ASSERT(gTextureSourceProviders->Contains(textureSourceProvider));
|
|
||||||
gTextureSourceProviders->RemoveElement(textureSourceProvider);
|
|
||||||
if (gTextureSourceProviders->Length() == 0) {
|
|
||||||
gTextureSourceProviders = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
TextureSync::SetTexturesLocked(pid_t pid, const nsTArray<uint64_t>& textureIds)
|
|
||||||
{
|
|
||||||
StaticMonitorAutoLock mal(gTextureLockMonitor);
|
|
||||||
std::unordered_set<uint64_t>* lockedTextureIds = GetLockedTextureIdsForProcess(pid);
|
|
||||||
for (uint64_t textureId : textureIds) {
|
|
||||||
lockedTextureIds->insert(textureId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
TextureSync::SetTexturesUnlocked(pid_t pid, const nsTArray<uint64_t>& textureIds)
|
|
||||||
{
|
|
||||||
bool oneErased = false;
|
|
||||||
{
|
|
||||||
StaticMonitorAutoLock mal(gTextureLockMonitor);
|
|
||||||
std::unordered_set<uint64_t>* lockedTextureIds = GetLockedTextureIdsForProcess(pid);
|
|
||||||
for (uint64_t textureId : textureIds) {
|
|
||||||
if (lockedTextureIds->erase(textureId)) {
|
|
||||||
oneErased = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (oneErased) {
|
|
||||||
gTextureLockMonitor.NotifyAll();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
TextureSync::Shutdown()
|
|
||||||
{
|
|
||||||
{
|
|
||||||
StaticMonitorAutoLock lock(gTextureLockMonitor);
|
|
||||||
|
|
||||||
for (auto& lockedTextureIds : gProcessTextureIds) {
|
|
||||||
lockedTextureIds.second.clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gTextureLockMonitor.NotifyAll();
|
|
||||||
|
|
||||||
{
|
|
||||||
StaticMonitorAutoLock lock(gTextureLockMonitor);
|
|
||||||
gProcessTextureIds.clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
TextureSync::UpdateTextureLocks(base::ProcessId aProcessId)
|
|
||||||
{
|
|
||||||
if (aProcessId == getpid()) {
|
|
||||||
DispatchCheckTexturesForUnlock();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
MachSendMessage smsg(ipc::kUpdateTextureLocksMsg);
|
|
||||||
smsg.SetData(&aProcessId, sizeof(aProcessId));
|
|
||||||
ipc::SharedMemoryBasic::SendMachMessage(aProcessId, smsg, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
TextureSync::WaitForTextures(base::ProcessId aProcessId, const nsTArray<uint64_t>& textureIds)
|
|
||||||
{
|
|
||||||
if (aProcessId == getpid()) {
|
|
||||||
bool success = WaitForTextureIdsToUnlock(aProcessId, MakeSpan<uint64_t>(textureIds));
|
|
||||||
if (!success) {
|
|
||||||
LOG_ERROR("Failed waiting for textures to unlock.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
MachSendMessage smsg(ipc::kWaitForTexturesMsg);
|
|
||||||
size_t messageSize = sizeof(WaitForTexturesRequest) + textureIds.Length() * sizeof(uint64_t);
|
|
||||||
UniquePtr<uint8_t[]> messageData = MakeUnique<uint8_t[]>(messageSize);
|
|
||||||
WaitForTexturesRequest* req = (WaitForTexturesRequest*)messageData.get();
|
|
||||||
uint64_t* reqTextureIds = (uint64_t*)(req + 1);
|
|
||||||
|
|
||||||
for (uint32_t i = 0; i < textureIds.Length(); ++i) {
|
|
||||||
reqTextureIds[i] = textureIds[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
req->pid = getpid();
|
|
||||||
bool dataWasSet = smsg.SetData(req, messageSize);
|
|
||||||
|
|
||||||
if (!dataWasSet) {
|
|
||||||
LOG_ERROR("Data was too large: %zu\n", messageSize);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
MachReceiveMessage msg;
|
|
||||||
bool success = ipc::SharedMemoryBasic::SendMachMessage(aProcessId, smsg, &msg);
|
|
||||||
if (!success) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (msg.GetDataLength() != sizeof(WaitForTexturesReply)) {
|
|
||||||
LOG_ERROR("Improperly formatted reply\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
WaitForTexturesReply* msg_data = reinterpret_cast<WaitForTexturesReply*>(msg.GetData());
|
|
||||||
if (!msg_data->success) {
|
|
||||||
LOG_ERROR("Failed waiting for textures to unlock.\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
TextureSync::CleanupForPid(base::ProcessId aProcessId)
|
|
||||||
{
|
|
||||||
{
|
|
||||||
StaticMonitorAutoLock lock(gTextureLockMonitor);
|
|
||||||
std::unordered_set<uint64_t>* lockedTextureIds = GetLockedTextureIdsForProcess(aProcessId);
|
|
||||||
lockedTextureIds->clear();
|
|
||||||
}
|
|
||||||
gTextureLockMonitor.NotifyAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace layers
|
|
||||||
|
|
||||||
} // namespace mozilla
|
|
||||||
|
|
@ -1,44 +0,0 @@
|
||||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
||||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
||||||
/* 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/. */
|
|
||||||
|
|
||||||
#ifndef MOZILLA_LAYERS_TEXTURESYNC_H
|
|
||||||
#define MOZILLA_LAYERS_TEXTURESYNC_H
|
|
||||||
|
|
||||||
#include "base/process.h"
|
|
||||||
|
|
||||||
#include "nsTArray.h"
|
|
||||||
#include "mozilla/layers/TextureSourceProvider.h"
|
|
||||||
|
|
||||||
#include "SharedMemory.h"
|
|
||||||
|
|
||||||
class MachReceiveMessage;
|
|
||||||
|
|
||||||
namespace mozilla {
|
|
||||||
namespace ipc {
|
|
||||||
struct MemoryPorts;
|
|
||||||
} // namespace ipc
|
|
||||||
|
|
||||||
namespace layers {
|
|
||||||
|
|
||||||
class TextureSync
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void RegisterTextureSourceProvider(layers::TextureSourceProvider* aTextureSourceProvider);
|
|
||||||
static void UnregisterTextureSourceProvider(layers::TextureSourceProvider* aTextureSourceProvider);
|
|
||||||
static void DispatchCheckTexturesForUnlock();
|
|
||||||
static void HandleWaitForTexturesMessage(MachReceiveMessage* rmsg, ipc::MemoryPorts* ports);
|
|
||||||
static void UpdateTextureLocks(base::ProcessId aProcessId);
|
|
||||||
static bool WaitForTextures(base::ProcessId aProcessId, const nsTArray<uint64_t>& aTextureIds);
|
|
||||||
static void SetTexturesLocked(base::ProcessId aProcessId, const nsTArray<uint64_t>& aTextureIds);
|
|
||||||
static void SetTexturesUnlocked(base::ProcessId aProcessId, const nsTArray<uint64_t>& aTextureIds);
|
|
||||||
static void Shutdown();
|
|
||||||
static void CleanupForPid(base::ProcessId aProcessId);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace layers
|
|
||||||
} // namespace mozilla
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -317,15 +317,6 @@ ClientLayerManager::EndTransactionInternal(DrawPaintedLayerCallback aCallback,
|
||||||
void* aCallbackData,
|
void* aCallbackData,
|
||||||
EndTransactionFlags)
|
EndTransactionFlags)
|
||||||
{
|
{
|
||||||
// This just causes the compositor to check whether the GPU is done with its
|
|
||||||
// textures or not and unlock them if it is. This helps us avoid the case
|
|
||||||
// where we take a long time painting asynchronously, turn IPC back on at
|
|
||||||
// the end of that, and then have to wait for the compositor to to get into
|
|
||||||
// TiledLayerBufferComposite::UseTiles before getting a response.
|
|
||||||
if (mForwarder) {
|
|
||||||
mForwarder->UpdateTextureLocks();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Wait for any previous async paints to complete before starting to paint again.
|
// Wait for any previous async paints to complete before starting to paint again.
|
||||||
// Do this outside the profiler and telemetry block so this doesn't count as time
|
// Do this outside the profiler and telemetry block so this doesn't count as time
|
||||||
// spent rasterizing.
|
// spent rasterizing.
|
||||||
|
|
|
||||||
|
|
@ -762,14 +762,10 @@ ContentClientRemoteBuffer::CreateBufferInternal(const gfx::IntRect& aRect,
|
||||||
|
|
||||||
RefPtr<TextureClient> textureClientOnWhite;
|
RefPtr<TextureClient> textureClientOnWhite;
|
||||||
if (aFlags & TextureFlags::COMPONENT_ALPHA) {
|
if (aFlags & TextureFlags::COMPONENT_ALPHA) {
|
||||||
TextureAllocationFlags allocFlags = ALLOC_CLEAR_BUFFER_WHITE;
|
|
||||||
if (mForwarder->SupportsTextureDirectMapping()) {
|
|
||||||
allocFlags = TextureAllocationFlags(allocFlags | ALLOC_ALLOW_DIRECT_MAPPING);
|
|
||||||
}
|
|
||||||
textureClientOnWhite = textureClient->CreateSimilar(
|
textureClientOnWhite = textureClient->CreateSimilar(
|
||||||
mForwarder->GetCompositorBackendType(),
|
mForwarder->GetCompositorBackendType(),
|
||||||
aFlags | ExtraTextureFlags(),
|
aFlags | ExtraTextureFlags(),
|
||||||
allocFlags
|
TextureAllocationFlags::ALLOC_CLEAR_BUFFER_WHITE
|
||||||
);
|
);
|
||||||
if (!textureClientOnWhite || !AddTextureClient(textureClientOnWhite)) {
|
if (!textureClientOnWhite || !AddTextureClient(textureClientOnWhite)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
||||||
|
|
@ -140,42 +140,6 @@ ClientMultiTiledLayerBuffer::PaintThebes(const nsIntRegion& aNewValidRegion,
|
||||||
mCallbackData = nullptr;
|
mCallbackData = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientMultiTiledLayerBuffer::MaybeSyncTextures(const nsIntRegion& aPaintRegion,
|
|
||||||
const TilesPlacement& aNewTiles,
|
|
||||||
const IntSize& aScaledTileSize)
|
|
||||||
{
|
|
||||||
if (mManager->AsShadowForwarder()->SupportsTextureDirectMapping()) {
|
|
||||||
AutoTArray<uint64_t, 10> syncTextureSerials;
|
|
||||||
SurfaceMode mode;
|
|
||||||
Unused << GetContentType(&mode);
|
|
||||||
|
|
||||||
// Pre-pass through the tiles (mirroring the filter logic below) to gather
|
|
||||||
// texture IDs that we need to ensure are unused by the GPU before we
|
|
||||||
// continue.
|
|
||||||
if (!aPaintRegion.IsEmpty()) {
|
|
||||||
MOZ_ASSERT(mPaintStates.size() == 0);
|
|
||||||
for (size_t i = 0; i < mRetainedTiles.Length(); ++i) {
|
|
||||||
const TileCoordIntPoint tileCoord = aNewTiles.TileCoord(i);
|
|
||||||
|
|
||||||
IntPoint tileOffset = GetTileOffset(tileCoord);
|
|
||||||
nsIntRegion tileDrawRegion = IntRect(tileOffset, aScaledTileSize);
|
|
||||||
tileDrawRegion.AndWith(aPaintRegion);
|
|
||||||
|
|
||||||
if (tileDrawRegion.IsEmpty()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
TileClient& tile = mRetainedTiles[i];
|
|
||||||
tile.GetSyncTextureSerials(mode, syncTextureSerials);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (syncTextureSerials.Length() > 0) {
|
|
||||||
mManager->AsShadowForwarder()->SyncTextures(syncTextureSerials);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ClientMultiTiledLayerBuffer::Update(const nsIntRegion& newValidRegion,
|
void ClientMultiTiledLayerBuffer::Update(const nsIntRegion& newValidRegion,
|
||||||
const nsIntRegion& aPaintRegion,
|
const nsIntRegion& aPaintRegion,
|
||||||
const nsIntRegion& aDirtyRegion,
|
const nsIntRegion& aDirtyRegion,
|
||||||
|
|
@ -217,9 +181,6 @@ void ClientMultiTiledLayerBuffer::Update(const nsIntRegion& newValidRegion,
|
||||||
|
|
||||||
nsIntRegion paintRegion = aPaintRegion;
|
nsIntRegion paintRegion = aPaintRegion;
|
||||||
nsIntRegion dirtyRegion = aDirtyRegion;
|
nsIntRegion dirtyRegion = aDirtyRegion;
|
||||||
|
|
||||||
MaybeSyncTextures(paintRegion, newTiles, scaledTileSize);
|
|
||||||
|
|
||||||
if (!paintRegion.IsEmpty()) {
|
if (!paintRegion.IsEmpty()) {
|
||||||
MOZ_ASSERT(mPaintStates.size() == 0);
|
MOZ_ASSERT(mPaintStates.size() == 0);
|
||||||
for (size_t i = 0; i < newTileCount; ++i) {
|
for (size_t i = 0; i < newTileCount; ++i) {
|
||||||
|
|
|
||||||
|
|
@ -156,10 +156,6 @@ private:
|
||||||
nsIntRegion& aRegionToPaint,
|
nsIntRegion& aRegionToPaint,
|
||||||
BasicTiledLayerPaintData* aPaintData,
|
BasicTiledLayerPaintData* aPaintData,
|
||||||
bool aIsRepeated);
|
bool aIsRepeated);
|
||||||
|
|
||||||
void MaybeSyncTextures(const nsIntRegion& aPaintRegion,
|
|
||||||
const TilesPlacement& aNewTiles,
|
|
||||||
const gfx::IntSize& aScaledTileSize);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -140,15 +140,6 @@ ClientSingleTiledLayerBuffer::PaintThebes(const nsIntRegion& aNewValidRegion,
|
||||||
mTile.SetTextureAllocator(this);
|
mTile.SetTextureAllocator(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (mManager->AsShadowForwarder()->SupportsTextureDirectMapping()) {
|
|
||||||
AutoTArray<uint64_t, 2> syncTextureSerials;
|
|
||||||
mTile.GetSyncTextureSerials(mode, syncTextureSerials);
|
|
||||||
if (syncTextureSerials.Length() > 0) {
|
|
||||||
mManager->AsShadowForwarder()->SyncTextures(syncTextureSerials);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// The dirty region relative to the top-left of the tile.
|
// The dirty region relative to the top-left of the tile.
|
||||||
nsIntRegion tileVisibleRegion = aNewValidRegion.MovedBy(-mTilingOrigin);
|
nsIntRegion tileVisibleRegion = aNewValidRegion.MovedBy(-mTilingOrigin);
|
||||||
nsIntRegion tileDirtyRegion = paintRegion.MovedBy(-mTilingOrigin);
|
nsIntRegion tileDirtyRegion = paintRegion.MovedBy(-mTilingOrigin);
|
||||||
|
|
|
||||||
|
|
@ -660,9 +660,7 @@ TextureClient::UpdateFromSurface(gfx::SourceSurface* aSurface)
|
||||||
|
|
||||||
|
|
||||||
already_AddRefed<TextureClient>
|
already_AddRefed<TextureClient>
|
||||||
TextureClient::CreateSimilar(LayersBackend aLayersBackend,
|
TextureClient::CreateSimilar(LayersBackend aLayersBackend, TextureFlags aFlags, TextureAllocationFlags aAllocFlags) const
|
||||||
TextureFlags aFlags,
|
|
||||||
TextureAllocationFlags aAllocFlags) const
|
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(IsValid());
|
MOZ_ASSERT(IsValid());
|
||||||
|
|
||||||
|
|
@ -672,10 +670,7 @@ TextureClient::CreateSimilar(LayersBackend aLayersBackend,
|
||||||
}
|
}
|
||||||
|
|
||||||
LockActor();
|
LockActor();
|
||||||
TextureData* data = mData->CreateSimilar(mAllocator,
|
TextureData* data = mData->CreateSimilar(mAllocator, aLayersBackend, aFlags, aAllocFlags);
|
||||||
aLayersBackend,
|
|
||||||
aFlags,
|
|
||||||
aAllocFlags);
|
|
||||||
UnlockActor();
|
UnlockActor();
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
|
|
@ -1065,9 +1060,6 @@ TextureClient::CreateForDrawing(KnowsCompositor* aAllocator,
|
||||||
TextureAllocationFlags aAllocFlags)
|
TextureAllocationFlags aAllocFlags)
|
||||||
{
|
{
|
||||||
LayersBackend layersBackend = aAllocator->GetCompositorBackendType();
|
LayersBackend layersBackend = aAllocator->GetCompositorBackendType();
|
||||||
if (aAllocator->SupportsTextureDirectMapping()) {
|
|
||||||
aAllocFlags = TextureAllocationFlags(aAllocFlags | ALLOC_ALLOW_DIRECT_MAPPING);
|
|
||||||
}
|
|
||||||
return TextureClient::CreateForDrawing(aAllocator->GetTextureForwarder(),
|
return TextureClient::CreateForDrawing(aAllocator->GetTextureForwarder(),
|
||||||
aFormat, aSize,
|
aFormat, aSize,
|
||||||
layersBackend,
|
layersBackend,
|
||||||
|
|
@ -1234,16 +1226,6 @@ TextureClient::CreateForRawBufferAccess(KnowsCompositor* aAllocator,
|
||||||
TextureFlags aTextureFlags,
|
TextureFlags aTextureFlags,
|
||||||
TextureAllocationFlags aAllocFlags)
|
TextureAllocationFlags aAllocFlags)
|
||||||
{
|
{
|
||||||
// If we exceed the max texture size for the GPU, then just fall back to no
|
|
||||||
// texture direct mapping. If it becomes a problem we can implement tiling
|
|
||||||
// logic inside DirectMapTextureSource to allow this.
|
|
||||||
bool supportsTextureDirectMapping = aAllocator->SupportsTextureDirectMapping() &&
|
|
||||||
std::max(aSize.width, aSize.height) <= aAllocator->GetMaxTextureSize();
|
|
||||||
if (supportsTextureDirectMapping) {
|
|
||||||
aAllocFlags = TextureAllocationFlags(aAllocFlags | ALLOC_ALLOW_DIRECT_MAPPING);
|
|
||||||
} else {
|
|
||||||
aAllocFlags = TextureAllocationFlags(aAllocFlags & ~ALLOC_ALLOW_DIRECT_MAPPING);
|
|
||||||
}
|
|
||||||
return CreateForRawBufferAccess(aAllocator->GetTextureForwarder(),
|
return CreateForRawBufferAccess(aAllocator->GetTextureForwarder(),
|
||||||
aFormat, aSize, aMoz2DBackend,
|
aFormat, aSize, aMoz2DBackend,
|
||||||
aAllocator->GetCompositorBackendType(),
|
aAllocator->GetCompositorBackendType(),
|
||||||
|
|
|
||||||
|
|
@ -94,10 +94,6 @@ enum TextureAllocationFlags {
|
||||||
// The texture is going to be updated using UpdateFromSurface and needs to support
|
// The texture is going to be updated using UpdateFromSurface and needs to support
|
||||||
// that call.
|
// that call.
|
||||||
ALLOC_UPDATE_FROM_SURFACE = 1 << 7,
|
ALLOC_UPDATE_FROM_SURFACE = 1 << 7,
|
||||||
|
|
||||||
// In practice, this means we support the APPLE_client_storage extension, meaning
|
|
||||||
// the buffer will not be internally copied by the graphics driver.
|
|
||||||
ALLOC_ALLOW_DIRECT_MAPPING = 1 << 8,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,6 @@ ClearCallback(nsITimer *aTimer, void *aClosure)
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureClientPool::TextureClientPool(LayersBackend aLayersBackend,
|
TextureClientPool::TextureClientPool(LayersBackend aLayersBackend,
|
||||||
bool aSupportsTextureDirectMapping,
|
|
||||||
int32_t aMaxTextureSize,
|
int32_t aMaxTextureSize,
|
||||||
gfx::SurfaceFormat aFormat,
|
gfx::SurfaceFormat aFormat,
|
||||||
gfx::IntSize aSize,
|
gfx::IntSize aSize,
|
||||||
|
|
@ -61,7 +60,6 @@ TextureClientPool::TextureClientPool(LayersBackend aLayersBackend,
|
||||||
, mOutstandingClients(0)
|
, mOutstandingClients(0)
|
||||||
, mSurfaceAllocator(aAllocator)
|
, mSurfaceAllocator(aAllocator)
|
||||||
, mDestroyed(false)
|
, mDestroyed(false)
|
||||||
, mSupportsTextureDirectMapping(aSupportsTextureDirectMapping)
|
|
||||||
{
|
{
|
||||||
TCP_LOG("TexturePool %p created with maximum unused texture clients %u\n",
|
TCP_LOG("TexturePool %p created with maximum unused texture clients %u\n",
|
||||||
this, mInitialPoolSize);
|
this, mInitialPoolSize);
|
||||||
|
|
@ -151,12 +149,6 @@ TextureClientPool::AllocateTextureClient()
|
||||||
TCP_LOG("TexturePool %p allocating TextureClient, outstanding %u\n",
|
TCP_LOG("TexturePool %p allocating TextureClient, outstanding %u\n",
|
||||||
this, mOutstandingClients);
|
this, mOutstandingClients);
|
||||||
|
|
||||||
TextureAllocationFlags allocFlags = ALLOC_DEFAULT;
|
|
||||||
|
|
||||||
if (mSupportsTextureDirectMapping) {
|
|
||||||
allocFlags = TextureAllocationFlags(allocFlags | ALLOC_ALLOW_DIRECT_MAPPING);
|
|
||||||
}
|
|
||||||
|
|
||||||
RefPtr<TextureClient> newClient;
|
RefPtr<TextureClient> newClient;
|
||||||
if (gfxPrefs::ForceShmemTiles()) {
|
if (gfxPrefs::ForceShmemTiles()) {
|
||||||
// gfx::BackendType::NONE means use the content backend
|
// gfx::BackendType::NONE means use the content backend
|
||||||
|
|
@ -165,7 +157,7 @@ TextureClientPool::AllocateTextureClient()
|
||||||
mFormat, mSize,
|
mFormat, mSize,
|
||||||
gfx::BackendType::NONE,
|
gfx::BackendType::NONE,
|
||||||
mBackend,
|
mBackend,
|
||||||
mFlags, allocFlags);
|
mFlags, ALLOC_DEFAULT);
|
||||||
} else {
|
} else {
|
||||||
newClient =
|
newClient =
|
||||||
TextureClient::CreateForDrawing(mSurfaceAllocator,
|
TextureClient::CreateForDrawing(mSurfaceAllocator,
|
||||||
|
|
@ -173,7 +165,7 @@ TextureClientPool::AllocateTextureClient()
|
||||||
mBackend,
|
mBackend,
|
||||||
mMaxTextureSize,
|
mMaxTextureSize,
|
||||||
BackendSelector::Content,
|
BackendSelector::Content,
|
||||||
mFlags, allocFlags);
|
mFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newClient) {
|
if (newClient) {
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,6 @@ class TextureClientPool final : public TextureClientAllocator
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TextureClientPool(LayersBackend aBackend,
|
TextureClientPool(LayersBackend aBackend,
|
||||||
bool aSupportsTextureDirectMapping,
|
|
||||||
int32_t aMaxTextureSize,
|
int32_t aMaxTextureSize,
|
||||||
gfx::SurfaceFormat aFormat,
|
gfx::SurfaceFormat aFormat,
|
||||||
gfx::IntSize aSize,
|
gfx::IntSize aSize,
|
||||||
|
|
@ -171,8 +170,6 @@ private:
|
||||||
// we won't accept returns of TextureClients anymore, and the refcounting
|
// we won't accept returns of TextureClients anymore, and the refcounting
|
||||||
// should take care of their destruction.
|
// should take care of their destruction.
|
||||||
bool mDestroyed;
|
bool mDestroyed;
|
||||||
|
|
||||||
bool mSupportsTextureDirectMapping;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace layers
|
} // namespace layers
|
||||||
|
|
|
||||||
|
|
@ -664,32 +664,6 @@ CreateBackBufferTexture(TextureClient* aCurrentTexture,
|
||||||
return texture.forget();
|
return texture.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
TileClient::GetSyncTextureSerials(SurfaceMode aMode, nsTArray<uint64_t>& aSerials)
|
|
||||||
{
|
|
||||||
if (mFrontBuffer &&
|
|
||||||
mFrontBuffer->HasIntermediateBuffer() &&
|
|
||||||
!mFrontBuffer->IsReadLocked() &&
|
|
||||||
(aMode != SurfaceMode::SURFACE_COMPONENT_ALPHA || (
|
|
||||||
mFrontBufferOnWhite && !mFrontBufferOnWhite->IsReadLocked())))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mBackBuffer &&
|
|
||||||
!mBackBuffer->HasIntermediateBuffer() &&
|
|
||||||
mBackBuffer->IsReadLocked()) {
|
|
||||||
aSerials.AppendElement(mBackBuffer->GetSerial());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (aMode == SurfaceMode::SURFACE_COMPONENT_ALPHA &&
|
|
||||||
mBackBufferOnWhite &&
|
|
||||||
!mBackBufferOnWhite->HasIntermediateBuffer() &&
|
|
||||||
mBackBufferOnWhite->IsReadLocked()) {
|
|
||||||
aSerials.AppendElement(mBackBufferOnWhite->GetSerial());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TextureClient*
|
TextureClient*
|
||||||
TileClient::GetBackBuffer(CompositableClient& aCompositable,
|
TileClient::GetBackBuffer(CompositableClient& aCompositable,
|
||||||
const nsIntRegion& aDirtyRegion,
|
const nsIntRegion& aDirtyRegion,
|
||||||
|
|
@ -748,18 +722,17 @@ TileClient::GetBackBuffer(CompositableClient& aCompositable,
|
||||||
mInvalidBack = IntRect(IntPoint(), mBackBuffer->GetSize());
|
mInvalidBack = IntRect(IntPoint(), mBackBuffer->GetSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aMode == SurfaceMode::SURFACE_COMPONENT_ALPHA) {
|
if (aMode == SurfaceMode::SURFACE_COMPONENT_ALPHA
|
||||||
if (!mBackBufferOnWhite || mBackBufferOnWhite->IsReadLocked()) {
|
&& (!mBackBufferOnWhite || mBackBufferOnWhite->IsReadLocked())) {
|
||||||
mBackBufferOnWhite = CreateBackBufferTexture(
|
mBackBufferOnWhite = CreateBackBufferTexture(
|
||||||
mBackBufferOnWhite, aCompositable, mAllocator
|
mBackBufferOnWhite, aCompositable, mAllocator
|
||||||
);
|
);
|
||||||
if (!mBackBufferOnWhite) {
|
if (!mBackBufferOnWhite) {
|
||||||
DiscardBackBuffer();
|
DiscardBackBuffer();
|
||||||
DiscardFrontBuffer();
|
DiscardFrontBuffer();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
|
||||||
mInvalidBack = IntRect(IntPoint(), mBackBufferOnWhite->GetSize());
|
|
||||||
}
|
}
|
||||||
|
mInvalidBack = IntRect(IntPoint(), mBackBufferOnWhite->GetSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
ValidateBackBufferFromFront(aDirtyRegion, aVisibleRegion, aAddPaintedRegion, aFlags, aCopies, aClients);
|
ValidateBackBufferFromFront(aDirtyRegion, aVisibleRegion, aAddPaintedRegion, aFlags, aCopies, aClients);
|
||||||
|
|
|
||||||
|
|
@ -114,8 +114,6 @@ struct TileClient
|
||||||
CompositableClient::DumpTextureClient(aStream, mFrontBuffer, aCompress);
|
CompositableClient::DumpTextureClient(aStream, mFrontBuffer, aCompress);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetSyncTextureSerials(SurfaceMode aMode, nsTArray<uint64_t>& aSerials);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an unlocked TextureClient that can be used for writing new
|
* Returns an unlocked TextureClient that can be used for writing new
|
||||||
* data to the tile. This may flip the front-buffer to the back-buffer if
|
* data to the tile. This may flip the front-buffer to the back-buffer if
|
||||||
|
|
@ -327,9 +325,6 @@ public:
|
||||||
LayerManager::DrawPaintedLayerCallback aCallback,
|
LayerManager::DrawPaintedLayerCallback aCallback,
|
||||||
void* aCallbackData,
|
void* aCallbackData,
|
||||||
TilePaintFlags aFlags) = 0;
|
TilePaintFlags aFlags) = 0;
|
||||||
virtual void GetSyncTextureSerials(const nsIntRegion& aPaintRegion,
|
|
||||||
const nsIntRegion& aDirtyRegion,
|
|
||||||
nsTArray<uint64_t>& aSerials) { return; }
|
|
||||||
|
|
||||||
virtual bool SupportsProgressiveUpdate() = 0;
|
virtual bool SupportsProgressiveUpdate() = 0;
|
||||||
virtual bool ProgressiveUpdate(const nsIntRegion& aValidRegion,
|
virtual bool ProgressiveUpdate(const nsIntRegion& aValidRegion,
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,6 @@
|
||||||
#include "mozilla/layers/TextureHostOGL.h" // for TextureHostOGL
|
#include "mozilla/layers/TextureHostOGL.h" // for TextureHostOGL
|
||||||
#include "mozilla/layers/ImageDataSerializer.h"
|
#include "mozilla/layers/ImageDataSerializer.h"
|
||||||
#include "mozilla/layers/TextureClient.h"
|
#include "mozilla/layers/TextureClient.h"
|
||||||
#ifdef XP_DARWIN
|
|
||||||
#include "mozilla/layers/TextureSync.h"
|
|
||||||
#endif
|
|
||||||
#include "mozilla/layers/GPUVideoTextureHost.h"
|
#include "mozilla/layers/GPUVideoTextureHost.h"
|
||||||
#include "mozilla/layers/WebRenderTextureHost.h"
|
#include "mozilla/layers/WebRenderTextureHost.h"
|
||||||
#include "mozilla/webrender/RenderBufferTextureHost.h"
|
#include "mozilla/webrender/RenderBufferTextureHost.h"
|
||||||
|
|
@ -373,14 +370,11 @@ TextureHost::TextureHost(TextureFlags aFlags)
|
||||||
|
|
||||||
TextureHost::~TextureHost()
|
TextureHost::~TextureHost()
|
||||||
{
|
{
|
||||||
if (mReadLocked) {
|
// If we still have a ReadLock, unlock it. At this point we don't care about
|
||||||
// If we still have a ReadLock, unlock it. At this point we don't care about
|
// the texture client being written into on the other side since it should be
|
||||||
// the texture client being written into on the other side since it should be
|
// destroyed by now. But we will hit assertions if we don't ReadUnlock before
|
||||||
// destroyed by now. But we will hit assertions if we don't ReadUnlock before
|
// destroying the lock itself.
|
||||||
// destroying the lock itself.
|
ReadUnlock();
|
||||||
ReadUnlock();
|
|
||||||
MaybeNotifyUnlocked();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureHost::Finalize()
|
void TextureHost::Finalize()
|
||||||
|
|
@ -406,7 +400,6 @@ TextureHost::UnbindTextureSource()
|
||||||
// GetCompositor returned null which means no compositor can be using this
|
// GetCompositor returned null which means no compositor can be using this
|
||||||
// texture. We can ReadUnlock right away.
|
// texture. We can ReadUnlock right away.
|
||||||
ReadUnlock();
|
ReadUnlock();
|
||||||
MaybeNotifyUnlocked();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -708,9 +701,6 @@ TextureHost::SetReadLocked()
|
||||||
// side should not have been able to write into this texture and read lock again!
|
// side should not have been able to write into this texture and read lock again!
|
||||||
MOZ_ASSERT(!mReadLocked);
|
MOZ_ASSERT(!mReadLocked);
|
||||||
mReadLocked = true;
|
mReadLocked = true;
|
||||||
if (mProvider) {
|
|
||||||
mProvider->MaybeUnlockBeforeNextComposition(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -896,36 +886,12 @@ BufferTextureHost::AcquireTextureSource(CompositableTextureSourceRef& aTexture)
|
||||||
return !!mFirstSource;
|
return !!mFirstSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
BufferTextureHost::ReadUnlock()
|
|
||||||
{
|
|
||||||
if (mFirstSource) {
|
|
||||||
mFirstSource->Sync(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
TextureHost::ReadUnlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
BufferTextureHost::MaybeNotifyUnlocked()
|
|
||||||
{
|
|
||||||
#ifdef XP_DARWIN
|
|
||||||
auto actor = GetIPDLActor();
|
|
||||||
if (actor) {
|
|
||||||
AutoTArray<uint64_t, 1> serials;
|
|
||||||
serials.AppendElement(TextureHost::GetTextureSerial(actor));
|
|
||||||
TextureSync::SetTexturesUnlocked(actor->OtherPid(), serials);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BufferTextureHost::UnbindTextureSource()
|
BufferTextureHost::UnbindTextureSource()
|
||||||
{
|
{
|
||||||
if (mFirstSource && mFirstSource->IsOwnedBy(this)) {
|
if (mFirstSource && mFirstSource->IsOwnedBy(this)) {
|
||||||
mFirstSource->Unbind();
|
mFirstSource->Unbind();
|
||||||
}
|
}
|
||||||
|
|
||||||
// This texture is not used by any layer anymore.
|
// This texture is not used by any layer anymore.
|
||||||
// If the texture doesn't have an intermediate buffer, it means we are
|
// If the texture doesn't have an intermediate buffer, it means we are
|
||||||
// compositing synchronously on the CPU, so we don't need to wait until
|
// compositing synchronously on the CPU, so we don't need to wait until
|
||||||
|
|
@ -934,7 +900,6 @@ BufferTextureHost::UnbindTextureSource()
|
||||||
// If the texture has an intermediate buffer we don't care either because
|
// If the texture has an intermediate buffer we don't care either because
|
||||||
// texture uploads are also performed synchronously for BufferTextureHost.
|
// texture uploads are also performed synchronously for BufferTextureHost.
|
||||||
ReadUnlock();
|
ReadUnlock();
|
||||||
MaybeNotifyUnlocked();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::SurfaceFormat
|
gfx::SurfaceFormat
|
||||||
|
|
@ -1001,7 +966,6 @@ BufferTextureHost::MaybeUpload(nsIntRegion *aRegion)
|
||||||
// We just did the texture upload, the content side can now freely write
|
// We just did the texture upload, the content side can now freely write
|
||||||
// into the shared buffer.
|
// into the shared buffer.
|
||||||
ReadUnlock();
|
ReadUnlock();
|
||||||
MaybeNotifyUnlocked();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// We no longer have an invalid region.
|
// We no longer have an invalid region.
|
||||||
|
|
@ -1031,9 +995,7 @@ BufferTextureHost::Upload(nsIntRegion *aRegion)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!mHasIntermediateBuffer && EnsureWrappingTextureSource()) {
|
if (!mHasIntermediateBuffer && EnsureWrappingTextureSource()) {
|
||||||
if (!mFirstSource || !mFirstSource->IsDirectMap()) {
|
return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mFormat == gfx::SurfaceFormat::UNKNOWN) {
|
if (mFormat == gfx::SurfaceFormat::UNKNOWN) {
|
||||||
|
|
@ -1315,12 +1277,9 @@ TextureParent::Destroy()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mTextureHost->mReadLocked) {
|
// ReadUnlock here to make sure the ReadLock's shmem does not outlive the
|
||||||
// ReadUnlock here to make sure the ReadLock's shmem does not outlive the
|
// protocol that created it.
|
||||||
// protocol that created it.
|
mTextureHost->ReadUnlock();
|
||||||
mTextureHost->ReadUnlock();
|
|
||||||
mTextureHost->MaybeNotifyUnlocked();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mTextureHost->GetFlags() & TextureFlags::DEALLOCATE_CLIENT) {
|
if (mTextureHost->GetFlags() & TextureFlags::DEALLOCATE_CLIENT) {
|
||||||
mTextureHost->ForgetSharedData();
|
mTextureHost->ForgetSharedData();
|
||||||
|
|
|
||||||
|
|
@ -183,16 +183,6 @@ public:
|
||||||
|
|
||||||
int NumCompositableRefs() const { return mCompositableCount; }
|
int NumCompositableRefs() const { return mCompositableCount; }
|
||||||
|
|
||||||
// Some texture sources could wrap the cpu buffer to gpu directly. Then,
|
|
||||||
// we could get better performance of texture uploading.
|
|
||||||
virtual bool IsDirectMap() { return false; }
|
|
||||||
// The direct-map cpu buffer should be alive when gpu uses it. And it
|
|
||||||
// should not be updated while gpu reads it. This Sync() function
|
|
||||||
// implements this synchronized behavior by allowing us to check if
|
|
||||||
// the GPU is done with the texture, and block on it if aBlocking is
|
|
||||||
// true.
|
|
||||||
virtual bool Sync(bool aBlocking) { return true; }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
RefPtr<TextureSource> mNextSibling;
|
RefPtr<TextureSource> mNextSibling;
|
||||||
|
|
@ -672,15 +662,11 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual MacIOSurface* GetMacIOSurface() { return nullptr; }
|
virtual MacIOSurface* GetMacIOSurface() { return nullptr; }
|
||||||
|
|
||||||
virtual bool IsDirectMap() { return false; }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void ReadUnlock();
|
void ReadUnlock();
|
||||||
|
|
||||||
void RecycleTexture(TextureFlags aFlags);
|
void RecycleTexture(TextureFlags aFlags);
|
||||||
|
|
||||||
virtual void MaybeNotifyUnlocked() {}
|
|
||||||
|
|
||||||
virtual void UpdatedInternal(const nsIntRegion *Region) {}
|
virtual void UpdatedInternal(const nsIntRegion *Region) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -782,11 +768,6 @@ public:
|
||||||
wr::ImageRendering aFilter,
|
wr::ImageRendering aFilter,
|
||||||
const Range<wr::ImageKey>& aImageKeys) override;
|
const Range<wr::ImageKey>& aImageKeys) override;
|
||||||
|
|
||||||
virtual void ReadUnlock() override;
|
|
||||||
virtual bool IsDirectMap() override { return mFirstSource && mFirstSource->IsDirectMap(); };
|
|
||||||
|
|
||||||
bool CanUnlock() { return !mFirstSource || mFirstSource->Sync(false); }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool Upload(nsIntRegion *aRegion = nullptr);
|
bool Upload(nsIntRegion *aRegion = nullptr);
|
||||||
bool UploadIfNeeded();
|
bool UploadIfNeeded();
|
||||||
|
|
@ -794,8 +775,6 @@ protected:
|
||||||
bool EnsureWrappingTextureSource();
|
bool EnsureWrappingTextureSource();
|
||||||
|
|
||||||
virtual void UpdatedInternal(const nsIntRegion* aRegion = nullptr) override;
|
virtual void UpdatedInternal(const nsIntRegion* aRegion = nullptr) override;
|
||||||
virtual void MaybeNotifyUnlocked() override;
|
|
||||||
|
|
||||||
|
|
||||||
BufferDescriptor mDescriptor;
|
BufferDescriptor mDescriptor;
|
||||||
RefPtr<Compositor> mCompositor;
|
RefPtr<Compositor> mCompositor;
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,6 @@
|
||||||
#include "mozilla/layers/Effects.h" // for TexturedEffect, Effect, etc
|
#include "mozilla/layers/Effects.h" // for TexturedEffect, Effect, etc
|
||||||
#include "mozilla/layers/LayerMetricsWrapper.h" // for LayerMetricsWrapper
|
#include "mozilla/layers/LayerMetricsWrapper.h" // for LayerMetricsWrapper
|
||||||
#include "mozilla/layers/TextureHostOGL.h" // for TextureHostOGL
|
#include "mozilla/layers/TextureHostOGL.h" // for TextureHostOGL
|
||||||
#ifdef XP_DARWIN
|
|
||||||
#include "mozilla/layers/TextureSync.h" // for TextureSync
|
|
||||||
#endif
|
|
||||||
#include "nsAString.h"
|
#include "nsAString.h"
|
||||||
#include "nsDebug.h" // for NS_WARNING
|
#include "nsDebug.h" // for NS_WARNING
|
||||||
#include "nsPoint.h" // for IntPoint
|
#include "nsPoint.h" // for IntPoint
|
||||||
|
|
@ -301,9 +298,6 @@ TiledLayerBufferComposite::UseTiles(const SurfaceDescriptorTiles& aTiles,
|
||||||
TextureSourceRecycler oldRetainedTiles(std::move(mRetainedTiles));
|
TextureSourceRecycler oldRetainedTiles(std::move(mRetainedTiles));
|
||||||
mRetainedTiles.SetLength(tileDescriptors.Length());
|
mRetainedTiles.SetLength(tileDescriptors.Length());
|
||||||
|
|
||||||
AutoTArray<uint64_t, 10> lockedTextureSerials;
|
|
||||||
base::ProcessId lockedTexturePid = 0;
|
|
||||||
|
|
||||||
// Step 1, deserialize the incoming set of tiles into mRetainedTiles, and attempt
|
// Step 1, deserialize the incoming set of tiles into mRetainedTiles, and attempt
|
||||||
// to recycle the TextureSource for any repeated tiles.
|
// to recycle the TextureSource for any repeated tiles.
|
||||||
//
|
//
|
||||||
|
|
@ -328,15 +322,6 @@ TiledLayerBufferComposite::UseTiles(const SurfaceDescriptorTiles& aTiles,
|
||||||
tile.mTextureHost = TextureHost::AsTextureHost(texturedDesc.textureParent());
|
tile.mTextureHost = TextureHost::AsTextureHost(texturedDesc.textureParent());
|
||||||
if (texturedDesc.readLocked()) {
|
if (texturedDesc.readLocked()) {
|
||||||
tile.mTextureHost->SetReadLocked();
|
tile.mTextureHost->SetReadLocked();
|
||||||
auto actor = tile.mTextureHost->GetIPDLActor();
|
|
||||||
if (actor && tile.mTextureHost->IsDirectMap()) {
|
|
||||||
lockedTextureSerials.AppendElement(TextureHost::GetTextureSerial(actor));
|
|
||||||
|
|
||||||
if (lockedTexturePid) {
|
|
||||||
MOZ_ASSERT(lockedTexturePid == actor->OtherPid());
|
|
||||||
}
|
|
||||||
lockedTexturePid = actor->OtherPid();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (texturedDesc.textureOnWhite().type() == MaybeTexture::TPTextureParent) {
|
if (texturedDesc.textureOnWhite().type() == MaybeTexture::TPTextureParent) {
|
||||||
|
|
@ -345,10 +330,6 @@ TiledLayerBufferComposite::UseTiles(const SurfaceDescriptorTiles& aTiles,
|
||||||
);
|
);
|
||||||
if (texturedDesc.readLockedOnWhite()) {
|
if (texturedDesc.readLockedOnWhite()) {
|
||||||
tile.mTextureHostOnWhite->SetReadLocked();
|
tile.mTextureHostOnWhite->SetReadLocked();
|
||||||
auto actor = tile.mTextureHostOnWhite->GetIPDLActor();
|
|
||||||
if (actor && tile.mTextureHostOnWhite->IsDirectMap()) {
|
|
||||||
lockedTextureSerials.AppendElement(TextureHost::GetTextureSerial(actor));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -373,12 +354,6 @@ TiledLayerBufferComposite::UseTiles(const SurfaceDescriptorTiles& aTiles,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef XP_DARWIN
|
|
||||||
if (lockedTextureSerials.Length() > 0) {
|
|
||||||
TextureSync::SetTexturesLocked(lockedTexturePid, lockedTextureSerials);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Step 2, attempt to recycle unused texture sources from the old tile set into new tiles.
|
// Step 2, attempt to recycle unused texture sources from the old tile set into new tiles.
|
||||||
//
|
//
|
||||||
// For gralloc, binding a new TextureHost to the existing TextureSource is the fastest way
|
// For gralloc, binding a new TextureHost to the existing TextureSource is the fastest way
|
||||||
|
|
|
||||||
|
|
@ -936,7 +936,6 @@ CompositorBridgeChild::GetTexturePool(KnowsCompositor* aAllocator,
|
||||||
|
|
||||||
mTexturePools.AppendElement(
|
mTexturePools.AppendElement(
|
||||||
new TextureClientPool(aAllocator->GetCompositorBackendType(),
|
new TextureClientPool(aAllocator->GetCompositorBackendType(),
|
||||||
aAllocator->SupportsTextureDirectMapping(),
|
|
||||||
aAllocator->GetMaxTextureSize(),
|
aAllocator->GetMaxTextureSize(),
|
||||||
aFormat,
|
aFormat,
|
||||||
gfx::gfxVars::TileSize(),
|
gfx::gfxVars::TileSize(),
|
||||||
|
|
|
||||||
|
|
@ -102,11 +102,6 @@ public:
|
||||||
return mTextureFactoryIdentifier.mSupportsComponentAlpha;
|
return mTextureFactoryIdentifier.mSupportsComponentAlpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SupportsTextureDirectMapping() const
|
|
||||||
{
|
|
||||||
return mTextureFactoryIdentifier.mSupportsTextureDirectMapping;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SupportsD3D11() const
|
bool SupportsD3D11() const
|
||||||
{
|
{
|
||||||
return GetCompositorBackendType() == layers::LayersBackend::LAYERS_D3D11 ||
|
return GetCompositorBackendType() == layers::LayersBackend::LAYERS_D3D11 ||
|
||||||
|
|
|
||||||
|
|
@ -335,7 +335,6 @@ struct ParamTraits<mozilla::layers::TextureFactoryIdentifier>
|
||||||
WriteParam(aMsg, aParam.mParentBackend);
|
WriteParam(aMsg, aParam.mParentBackend);
|
||||||
WriteParam(aMsg, aParam.mParentProcessType);
|
WriteParam(aMsg, aParam.mParentProcessType);
|
||||||
WriteParam(aMsg, aParam.mMaxTextureSize);
|
WriteParam(aMsg, aParam.mMaxTextureSize);
|
||||||
WriteParam(aMsg, aParam.mSupportsTextureDirectMapping);
|
|
||||||
WriteParam(aMsg, aParam.mCompositorUseANGLE);
|
WriteParam(aMsg, aParam.mCompositorUseANGLE);
|
||||||
WriteParam(aMsg, aParam.mSupportsTextureBlitting);
|
WriteParam(aMsg, aParam.mSupportsTextureBlitting);
|
||||||
WriteParam(aMsg, aParam.mSupportsPartialUploads);
|
WriteParam(aMsg, aParam.mSupportsPartialUploads);
|
||||||
|
|
@ -349,7 +348,6 @@ struct ParamTraits<mozilla::layers::TextureFactoryIdentifier>
|
||||||
bool result = ReadParam(aMsg, aIter, &aResult->mParentBackend) &&
|
bool result = ReadParam(aMsg, aIter, &aResult->mParentBackend) &&
|
||||||
ReadParam(aMsg, aIter, &aResult->mParentProcessType) &&
|
ReadParam(aMsg, aIter, &aResult->mParentProcessType) &&
|
||||||
ReadParam(aMsg, aIter, &aResult->mMaxTextureSize) &&
|
ReadParam(aMsg, aIter, &aResult->mMaxTextureSize) &&
|
||||||
ReadParam(aMsg, aIter, &aResult->mSupportsTextureDirectMapping) &&
|
|
||||||
ReadParam(aMsg, aIter, &aResult->mCompositorUseANGLE) &&
|
ReadParam(aMsg, aIter, &aResult->mCompositorUseANGLE) &&
|
||||||
ReadParam(aMsg, aIter, &aResult->mSupportsTextureBlitting) &&
|
ReadParam(aMsg, aIter, &aResult->mSupportsTextureBlitting) &&
|
||||||
ReadParam(aMsg, aIter, &aResult->mSupportsPartialUploads) &&
|
ReadParam(aMsg, aIter, &aResult->mSupportsPartialUploads) &&
|
||||||
|
|
|
||||||
|
|
@ -32,9 +32,6 @@
|
||||||
#include "mozilla/layers/LayerTransactionChild.h"
|
#include "mozilla/layers/LayerTransactionChild.h"
|
||||||
#include "mozilla/layers/PTextureChild.h"
|
#include "mozilla/layers/PTextureChild.h"
|
||||||
#include "mozilla/layers/SyncObject.h"
|
#include "mozilla/layers/SyncObject.h"
|
||||||
#ifdef XP_DARWIN
|
|
||||||
#include "mozilla/layers/TextureSync.h"
|
|
||||||
#endif
|
|
||||||
#include "ShadowLayerUtils.h"
|
#include "ShadowLayerUtils.h"
|
||||||
#include "mozilla/layers/TextureClient.h" // for TextureClient
|
#include "mozilla/layers/TextureClient.h" // for TextureClient
|
||||||
#include "mozilla/mozalloc.h" // for operator new, etc
|
#include "mozilla/mozalloc.h" // for operator new, etc
|
||||||
|
|
@ -808,38 +805,6 @@ ShadowLayerForwarder::SetLayerObserverEpoch(uint64_t aLayerObserverEpoch)
|
||||||
Unused << mShadowManager->SendSetLayerObserverEpoch(aLayerObserverEpoch);
|
Unused << mShadowManager->SendSetLayerObserverEpoch(aLayerObserverEpoch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
ShadowLayerForwarder::UpdateTextureLocks()
|
|
||||||
{
|
|
||||||
#ifdef XP_DARWIN
|
|
||||||
if (!IPCOpen()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto compositorBridge = GetCompositorBridgeChild();
|
|
||||||
if (compositorBridge) {
|
|
||||||
auto pid = compositorBridge->OtherPid();
|
|
||||||
TextureSync::UpdateTextureLocks(pid);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
ShadowLayerForwarder::SyncTextures(const nsTArray<uint64_t>& aSerials)
|
|
||||||
{
|
|
||||||
#ifdef XP_DARWIN
|
|
||||||
if (!IPCOpen()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto compositorBridge = GetCompositorBridgeChild();
|
|
||||||
if (compositorBridge) {
|
|
||||||
auto pid = compositorBridge->OtherPid();
|
|
||||||
TextureSync::WaitForTextures(pid, aSerials);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShadowLayerForwarder::ReleaseLayer(const LayerHandle& aHandle)
|
ShadowLayerForwarder::ReleaseLayer(const LayerHandle& aHandle)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -361,9 +361,6 @@ public:
|
||||||
virtual void UpdateFwdTransactionId() override;
|
virtual void UpdateFwdTransactionId() override;
|
||||||
virtual uint64_t GetFwdTransactionId() override;
|
virtual uint64_t GetFwdTransactionId() override;
|
||||||
|
|
||||||
void UpdateTextureLocks();
|
|
||||||
void SyncTextures(const nsTArray<uint64_t>& aSerials);
|
|
||||||
|
|
||||||
void ReleaseLayer(const LayerHandle& aHandle);
|
void ReleaseLayer(const LayerHandle& aHandle);
|
||||||
|
|
||||||
bool InForwarderThread() override {
|
bool InForwarderThread() override {
|
||||||
|
|
|
||||||
|
|
@ -115,11 +115,8 @@ SharedPlanarYCbCrImage::AdoptData(const Data& aData)
|
||||||
uint32_t crOffset = aData.mCrChannel - base;
|
uint32_t crOffset = aData.mCrChannel - base;
|
||||||
|
|
||||||
auto fwd = mCompositable->GetForwarder();
|
auto fwd = mCompositable->GetForwarder();
|
||||||
bool supportsTextureDirectMapping = fwd->SupportsTextureDirectMapping() &&
|
|
||||||
std::max(mSize.width, mSize.height) <= fwd->GetMaxTextureSize();
|
|
||||||
bool hasIntermediateBuffer = ComputeHasIntermediateBuffer(
|
bool hasIntermediateBuffer = ComputeHasIntermediateBuffer(
|
||||||
gfx::SurfaceFormat::YUV, fwd->GetCompositorBackendType(),
|
gfx::SurfaceFormat::YUV, fwd->GetCompositorBackendType());
|
||||||
supportsTextureDirectMapping);
|
|
||||||
|
|
||||||
static_cast<BufferTextureData*>(mTextureClient->GetInternalData())
|
static_cast<BufferTextureData*>(mTextureClient->GetInternalData())
|
||||||
->SetDesciptor(YCbCrDescriptor(aData.mYSize,
|
->SetDesciptor(YCbCrDescriptor(aData.mYSize,
|
||||||
|
|
|
||||||
|
|
@ -274,7 +274,6 @@ if CONFIG['MOZ_X11']:
|
||||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
|
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
|
||||||
EXPORTS.mozilla.layers += [
|
EXPORTS.mozilla.layers += [
|
||||||
'opengl/GLManager.h',
|
'opengl/GLManager.h',
|
||||||
'TextureSync.h',
|
|
||||||
]
|
]
|
||||||
EXPORTS += [
|
EXPORTS += [
|
||||||
'MacIOSurfaceHelpers.h',
|
'MacIOSurfaceHelpers.h',
|
||||||
|
|
@ -282,7 +281,6 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
|
||||||
]
|
]
|
||||||
UNIFIED_SOURCES += [
|
UNIFIED_SOURCES += [
|
||||||
'opengl/GLManager.cpp',
|
'opengl/GLManager.cpp',
|
||||||
'TextureSync.cpp',
|
|
||||||
]
|
]
|
||||||
SOURCES += [
|
SOURCES += [
|
||||||
'ipc/ShadowLayerUtilsMac.cpp',
|
'ipc/ShadowLayerUtilsMac.cpp',
|
||||||
|
|
|
||||||
|
|
@ -25,16 +25,11 @@
|
||||||
#include "mozilla/gfx/Matrix.h" // for Matrix4x4, Matrix
|
#include "mozilla/gfx/Matrix.h" // for Matrix4x4, Matrix
|
||||||
#include "mozilla/gfx/Triangle.h" // for Triangle
|
#include "mozilla/gfx/Triangle.h" // for Triangle
|
||||||
#include "mozilla/gfx/gfxVars.h" // for gfxVars
|
#include "mozilla/gfx/gfxVars.h" // for gfxVars
|
||||||
#include "mozilla/layers/ImageDataSerializer.h"
|
|
||||||
#include "mozilla/layers/LayerManagerComposite.h" // for LayerComposite, etc
|
#include "mozilla/layers/LayerManagerComposite.h" // for LayerComposite, etc
|
||||||
#include "mozilla/layers/CompositingRenderTargetOGL.h"
|
#include "mozilla/layers/CompositingRenderTargetOGL.h"
|
||||||
#include "mozilla/layers/Effects.h" // for EffectChain, TexturedEffect, etc
|
#include "mozilla/layers/Effects.h" // for EffectChain, TexturedEffect, etc
|
||||||
#include "mozilla/layers/TextureHost.h" // for TextureSource, etc
|
#include "mozilla/layers/TextureHost.h" // for TextureSource, etc
|
||||||
#include "mozilla/layers/TextureHostOGL.h" // for TextureSourceOGL, etc
|
#include "mozilla/layers/TextureHostOGL.h" // for TextureSourceOGL, etc
|
||||||
#include "mozilla/layers/PTextureParent.h" // for OtherPid() on PTextureParent
|
|
||||||
#ifdef XP_DARWIN
|
|
||||||
#include "mozilla/layers/TextureSync.h" // for TextureSync::etc.
|
|
||||||
#endif
|
|
||||||
#include "mozilla/mozalloc.h" // for operator delete, etc
|
#include "mozilla/mozalloc.h" // for operator delete, etc
|
||||||
#include "nsAppRunner.h"
|
#include "nsAppRunner.h"
|
||||||
#include "nsAString.h"
|
#include "nsAString.h"
|
||||||
|
|
@ -187,17 +182,11 @@ CompositorOGL::CompositorOGL(CompositorBridgeParent* aParent,
|
||||||
, mViewportSize(0, 0)
|
, mViewportSize(0, 0)
|
||||||
, mCurrentProgram(nullptr)
|
, mCurrentProgram(nullptr)
|
||||||
{
|
{
|
||||||
#ifdef XP_DARWIN
|
|
||||||
TextureSync::RegisterTextureSourceProvider(this);
|
|
||||||
#endif
|
|
||||||
MOZ_COUNT_CTOR(CompositorOGL);
|
MOZ_COUNT_CTOR(CompositorOGL);
|
||||||
}
|
}
|
||||||
|
|
||||||
CompositorOGL::~CompositorOGL()
|
CompositorOGL::~CompositorOGL()
|
||||||
{
|
{
|
||||||
#ifdef XP_DARWIN
|
|
||||||
TextureSync::UnregisterTextureSourceProvider(this);
|
|
||||||
#endif
|
|
||||||
MOZ_COUNT_DTOR(CompositorOGL);
|
MOZ_COUNT_DTOR(CompositorOGL);
|
||||||
Destroy();
|
Destroy();
|
||||||
}
|
}
|
||||||
|
|
@ -256,8 +245,6 @@ CompositorOGL::Destroy()
|
||||||
mTexturePool = nullptr;
|
mTexturePool = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
mMaybeUnlockBeforeNextComposition.Clear();
|
|
||||||
|
|
||||||
if (!mDestroyed) {
|
if (!mDestroyed) {
|
||||||
mDestroyed = true;
|
mDestroyed = true;
|
||||||
CleanupResources();
|
CleanupResources();
|
||||||
|
|
@ -1886,93 +1873,6 @@ CompositorOGL::CreateDataTextureSource(TextureFlags aFlags)
|
||||||
return MakeAndAddRef<TextureImageTextureSourceOGL>(this, aFlags);
|
return MakeAndAddRef<TextureImageTextureSourceOGL>(this, aFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<DataTextureSource>
|
|
||||||
CompositorOGL::CreateDataTextureSourceAroundYCbCr(TextureHost* aTexture)
|
|
||||||
{
|
|
||||||
BufferTextureHost* bufferTexture = aTexture->AsBufferTextureHost();
|
|
||||||
MOZ_ASSERT(bufferTexture);
|
|
||||||
|
|
||||||
if (!bufferTexture) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t* buf = bufferTexture->GetBuffer();
|
|
||||||
const BufferDescriptor& buffDesc = bufferTexture->GetBufferDescriptor();
|
|
||||||
const YCbCrDescriptor& desc = buffDesc.get_YCbCrDescriptor();
|
|
||||||
|
|
||||||
RefPtr<gfx::DataSourceSurface> tempY =
|
|
||||||
gfx::Factory::CreateWrappingDataSourceSurface(ImageDataSerializer::GetYChannel(buf, desc),
|
|
||||||
desc.yStride(),
|
|
||||||
desc.ySize(),
|
|
||||||
SurfaceFormatForAlphaBitDepth(desc.bitDepth()));
|
|
||||||
if (!tempY) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
RefPtr<gfx::DataSourceSurface> tempCb =
|
|
||||||
gfx::Factory::CreateWrappingDataSourceSurface(ImageDataSerializer::GetCbChannel(buf, desc),
|
|
||||||
desc.cbCrStride(),
|
|
||||||
desc.cbCrSize(),
|
|
||||||
SurfaceFormatForAlphaBitDepth(desc.bitDepth()));
|
|
||||||
if (!tempCb) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
RefPtr<gfx::DataSourceSurface> tempCr =
|
|
||||||
gfx::Factory::CreateWrappingDataSourceSurface(ImageDataSerializer::GetCrChannel(buf, desc),
|
|
||||||
desc.cbCrStride(),
|
|
||||||
desc.cbCrSize(),
|
|
||||||
SurfaceFormatForAlphaBitDepth(desc.bitDepth()));
|
|
||||||
if (!tempCr) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
RefPtr<DirectMapTextureSource> srcY = new DirectMapTextureSource(this, tempY);
|
|
||||||
RefPtr<DirectMapTextureSource> srcU = new DirectMapTextureSource(this, tempCb);
|
|
||||||
RefPtr<DirectMapTextureSource> srcV = new DirectMapTextureSource(this, tempCr);
|
|
||||||
|
|
||||||
srcY->SetNextSibling(srcU);
|
|
||||||
srcU->SetNextSibling(srcV);
|
|
||||||
|
|
||||||
return srcY.forget();
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef XP_DARWIN
|
|
||||||
void
|
|
||||||
CompositorOGL::MaybeUnlockBeforeNextComposition(TextureHost* aTextureHost)
|
|
||||||
{
|
|
||||||
auto bufferTexture = aTextureHost->AsBufferTextureHost();
|
|
||||||
if (bufferTexture) {
|
|
||||||
mMaybeUnlockBeforeNextComposition.AppendElement(bufferTexture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
CompositorOGL::TryUnlockTextures()
|
|
||||||
{
|
|
||||||
nsClassHashtable<nsUint32HashKey, nsTArray<uint64_t>> texturesIdsToUnlockByPid;
|
|
||||||
for (auto& texture : mMaybeUnlockBeforeNextComposition) {
|
|
||||||
if (texture->IsDirectMap() && texture->CanUnlock()) {
|
|
||||||
texture->ReadUnlock();
|
|
||||||
auto actor = texture->GetIPDLActor();
|
|
||||||
if (actor) {
|
|
||||||
base::ProcessId pid = actor->OtherPid();
|
|
||||||
nsTArray<uint64_t>* textureIds = texturesIdsToUnlockByPid.LookupOrAdd(pid);
|
|
||||||
textureIds->AppendElement(TextureHost::GetTextureSerial(actor));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mMaybeUnlockBeforeNextComposition.Clear();
|
|
||||||
for (auto it = texturesIdsToUnlockByPid.ConstIter(); !it.Done(); it.Next()) {
|
|
||||||
TextureSync::SetTexturesUnlocked(it.Key(), *it.UserData());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
already_AddRefed<DataTextureSource>
|
|
||||||
CompositorOGL::CreateDataTextureSourceAround(gfx::DataSourceSurface* aSurface)
|
|
||||||
{
|
|
||||||
return MakeAndAddRef<DirectMapTextureSource>(this, aSurface);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
CompositorOGL::SupportsPartialTextureUpdate()
|
CompositorOGL::SupportsPartialTextureUpdate()
|
||||||
{
|
{
|
||||||
|
|
@ -2009,6 +1909,8 @@ CompositorOGL::BlitTextureImageHelper()
|
||||||
return mBlitTextureImageHelper.get();
|
return mBlitTextureImageHelper.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GLuint
|
GLuint
|
||||||
CompositorOGL::GetTemporaryTexture(GLenum aTarget, GLenum aUnit)
|
CompositorOGL::GetTemporaryTexture(GLenum aTarget, GLenum aUnit)
|
||||||
{
|
{
|
||||||
|
|
@ -2018,22 +1920,6 @@ CompositorOGL::GetTemporaryTexture(GLenum aTarget, GLenum aUnit)
|
||||||
return mTexturePool->GetTexture(aTarget, aUnit);
|
return mTexturePool->GetTexture(aTarget, aUnit);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
CompositorOGL::SupportsTextureDirectMapping()
|
|
||||||
{
|
|
||||||
if (!gfxPrefs::AllowTextureDirectMapping()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mGLContext) {
|
|
||||||
mGLContext->MakeCurrent();
|
|
||||||
return mGLContext->IsExtensionSupported(gl::GLContext::APPLE_client_storage) &&
|
|
||||||
mGLContext->IsExtensionSupported(gl::GLContext::APPLE_texture_range);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
GLuint
|
GLuint
|
||||||
PerUnitTexturePoolOGL::GetTexture(GLenum aTarget, GLenum aTextureUnit)
|
PerUnitTexturePoolOGL::GetTexture(GLenum aTarget, GLenum aTextureUnit)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,6 @@ class CompositingRenderTargetOGL;
|
||||||
class DataTextureSource;
|
class DataTextureSource;
|
||||||
class GLManagerCompositor;
|
class GLManagerCompositor;
|
||||||
class TextureSource;
|
class TextureSource;
|
||||||
class BufferTextureHost;
|
|
||||||
struct Effect;
|
struct Effect;
|
||||||
struct EffectChain;
|
struct EffectChain;
|
||||||
class GLBlitTextureImageHelper;
|
class GLBlitTextureImageHelper;
|
||||||
|
|
@ -132,12 +131,6 @@ public:
|
||||||
virtual already_AddRefed<DataTextureSource>
|
virtual already_AddRefed<DataTextureSource>
|
||||||
CreateDataTextureSource(TextureFlags aFlags = TextureFlags::NO_FLAGS) override;
|
CreateDataTextureSource(TextureFlags aFlags = TextureFlags::NO_FLAGS) override;
|
||||||
|
|
||||||
virtual already_AddRefed<DataTextureSource>
|
|
||||||
CreateDataTextureSourceAroundYCbCr(TextureHost* aTexture) override;
|
|
||||||
|
|
||||||
virtual already_AddRefed<DataTextureSource>
|
|
||||||
CreateDataTextureSourceAround(gfx::DataSourceSurface* aSurface) override;
|
|
||||||
|
|
||||||
virtual bool Initialize(nsCString* const out_failureReason) override;
|
virtual bool Initialize(nsCString* const out_failureReason) override;
|
||||||
|
|
||||||
virtual void Destroy() override;
|
virtual void Destroy() override;
|
||||||
|
|
@ -148,7 +141,6 @@ public:
|
||||||
TextureFactoryIdentifier(LayersBackend::LAYERS_OPENGL,
|
TextureFactoryIdentifier(LayersBackend::LAYERS_OPENGL,
|
||||||
XRE_GetProcessType(),
|
XRE_GetProcessType(),
|
||||||
GetMaxTextureSize(),
|
GetMaxTextureSize(),
|
||||||
SupportsTextureDirectMapping(),
|
|
||||||
false,
|
false,
|
||||||
mFBOTextureTarget == LOCAL_GL_TEXTURE_2D,
|
mFBOTextureTarget == LOCAL_GL_TEXTURE_2D,
|
||||||
SupportsPartialTextureUpdate());
|
SupportsPartialTextureUpdate());
|
||||||
|
|
@ -236,11 +228,6 @@ public:
|
||||||
GLContext* gl() const { return mGLContext; }
|
GLContext* gl() const { return mGLContext; }
|
||||||
GLContext* GetGLContext() const override { return mGLContext; }
|
GLContext* GetGLContext() const override { return mGLContext; }
|
||||||
|
|
||||||
#ifdef XP_DARWIN
|
|
||||||
virtual void MaybeUnlockBeforeNextComposition(TextureHost* aTextureHost) override;
|
|
||||||
virtual void TryUnlockTextures() override;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear the program state. This must be called
|
* Clear the program state. This must be called
|
||||||
* before operating on the GLContext directly. */
|
* before operating on the GLContext directly. */
|
||||||
|
|
@ -286,18 +273,12 @@ private:
|
||||||
|
|
||||||
void PrepareViewport(CompositingRenderTargetOGL *aRenderTarget);
|
void PrepareViewport(CompositingRenderTargetOGL *aRenderTarget);
|
||||||
|
|
||||||
bool SupportsTextureDirectMapping();
|
|
||||||
|
|
||||||
/** Widget associated with this compositor */
|
/** Widget associated with this compositor */
|
||||||
LayoutDeviceIntSize mWidgetSize;
|
LayoutDeviceIntSize mWidgetSize;
|
||||||
RefPtr<GLContext> mGLContext;
|
RefPtr<GLContext> mGLContext;
|
||||||
UniquePtr<GLBlitTextureImageHelper> mBlitTextureImageHelper;
|
UniquePtr<GLBlitTextureImageHelper> mBlitTextureImageHelper;
|
||||||
gfx::Matrix4x4 mProjMatrix;
|
gfx::Matrix4x4 mProjMatrix;
|
||||||
|
|
||||||
#ifdef XP_DARWIN
|
|
||||||
nsTArray<RefPtr<BufferTextureHost>> mMaybeUnlockBeforeNextComposition;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** The size of the surface we are rendering to */
|
/** The size of the surface we are rendering to */
|
||||||
gfx::IntSize mSurfaceSize;
|
gfx::IntSize mSurfaceSize;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -242,12 +242,14 @@ GLTextureSource::GLTextureSource(TextureSourceProvider* aProvider,
|
||||||
GLuint aTextureHandle,
|
GLuint aTextureHandle,
|
||||||
GLenum aTarget,
|
GLenum aTarget,
|
||||||
gfx::IntSize aSize,
|
gfx::IntSize aSize,
|
||||||
gfx::SurfaceFormat aFormat)
|
gfx::SurfaceFormat aFormat,
|
||||||
|
bool aExternallyOwned)
|
||||||
: mGL(aProvider->GetGLContext())
|
: mGL(aProvider->GetGLContext())
|
||||||
, mTextureHandle(aTextureHandle)
|
, mTextureHandle(aTextureHandle)
|
||||||
, mTextureTarget(aTarget)
|
, mTextureTarget(aTarget)
|
||||||
, mSize(aSize)
|
, mSize(aSize)
|
||||||
, mFormat(aFormat)
|
, mFormat(aFormat)
|
||||||
|
, mExternallyOwned(aExternallyOwned)
|
||||||
{
|
{
|
||||||
MOZ_COUNT_CTOR(GLTextureSource);
|
MOZ_COUNT_CTOR(GLTextureSource);
|
||||||
}
|
}
|
||||||
|
|
@ -255,13 +257,17 @@ GLTextureSource::GLTextureSource(TextureSourceProvider* aProvider,
|
||||||
GLTextureSource::~GLTextureSource()
|
GLTextureSource::~GLTextureSource()
|
||||||
{
|
{
|
||||||
MOZ_COUNT_DTOR(GLTextureSource);
|
MOZ_COUNT_DTOR(GLTextureSource);
|
||||||
DeleteTextureHandle();
|
if (!mExternallyOwned) {
|
||||||
|
DeleteTextureHandle();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
GLTextureSource::DeallocateDeviceData()
|
GLTextureSource::DeallocateDeviceData()
|
||||||
{
|
{
|
||||||
DeleteTextureHandle();
|
if (!mExternallyOwned) {
|
||||||
|
DeleteTextureHandle();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -309,98 +315,6 @@ GLTextureSource::IsValid() const
|
||||||
return !!gl() && mTextureHandle != 0;
|
return !!gl() && mTextureHandle != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
// DirectMapTextureSource
|
|
||||||
|
|
||||||
DirectMapTextureSource::DirectMapTextureSource(TextureSourceProvider* aProvider,
|
|
||||||
gfx::DataSourceSurface* aSurface)
|
|
||||||
: GLTextureSource(aProvider,
|
|
||||||
0,
|
|
||||||
LOCAL_GL_TEXTURE_2D,
|
|
||||||
aSurface->GetSize(),
|
|
||||||
aSurface->GetFormat())
|
|
||||||
{
|
|
||||||
MOZ_ASSERT(aSurface);
|
|
||||||
|
|
||||||
UpdateInternal(aSurface, nullptr, nullptr, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
DirectMapTextureSource::Update(gfx::DataSourceSurface* aSurface,
|
|
||||||
nsIntRegion* aDestRegion,
|
|
||||||
gfx::IntPoint* aSrcOffset)
|
|
||||||
{
|
|
||||||
if (!aSurface) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return UpdateInternal(aSurface, aDestRegion, aSrcOffset, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
DirectMapTextureSource::Sync(bool aBlocking)
|
|
||||||
{
|
|
||||||
gl()->MakeCurrent();
|
|
||||||
if (!gl()->IsDestroyed()) {
|
|
||||||
if (aBlocking) {
|
|
||||||
gl()->fFinishObjectAPPLE(LOCAL_GL_TEXTURE, mTextureHandle);
|
|
||||||
} else {
|
|
||||||
return gl()->fTestObjectAPPLE(LOCAL_GL_TEXTURE, mTextureHandle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
DirectMapTextureSource::UpdateInternal(gfx::DataSourceSurface* aSurface,
|
|
||||||
nsIntRegion* aDestRegion,
|
|
||||||
gfx::IntPoint* aSrcOffset,
|
|
||||||
bool aInit)
|
|
||||||
{
|
|
||||||
gl()->MakeCurrent();
|
|
||||||
|
|
||||||
if (aInit) {
|
|
||||||
gl()->fGenTextures(1, &mTextureHandle);
|
|
||||||
gl()->fBindTexture(LOCAL_GL_TEXTURE_2D, mTextureHandle);
|
|
||||||
|
|
||||||
gl()->fTexParameteri(LOCAL_GL_TEXTURE_2D,
|
|
||||||
LOCAL_GL_TEXTURE_STORAGE_HINT_APPLE,
|
|
||||||
LOCAL_GL_STORAGE_CACHED_APPLE);
|
|
||||||
|
|
||||||
gl()->fTexParameteri(LOCAL_GL_TEXTURE_2D,
|
|
||||||
LOCAL_GL_TEXTURE_WRAP_S,
|
|
||||||
LOCAL_GL_CLAMP_TO_EDGE);
|
|
||||||
gl()->fTexParameteri(LOCAL_GL_TEXTURE_2D,
|
|
||||||
LOCAL_GL_TEXTURE_WRAP_T,
|
|
||||||
LOCAL_GL_CLAMP_TO_EDGE);
|
|
||||||
}
|
|
||||||
|
|
||||||
MOZ_ASSERT(mTextureHandle);
|
|
||||||
|
|
||||||
// APPLE_client_storage
|
|
||||||
gl()->fPixelStorei(LOCAL_GL_UNPACK_CLIENT_STORAGE_APPLE, LOCAL_GL_TRUE);
|
|
||||||
|
|
||||||
nsIntRegion destRegion = aDestRegion ? *aDestRegion
|
|
||||||
: IntRect(0, 0,
|
|
||||||
aSurface->GetSize().width,
|
|
||||||
aSurface->GetSize().height);
|
|
||||||
gfx::IntPoint srcPoint = aSrcOffset ? *aSrcOffset
|
|
||||||
: gfx::IntPoint(0, 0);
|
|
||||||
mFormat = gl::UploadSurfaceToTexture(gl(),
|
|
||||||
aSurface,
|
|
||||||
destRegion,
|
|
||||||
mTextureHandle,
|
|
||||||
aSurface->GetSize(),
|
|
||||||
nullptr,
|
|
||||||
aInit,
|
|
||||||
srcPoint,
|
|
||||||
LOCAL_GL_TEXTURE0,
|
|
||||||
LOCAL_GL_TEXTURE_2D);
|
|
||||||
|
|
||||||
gl()->fPixelStorei(LOCAL_GL_UNPACK_CLIENT_STORAGE_APPLE, LOCAL_GL_FALSE);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// SurfaceTextureHost
|
// SurfaceTextureHost
|
||||||
|
|
@ -850,7 +764,8 @@ GLTextureHost::Lock()
|
||||||
mTexture,
|
mTexture,
|
||||||
mTarget,
|
mTarget,
|
||||||
mSize,
|
mSize,
|
||||||
format);
|
format,
|
||||||
|
false /* owned by the client */);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -224,7 +224,7 @@ protected:
|
||||||
*
|
*
|
||||||
* The shared texture handle is owned by the TextureHost.
|
* The shared texture handle is owned by the TextureHost.
|
||||||
*/
|
*/
|
||||||
class GLTextureSource : public DataTextureSource
|
class GLTextureSource : public TextureSource
|
||||||
, public TextureSourceOGL
|
, public TextureSourceOGL
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -232,9 +232,10 @@ public:
|
||||||
GLuint aTextureHandle,
|
GLuint aTextureHandle,
|
||||||
GLenum aTarget,
|
GLenum aTarget,
|
||||||
gfx::IntSize aSize,
|
gfx::IntSize aSize,
|
||||||
gfx::SurfaceFormat aFormat);
|
gfx::SurfaceFormat aFormat,
|
||||||
|
bool aExternallyOwned = false);
|
||||||
|
|
||||||
virtual ~GLTextureSource();
|
~GLTextureSource();
|
||||||
|
|
||||||
virtual const char* Name() const override { return "GLTextureSource"; }
|
virtual const char* Name() const override { return "GLTextureSource"; }
|
||||||
|
|
||||||
|
|
@ -269,13 +270,6 @@ public:
|
||||||
return mGL;
|
return mGL;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool Update(gfx::DataSourceSurface* aSurface,
|
|
||||||
nsIntRegion* aDestRegion = nullptr,
|
|
||||||
gfx::IntPoint* aSrcOffset = nullptr) override
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void DeleteTextureHandle();
|
void DeleteTextureHandle();
|
||||||
|
|
||||||
|
|
@ -285,35 +279,9 @@ protected:
|
||||||
GLenum mTextureTarget;
|
GLenum mTextureTarget;
|
||||||
gfx::IntSize mSize;
|
gfx::IntSize mSize;
|
||||||
gfx::SurfaceFormat mFormat;
|
gfx::SurfaceFormat mFormat;
|
||||||
};
|
// If the texture is externally owned, the gl handle will not be deleted
|
||||||
|
// in the destructor.
|
||||||
// This texture source try to wrap "aSurface" in ctor for compositor direct
|
bool mExternallyOwned;
|
||||||
// access. Since we can't know the timing for gpu buffer access, the surface
|
|
||||||
// should be alive until the ~ClientStorageTextureSource(). And if we try to
|
|
||||||
// update the surface we mapped before, we need to call Sync() to make sure
|
|
||||||
// the surface is not used by compositor.
|
|
||||||
class DirectMapTextureSource : public GLTextureSource
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DirectMapTextureSource(TextureSourceProvider* aProvider,
|
|
||||||
gfx::DataSourceSurface* aSurface);
|
|
||||||
|
|
||||||
virtual bool Update(gfx::DataSourceSurface* aSurface,
|
|
||||||
nsIntRegion* aDestRegion = nullptr,
|
|
||||||
gfx::IntPoint* aSrcOffset = nullptr) override;
|
|
||||||
|
|
||||||
virtual bool IsDirectMap() override { return true; }
|
|
||||||
|
|
||||||
// If aBlocking is false, check if this texture is no longer being used
|
|
||||||
// by the GPU - if aBlocking is true, this will block until the GPU is
|
|
||||||
// done with it.
|
|
||||||
virtual bool Sync(bool aBlocking) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool UpdateInternal(gfx::DataSourceSurface* aSurface,
|
|
||||||
nsIntRegion* aDestRegion,
|
|
||||||
gfx::IntPoint* aSrcOffset,
|
|
||||||
bool aInit);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class GLTextureHost : public TextureHost
|
class GLTextureHost : public TextureHost
|
||||||
|
|
|
||||||
|
|
@ -513,12 +513,6 @@ private:
|
||||||
DECL_GFX_PREF(Once, "gfx.use-mutex-on-present", UseMutexOnPresent, bool, false);
|
DECL_GFX_PREF(Once, "gfx.use-mutex-on-present", UseMutexOnPresent, bool, false);
|
||||||
DECL_GFX_PREF(Once, "gfx.use-surfacetexture-textures", UseSurfaceTextureTextures, bool, false);
|
DECL_GFX_PREF(Once, "gfx.use-surfacetexture-textures", UseSurfaceTextureTextures, bool, false);
|
||||||
|
|
||||||
#if defined(RELEASE_OR_BETA)
|
|
||||||
DECL_GFX_PREF(Once, "gfx.allow-texture-direct-mapping", AllowTextureDirectMapping, bool, false);
|
|
||||||
#else
|
|
||||||
DECL_GFX_PREF(Once, "gfx.allow-texture-direct-mapping", AllowTextureDirectMapping, bool, true);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
DECL_GFX_PREF(Live, "gfx.vsync.collect-scroll-transforms", CollectScrollTransforms, bool, false);
|
DECL_GFX_PREF(Live, "gfx.vsync.collect-scroll-transforms", CollectScrollTransforms, bool, false);
|
||||||
DECL_GFX_PREF(Once, "gfx.vsync.compositor.unobserve-count", CompositorUnobserveCount, int32_t, 10);
|
DECL_GFX_PREF(Once, "gfx.vsync.compositor.unobserve-count", CompositorUnobserveCount, int32_t, 10);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@
|
||||||
|
|
||||||
#include "SharedMemory.h"
|
#include "SharedMemory.h"
|
||||||
#include <mach/port.h>
|
#include <mach/port.h>
|
||||||
#include "chrome/common/mach_ipc_mac.h"
|
|
||||||
|
|
||||||
#ifdef FUZZING
|
#ifdef FUZZING
|
||||||
#include "SharedMemoryFuzzer.h"
|
#include "SharedMemoryFuzzer.h"
|
||||||
|
|
@ -29,27 +28,6 @@ class ReceivePort;
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace ipc {
|
namespace ipc {
|
||||||
|
|
||||||
enum {
|
|
||||||
kGetPortsMsg = 1,
|
|
||||||
kSharePortsMsg,
|
|
||||||
kWaitForTexturesMsg,
|
|
||||||
kUpdateTextureLocksMsg,
|
|
||||||
kReturnIdMsg,
|
|
||||||
kReturnWaitForTexturesMsg,
|
|
||||||
kReturnPortsMsg,
|
|
||||||
kShutdownMsg,
|
|
||||||
kCleanupMsg,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct MemoryPorts {
|
|
||||||
MachPortSender* mSender;
|
|
||||||
ReceivePort* mReceiver;
|
|
||||||
|
|
||||||
MemoryPorts() = default;
|
|
||||||
MemoryPorts(MachPortSender* sender, ReceivePort* receiver)
|
|
||||||
: mSender(sender), mReceiver(receiver) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
class SharedMemoryBasic final : public SharedMemoryCommon<mach_port_t>
|
class SharedMemoryBasic final : public SharedMemoryCommon<mach_port_t>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -64,10 +42,6 @@ public:
|
||||||
|
|
||||||
static void Shutdown();
|
static void Shutdown();
|
||||||
|
|
||||||
static bool SendMachMessage(pid_t pid,
|
|
||||||
MachSendMessage& message,
|
|
||||||
MachReceiveMessage* response);
|
|
||||||
|
|
||||||
SharedMemoryBasic();
|
SharedMemoryBasic();
|
||||||
|
|
||||||
virtual bool SetHandle(const Handle& aHandle, OpenRights aRights) override;
|
virtual bool SetHandle(const Handle& aHandle, OpenRights aRights) override;
|
||||||
|
|
|
||||||
|
|
@ -22,11 +22,11 @@
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "SharedMemoryBasic.h"
|
#include "SharedMemoryBasic.h"
|
||||||
|
#include "chrome/common/mach_ipc_mac.h"
|
||||||
|
|
||||||
#include "mozilla/IntegerPrintfMacros.h"
|
#include "mozilla/IntegerPrintfMacros.h"
|
||||||
#include "mozilla/Printf.h"
|
#include "mozilla/Printf.h"
|
||||||
#include "mozilla/StaticMutex.h"
|
#include "mozilla/StaticMutex.h"
|
||||||
#include "mozilla/layers/TextureSync.h"
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#define LOG_ERROR(str, args...) \
|
#define LOG_ERROR(str, args...) \
|
||||||
|
|
@ -82,10 +82,29 @@
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace ipc {
|
namespace ipc {
|
||||||
|
|
||||||
|
struct MemoryPorts {
|
||||||
|
MachPortSender* mSender;
|
||||||
|
ReceivePort* mReceiver;
|
||||||
|
|
||||||
|
MemoryPorts() = default;
|
||||||
|
MemoryPorts(MachPortSender* sender, ReceivePort* receiver)
|
||||||
|
: mSender(sender), mReceiver(receiver) {}
|
||||||
|
};
|
||||||
|
|
||||||
// Protects gMemoryCommPorts and gThreads.
|
// Protects gMemoryCommPorts and gThreads.
|
||||||
static StaticMutex gMutex;
|
static StaticMutex gMutex;
|
||||||
|
|
||||||
static std::map<pid_t, MemoryPorts> gMemoryCommPorts;
|
static std::map<pid_t, MemoryPorts> gMemoryCommPorts;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
kGetPortsMsg = 1,
|
||||||
|
kSharePortsMsg,
|
||||||
|
kReturnIdMsg,
|
||||||
|
kReturnPortsMsg,
|
||||||
|
kShutdownMsg,
|
||||||
|
kCleanupMsg,
|
||||||
|
};
|
||||||
|
|
||||||
const int kTimeout = 1000;
|
const int kTimeout = 1000;
|
||||||
const int kLongTimeout = 60 * kTimeout;
|
const int kLongTimeout = 60 * kTimeout;
|
||||||
|
|
||||||
|
|
@ -135,7 +154,6 @@ SetupMachMemory(pid_t pid,
|
||||||
pthread_attr_t attr;
|
pthread_attr_t attr;
|
||||||
pthread_attr_init(&attr);
|
pthread_attr_init(&attr);
|
||||||
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
||||||
|
|
||||||
int err = pthread_create(&thread, &attr, PortServerThread, listen_ports);
|
int err = pthread_create(&thread, &attr, PortServerThread, listen_ports);
|
||||||
if (err) {
|
if (err) {
|
||||||
LOG_ERROR("pthread_create failed with %x\n", err);
|
LOG_ERROR("pthread_create failed with %x\n", err);
|
||||||
|
|
@ -387,36 +405,30 @@ PortServerThread(void *argument)
|
||||||
delete ports;
|
delete ports;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (rmsg.GetMessageID() == kWaitForTexturesMsg) {
|
StaticMutexAutoLock smal(gMutex);
|
||||||
layers::TextureSync::HandleWaitForTexturesMessage(&rmsg, ports);
|
switch (rmsg.GetMessageID()) {
|
||||||
} else if (rmsg.GetMessageID() == kUpdateTextureLocksMsg) {
|
case kSharePortsMsg:
|
||||||
layers::TextureSync::DispatchCheckTexturesForUnlock();
|
HandleSharePortsMessage(&rmsg, ports);
|
||||||
} else {
|
break;
|
||||||
StaticMutexAutoLock smal(gMutex);
|
case kGetPortsMsg:
|
||||||
switch (rmsg.GetMessageID()) {
|
HandleGetPortsMessage(&rmsg, ports);
|
||||||
case kSharePortsMsg:
|
break;
|
||||||
HandleSharePortsMessage(&rmsg, ports);
|
case kCleanupMsg:
|
||||||
break;
|
if (gParentPid == 0) {
|
||||||
case kGetPortsMsg:
|
LOG_ERROR("Cleanup message not valid for parent process");
|
||||||
HandleGetPortsMessage(&rmsg, ports);
|
continue;
|
||||||
break;
|
}
|
||||||
case kCleanupMsg:
|
|
||||||
if (gParentPid == 0) {
|
|
||||||
LOG_ERROR("Cleanup message not valid for parent process");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
pid_t* pid;
|
pid_t* pid;
|
||||||
if (rmsg.GetDataLength() != sizeof(pid_t)) {
|
if (rmsg.GetDataLength() != sizeof(pid_t)) {
|
||||||
LOG_ERROR("Improperly formatted message\n");
|
LOG_ERROR("Improperly formatted message\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
pid = reinterpret_cast<pid_t*>(rmsg.GetData());
|
|
||||||
SharedMemoryBasic::CleanupForPid(*pid);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
LOG_ERROR("Unknown message\n");
|
|
||||||
}
|
}
|
||||||
|
pid = reinterpret_cast<pid_t*>(rmsg.GetData());
|
||||||
|
SharedMemoryBasic::CleanupForPid(*pid);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
LOG_ERROR("Unknown message\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -438,8 +450,6 @@ SharedMemoryBasic::Shutdown()
|
||||||
{
|
{
|
||||||
StaticMutexAutoLock smal(gMutex);
|
StaticMutexAutoLock smal(gMutex);
|
||||||
|
|
||||||
layers::TextureSync::Shutdown();
|
|
||||||
|
|
||||||
for (auto& thread : gThreads) {
|
for (auto& thread : gThreads) {
|
||||||
MachSendMessage shutdownMsg(kShutdownMsg);
|
MachSendMessage shutdownMsg(kShutdownMsg);
|
||||||
thread.second.mPorts->mReceiver->SendMessageToSelf(shutdownMsg, kTimeout);
|
thread.second.mPorts->mReceiver->SendMessageToSelf(shutdownMsg, kTimeout);
|
||||||
|
|
@ -459,9 +469,6 @@ SharedMemoryBasic::CleanupForPid(pid_t pid)
|
||||||
if (gThreads.find(pid) == gThreads.end()) {
|
if (gThreads.find(pid) == gThreads.end()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
layers::TextureSync::CleanupForPid(pid);
|
|
||||||
|
|
||||||
const ListeningThread& listeningThread = gThreads[pid];
|
const ListeningThread& listeningThread = gThreads[pid];
|
||||||
MachSendMessage shutdownMsg(kShutdownMsg);
|
MachSendMessage shutdownMsg(kShutdownMsg);
|
||||||
kern_return_t ret = listeningThread.mPorts->mReceiver->SendMessageToSelf(shutdownMsg, kTimeout);
|
kern_return_t ret = listeningThread.mPorts->mReceiver->SendMessageToSelf(shutdownMsg, kTimeout);
|
||||||
|
|
@ -486,40 +493,6 @@ SharedMemoryBasic::CleanupForPid(pid_t pid)
|
||||||
gMemoryCommPorts.erase(pid);
|
gMemoryCommPorts.erase(pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
SharedMemoryBasic::SendMachMessage(pid_t pid,
|
|
||||||
MachSendMessage& message,
|
|
||||||
MachReceiveMessage* response)
|
|
||||||
{
|
|
||||||
StaticMutexAutoLock smal(gMutex);
|
|
||||||
ipc::MemoryPorts* ports = GetMemoryPortsForPid(pid);
|
|
||||||
if (!ports) {
|
|
||||||
LOG_ERROR("Unable to get ports for process.\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
kern_return_t err = ports->mSender->SendMessage(message, kTimeout);
|
|
||||||
if (err != KERN_SUCCESS) {
|
|
||||||
LOG_ERROR("Failed updating texture locks.\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (response) {
|
|
||||||
err = ports->mReceiver->WaitForMessage(response, kTimeout);
|
|
||||||
if (err != KERN_SUCCESS) {
|
|
||||||
LOG_ERROR("short timeout didn't get an id %s %x\n", mach_error_string(err), err);
|
|
||||||
err = ports->mReceiver->WaitForMessage(response, kLongTimeout);
|
|
||||||
|
|
||||||
if (err != KERN_SUCCESS) {
|
|
||||||
LOG_ERROR("long timeout didn't get an id %s %x\n", mach_error_string(err), err);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
SharedMemoryBasic::SharedMemoryBasic()
|
SharedMemoryBasic::SharedMemoryBasic()
|
||||||
: mPort(MACH_PORT_NULL)
|
: mPort(MACH_PORT_NULL)
|
||||||
, mMemory(nullptr)
|
, mMemory(nullptr)
|
||||||
|
|
|
||||||
|
|
@ -1,129 +0,0 @@
|
||||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
||||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
||||||
/* 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/. */
|
|
||||||
|
|
||||||
#ifndef mozilla_StaticMonitor_h
|
|
||||||
#define mozilla_StaticMonitor_h
|
|
||||||
|
|
||||||
#include "mozilla/Atomics.h"
|
|
||||||
#include "mozilla/CondVar.h"
|
|
||||||
|
|
||||||
namespace mozilla {
|
|
||||||
|
|
||||||
class MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS StaticMonitor
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// In debug builds, check that mMutex is initialized for us as we expect by
|
|
||||||
// the compiler. In non-debug builds, don't declare a constructor so that
|
|
||||||
// the compiler can see that the constructor is trivial.
|
|
||||||
#ifdef DEBUG
|
|
||||||
StaticMonitor()
|
|
||||||
{
|
|
||||||
MOZ_ASSERT(!mMutex);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void Lock()
|
|
||||||
{
|
|
||||||
Mutex()->Lock();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Unlock()
|
|
||||||
{
|
|
||||||
Mutex()->Unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Wait() { CondVar()->Wait(); }
|
|
||||||
CVStatus Wait(TimeDuration aDuration) { return CondVar()->Wait(aDuration); }
|
|
||||||
|
|
||||||
nsresult Notify() { return CondVar()->Notify(); }
|
|
||||||
nsresult NotifyAll() { return CondVar()->NotifyAll(); }
|
|
||||||
|
|
||||||
void AssertCurrentThreadOwns()
|
|
||||||
{
|
|
||||||
#ifdef DEBUG
|
|
||||||
Mutex()->AssertCurrentThreadOwns();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
OffTheBooksMutex* Mutex()
|
|
||||||
{
|
|
||||||
if (mMutex) {
|
|
||||||
return mMutex;
|
|
||||||
}
|
|
||||||
|
|
||||||
OffTheBooksMutex* mutex = new OffTheBooksMutex("StaticMutex");
|
|
||||||
if (!mMutex.compareExchange(nullptr, mutex)) {
|
|
||||||
delete mutex;
|
|
||||||
}
|
|
||||||
|
|
||||||
return mMutex;
|
|
||||||
}
|
|
||||||
|
|
||||||
OffTheBooksCondVar* CondVar()
|
|
||||||
{
|
|
||||||
if (mCondVar) {
|
|
||||||
return mCondVar;
|
|
||||||
}
|
|
||||||
|
|
||||||
OffTheBooksCondVar* condvar = new OffTheBooksCondVar(*Mutex(), "StaticCondVar");
|
|
||||||
if (!mCondVar.compareExchange(nullptr, condvar)) {
|
|
||||||
delete condvar;
|
|
||||||
}
|
|
||||||
|
|
||||||
return mCondVar;
|
|
||||||
}
|
|
||||||
|
|
||||||
Atomic<OffTheBooksMutex*> mMutex;
|
|
||||||
Atomic<OffTheBooksCondVar*> mCondVar;
|
|
||||||
|
|
||||||
|
|
||||||
// Disallow copy constructor, but only in debug mode. We only define
|
|
||||||
// a default constructor in debug mode (see above); if we declared
|
|
||||||
// this constructor always, the compiler wouldn't generate a trivial
|
|
||||||
// default constructor for us in non-debug mode.
|
|
||||||
#ifdef DEBUG
|
|
||||||
StaticMonitor(const StaticMonitor& aOther);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Disallow these operators.
|
|
||||||
StaticMonitor& operator=(const StaticMonitor& aRhs);
|
|
||||||
static void* operator new(size_t) CPP_THROW_NEW;
|
|
||||||
static void operator delete(void*);
|
|
||||||
};
|
|
||||||
|
|
||||||
class MOZ_STACK_CLASS StaticMonitorAutoLock
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit StaticMonitorAutoLock(StaticMonitor& aMonitor)
|
|
||||||
: mMonitor(&aMonitor)
|
|
||||||
{
|
|
||||||
mMonitor->Lock();
|
|
||||||
}
|
|
||||||
|
|
||||||
~StaticMonitorAutoLock()
|
|
||||||
{
|
|
||||||
mMonitor->Unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Wait() { mMonitor->Wait(); }
|
|
||||||
CVStatus Wait(TimeDuration aDuration) { return mMonitor->Wait(aDuration); }
|
|
||||||
|
|
||||||
nsresult Notify() { return mMonitor->Notify(); }
|
|
||||||
nsresult NotifyAll() { return mMonitor->NotifyAll(); }
|
|
||||||
|
|
||||||
private:
|
|
||||||
StaticMonitorAutoLock();
|
|
||||||
StaticMonitorAutoLock(const StaticMonitorAutoLock&);
|
|
||||||
StaticMonitorAutoLock& operator=(const StaticMonitorAutoLock&);
|
|
||||||
static void* operator new(size_t) CPP_THROW_NEW;
|
|
||||||
|
|
||||||
StaticMonitor* mMonitor;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace mozilla
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -117,7 +117,6 @@ EXPORTS.mozilla += [
|
||||||
'NSPRLogModulesParser.h',
|
'NSPRLogModulesParser.h',
|
||||||
'OwningNonNull.h',
|
'OwningNonNull.h',
|
||||||
'SizeOfState.h',
|
'SizeOfState.h',
|
||||||
'StaticMonitor.h',
|
|
||||||
'StaticMutex.h',
|
'StaticMutex.h',
|
||||||
'StaticPtr.h',
|
'StaticPtr.h',
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -587,15 +587,15 @@ RecursiveMutex::AssertCurrentThreadIn()
|
||||||
//
|
//
|
||||||
// Debug implementation of CondVar
|
// Debug implementation of CondVar
|
||||||
void
|
void
|
||||||
OffTheBooksCondVar::Wait()
|
CondVar::Wait()
|
||||||
{
|
{
|
||||||
// Forward to the timed version of OffTheBooksCondVar::Wait to avoid code duplication.
|
// Forward to the timed version of CondVar::Wait to avoid code duplication.
|
||||||
CVStatus status = Wait(TimeDuration::Forever());
|
CVStatus status = Wait(TimeDuration::Forever());
|
||||||
MOZ_ASSERT(status == CVStatus::NoTimeout);
|
MOZ_ASSERT(status == CVStatus::NoTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
CVStatus
|
CVStatus
|
||||||
OffTheBooksCondVar::Wait(TimeDuration aDuration)
|
CondVar::Wait(TimeDuration aDuration)
|
||||||
{
|
{
|
||||||
AssertCurrentThreadOwnsMutex();
|
AssertCurrentThreadOwnsMutex();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,17 +17,17 @@
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Similarly to OffTheBooksMutex, OffTheBooksCondvar is identical to CondVar,
|
* CondVar
|
||||||
* except that OffTheBooksCondVar doesn't include leak checking. Sometimes
|
* Vanilla condition variable. Please don't use this unless you have a
|
||||||
* you want to intentionally "leak" a CondVar until shutdown; in these cases,
|
* compelling reason --- Monitor provides a simpler API.
|
||||||
* OffTheBooksCondVar is for you.
|
|
||||||
*/
|
*/
|
||||||
class OffTheBooksCondVar : BlockingResourceBase
|
class CondVar : BlockingResourceBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* OffTheBooksCondVar
|
* CondVar
|
||||||
*
|
*
|
||||||
* The CALLER owns |aLock|.
|
* The CALLER owns |aLock|.
|
||||||
*
|
*
|
||||||
|
|
@ -37,18 +37,20 @@ public:
|
||||||
* If success, a valid Monitor* which must be destroyed
|
* If success, a valid Monitor* which must be destroyed
|
||||||
* by Monitor::DestroyMonitor()
|
* by Monitor::DestroyMonitor()
|
||||||
**/
|
**/
|
||||||
OffTheBooksCondVar(OffTheBooksMutex& aLock, const char* aName)
|
CondVar(Mutex& aLock, const char* aName)
|
||||||
: BlockingResourceBase(aName, eCondVar)
|
: BlockingResourceBase(aName, eCondVar)
|
||||||
, mLock(&aLock)
|
, mLock(&aLock)
|
||||||
{
|
{
|
||||||
|
MOZ_COUNT_CTOR(CondVar);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ~OffTheBooksCondVar
|
* ~CondVar
|
||||||
* Clean up after this OffTheBooksCondVar, but NOT its associated Mutex.
|
* Clean up after this CondVar, but NOT its associated Mutex.
|
||||||
**/
|
**/
|
||||||
~OffTheBooksCondVar()
|
~CondVar()
|
||||||
{
|
{
|
||||||
|
MOZ_COUNT_DTOR(CondVar);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -122,38 +124,13 @@ public:
|
||||||
|
|
||||||
#endif // ifdef DEBUG
|
#endif // ifdef DEBUG
|
||||||
|
|
||||||
private:
|
|
||||||
OffTheBooksCondVar();
|
|
||||||
OffTheBooksCondVar(const OffTheBooksCondVar&) = delete;
|
|
||||||
OffTheBooksCondVar& operator=(const OffTheBooksCondVar&) = delete;
|
|
||||||
|
|
||||||
OffTheBooksMutex* mLock;
|
|
||||||
detail::ConditionVariableImpl mImpl;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CondVar
|
|
||||||
* Vanilla condition variable. Please don't use this unless you have a
|
|
||||||
* compelling reason --- Monitor provides a simpler API.
|
|
||||||
*/
|
|
||||||
class CondVar : public OffTheBooksCondVar
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CondVar(OffTheBooksMutex& aLock, const char* aName)
|
|
||||||
: OffTheBooksCondVar(aLock, aName)
|
|
||||||
{
|
|
||||||
MOZ_COUNT_CTOR(CondVar);
|
|
||||||
}
|
|
||||||
|
|
||||||
~CondVar()
|
|
||||||
{
|
|
||||||
MOZ_COUNT_DTOR(CondVar);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CondVar();
|
CondVar();
|
||||||
CondVar(const CondVar&);
|
CondVar(const CondVar&) = delete;
|
||||||
CondVar& operator=(const CondVar&);
|
CondVar& operator=(const CondVar&) = delete;
|
||||||
|
|
||||||
|
Mutex* mLock;
|
||||||
|
detail::ConditionVariableImpl mImpl;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ private:
|
||||||
OffTheBooksMutex(const OffTheBooksMutex&);
|
OffTheBooksMutex(const OffTheBooksMutex&);
|
||||||
OffTheBooksMutex& operator=(const OffTheBooksMutex&);
|
OffTheBooksMutex& operator=(const OffTheBooksMutex&);
|
||||||
|
|
||||||
friend class OffTheBooksCondVar;
|
friend class CondVar;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
PRThread* mOwningThread;
|
PRThread* mOwningThread;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue