mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 04:41:11 +00:00
Backed out 3 changesets (bug 1871467) for causing reftest failures on transformations-1.html. CLOSED TREE
Backed out changeset 1b02448b1e9b (bug 1871467) Backed out changeset 0fd0c31a5140 (bug 1871467) Backed out changeset a1c8e8621bdd (bug 1871467)
This commit is contained in:
parent
c9bc4cb68f
commit
f885d9e42d
@ -13,5 +13,5 @@ defaults pref(webgl.force-enabled,true)
|
||||
== color_quads.html?desc=no-alpha______&e_context=webgl&e_options={alpha:false}&e_color_o1=rgb(0,0,0,0.95)&e_color_o2=rgb(16,16,16,0.95)&e_color_o3=rgb(235,235,235,0.95)&e_color_o4=rgb(255,255,255,0.95)&e_color_i4=rgb(0,0,0,0) color_quads.html?e_color_i4=rgb(0,0,0)
|
||||
|
||||
skip-if(swgl) skip-if(gtkWidget&&useDrawSnapshot) fuzzy-if(Android&&!swgl,255-255,120000-120000) == color_quads.html?desc=straight-alpha&e_context=webgl&e_options={premultipliedAlpha:false}&e_color_o1=rgb(0,0,0,0.95)&e_color_o2=rgb(16,16,16,0.95)&e_color_o3=rgb(235,235,235,0.95)&e_color_o4=rgb(255,255,255,0.95)&e_color_i4=rgb(0,0,0,0) color_quads.html?e_color_o1=rgb(13,13,13)&e_color_o2=rgb(28,28,28)&e_color_o3=rgb(236,236,236)&e_color_i4=rgb(255,255,255)
|
||||
skip-if(!swgl) fuzzy-if(winWidget,0-2,0-120000) == color_quads.html?desc=straight-alpha&e_context=webgl&e_options={premultipliedAlpha:false}&e_color_o1=rgb(0,0,0,0.95)&e_color_o2=rgb(16,16,16,0.95)&e_color_o3=rgb(235,235,235,0.95)&e_color_o4=rgb(255,255,255,0.95)&e_color_i4=rgb(0,0,0,0) color_quads.html?e_color_o1=rgb(14,14,14)&e_color_o2=rgb(30,30,30)&e_color_o3=rgb(237,237,237)&e_color_i1=rgb(128,1,1)&e_color_i2=rgb(1,128,1)&e_color_i3=rgb(1,1,128)&e_color_i4=rgb(255,255,255)
|
||||
skip-if(!swgl) == color_quads.html?desc=straight-alpha&e_context=webgl&e_options={premultipliedAlpha:false}&e_color_o1=rgb(0,0,0,0.95)&e_color_o2=rgb(16,16,16,0.95)&e_color_o3=rgb(235,235,235,0.95)&e_color_o4=rgb(255,255,255,0.95)&e_color_i4=rgb(0,0,0,0) color_quads.html?e_color_o1=rgb(14,14,14)&e_color_o2=rgb(30,30,30)&e_color_o3=rgb(237,237,237)&e_color_i1=rgb(128,1,1)&e_color_i2=rgb(1,128,1)&e_color_i3=rgb(1,1,128)&e_color_i4=rgb(255,255,255)
|
||||
skip-if(!(gtkWidget&&useDrawSnapshot)) == color_quads.html?desc=straight-alpha&e_context=webgl&e_options={premultipliedAlpha:false}&e_color_o1=rgb(0,0,0,0.95)&e_color_o2=rgb(16,16,16,0.95)&e_color_o3=rgb(235,235,235,0.95)&e_color_o4=rgb(255,255,255,0.95)&e_color_i4=rgb(0,0,0,0) color_quads.html?e_color_o1=rgb(13,13,13)&e_color_o2=rgb(29,29,29)&e_color_o3=rgb(237,237,237)&e_color_i4=rgb(255,255,255)
|
||||
|
@ -1,4 +1,4 @@
|
||||
skip-if(Android) fuzzy-if(OSX,0-80,0-76800) fuzzy-if(appleSilicon,0-80,0-76800) fuzzy-if(winWidget,0-63,0-76799) fuzzy-if(gtkWidget&&layersGPUAccelerated,0-70,0-2032) HTTP(..) == short.mp4.firstframe.html short.mp4.firstframe-ref.html
|
||||
skip-if(Android) fuzzy-if(OSX,0-80,0-76800) fuzzy-if(appleSilicon,0-80,0-76800) fuzzy-if(winWidget,0-62,0-76799) fuzzy-if(swgl&&winWidget,0-63,0-1969) fuzzy-if(gtkWidget&&layersGPUAccelerated,0-70,0-2032) HTTP(..) == short.mp4.firstframe.html short.mp4.firstframe-ref.html
|
||||
skip-if(Android) fuzzy-if(OSX,0-87,0-76797) fuzzy-if(appleSilicon,0-87,0-76797) fuzzy-if(winWidget,0-60,0-76797) fuzzy-if(gtkWidget&&layersGPUAccelerated,0-60,0-6070) HTTP(..) == short.mp4.lastframe.html short.mp4.lastframe-ref.html
|
||||
skip-if(Android) skip-if(cocoaWidget) skip-if(winWidget) fuzzy-if(gtkWidget&&layersGPUAccelerated,0-57,0-4282) fuzzy-if(OSX,55-80,4173-4417) HTTP(..) == bipbop_300_215kbps.mp4.lastframe.html bipbop_300_215kbps.mp4.lastframe-ref.html
|
||||
skip-if(Android) fuzzy-if(OSX,0-25,0-175921) fuzzy-if(appleSilicon,34-34,40100-40100) fuzzy-if(winWidget,0-71,0-179198) HTTP(..) == gizmo.mp4.seek.html gizmo.mp4.55thframe-ref.html
|
||||
|
@ -23,6 +23,11 @@ namespace mozilla::gfx {
|
||||
|
||||
CanvasManagerParent::ManagerSet CanvasManagerParent::sManagers;
|
||||
|
||||
StaticMonitor CanvasManagerParent::sReplayTexturesMonitor;
|
||||
nsTArray<CanvasManagerParent::ReplayTexture>
|
||||
CanvasManagerParent::sReplayTextures;
|
||||
bool CanvasManagerParent::sReplayTexturesEnabled(true);
|
||||
|
||||
/* static */ void CanvasManagerParent::Init(
|
||||
Endpoint<PCanvasManagerParent>&& aEndpoint,
|
||||
layers::SharedSurfacesHolder* aSharedSurfacesHolder,
|
||||
@ -65,6 +70,10 @@ CanvasManagerParent::ManagerSet CanvasManagerParent::sManagers;
|
||||
for (auto const& actor : actors) {
|
||||
actor->Close();
|
||||
}
|
||||
|
||||
StaticMonitorAutoLock lock(sReplayTexturesMonitor);
|
||||
sReplayTextures.Clear();
|
||||
lock.NotifyAll();
|
||||
}
|
||||
|
||||
/* static */ void CanvasManagerParent::DisableRemoteCanvas() {
|
||||
@ -97,9 +106,121 @@ CanvasManagerParent::ManagerSet CanvasManagerParent::sManagers;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
StaticMonitorAutoLock lock(sReplayTexturesMonitor);
|
||||
sReplayTexturesEnabled = false;
|
||||
sReplayTextures.Clear();
|
||||
}
|
||||
|
||||
for (const auto& actor : actors) {
|
||||
Unused << NS_WARN_IF(!actor->SendDeactivate());
|
||||
}
|
||||
|
||||
{
|
||||
StaticMonitorAutoLock lock(sReplayTexturesMonitor);
|
||||
lock.NotifyAll();
|
||||
}
|
||||
}
|
||||
|
||||
/* static */ void CanvasManagerParent::AddReplayTexture(
|
||||
layers::CanvasTranslator* aOwner, int64_t aTextureId,
|
||||
layers::TextureData* aTextureData) {
|
||||
auto desc = MakeUnique<layers::SurfaceDescriptor>();
|
||||
if (!aTextureData->Serialize(*desc)) {
|
||||
MOZ_CRASH("Failed to serialize");
|
||||
}
|
||||
|
||||
StaticMonitorAutoLock lock(sReplayTexturesMonitor);
|
||||
sReplayTextures.AppendElement(
|
||||
ReplayTexture{std::move(desc), aOwner->GetContentId(), aTextureId,
|
||||
aOwner->GetManagerId()});
|
||||
lock.NotifyAll();
|
||||
}
|
||||
|
||||
/* static */ void CanvasManagerParent::RemoveReplayTexture(
|
||||
layers::CanvasTranslator* aOwner, int64_t aTextureId) {
|
||||
StaticMonitorAutoLock lock(sReplayTexturesMonitor);
|
||||
|
||||
auto i = sReplayTextures.Length();
|
||||
while (i > 0) {
|
||||
--i;
|
||||
const auto& texture = sReplayTextures[i];
|
||||
if (texture.mContentId == aOwner->GetContentId() &&
|
||||
texture.mTextureId == aTextureId) {
|
||||
MOZ_ASSERT(texture.mManagerId == aOwner->GetManagerId());
|
||||
sReplayTextures.RemoveElementAt(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* static */ void CanvasManagerParent::RemoveReplayTextures(
|
||||
layers::CanvasTranslator* aOwner) {
|
||||
StaticMonitorAutoLock lock(sReplayTexturesMonitor);
|
||||
|
||||
auto i = sReplayTextures.Length();
|
||||
while (i > 0) {
|
||||
--i;
|
||||
const auto& texture = sReplayTextures[i];
|
||||
if (texture.mContentId == aOwner->GetContentId() &&
|
||||
texture.mManagerId == aOwner->GetManagerId()) {
|
||||
sReplayTextures.RemoveElementAt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* static */ UniquePtr<layers::SurfaceDescriptor>
|
||||
CanvasManagerParent::TakeReplayTexture(const dom::ContentParentId& aContentId,
|
||||
int64_t aTextureId) {
|
||||
// While in theory this could be relatively expensive, the array is most
|
||||
// likely very small as the textures are removed during each composite.
|
||||
auto i = sReplayTextures.Length();
|
||||
while (i > 0) {
|
||||
--i;
|
||||
const auto& texture = sReplayTextures[i];
|
||||
if (texture.mContentId == aContentId && texture.mTextureId == aTextureId) {
|
||||
UniquePtr<layers::SurfaceDescriptor> desc =
|
||||
std::move(sReplayTextures[i].mDesc);
|
||||
sReplayTextures.RemoveElementAt(i);
|
||||
return desc;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* static */ UniquePtr<layers::SurfaceDescriptor>
|
||||
CanvasManagerParent::WaitForReplayTexture(layers::HostIPCAllocator* aAllocator,
|
||||
int64_t aTextureId) {
|
||||
MOZ_ASSERT(!CanvasRenderThread::IsInCanvasRenderThread());
|
||||
|
||||
StaticMonitorAutoLock lock(sReplayTexturesMonitor);
|
||||
|
||||
dom::ContentParentId contentId = aAllocator->GetContentId();
|
||||
|
||||
UniquePtr<layers::SurfaceDescriptor> desc;
|
||||
while (!(desc = TakeReplayTexture(contentId, aTextureId))) {
|
||||
if (NS_WARN_IF(!sReplayTexturesEnabled)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (NS_WARN_IF(!aAllocator->IPCOpen())) {
|
||||
// We don't know exactly which CanvasManagerParent/CanvasTranslator this
|
||||
// is for, but we do know that the allocator points to the same process.
|
||||
// Use this as a proxy to detect if the process was shutdown.
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
TimeDuration timeout = TimeDuration::FromMilliseconds(
|
||||
StaticPrefs::gfx_canvas_remote_texture_timeout_ms());
|
||||
CVStatus status = lock.Wait(timeout);
|
||||
if (status == CVStatus::Timeout) {
|
||||
// If something has gone wrong and the texture has already been destroyed,
|
||||
// it will have cleaned up its descriptor.
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
return desc;
|
||||
}
|
||||
|
||||
CanvasManagerParent::CanvasManagerParent(
|
||||
|
@ -35,6 +35,18 @@ class CanvasManagerParent final : public PCanvasManagerParent {
|
||||
|
||||
static void DisableRemoteCanvas();
|
||||
|
||||
static void AddReplayTexture(layers::CanvasTranslator* aOwner,
|
||||
int64_t aTextureId,
|
||||
layers::TextureData* aTextureData);
|
||||
|
||||
static void RemoveReplayTexture(layers::CanvasTranslator* aOwner,
|
||||
int64_t aTextureId);
|
||||
|
||||
static void RemoveReplayTextures(layers::CanvasTranslator* aOwner);
|
||||
|
||||
static UniquePtr<layers::SurfaceDescriptor> WaitForReplayTexture(
|
||||
layers::HostIPCAllocator* aAllocator, int64_t aTextureId);
|
||||
|
||||
CanvasManagerParent(layers::SharedSurfacesHolder* aSharedSurfacesHolder,
|
||||
const dom::ContentParentId& aContentId);
|
||||
|
||||
@ -52,6 +64,10 @@ class CanvasManagerParent final : public PCanvasManagerParent {
|
||||
webgl::FrontBufferSnapshotIpc* aResult);
|
||||
|
||||
private:
|
||||
static UniquePtr<layers::SurfaceDescriptor> TakeReplayTexture(
|
||||
const dom::ContentParentId& aContentId, int64_t aTextureId)
|
||||
MOZ_REQUIRES(sReplayTexturesMonitor);
|
||||
|
||||
static void ShutdownInternal();
|
||||
static void DisableRemoteCanvasInternal();
|
||||
|
||||
@ -63,6 +79,18 @@ class CanvasManagerParent final : public PCanvasManagerParent {
|
||||
|
||||
using ManagerSet = nsTHashSet<RefPtr<CanvasManagerParent>>;
|
||||
static ManagerSet sManagers;
|
||||
|
||||
struct ReplayTexture {
|
||||
UniquePtr<layers::SurfaceDescriptor> mDesc;
|
||||
dom::ContentParentId mContentId;
|
||||
int64_t mTextureId;
|
||||
uint32_t mManagerId;
|
||||
};
|
||||
|
||||
static StaticMonitor sReplayTexturesMonitor;
|
||||
static nsTArray<ReplayTexture> sReplayTextures
|
||||
MOZ_GUARDED_BY(sReplayTexturesMonitor);
|
||||
static bool sReplayTexturesEnabled MOZ_GUARDED_BY(sReplayTexturesMonitor);
|
||||
};
|
||||
|
||||
} // namespace gfx
|
||||
|
@ -68,8 +68,6 @@ class MemoryTextureData : public BufferTextureData {
|
||||
|
||||
virtual size_t GetBufferSize() override { return mBufferSize; }
|
||||
|
||||
TextureType GetTextureType() const override { return TextureType::Unknown; }
|
||||
|
||||
protected:
|
||||
uint8_t* mBuffer;
|
||||
size_t mBufferSize;
|
||||
|
@ -126,22 +126,13 @@ already_AddRefed<PersistentBufferProviderAccelerated>
|
||||
PersistentBufferProviderAccelerated::Create(gfx::IntSize aSize,
|
||||
gfx::SurfaceFormat aFormat,
|
||||
KnowsCompositor* aKnowsCompositor) {
|
||||
if (!aKnowsCompositor || !aKnowsCompositor->GetTextureForwarder() ||
|
||||
!aKnowsCompositor->GetTextureForwarder()->IPCOpen()) {
|
||||
if (!DrawTargetWebgl::CanCreate(aSize, aFormat)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!DrawTargetWebgl::CanCreate(aSize, aFormat)) {
|
||||
#ifdef XP_WIN
|
||||
// Direct2D acceleration does not require DrawTargetWebgl, but still
|
||||
// requires PersistentBufferProviderAccelerated.
|
||||
if (!TextureData::IsRemote(aKnowsCompositor, BackendSelector::Canvas,
|
||||
aFormat, aSize)) {
|
||||
return nullptr;
|
||||
}
|
||||
#else
|
||||
if (!aKnowsCompositor || !aKnowsCompositor->GetTextureForwarder() ||
|
||||
!aKnowsCompositor->GetTextureForwarder()->IPCOpen()) {
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
auto remoteTextureOwnerId = RemoteTextureOwnerId::GetNext();
|
||||
@ -270,8 +261,12 @@ PersistentBufferProviderShared::Create(gfx::IntSize aSize,
|
||||
|
||||
#ifdef XP_WIN
|
||||
// Bug 1285271 - Disable shared buffer provider on Windows with D2D due to
|
||||
// instability.
|
||||
aWillReadFrequently = true;
|
||||
// instability, unless we are remoting the canvas drawing to the GPU process.
|
||||
if (gfxPlatform::GetPlatform()->GetPreferredCanvasBackend() ==
|
||||
BackendType::DIRECT2D1_1 &&
|
||||
!TextureData::IsRemote(aKnowsCompositor, BackendSelector::Canvas)) {
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
RefPtr<TextureClient> texture =
|
||||
@ -760,5 +755,19 @@ void PersistentBufferProviderShared::Destroy() {
|
||||
mTextures.clear();
|
||||
}
|
||||
|
||||
bool PersistentBufferProviderShared::IsAccelerated() const {
|
||||
#ifdef XP_WIN
|
||||
// Detect if we're using D2D canvas.
|
||||
if (mWillReadFrequently || mTextures.empty() || !mTextures[0]) {
|
||||
return false;
|
||||
}
|
||||
auto* data = mTextures[0]->GetInternalData();
|
||||
if (data && data->AsD3D11TextureData()) {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
@ -223,6 +223,8 @@ class PersistentBufferProviderShared : public PersistentBufferProvider,
|
||||
|
||||
bool PreservesDrawingState() const override { return false; }
|
||||
|
||||
bool IsAccelerated() const override;
|
||||
|
||||
protected:
|
||||
PersistentBufferProviderShared(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
|
||||
KnowsCompositor* aKnowsCompositor,
|
||||
|
@ -70,13 +70,6 @@ void RemoteTextureOwnerClient::NotifyContextLost() {
|
||||
RemoteTextureMap::Get()->NotifyContextLost(mOwnerIds, mForPid);
|
||||
}
|
||||
|
||||
void RemoteTextureOwnerClient::NotifyContextRestored() {
|
||||
if (mOwnerIds.empty()) {
|
||||
return;
|
||||
}
|
||||
RemoteTextureMap::Get()->NotifyContextRestored(mOwnerIds, mForPid);
|
||||
}
|
||||
|
||||
void RemoteTextureOwnerClient::PushTexture(
|
||||
const RemoteTextureId aTextureId, const RemoteTextureOwnerId aOwnerId,
|
||||
UniquePtr<TextureData>&& aTextureData) {
|
||||
@ -166,19 +159,12 @@ void RemoteTextureOwnerClient::GetLatestBufferSnapshot(
|
||||
aDestShmem, aSize);
|
||||
}
|
||||
|
||||
UniquePtr<TextureData> RemoteTextureOwnerClient::GetRecycledTextureData(
|
||||
const RemoteTextureOwnerId aOwnerId, gfx::IntSize aSize,
|
||||
gfx::SurfaceFormat aFormat, TextureType aTextureType) {
|
||||
return RemoteTextureMap::Get()->GetRecycledTextureData(
|
||||
aOwnerId, mForPid, aSize, aFormat, aTextureType);
|
||||
}
|
||||
|
||||
UniquePtr<TextureData>
|
||||
RemoteTextureOwnerClient::CreateOrRecycleBufferTextureData(
|
||||
const RemoteTextureOwnerId aOwnerId, gfx::IntSize aSize,
|
||||
gfx::SurfaceFormat aFormat) {
|
||||
auto texture =
|
||||
GetRecycledTextureData(aOwnerId, aSize, aFormat, TextureType::Unknown);
|
||||
auto texture = RemoteTextureMap::Get()->GetRecycledBufferTextureData(
|
||||
aOwnerId, mForPid, aSize, aFormat);
|
||||
if (texture) {
|
||||
return texture;
|
||||
}
|
||||
@ -239,8 +225,7 @@ void RemoteTextureMap::PushTexture(
|
||||
const RemoteTextureId aTextureId, const RemoteTextureOwnerId aOwnerId,
|
||||
const base::ProcessId aForPid, UniquePtr<TextureData>&& aTextureData,
|
||||
RefPtr<TextureHost>& aTextureHost,
|
||||
UniquePtr<SharedResourceWrapper>&& aResourceWrapper,
|
||||
TextureType aRecycleType) {
|
||||
UniquePtr<SharedResourceWrapper>&& aResourceWrapper) {
|
||||
MOZ_RELEASE_ASSERT(aTextureHost);
|
||||
|
||||
std::vector<RefPtr<TextureHost>>
|
||||
@ -348,8 +333,7 @@ void RemoteTextureMap::PushTexture(
|
||||
}
|
||||
// Recycle BufferTextureData
|
||||
if (!(front->mTextureHost->GetFlags() & TextureFlags::DUMMY_TEXTURE) &&
|
||||
(front->mTextureData &&
|
||||
front->mTextureData->GetTextureType() == aRecycleType)) {
|
||||
(front->mTextureData && front->mTextureData->AsBufferTextureData())) {
|
||||
owner->mRecycledTextures.push(std::move(front->mTextureData));
|
||||
}
|
||||
owner->mReleasingTextureDataHolders.pop_front();
|
||||
@ -642,33 +626,8 @@ void RemoteTextureMap::NotifyContextLost(
|
||||
const std::unordered_set<RemoteTextureOwnerId,
|
||||
RemoteTextureOwnerId::HashFn>& aOwnerIds,
|
||||
const base::ProcessId aForPid) {
|
||||
std::vector<UniquePtr<TextureData>>
|
||||
releasingTextures; // Release outside the monitor
|
||||
{
|
||||
MonitorAutoLock lock(mMonitor);
|
||||
MonitorAutoLock lock(mMonitor);
|
||||
|
||||
for (auto id : aOwnerIds) {
|
||||
const auto key = std::pair(aForPid, id);
|
||||
auto it = mTextureOwners.find(key);
|
||||
if (it == mTextureOwners.end()) {
|
||||
MOZ_ASSERT_UNREACHABLE("unexpected to be called");
|
||||
continue;
|
||||
}
|
||||
auto& owner = it->second;
|
||||
owner->mIsContextLost = true;
|
||||
while (!owner->mRecycledTextures.empty()) {
|
||||
releasingTextures.push_back(std::move(owner->mRecycledTextures.top()));
|
||||
owner->mRecycledTextures.pop();
|
||||
}
|
||||
}
|
||||
mMonitor.Notify();
|
||||
}
|
||||
}
|
||||
|
||||
void RemoteTextureMap::NotifyContextRestored(
|
||||
const std::unordered_set<RemoteTextureOwnerId,
|
||||
RemoteTextureOwnerId::HashFn>& aOwnerIds,
|
||||
const base::ProcessId aForPid) {
|
||||
for (auto id : aOwnerIds) {
|
||||
const auto key = std::pair(aForPid, id);
|
||||
auto it = mTextureOwners.find(key);
|
||||
@ -676,9 +635,9 @@ void RemoteTextureMap::NotifyContextRestored(
|
||||
MOZ_ASSERT_UNREACHABLE("unexpected to be called");
|
||||
continue;
|
||||
}
|
||||
auto& owner = it->second;
|
||||
owner->mIsContextLost = false;
|
||||
it->second->mIsContextLost = true;
|
||||
}
|
||||
mMonitor.Notify();
|
||||
}
|
||||
|
||||
/* static */
|
||||
@ -1189,11 +1148,12 @@ void RemoteTextureMap::SuppressRemoteTextureReadyCheck(
|
||||
it->second->mReadyCheckSuppressed = true;
|
||||
}
|
||||
|
||||
UniquePtr<TextureData> RemoteTextureMap::GetRecycledTextureData(
|
||||
UniquePtr<TextureData> RemoteTextureMap::GetRecycledBufferTextureData(
|
||||
const RemoteTextureOwnerId aOwnerId, const base::ProcessId aForPid,
|
||||
gfx::IntSize aSize, gfx::SurfaceFormat aFormat, TextureType aTextureType) {
|
||||
gfx::IntSize aSize, gfx::SurfaceFormat aFormat) {
|
||||
std::stack<UniquePtr<TextureData>>
|
||||
releasingTextures; // Release outside the monitor
|
||||
UniquePtr<TextureData> texture;
|
||||
{
|
||||
MonitorAutoLock lock(mMonitor);
|
||||
|
||||
@ -1208,20 +1168,19 @@ UniquePtr<TextureData> RemoteTextureMap::GetRecycledTextureData(
|
||||
|
||||
if (!owner->mRecycledTextures.empty()) {
|
||||
auto& top = owner->mRecycledTextures.top();
|
||||
if (top->GetTextureType() == aTextureType) {
|
||||
TextureData::Info info;
|
||||
top->FillInfo(info);
|
||||
if (info.size == aSize && info.format == aFormat) {
|
||||
UniquePtr<TextureData> texture = std::move(top);
|
||||
owner->mRecycledTextures.pop();
|
||||
return texture;
|
||||
}
|
||||
auto* bufferTexture = top->AsBufferTextureData();
|
||||
|
||||
if (bufferTexture && bufferTexture->GetSize() == aSize &&
|
||||
bufferTexture->GetFormat() == aFormat) {
|
||||
texture = std::move(top);
|
||||
owner->mRecycledTextures.pop();
|
||||
} else {
|
||||
// If size or format are different, release all textures.
|
||||
owner->mRecycledTextures.swap(releasingTextures);
|
||||
}
|
||||
// If size or format are different, release all textures.
|
||||
owner->mRecycledTextures.swap(releasingTextures);
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
return texture;
|
||||
}
|
||||
|
||||
UniquePtr<SharedResourceWrapper> RemoteTextureMap::GetRecycledSharedTexture(
|
||||
|
@ -126,7 +126,6 @@ class RemoteTextureOwnerClient final {
|
||||
void UnregisterTextureOwner(const RemoteTextureOwnerId aOwnerId);
|
||||
void UnregisterAllTextureOwners();
|
||||
void NotifyContextLost();
|
||||
void NotifyContextRestored();
|
||||
void PushTexture(const RemoteTextureId aTextureId,
|
||||
const RemoteTextureOwnerId aOwnerId,
|
||||
UniquePtr<TextureData>&& aTextureData);
|
||||
@ -143,9 +142,6 @@ class RemoteTextureOwnerClient final {
|
||||
void GetLatestBufferSnapshot(const RemoteTextureOwnerId aOwnerId,
|
||||
const mozilla::ipc::Shmem& aDestShmem,
|
||||
const gfx::IntSize& aSize);
|
||||
UniquePtr<TextureData> GetRecycledTextureData(
|
||||
const RemoteTextureOwnerId aOwnerId, gfx::IntSize aSize,
|
||||
gfx::SurfaceFormat aFormat, TextureType aTextureType);
|
||||
UniquePtr<TextureData> CreateOrRecycleBufferTextureData(
|
||||
const RemoteTextureOwnerId aOwnerId, gfx::IntSize aSize,
|
||||
gfx::SurfaceFormat aFormat);
|
||||
@ -186,8 +182,7 @@ class RemoteTextureMap {
|
||||
const base::ProcessId aForPid,
|
||||
UniquePtr<TextureData>&& aTextureData,
|
||||
RefPtr<TextureHost>& aTextureHost,
|
||||
UniquePtr<SharedResourceWrapper>&& aResourceWrapper,
|
||||
TextureType aRecycleType = TextureType::Unknown);
|
||||
UniquePtr<SharedResourceWrapper>&& aResourceWrapper);
|
||||
|
||||
// Remove waiting texture that will not be used.
|
||||
bool RemoveTexture(const RemoteTextureId aTextureId,
|
||||
@ -214,10 +209,6 @@ class RemoteTextureMap {
|
||||
const std::unordered_set<RemoteTextureOwnerId,
|
||||
RemoteTextureOwnerId::HashFn>& aOwnerIds,
|
||||
const base::ProcessId aForPid);
|
||||
void NotifyContextRestored(
|
||||
const std::unordered_set<RemoteTextureOwnerId,
|
||||
RemoteTextureOwnerId::HashFn>& aOwnerIds,
|
||||
const base::ProcessId aForPid);
|
||||
|
||||
// Get TextureHost that is used for building wr display list.
|
||||
// In sync mode, mRemoteTextureForDisplayList holds TextureHost of mTextureId.
|
||||
@ -264,9 +255,9 @@ class RemoteTextureMap {
|
||||
void SuppressRemoteTextureReadyCheck(const RemoteTextureId aTextureId,
|
||||
const base::ProcessId aForPid);
|
||||
|
||||
UniquePtr<TextureData> GetRecycledTextureData(
|
||||
UniquePtr<TextureData> GetRecycledBufferTextureData(
|
||||
const RemoteTextureOwnerId aOwnerId, const base::ProcessId aForPid,
|
||||
gfx::IntSize aSize, gfx::SurfaceFormat aFormat, TextureType aTextureType);
|
||||
gfx::IntSize aSize, gfx::SurfaceFormat aFormat);
|
||||
|
||||
UniquePtr<SharedResourceWrapper> GetRecycledSharedTexture(
|
||||
const RemoteTextureOwnerId aOwnerId, const base::ProcessId aForPid);
|
||||
|
@ -252,11 +252,11 @@ static inline gfx::BackendType BackendTypeForBackendSelector(
|
||||
}
|
||||
};
|
||||
|
||||
static TextureType ChooseTextureType(gfx::SurfaceFormat aFormat,
|
||||
gfx::IntSize aSize,
|
||||
KnowsCompositor* aKnowsCompositor,
|
||||
BackendSelector aSelector,
|
||||
TextureAllocationFlags aAllocFlags) {
|
||||
static TextureType GetTextureType(gfx::SurfaceFormat aFormat,
|
||||
gfx::IntSize aSize,
|
||||
KnowsCompositor* aKnowsCompositor,
|
||||
BackendSelector aSelector,
|
||||
TextureAllocationFlags aAllocFlags) {
|
||||
LayersBackend layersBackend = aKnowsCompositor->GetCompositorBackendType();
|
||||
gfx::BackendType moz2DBackend =
|
||||
BackendTypeForBackendSelector(layersBackend, aSelector);
|
||||
@ -299,9 +299,23 @@ static TextureType ChooseTextureType(gfx::SurfaceFormat aFormat,
|
||||
}
|
||||
|
||||
TextureType PreferredCanvasTextureType(KnowsCompositor* aKnowsCompositor) {
|
||||
return ChooseTextureType(gfx::SurfaceFormat::R8G8B8A8, {1, 1},
|
||||
aKnowsCompositor, BackendSelector::Canvas,
|
||||
TextureAllocationFlags::ALLOC_DEFAULT);
|
||||
return GetTextureType(gfx::SurfaceFormat::R8G8B8A8, {1, 1}, aKnowsCompositor,
|
||||
BackendSelector::Canvas,
|
||||
TextureAllocationFlags::ALLOC_DEFAULT);
|
||||
}
|
||||
|
||||
static bool ShouldRemoteTextureType(TextureType aTextureType,
|
||||
BackendSelector aSelector) {
|
||||
if (aSelector != BackendSelector::Canvas || !gfxPlatform::UseRemoteCanvas()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (aTextureType) {
|
||||
case TextureType::D3D11:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* static */
|
||||
@ -341,18 +355,25 @@ TextureData* TextureData::Create(TextureForwarder* aAllocator,
|
||||
BackendSelector aSelector,
|
||||
TextureFlags aTextureFlags,
|
||||
TextureAllocationFlags aAllocFlags) {
|
||||
TextureType textureType = ChooseTextureType(aFormat, aSize, aKnowsCompositor,
|
||||
aSelector, aAllocFlags);
|
||||
TextureType textureType =
|
||||
GetTextureType(aFormat, aSize, aKnowsCompositor, aSelector, aAllocFlags);
|
||||
|
||||
if (aAllocFlags & ALLOC_FORCE_REMOTE) {
|
||||
if ((aAllocFlags & ALLOC_FORCE_REMOTE) ||
|
||||
ShouldRemoteTextureType(textureType, aSelector)) {
|
||||
RefPtr<CanvasChild> canvasChild = aAllocator->GetCanvasChild();
|
||||
if (canvasChild) {
|
||||
return new RecordedTextureData(canvasChild.forget(), aSize, aFormat,
|
||||
textureType);
|
||||
}
|
||||
// If we must be remote, but there is no canvas child, then falling back
|
||||
// is not possible.
|
||||
return nullptr;
|
||||
if (aAllocFlags & ALLOC_FORCE_REMOTE) {
|
||||
// If we must be remote, but there is no canvas child, then falling back
|
||||
// is not possible.
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// We don't have a CanvasChild, but are supposed to be remote.
|
||||
// Fall back to software.
|
||||
textureType = TextureType::Unknown;
|
||||
}
|
||||
|
||||
gfx::BackendType moz2DBackend = gfx::BackendType::NONE;
|
||||
@ -368,22 +389,12 @@ TextureData* TextureData::Create(TextureForwarder* aAllocator,
|
||||
|
||||
/* static */
|
||||
bool TextureData::IsRemote(KnowsCompositor* aKnowsCompositor,
|
||||
BackendSelector aSelector,
|
||||
gfx::SurfaceFormat aFormat, gfx::IntSize aSize) {
|
||||
if (aSelector != BackendSelector::Canvas || !gfxPlatform::UseRemoteCanvas()) {
|
||||
return false;
|
||||
}
|
||||
BackendSelector aSelector) {
|
||||
TextureType textureType = GetTextureType(
|
||||
gfx::SurfaceFormat::UNKNOWN, gfx::IntSize(1, 1), aKnowsCompositor,
|
||||
aSelector, TextureAllocationFlags::ALLOC_DEFAULT);
|
||||
|
||||
TextureType textureType =
|
||||
ChooseTextureType(aFormat, aSize, aKnowsCompositor, aSelector,
|
||||
TextureAllocationFlags::ALLOC_DEFAULT);
|
||||
|
||||
switch (textureType) {
|
||||
case TextureType::D3D11:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return ShouldRemoteTextureType(textureType, aSelector);
|
||||
}
|
||||
|
||||
static void DestroyTextureData(TextureData* aTextureData,
|
||||
|
@ -239,14 +239,10 @@ class TextureData {
|
||||
TextureAllocationFlags aAllocFlags);
|
||||
|
||||
static bool IsRemote(KnowsCompositor* aKnowsCompositor,
|
||||
BackendSelector aSelector,
|
||||
gfx::SurfaceFormat aFormat = gfx::SurfaceFormat::UNKNOWN,
|
||||
gfx::IntSize aSize = gfx::IntSize(1, 1));
|
||||
BackendSelector aSelector);
|
||||
|
||||
MOZ_COUNTED_DTOR_VIRTUAL(TextureData)
|
||||
|
||||
virtual TextureType GetTextureType() const { return TextureType::Last; }
|
||||
|
||||
virtual void FillInfo(TextureData::Info& aInfo) const = 0;
|
||||
|
||||
virtual bool Lock(OpenMode aMode) = 0;
|
||||
|
@ -51,22 +51,19 @@ bool RecordedTextureData::Lock(OpenMode aMode) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!mRemoteTextureOwnerId.IsValid()) {
|
||||
MOZ_ASSERT(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
// By the time we allocate a new remote texture id, the previous texture id
|
||||
// should have been used. Since we're overwriting its id, if it hasn't been
|
||||
// used yet, then it is safe to preemptively remove it since nothing can
|
||||
// actually composite it. This prevents accumulation of a series of canvas
|
||||
// frames that never get shown.
|
||||
RemoteTextureId obsoleteRemoteTextureId;
|
||||
if (!mUsedRemoteTexture) {
|
||||
obsoleteRemoteTextureId = mLastRemoteTextureId;
|
||||
if (mRemoteTextureOwnerId.IsValid()) {
|
||||
// By the time we allocate a new remote texture id, the previous texture id
|
||||
// should have been used. Since we're overwriting its id, if it hasn't been
|
||||
// used yet, then it is safe to preemptively remove it since nothing can
|
||||
// actually composite it. This prevents accumulation of a series of canvas
|
||||
// frames that never get shown.
|
||||
if (!mUsedRemoteTexture) {
|
||||
obsoleteRemoteTextureId = mLastRemoteTextureId;
|
||||
}
|
||||
mLastRemoteTextureId = RemoteTextureId::GetNext();
|
||||
mUsedRemoteTexture = false;
|
||||
}
|
||||
mLastRemoteTextureId = RemoteTextureId::GetNext();
|
||||
mUsedRemoteTexture = false;
|
||||
|
||||
if (!mDT) {
|
||||
mTextureId = sNextRecordedTextureId++;
|
||||
@ -153,14 +150,14 @@ void RecordedTextureData::ReturnSnapshot(
|
||||
void RecordedTextureData::Deallocate(LayersIPCChannel* aAllocator) {}
|
||||
|
||||
bool RecordedTextureData::Serialize(SurfaceDescriptor& aDescriptor) {
|
||||
if (!mRemoteTextureOwnerId.IsValid() || !mLastRemoteTextureId.IsValid()) {
|
||||
MOZ_ASSERT_UNREACHABLE("Missing remote texture ids!");
|
||||
return false;
|
||||
if (mRemoteTextureOwnerId.IsValid()) {
|
||||
aDescriptor = SurfaceDescriptorRemoteTexture(mLastRemoteTextureId,
|
||||
mRemoteTextureOwnerId);
|
||||
// If something is querying the id, assume it is going to be composited.
|
||||
mUsedRemoteTexture = true;
|
||||
} else {
|
||||
aDescriptor = SurfaceDescriptorRecorded(mTextureId);
|
||||
}
|
||||
aDescriptor = SurfaceDescriptorRemoteTexture(mLastRemoteTextureId,
|
||||
mRemoteTextureOwnerId);
|
||||
// If something is querying the id, assume it is going to be composited.
|
||||
mUsedRemoteTexture = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -232,6 +232,32 @@ already_AddRefed<TextureHost> TextureHost::Create(
|
||||
break;
|
||||
# endif
|
||||
#endif
|
||||
case SurfaceDescriptor::TSurfaceDescriptorRecorded: {
|
||||
const SurfaceDescriptorRecorded& desc =
|
||||
aDesc.get_SurfaceDescriptorRecorded();
|
||||
if (NS_WARN_IF(!aDeallocator)) {
|
||||
gfxCriticalNote
|
||||
<< "Missing allocator to get descriptor for recorded texture.";
|
||||
// Create a dummy to prevent any crashes due to missing IPDL actors.
|
||||
result = CreateDummyBufferTextureHost(aBackend, aFlags);
|
||||
break;
|
||||
}
|
||||
|
||||
UniquePtr<SurfaceDescriptor> realDesc =
|
||||
gfx::CanvasManagerParent::WaitForReplayTexture(aDeallocator,
|
||||
desc.textureId());
|
||||
if (!realDesc) {
|
||||
gfxCriticalNote << "Failed to get descriptor for recorded texture.";
|
||||
// Create a dummy to prevent any crashes due to missing IPDL actors.
|
||||
result = CreateDummyBufferTextureHost(aBackend, aFlags);
|
||||
break;
|
||||
}
|
||||
|
||||
result =
|
||||
TextureHost::Create(*realDesc, std::move(aReadLock), aDeallocator,
|
||||
aBackend, aFlags, aExternalImageId);
|
||||
return result.forget();
|
||||
}
|
||||
default:
|
||||
MOZ_CRASH("GFX: Unsupported Surface type host");
|
||||
}
|
||||
|
@ -99,8 +99,6 @@ class D3D11TextureData final : public TextureData {
|
||||
return mAllocationFlags;
|
||||
}
|
||||
|
||||
TextureType GetTextureType() const override { return TextureType::D3D11; }
|
||||
|
||||
void FillInfo(TextureData::Info& aInfo) const override;
|
||||
|
||||
bool Serialize(SurfaceDescriptor& aOutDescrptor) override;
|
||||
|
@ -38,18 +38,13 @@ namespace layers {
|
||||
TextureData* CanvasTranslator::CreateTextureData(TextureType aTextureType,
|
||||
gfx::BackendType aBackendType,
|
||||
const gfx::IntSize& aSize,
|
||||
gfx::SurfaceFormat aFormat,
|
||||
bool aClear) {
|
||||
gfx::SurfaceFormat aFormat) {
|
||||
TextureData* textureData = nullptr;
|
||||
TextureAllocationFlags allocFlags =
|
||||
aClear ? ALLOC_CLEAR_BUFFER : ALLOC_DEFAULT;
|
||||
switch (aTextureType) {
|
||||
#ifdef XP_WIN
|
||||
case TextureType::D3D11: {
|
||||
allocFlags =
|
||||
TextureAllocationFlags(allocFlags | ALLOC_MANUAL_SYNCHRONIZATION);
|
||||
textureData =
|
||||
D3D11TextureData::Create(aSize, aFormat, allocFlags, mDevice);
|
||||
D3D11TextureData::Create(aSize, aFormat, ALLOC_CLEAR_BUFFER, mDevice);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
@ -57,11 +52,11 @@ TextureData* CanvasTranslator::CreateTextureData(TextureType aTextureType,
|
||||
textureData = BufferTextureData::Create(
|
||||
aSize, aFormat, gfx::BackendType::SKIA, LayersBackend::LAYERS_WR,
|
||||
TextureFlags::DEALLOCATE_CLIENT | TextureFlags::REMOTE_TEXTURE,
|
||||
allocFlags, nullptr);
|
||||
ALLOC_CLEAR_BUFFER, nullptr);
|
||||
break;
|
||||
default:
|
||||
textureData = TextureData::Create(aTextureType, aFormat, aSize,
|
||||
allocFlags, aBackendType);
|
||||
ALLOC_CLEAR_BUFFER, aBackendType);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -355,6 +350,8 @@ void CanvasTranslator::FinishShutdown() {
|
||||
MOZ_ASSERT(gfx::CanvasRenderThread::IsInCanvasRenderThread());
|
||||
|
||||
ClearTextureInfo();
|
||||
|
||||
gfx::CanvasManagerParent::RemoveReplayTextures(this);
|
||||
}
|
||||
|
||||
bool CanvasTranslator::CheckDeactivated() {
|
||||
@ -383,6 +380,13 @@ void CanvasTranslator::Deactivate() {
|
||||
NewRunnableMethod("CanvasTranslator::SendDeactivate", this,
|
||||
&CanvasTranslator::SendDeactivate));
|
||||
|
||||
// Unlock all of our textures.
|
||||
for (auto const& entry : mTextureInfo) {
|
||||
if (entry.second.mTextureData && entry.second.mTextureLocked) {
|
||||
entry.second.mTextureData->Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
// Disable remote canvas for all.
|
||||
gfx::CanvasManagerParent::DisableRemoteCanvas();
|
||||
}
|
||||
@ -588,12 +592,13 @@ void CanvasTranslator::EndTransaction() {
|
||||
|
||||
void CanvasTranslator::DeviceChangeAcknowledged() {
|
||||
mDeviceResetInProgress = false;
|
||||
if (mRemoteTextureOwner) {
|
||||
mRemoteTextureOwner->NotifyContextRestored();
|
||||
}
|
||||
}
|
||||
|
||||
bool CanvasTranslator::CreateReferenceTexture() {
|
||||
if (mReferenceTextureData) {
|
||||
mReferenceTextureData->Unlock();
|
||||
}
|
||||
|
||||
mReferenceTextureData.reset(CreateTextureData(mTextureType, mBackendType,
|
||||
gfx::IntSize(1, 1),
|
||||
gfx::SurfaceFormat::B8G8R8A8));
|
||||
@ -601,6 +606,12 @@ bool CanvasTranslator::CreateReferenceTexture() {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (NS_WARN_IF(!mReferenceTextureData->Lock(OpenMode::OPEN_READ_WRITE))) {
|
||||
gfxCriticalNote << "CanvasTranslator::CreateReferenceTexture lock failed";
|
||||
mReferenceTextureData.reset();
|
||||
return false;
|
||||
}
|
||||
|
||||
mBaseDT = mReferenceTextureData->BorrowDrawTarget();
|
||||
|
||||
if (!mBaseDT) {
|
||||
@ -664,10 +675,6 @@ bool CanvasTranslator::CheckForFreshCanvasDevice(int aLineNumber) {
|
||||
}
|
||||
|
||||
void CanvasTranslator::NotifyDeviceChanged() {
|
||||
// Clear out any old recycled texture datas with the wrong device.
|
||||
if (mRemoteTextureOwner) {
|
||||
mRemoteTextureOwner->NotifyContextLost();
|
||||
}
|
||||
mDeviceResetInProgress = true;
|
||||
gfx::CanvasRenderThread::Dispatch(
|
||||
NewRunnableMethod("CanvasTranslator::SendNotifyDeviceChanged", this,
|
||||
@ -736,8 +743,7 @@ already_AddRefed<gfx::DrawTarget> CanvasTranslator::CreateDrawTarget(
|
||||
gfx::SurfaceFormat aFormat) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(mNextTextureId >= 0, "No texture ID set");
|
||||
RefPtr<gfx::DrawTarget> dt;
|
||||
if (mNextRemoteTextureOwnerId.IsValid() &&
|
||||
gfx::gfxVars::UseAcceleratedCanvas2D()) {
|
||||
if (mNextRemoteTextureOwnerId.IsValid()) {
|
||||
if (EnsureSharedContextWebgl()) {
|
||||
mSharedContext->EnterTlsScope();
|
||||
}
|
||||
@ -765,13 +771,20 @@ already_AddRefed<gfx::DrawTarget> CanvasTranslator::CreateDrawTarget(
|
||||
continue;
|
||||
}
|
||||
|
||||
if (NS_WARN_IF(!textureData->Lock(OpenMode::OPEN_READ_WRITE))) {
|
||||
gfxCriticalNote << "CanvasTranslator::CreateDrawTarget lock failed";
|
||||
continue;
|
||||
}
|
||||
|
||||
dt = textureData->BorrowDrawTarget();
|
||||
if (NS_WARN_IF(!dt)) {
|
||||
textureData->Unlock();
|
||||
continue;
|
||||
}
|
||||
|
||||
TextureInfo& info = mTextureInfo[mNextTextureId];
|
||||
info.mTextureData = std::move(textureData);
|
||||
info.mTextureLocked = true;
|
||||
info.mRemoteTextureOwnerId = mNextRemoteTextureOwnerId;
|
||||
} while (!dt && CheckForFreshCanvasDevice(__LINE__));
|
||||
}
|
||||
@ -784,12 +797,18 @@ already_AddRefed<gfx::DrawTarget> CanvasTranslator::CreateDrawTarget(
|
||||
}
|
||||
|
||||
void CanvasTranslator::RemoveTexture(int64_t aTextureId) {
|
||||
// Don't erase the texture if still in use
|
||||
auto result = mTextureInfo.find(aTextureId);
|
||||
if (result == mTextureInfo.end() || --result->second.mLocked > 0) {
|
||||
return;
|
||||
{
|
||||
// Don't erase the texture if still in use
|
||||
auto result = mTextureInfo.find(aTextureId);
|
||||
if (result == mTextureInfo.end() || --result->second.mLocked > 0) {
|
||||
return;
|
||||
}
|
||||
mTextureInfo.erase(result);
|
||||
}
|
||||
mTextureInfo.erase(result);
|
||||
|
||||
// It is possible that the texture from the content process has never been
|
||||
// forwarded from the GPU process, so make sure its descriptor is removed.
|
||||
gfx::CanvasManagerParent::RemoveReplayTexture(this, aTextureId);
|
||||
}
|
||||
|
||||
bool CanvasTranslator::LockTexture(int64_t aTextureId, OpenMode aMode,
|
||||
@ -808,8 +827,18 @@ bool CanvasTranslator::LockTexture(int64_t aTextureId, OpenMode aMode,
|
||||
gfx::DrawTargetWebgl* webgl =
|
||||
static_cast<gfx::DrawTargetWebgl*>(result->second.mDrawTarget.get());
|
||||
webgl->BeginFrame(webgl->GetRect());
|
||||
} else if (!result->second.mTextureData) {
|
||||
return false;
|
||||
} else if (TextureData* data = result->second.mTextureData.get()) {
|
||||
if (NS_WARN_IF(result->second.mTextureLocked)) {
|
||||
MOZ_ASSERT_UNREACHABLE("Texture already locked?");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool locked = data->Lock(aMode);
|
||||
if (NS_WARN_IF(!locked)) {
|
||||
gfxCriticalNote << "CanvasTranslator::LockTexture lock failed";
|
||||
}
|
||||
result->second.mTextureLocked = locked;
|
||||
return locked;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -831,12 +860,23 @@ bool CanvasTranslator::UnlockTexture(int64_t aTextureId, RemoteTextureId aId) {
|
||||
NotifyRequiresRefresh(aTextureId);
|
||||
}
|
||||
} else if (TextureData* data = result->second.mTextureData.get()) {
|
||||
PushRemoteTexture(aTextureId, data, aId, ownerId);
|
||||
if (aId.IsValid()) {
|
||||
PushRemoteTexture(data, aId, ownerId);
|
||||
}
|
||||
if (!NS_WARN_IF(!result->second.mTextureLocked)) {
|
||||
data->Unlock();
|
||||
result->second.mTextureLocked = false;
|
||||
} else {
|
||||
MOZ_ASSERT_UNREACHABLE("Texture not locked?");
|
||||
}
|
||||
if (!aId.IsValid()) {
|
||||
gfx::CanvasManagerParent::AddReplayTexture(this, aTextureId, data);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CanvasTranslator::PushRemoteTexture(int64_t aTextureId, TextureData* aData,
|
||||
bool CanvasTranslator::PushRemoteTexture(TextureData* aData,
|
||||
RemoteTextureId aId,
|
||||
RemoteTextureOwnerId aOwnerId) {
|
||||
if (!mRemoteTextureOwner) {
|
||||
@ -847,34 +887,32 @@ bool CanvasTranslator::PushRemoteTexture(int64_t aTextureId, TextureData* aData,
|
||||
aOwnerId,
|
||||
/* aIsSyncMode */ gfx::gfxVars::WebglOopAsyncPresentForceSync());
|
||||
}
|
||||
TextureData::Info info;
|
||||
aData->FillInfo(info);
|
||||
UniquePtr<TextureData> dstData;
|
||||
if (!mDeviceResetInProgress) {
|
||||
TextureData::Info info;
|
||||
aData->FillInfo(info);
|
||||
if (mTextureType == TextureType::Unknown) {
|
||||
dstData = mRemoteTextureOwner->CreateOrRecycleBufferTextureData(
|
||||
aOwnerId, info.size, info.format);
|
||||
} else {
|
||||
dstData = mRemoteTextureOwner->GetRecycledTextureData(
|
||||
aOwnerId, info.size, info.format, mTextureType);
|
||||
if (!dstData) {
|
||||
dstData.reset(CreateTextureData(mTextureType, mBackendType, info.size,
|
||||
info.format, false));
|
||||
}
|
||||
}
|
||||
if (mTextureType == TextureType::Unknown) {
|
||||
dstData = mRemoteTextureOwner->CreateOrRecycleBufferTextureData(
|
||||
aOwnerId, info.size, info.format);
|
||||
} else {
|
||||
dstData.reset(
|
||||
CreateTextureData(mTextureType, mBackendType, info.size, info.format));
|
||||
}
|
||||
bool success = false;
|
||||
// Source data is already locked.
|
||||
if (dstData) {
|
||||
if (RefPtr<gfx::DrawTarget> dstDT = dstData->BorrowDrawTarget()) {
|
||||
if (RefPtr<gfx::DrawTarget> srcDT = aData->BorrowDrawTarget()) {
|
||||
if (RefPtr<gfx::SourceSurface> snapshot = srcDT->Snapshot()) {
|
||||
dstDT->CopySurface(snapshot, snapshot->GetRect(),
|
||||
gfx::IntPoint(0, 0));
|
||||
dstDT->Flush();
|
||||
success = true;
|
||||
if (dstData->Lock(OpenMode::OPEN_WRITE)) {
|
||||
if (RefPtr<gfx::DrawTarget> dstDT = dstData->BorrowDrawTarget()) {
|
||||
if (RefPtr<gfx::DrawTarget> srcDT = aData->BorrowDrawTarget()) {
|
||||
if (RefPtr<gfx::SourceSurface> snapshot = srcDT->Snapshot()) {
|
||||
dstDT->CopySurface(snapshot, snapshot->GetRect(),
|
||||
gfx::IntPoint(0, 0));
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
dstData->Unlock();
|
||||
} else {
|
||||
gfxCriticalNote << "CanvasTranslator::PushRemoteTexture lock failed";
|
||||
}
|
||||
}
|
||||
if (success) {
|
||||
@ -886,10 +924,18 @@ bool CanvasTranslator::PushRemoteTexture(int64_t aTextureId, TextureData* aData,
|
||||
}
|
||||
|
||||
void CanvasTranslator::ClearTextureInfo() {
|
||||
for (auto const& entry : mTextureInfo) {
|
||||
if (entry.second.mTextureData && entry.second.mTextureLocked) {
|
||||
entry.second.mTextureData->Unlock();
|
||||
}
|
||||
}
|
||||
mTextureInfo.clear();
|
||||
mDrawTargets.Clear();
|
||||
mSharedContext = nullptr;
|
||||
mBaseDT = nullptr;
|
||||
if (mReferenceTextureData) {
|
||||
mReferenceTextureData->Unlock();
|
||||
}
|
||||
if (mRemoteTextureOwner) {
|
||||
mRemoteTextureOwner->UnregisterAllTextureOwners();
|
||||
mRemoteTextureOwner = nullptr;
|
||||
|
@ -177,8 +177,8 @@ class CanvasTranslator final : public gfx::InlineTranslator,
|
||||
RemoteTextureId aObsoleteId = RemoteTextureId());
|
||||
bool UnlockTexture(int64_t aTextureId, RemoteTextureId aId);
|
||||
|
||||
bool PushRemoteTexture(int64_t aTextureId, TextureData* aData,
|
||||
RemoteTextureId aId, RemoteTextureOwnerId aOwnerId);
|
||||
bool PushRemoteTexture(TextureData* aData, RemoteTextureId aId,
|
||||
RemoteTextureOwnerId aOwnerId);
|
||||
|
||||
/**
|
||||
* Overriden to remove any DataSourceSurfaces associated with the RefPtr.
|
||||
@ -293,8 +293,7 @@ class CanvasTranslator final : public gfx::InlineTranslator,
|
||||
TextureData* CreateTextureData(TextureType aTextureType,
|
||||
gfx::BackendType aBackendType,
|
||||
const gfx::IntSize& aSize,
|
||||
gfx::SurfaceFormat aFormat,
|
||||
bool aClear = false);
|
||||
gfx::SurfaceFormat aFormat);
|
||||
|
||||
void ClearTextureInfo();
|
||||
|
||||
@ -352,6 +351,7 @@ class CanvasTranslator final : public gfx::InlineTranslator,
|
||||
UniquePtr<TextureData> mTextureData;
|
||||
RefPtr<gfx::DrawTarget> mDrawTarget;
|
||||
RemoteTextureOwnerId mRemoteTextureOwnerId;
|
||||
bool mTextureLocked = false;
|
||||
bool mNotifiedRequiresRefresh = false;
|
||||
// Ref-count of how active uses of the DT. Avoids deletion when locked.
|
||||
int32_t mLocked = 1;
|
||||
|
@ -189,6 +189,10 @@ namespace layers {
|
||||
ExternalImageId id;
|
||||
};
|
||||
|
||||
[Comparable] struct SurfaceDescriptorRecorded {
|
||||
int64_t textureId;
|
||||
};
|
||||
|
||||
[Comparable] struct SurfaceDescriptorRemoteTexture {
|
||||
RemoteTextureId textureId;
|
||||
RemoteTextureOwnerId ownerId;
|
||||
@ -205,6 +209,7 @@ namespace layers {
|
||||
SurfaceDescriptorMacIOSurface;
|
||||
SurfaceDescriptorSharedGLTexture;
|
||||
SurfaceDescriptorGPUVideo;
|
||||
SurfaceDescriptorRecorded;
|
||||
SurfaceDescriptorRemoteTexture;
|
||||
SurfaceDescriptorDcompSurface;
|
||||
SurfaceDescriptorExternalImage;
|
||||
|
@ -32,8 +32,6 @@ class DMABUFTextureData : public TextureData {
|
||||
TextureFlags aFlags = TextureFlags::DEFAULT,
|
||||
TextureAllocationFlags aAllocFlags = ALLOC_DEFAULT) const override;
|
||||
|
||||
TextureType GetTextureType() const override { return TextureType::DMABUF; }
|
||||
|
||||
void FillInfo(TextureData::Info& aInfo) const override;
|
||||
|
||||
bool Lock(OpenMode) override;
|
||||
|
@ -25,10 +25,6 @@ class MacIOSurfaceTextureData : public TextureData {
|
||||
|
||||
~MacIOSurfaceTextureData();
|
||||
|
||||
TextureType GetTextureType() const override {
|
||||
return TextureType::MacIOSurface;
|
||||
}
|
||||
|
||||
void FillInfo(TextureData::Info& aInfo) const override;
|
||||
|
||||
bool Lock(OpenMode) override;
|
||||
|
@ -78,10 +78,6 @@ class AndroidNativeWindowTextureData : public TextureData {
|
||||
static AndroidNativeWindowTextureData* Create(gfx::IntSize aSize,
|
||||
gfx::SurfaceFormat aFormat);
|
||||
|
||||
TextureType GetTextureType() const override {
|
||||
return TextureType::AndroidNativeWindow;
|
||||
}
|
||||
|
||||
void FillInfo(TextureData::Info& aInfo) const override;
|
||||
|
||||
bool Serialize(SurfaceDescriptor& aOutDescriptor) override;
|
||||
|
@ -122,4 +122,4 @@ random-if(cocoaWidget) == subsuper-nofallback.html subsuper-nofallback-ref2.html
|
||||
== subsuper-fallback-size.html subsuper-fallback-size-ref.html
|
||||
|
||||
# GPOS spacing adjustments in vertical mode -- subsetted opentype/cff test font fails to load on Win7
|
||||
fuzzy-if(winWidget,0-1,0-70) == 1376231-vertical-gpos-adjustments.html 1376231-vertical-gpos-adjustments-ref.html
|
||||
fuzzy-if(winWidget&&!swgl,0-1,0-70) == 1376231-vertical-gpos-adjustments.html 1376231-vertical-gpos-adjustments-ref.html
|
||||
|
@ -24,12 +24,21 @@ skip-if(!asyncPan) != pull-background-displayport-5.html about:blank
|
||||
skip-if(!asyncPan) != pull-background-displayport-6.html about:blank # fails with non-overlay scrollbars and event regions due to bug 1148515
|
||||
|
||||
skip-if(Android&&emulator) fuzzy(0-2,0-30150) == opacity-blending.html opacity-blending-ref.html
|
||||
fuzzy(0-16,0-30) == mask-layer-transform.html mask-layer-transform-ref.html
|
||||
fuzzy(0-16,0-29) == mask-layer-transform.html mask-layer-transform-ref.html
|
||||
fuzzy-if(gtkWidget,0-1,0-17) fuzzy-if(Android,0-3,0-4) == forced-bg-color-outside-visible-region.html forced-bg-color-outside-visible-region-ref.html
|
||||
!= layerize-over-fixed-bg-1.html about:blank
|
||||
skip-if(!asyncPan) != fixed-pos-scrolled-clip-layerize.html about:blank
|
||||
skip-if(!asyncPan) == fixed-pos-scrolled-clip-opacity-layerize.html fixed-pos-scrolled-clip-opacity-inside-layerize.html
|
||||
|
||||
# These tests check whether the GPU process is working. We expect it to work if:
|
||||
# E10S is enabled, and
|
||||
# Direct2D 1.1 works (as a proxy for Windows 7 SP1 + Platform Update or higher), OR
|
||||
# The GPU process has been forced on.
|
||||
# If these conditions are met, but the GPU process is not on, these tests will turn on
|
||||
# and compare false.
|
||||
skip-if(!browserIsRemote||!d2d||gpuProcess) == data:text/plain,FAIL about:blank
|
||||
skip-if(!gpuProcessForceEnabled||gpuProcess) == data:text/plain,FAIL about:blank
|
||||
|
||||
fuzzy(0-1,0-8033) == opacity-background-1.html opacity-background-1-ref.html
|
||||
== opacity-flattening-large-image.html opacity-flattening-large-image-ref.html
|
||||
|
||||
|
@ -40,7 +40,7 @@ fuzzy-if(Android,0-4,0-810) == containing-block-1.html containing-block-1-ref.ht
|
||||
== inline-1.html inline-1-ref.html
|
||||
== inline-2.html inline-2-ref.html
|
||||
fuzzy-if(OSX,0-99,0-210) == inline-3.html inline-3-ref.html
|
||||
skip-if(!asyncPan) fuzzy-if(swgl&&!Android,0-1,0-3) fails-if(useDrawSnapshot) == inline-4.html inline-4-ref.html
|
||||
skip-if(!asyncPan) fuzzy-if(swgl&&!Android,1-1,2-3) fails-if(useDrawSnapshot) == inline-4.html inline-4-ref.html
|
||||
== column-contain-1a.html column-contain-1-ref.html
|
||||
== column-contain-1b.html column-contain-1-ref.html
|
||||
== column-contain-2.html column-contain-2-ref.html
|
||||
|
@ -415,7 +415,7 @@ fuzzy(0-27,0-9058) fuzzy-if(Android,0-28,0-11159) == pattern-transformed-02.svg
|
||||
|
||||
== radialGradient-basic-01.svg pass.svg
|
||||
== radialGradient-basic-02.svg pass.svg
|
||||
fuzzy(0-1,0-5) fuzzy-if(winWidget,0-96,0-21713) skip-if(winWidget&&isCoverageBuild) fuzzy-if(Android&&device,0-4,0-946) == radialGradient-basic-03.svg radialGradient-basic-03-ref.html # Bug 1718175 (Win CCov: Bug 1740155)
|
||||
fuzzy(0-1,0-5) fuzzy-if(winWidget,0-32,0-223) fuzzy-if(winWidget&&!swgl,68-96,21668-21713) skip-if(winWidget&&isCoverageBuild) fuzzy-if(Android&&device,0-4,0-946) == radialGradient-basic-03.svg radialGradient-basic-03-ref.html # Bug 1718175 (Win CCov: Bug 1740155)
|
||||
== radialGradient-basic-04.svg pass.svg
|
||||
== radialGradient-fr-01.svg pass.svg
|
||||
fuzzy(0-1,0-3235) fuzzy-if(winWidget,0-1,0-7030) == radialGradient-fr-02.svg radialGradient-fr-02-ref.svg
|
||||
|
@ -5739,6 +5739,12 @@
|
||||
value: false
|
||||
mirror: once
|
||||
|
||||
# How long to wait in milliseconds for a texture to be resolved
|
||||
- name: gfx.canvas.remote.texture-timeout-ms
|
||||
type: RelaxedAtomicUint32
|
||||
value: 10000
|
||||
mirror: always
|
||||
|
||||
# How many worker threads spawned for remote canvas
|
||||
# -1 - Calculate based on processor cores
|
||||
# 0 - No worker threads spawned, will do work on CanvasRenderThread
|
||||
|
Loading…
Reference in New Issue
Block a user