forked from mirrors/gecko-dev
Bug 1881076 - Ref snapshot shmem. r=aosmond
Differential Revision: https://phabricator.services.mozilla.com/D205404
This commit is contained in:
parent
2537e5eaaf
commit
6525b36941
1 changed files with 13 additions and 8 deletions
|
|
@ -511,6 +511,10 @@ already_AddRefed<gfx::DataSourceSurface> CanvasChild::GetDataSurface(
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gfx::IntSize ssSize = aSurface->GetSize();
|
||||||
|
gfx::SurfaceFormat ssFormat = aSurface->GetFormat();
|
||||||
|
auto stride = ImageDataSerializer::ComputeRGBStride(ssFormat, ssSize.width);
|
||||||
|
|
||||||
// Shmem is only valid if the surface is the latest snapshot (not detached).
|
// Shmem is only valid if the surface is the latest snapshot (not detached).
|
||||||
if (!aDetached) {
|
if (!aDetached) {
|
||||||
// If there is a shmem associated with this snapshot id, then we want to try
|
// If there is a shmem associated with this snapshot id, then we want to try
|
||||||
|
|
@ -525,12 +529,16 @@ already_AddRefed<gfx::DataSourceSurface> CanvasChild::GetDataSurface(
|
||||||
if (NS_WARN_IF(!mRecorder->WaitForCheckpoint(checkpoint))) {
|
if (NS_WARN_IF(!mRecorder->WaitForCheckpoint(checkpoint))) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
gfx::IntSize size = aSurface->GetSize();
|
auto* closure =
|
||||||
gfx::SurfaceFormat format = aSurface->GetFormat();
|
new CanvasDataShmemHolder(it->second.mSnapshotShmem, this);
|
||||||
auto stride = ImageDataSerializer::ComputeRGBStride(format, size.width);
|
if (NS_WARN_IF(!closure->Init(mWorkerRef))) {
|
||||||
|
delete closure;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
RefPtr<gfx::DataSourceSurface> dataSurface =
|
RefPtr<gfx::DataSourceSurface> dataSurface =
|
||||||
gfx::Factory::CreateWrappingDataSourceSurface(shmemPtr, stride, size,
|
gfx::Factory::CreateWrappingDataSourceSurface(
|
||||||
format);
|
shmemPtr, stride, ssSize, ssFormat, ReleaseDataShmemHolder,
|
||||||
|
closure);
|
||||||
aMayInvalidate = true;
|
aMayInvalidate = true;
|
||||||
return dataSurface.forget();
|
return dataSurface.forget();
|
||||||
}
|
}
|
||||||
|
|
@ -538,8 +546,6 @@ already_AddRefed<gfx::DataSourceSurface> CanvasChild::GetDataSurface(
|
||||||
|
|
||||||
RecordEvent(RecordedPrepareDataForSurface(aSurface));
|
RecordEvent(RecordedPrepareDataForSurface(aSurface));
|
||||||
|
|
||||||
gfx::IntSize ssSize = aSurface->GetSize();
|
|
||||||
gfx::SurfaceFormat ssFormat = aSurface->GetFormat();
|
|
||||||
if (!EnsureDataSurfaceShmem(ssSize, ssFormat)) {
|
if (!EnsureDataSurfaceShmem(ssSize, ssFormat)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
@ -559,7 +565,6 @@ already_AddRefed<gfx::DataSourceSurface> CanvasChild::GetDataSurface(
|
||||||
mDataSurfaceShmemAvailable = false;
|
mDataSurfaceShmemAvailable = false;
|
||||||
|
|
||||||
auto* data = static_cast<uint8_t*>(mDataSurfaceShmem->memory());
|
auto* data = static_cast<uint8_t*>(mDataSurfaceShmem->memory());
|
||||||
auto stride = ImageDataSerializer::ComputeRGBStride(ssFormat, ssSize.width);
|
|
||||||
|
|
||||||
RefPtr<gfx::DataSourceSurface> dataSurface =
|
RefPtr<gfx::DataSourceSurface> dataSurface =
|
||||||
gfx::Factory::CreateWrappingDataSourceSurface(
|
gfx::Factory::CreateWrappingDataSourceSurface(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue