Bug 1734735 - Part 6: Remove dead TextureSync code, r=dthayer

Differential Revision: https://phabricator.services.mozilla.com/D128215
This commit is contained in:
Nika Layzell 2021-11-23 16:15:22 +00:00
parent f6598b1f3c
commit e8759da1c8
19 changed files with 54 additions and 541 deletions

View File

@ -100,12 +100,7 @@ class ShmemTextureData : public BufferTextureData {
};
bool ComputeHasIntermediateBuffer(gfx::SurfaceFormat aFormat,
LayersBackend aLayersBackend,
bool aSupportsTextureDirectMapping) {
if (aSupportsTextureDirectMapping) {
return false;
}
LayersBackend aLayersBackend) {
return aFormat == gfx::SurfaceFormat::UNKNOWN;
}
@ -167,18 +162,10 @@ BufferTextureData* BufferTextureData::CreateForYCbCr(
aCbCrSize.height, yOffset, cbOffset,
crOffset);
bool supportsTextureDirectMapping =
aAllocator->SupportsTextureDirectMapping() &&
aAllocator->GetMaxTextureSize() >
std::max(aYSize.width,
std::max(aYSize.height,
std::max(aCbCrSize.width, aCbCrSize.height)));
bool hasIntermediateBuffer =
aAllocator
? ComputeHasIntermediateBuffer(gfx::SurfaceFormat::YUV,
aAllocator->GetCompositorBackendType(),
supportsTextureDirectMapping)
aAllocator->GetCompositorBackendType())
: true;
YCbCrDescriptor descriptor =
@ -463,8 +450,8 @@ MemoryTextureData* MemoryTextureData::Create(gfx::IntSize aSize,
return nullptr;
}
bool hasIntermediateBuffer = ComputeHasIntermediateBuffer(
aFormat, aLayersBackend, aAllocFlags & ALLOC_ALLOW_DIRECT_MAPPING);
bool hasIntermediateBuffer =
ComputeHasIntermediateBuffer(aFormat, aLayersBackend);
GfxMemoryImageReporter::DidAlloc(buf);
@ -537,8 +524,8 @@ ShmemTextureData* ShmemTextureData::Create(gfx::IntSize aSize,
return nullptr;
}
bool hasIntermediateBuffer = ComputeHasIntermediateBuffer(
aFormat, aLayersBackend, aAllocFlags & ALLOC_ALLOW_DIRECT_MAPPING);
bool hasIntermediateBuffer =
ComputeHasIntermediateBuffer(aFormat, aLayersBackend);
BufferDescriptor descriptor =
RGBDescriptor(aSize, aFormat, hasIntermediateBuffer);

View File

@ -17,8 +17,7 @@ namespace mozilla {
namespace layers {
bool ComputeHasIntermediateBuffer(gfx::SurfaceFormat aFormat,
LayersBackend aLayersBackend,
bool aSupportsTextureDirectMapping);
LayersBackend aLayersBackend);
class BufferTextureData : public TextureData {
public:

View File

@ -149,7 +149,6 @@ struct TextureFactoryIdentifier {
WebRenderCompositor mWebRenderCompositor;
GeckoProcessType mParentProcessType;
int32_t mMaxTextureSize;
bool mSupportsTextureDirectMapping;
bool mCompositorUseANGLE;
bool mCompositorUseDComp;
bool mUseCompositorWnd;
@ -161,10 +160,9 @@ struct TextureFactoryIdentifier {
explicit TextureFactoryIdentifier(
LayersBackend aLayersBackend = LayersBackend::LAYERS_NONE,
GeckoProcessType aParentProcessType = GeckoProcessType_Default,
int32_t aMaxTextureSize = 4096,
bool aSupportsTextureDirectMapping = false,
bool aCompositorUseANGLE = false, bool aCompositorUseDComp = false,
bool aUseCompositorWnd = false, bool aSupportsTextureBlitting = false,
int32_t aMaxTextureSize = 4096, bool aCompositorUseANGLE = false,
bool aCompositorUseDComp = false, bool aUseCompositorWnd = false,
bool aSupportsTextureBlitting = false,
bool aSupportsPartialUploads = false, bool aSupportsComponentAlpha = true,
SyncHandle aSyncHandle = 0)
: mParentBackend(aLayersBackend),
@ -172,7 +170,6 @@ struct TextureFactoryIdentifier {
mWebRenderCompositor(WebRenderCompositor::DRAW),
mParentProcessType(aParentProcessType),
mMaxTextureSize(aMaxTextureSize),
mSupportsTextureDirectMapping(aSupportsTextureDirectMapping),
mCompositorUseANGLE(aCompositorUseANGLE),
mCompositorUseDComp(aCompositorUseDComp),
mUseCompositorWnd(aUseCompositorWnd),
@ -185,10 +182,9 @@ struct TextureFactoryIdentifier {
WebRenderBackend aWebRenderBackend,
WebRenderCompositor aWebRenderCompositor,
GeckoProcessType aParentProcessType = GeckoProcessType_Default,
int32_t aMaxTextureSize = 4096,
bool aSupportsTextureDirectMapping = false,
bool aCompositorUseANGLE = false, bool aCompositorUseDComp = false,
bool aUseCompositorWnd = false, bool aSupportsTextureBlitting = false,
int32_t aMaxTextureSize = 4096, bool aCompositorUseANGLE = false,
bool aCompositorUseDComp = false, bool aUseCompositorWnd = false,
bool aSupportsTextureBlitting = false,
bool aSupportsPartialUploads = false, bool aSupportsComponentAlpha = true,
SyncHandle aSyncHandle = 0)
: mParentBackend(LayersBackend::LAYERS_WR),
@ -196,7 +192,6 @@ struct TextureFactoryIdentifier {
mWebRenderCompositor(aWebRenderCompositor),
mParentProcessType(aParentProcessType),
mMaxTextureSize(aMaxTextureSize),
mSupportsTextureDirectMapping(aSupportsTextureDirectMapping),
mCompositorUseANGLE(aCompositorUseANGLE),
mCompositorUseDComp(aCompositorUseDComp),
mUseCompositorWnd(aUseCompositorWnd),
@ -211,8 +206,6 @@ struct TextureFactoryIdentifier {
mWebRenderCompositor == aOther.mWebRenderCompositor &&
mParentProcessType == aOther.mParentProcessType &&
mMaxTextureSize == aOther.mMaxTextureSize &&
mSupportsTextureDirectMapping ==
aOther.mSupportsTextureDirectMapping &&
mCompositorUseANGLE == aOther.mCompositorUseANGLE &&
mCompositorUseDComp == aOther.mCompositorUseDComp &&
mUseCompositorWnd == aOther.mUseCompositorWnd &&

View File

@ -117,10 +117,7 @@ PersistentBufferProviderShared::Create(gfx::IntSize aSize,
gfx::SurfaceFormat aFormat,
KnowsCompositor* aKnowsCompositor) {
if (!aKnowsCompositor || !aKnowsCompositor->GetTextureForwarder() ||
!aKnowsCompositor->GetTextureForwarder()->IPCOpen() ||
// Bug 1556433 - shared buffer provider and direct texture mapping do not
// synchronize properly
aKnowsCompositor->SupportsTextureDirectMapping()) {
!aKnowsCompositor->GetTextureForwarder()->IPCOpen()) {
return nullptr;
}

View File

@ -7,10 +7,6 @@
#include "mozilla/layers/TextureSourceProvider.h"
#include "mozilla/layers/TextureHost.h"
#include "mozilla/layers/PTextureParent.h"
#ifdef XP_DARWIN
# include "mozilla/layers/TextureSync.h"
# include "nsClassHashtable.h"
#endif
namespace mozilla {
namespace layers {

View File

@ -1,284 +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 "base/process_util.h"
#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"
#include "nsThreadUtils.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;
};
static 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);
}
static 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;
}
}
}
}
static 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);
CompositorThread()->Dispatch(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, Span(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 == base::GetCurrentProcId()) {
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 == base::GetCurrentProcId()) {
bool success = WaitForTextureIdsToUnlock(aProcessId, Span(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 = base::GetCurrentProcId();
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

View File

@ -1,49 +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 "mozilla/ipc/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

View File

@ -1137,11 +1137,6 @@ already_AddRefed<TextureClient> TextureClient::CreateForDrawing(
KnowsCompositor* aAllocator, gfx::SurfaceFormat aFormat, gfx::IntSize aSize,
BackendSelector aSelector, TextureFlags aTextureFlags,
TextureAllocationFlags aAllocFlags) {
if (aAllocator->SupportsTextureDirectMapping() &&
std::max(aSize.width, aSize.height) <= aAllocator->GetMaxTextureSize()) {
aAllocFlags =
TextureAllocationFlags(aAllocFlags | ALLOC_ALLOW_DIRECT_MAPPING);
}
return TextureClient::CreateForDrawing(aAllocator->GetTextureForwarder(),
aFormat, aSize, aAllocator, aSelector,
aTextureFlags, aAllocFlags);
@ -1244,19 +1239,6 @@ already_AddRefed<TextureClient> TextureClient::CreateForRawBufferAccess(
KnowsCompositor* aAllocator, gfx::SurfaceFormat aFormat, gfx::IntSize aSize,
gfx::BackendType aMoz2DBackend, TextureFlags aTextureFlags,
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(), aFormat, aSize, aMoz2DBackend,
aAllocator->GetCompositorBackendType(), aTextureFlags, aAllocFlags);

View File

@ -97,10 +97,6 @@ enum TextureAllocationFlags {
// The texture is going to be updated using UpdateFromSurface and needs to
// support that call.
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,
};
/**

View File

@ -130,12 +130,6 @@ void TextureClientPool::AllocateTextureClient() {
TextureAllocationFlags allocFlags = ALLOC_DEFAULT;
if (mKnowsCompositor->SupportsTextureDirectMapping() &&
std::max(mSize.width, mSize.height) <= GetMaxTextureSize()) {
allocFlags =
TextureAllocationFlags(allocFlags | ALLOC_ALLOW_DIRECT_MAPPING);
}
RefPtr<TextureClient> newClient;
if (StaticPrefs::layers_force_shmem_tiles_AtStartup()) {
// gfx::BackendType::NONE means use the content backend

View File

@ -21,9 +21,6 @@
#include "mozilla/layers/TextureHostOGL.h" // for TextureHostOGL
#include "mozilla/layers/ImageDataSerializer.h"
#include "mozilla/layers/TextureClient.h"
#ifdef XP_DARWIN
# include "mozilla/layers/TextureSync.h"
#endif
#include "mozilla/layers/GPUVideoTextureHost.h"
#include "mozilla/layers/WebRenderTextureHost.h"
#include "mozilla/StaticPrefs_layers.h"
@ -629,16 +626,7 @@ bool TextureHost::NeedsYFlip() const {
return bool(mFlags & TextureFlags::ORIGIN_BOTTOM_LEFT);
}
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 BufferTextureHost::MaybeNotifyUnlocked() {}
gfx::SurfaceFormat BufferTextureHost::GetFormat() const { return mFormat; }

View File

@ -113,11 +113,6 @@ class KnowsCompositor {
return lock.ref().mTextureFactoryIdentifier.mSupportsComponentAlpha;
}
bool SupportsTextureDirectMapping() const {
auto lock = mData.Lock();
return lock.ref().mTextureFactoryIdentifier.mSupportsTextureDirectMapping;
}
bool SupportsD3D11() const {
auto lock = mData.Lock();
return lock.ref().mTextureFactoryIdentifier.mParentBackend ==

View File

@ -492,7 +492,6 @@ struct ParamTraits<mozilla::layers::TextureFactoryIdentifier> {
WriteParam(aMsg, aParam.mWebRenderCompositor);
WriteParam(aMsg, aParam.mParentProcessType);
WriteParam(aMsg, aParam.mMaxTextureSize);
WriteParam(aMsg, aParam.mSupportsTextureDirectMapping);
WriteParam(aMsg, aParam.mCompositorUseANGLE);
WriteParam(aMsg, aParam.mCompositorUseDComp);
WriteParam(aMsg, aParam.mUseCompositorWnd);
@ -504,20 +503,18 @@ struct ParamTraits<mozilla::layers::TextureFactoryIdentifier> {
static bool Read(const Message* aMsg, PickleIterator* aIter,
paramType* aResult) {
bool result =
ReadParam(aMsg, aIter, &aResult->mParentBackend) &&
ReadParam(aMsg, aIter, &aResult->mWebRenderBackend) &&
ReadParam(aMsg, aIter, &aResult->mWebRenderCompositor) &&
ReadParam(aMsg, aIter, &aResult->mParentProcessType) &&
ReadParam(aMsg, aIter, &aResult->mMaxTextureSize) &&
ReadParam(aMsg, aIter, &aResult->mSupportsTextureDirectMapping) &&
ReadParam(aMsg, aIter, &aResult->mCompositorUseANGLE) &&
ReadParam(aMsg, aIter, &aResult->mCompositorUseDComp) &&
ReadParam(aMsg, aIter, &aResult->mUseCompositorWnd) &&
ReadParam(aMsg, aIter, &aResult->mSupportsTextureBlitting) &&
ReadParam(aMsg, aIter, &aResult->mSupportsPartialUploads) &&
ReadParam(aMsg, aIter, &aResult->mSupportsComponentAlpha) &&
ReadParam(aMsg, aIter, &aResult->mSyncHandle);
bool result = ReadParam(aMsg, aIter, &aResult->mParentBackend) &&
ReadParam(aMsg, aIter, &aResult->mWebRenderBackend) &&
ReadParam(aMsg, aIter, &aResult->mWebRenderCompositor) &&
ReadParam(aMsg, aIter, &aResult->mParentProcessType) &&
ReadParam(aMsg, aIter, &aResult->mMaxTextureSize) &&
ReadParam(aMsg, aIter, &aResult->mCompositorUseANGLE) &&
ReadParam(aMsg, aIter, &aResult->mCompositorUseDComp) &&
ReadParam(aMsg, aIter, &aResult->mUseCompositorWnd) &&
ReadParam(aMsg, aIter, &aResult->mSupportsTextureBlitting) &&
ReadParam(aMsg, aIter, &aResult->mSupportsPartialUploads) &&
ReadParam(aMsg, aIter, &aResult->mSupportsComponentAlpha) &&
ReadParam(aMsg, aIter, &aResult->mSyncHandle);
return result;
}
};

View File

@ -249,7 +249,6 @@ if CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa":
EXPORTS.mozilla.layers += [
"NativeLayerCA.h",
"SurfacePoolCA.h",
"TextureSync.h",
]
EXPORTS += [
"MacIOSurfaceHelpers.h",
@ -258,7 +257,6 @@ if CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa":
UNIFIED_SOURCES += [
"NativeLayerCA.mm",
"SurfacePoolCA.mm",
"TextureSync.cpp",
]
SOURCES += [
"MacIOSurfaceHelpers.cpp",

View File

@ -34,10 +34,7 @@
#include "mozilla/layers/TextureHost.h" // for TextureSource, 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 "nsAString.h"
#include "nsClassHashtable.h"
@ -185,18 +182,10 @@ CompositorOGL::CompositorOGL(widget::CompositorWidget* aWidget,
// default framebuffer.
mCanRenderToDefaultFramebuffer = false;
}
#ifdef XP_DARWIN
TextureSync::RegisterTextureSourceProvider(this);
#endif
MOZ_COUNT_CTOR(CompositorOGL);
}
CompositorOGL::~CompositorOGL() {
#ifdef XP_DARWIN
TextureSync::UnregisterTextureSourceProvider(this);
#endif
MOZ_COUNT_DTOR(CompositorOGL);
}
CompositorOGL::~CompositorOGL() { MOZ_COUNT_DTOR(CompositorOGL); }
already_AddRefed<mozilla::gl::GLContext> CompositorOGL::CreateContext() {
RefPtr<GLContext> context;
@ -1650,21 +1639,6 @@ GLuint CompositorOGL::GetTemporaryTexture(GLenum aTarget, GLenum aUnit) {
return mTexturePool->GetTexture(aTarget, aUnit);
}
bool CompositorOGL::SupportsTextureDirectMapping() {
if (!StaticPrefs::gfx_allow_texture_direct_mapping_AtStartup()) {
return false;
}
if (mGLContext) {
mGLContext->MakeCurrent();
return mGLContext->IsExtensionSupported(
gl::GLContext::APPLE_client_storage) &&
mGLContext->IsExtensionSupported(gl::GLContext::APPLE_texture_range);
}
return false;
}
GLuint PerUnitTexturePoolOGL::GetTexture(GLenum aTarget, GLenum aTextureUnit) {
if (mTextureTarget == 0) {
mTextureTarget = aTarget;

View File

@ -230,8 +230,6 @@ class CompositorOGL final : public Compositor {
void PrepareViewport(CompositingRenderTargetOGL* aRenderTarget);
bool SupportsTextureDirectMapping();
void InsertFrameDoneSync();
bool NeedToRecreateFullWindowRenderTarget() const;

View File

@ -2735,9 +2735,9 @@ TextureFactoryIdentifier WebRenderBridgeParent::GetTextureFactoryIdentifier() {
TextureFactoryIdentifier ident(
mApi->GetBackendType(), mApi->GetCompositorType(), XRE_GetProcessType(),
mApi->GetMaxTextureSize(), false, mApi->GetUseANGLE(),
mApi->GetUseDComp(), mAsyncImageManager->UseCompositorWnd(), false, false,
false, mApi->GetSyncHandle());
mApi->GetMaxTextureSize(), mApi->GetUseANGLE(), mApi->GetUseDComp(),
mAsyncImageManager->UseCompositorWnd(), false, false, false,
mApi->GetSyncHandle());
return ident;
}

View File

@ -31,10 +31,7 @@ namespace ipc {
enum {
kGetPortsMsg = 1,
kWaitForTexturesMsg,
kUpdateTextureLocksMsg,
kReturnIdMsg,
kReturnWaitForTexturesMsg,
kReturnPortsMsg,
kShutdownMsg,
kCleanupMsg,
@ -62,9 +59,6 @@ class SharedMemoryBasic final
static void Shutdown();
static bool SendMachMessage(pid_t pid, MachSendMessage& message,
MachReceiveMessage* response);
SharedMemoryBasic();
virtual bool SetHandle(Handle aHandle, OpenRights aRights) override;

View File

@ -26,7 +26,6 @@
#include "mozilla/IntegerPrintfMacros.h"
#include "mozilla/Printf.h"
#include "mozilla/StaticMutex.h"
#include "mozilla/layers/TextureSync.h"
#ifdef DEBUG
# define LOG_ERROR(str, args...) \
@ -330,37 +329,31 @@ static void* PortServerThread(void* argument) {
delete ports;
return nullptr;
}
if (rmsg.GetMessageID() == kWaitForTexturesMsg) {
layers::TextureSync::HandleWaitForTexturesMessage(&rmsg, ports);
} else if (rmsg.GetMessageID() == kUpdateTextureLocksMsg) {
layers::TextureSync::DispatchCheckTexturesForUnlock();
} else {
switch (rmsg.GetMessageID()) {
case kGetPortsMsg: {
StaticMutexAutoLock smal(gMutex);
HandleGetPortsMessage(&rmsg, ports);
break;
switch (rmsg.GetMessageID()) {
case kGetPortsMsg: {
StaticMutexAutoLock smal(gMutex);
HandleGetPortsMessage(&rmsg, ports);
break;
}
case kCleanupMsg: {
StaticMutexAutoLock smal(gMutex);
if (gParentPid == 0) {
LOG_ERROR("Cleanup message not valid for parent process");
continue;
}
case kCleanupMsg: {
StaticMutexAutoLock smal(gMutex);
if (gParentPid == 0) {
LOG_ERROR("Cleanup message not valid for parent process");
continue;
}
pid_t* pid;
if (rmsg.GetDataLength() != sizeof(pid_t)) {
LOG_ERROR("Improperly formatted message\n");
continue;
}
pid = reinterpret_cast<pid_t*>(rmsg.GetData());
SharedMemoryBasic::CleanupForPid(*pid);
break;
}
default: {
// gMutex not required
LOG_ERROR("Unknown message\n");
pid_t* pid;
if (rmsg.GetDataLength() != sizeof(pid_t)) {
LOG_ERROR("Improperly formatted message\n");
continue;
}
pid = reinterpret_cast<pid_t*>(rmsg.GetData());
SharedMemoryBasic::CleanupForPid(*pid);
break;
}
default: {
// gMutex not required
LOG_ERROR("Unknown message\n");
}
}
}
@ -377,8 +370,6 @@ void SharedMemoryBasic::SetupMachMemory(pid_t pid, ReceivePort* listen_port,
void SharedMemoryBasic::Shutdown() {
StaticMutexAutoLock smal(gMutex);
layers::TextureSync::Shutdown();
for (auto& thread : gThreads) {
MachSendMessage shutdownMsg(kShutdownMsg);
thread.second.mPorts->mReceiver->SendMessageToSelf(shutdownMsg, kTimeout);
@ -404,8 +395,6 @@ void SharedMemoryBasic::CleanupForPid(pid_t pid) {
return;
}
layers::TextureSync::CleanupForPid(pid);
const ListeningThread& listeningThread = gThreads[pid];
MachSendMessage shutdownMsg(kShutdownMsg);
kern_return_t ret = listeningThread.mPorts->mReceiver->SendMessageToSelf(shutdownMsg, kTimeout);
@ -430,37 +419,6 @@ void SharedMemoryBasic::CleanupForPid(pid_t 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()
: mPort(MACH_PORT_NULL), mMemory(nullptr), mOpenRights(RightsReadWrite) {}