зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1403539 - Skip to PushImage in WebRenderCommandsBuilder if AddXXXImage fails to return. r=nical
This commit is contained in:
Родитель
fb61ca8219
Коммит
eaa646a782
|
@ -41,10 +41,18 @@ ShmSegmentsWriter::Write(Range<uint8_t> aBytes)
|
|||
|
||||
size_t srcCursor = 0;
|
||||
size_t dstCursor = mCursor;
|
||||
size_t currAllocLen = mSmallAllocs.Length();
|
||||
|
||||
while (remainingBytesToCopy > 0) {
|
||||
if (dstCursor >= mSmallAllocs.Length() * mChunkSize) {
|
||||
AllocChunk();
|
||||
if (!AllocChunk()) {
|
||||
for (size_t i = mSmallAllocs.Length() ; currAllocLen <= i ; i--) {
|
||||
ipc::Shmem shm = mSmallAllocs.ElementAt(i);
|
||||
mShmAllocator->DeallocShmem(shm);
|
||||
mSmallAllocs.RemoveElementAt(i);
|
||||
}
|
||||
return layers::OffsetRange(0, start, 0);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -75,16 +83,18 @@ ShmSegmentsWriter::Write(Range<uint8_t> aBytes)
|
|||
return layers::OffsetRange(0, start, length);
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
ShmSegmentsWriter::AllocChunk()
|
||||
{
|
||||
ipc::Shmem shm;
|
||||
auto shmType = ipc::SharedMemory::SharedMemoryType::TYPE_BASIC;
|
||||
if (!mShmAllocator->AllocShmem(mChunkSize, shmType, &shm)) {
|
||||
gfxCriticalError() << "ShmSegmentsWriter failed to allocate chunk #" << mSmallAllocs.Length();
|
||||
MOZ_CRASH();
|
||||
gfxCriticalNote << "ShmSegmentsWriter failed to allocate chunk #" << mSmallAllocs.Length();
|
||||
MOZ_ASSERT(false, "ShmSegmentsWriter fails to allocate chunk");
|
||||
return false;
|
||||
}
|
||||
mSmallAllocs.AppendElement(shm);
|
||||
return true;
|
||||
}
|
||||
|
||||
layers::OffsetRange
|
||||
|
@ -93,8 +103,9 @@ ShmSegmentsWriter::AllocLargeChunk(size_t aSize)
|
|||
ipc::Shmem shm;
|
||||
auto shmType = ipc::SharedMemory::SharedMemoryType::TYPE_BASIC;
|
||||
if (!mShmAllocator->AllocShmem(aSize, shmType, &shm)) {
|
||||
gfxCriticalError() << "ShmSegmentsWriter failed to allocate large chunk of size " << aSize;
|
||||
MOZ_CRASH();
|
||||
gfxCriticalNote << "ShmSegmentsWriter failed to allocate large chunk of size " << aSize;
|
||||
MOZ_ASSERT(false, "ShmSegmentsWriter fails to allocate large chunk");
|
||||
return layers::OffsetRange(0, 0, 0);
|
||||
}
|
||||
mLargeAllocs.AppendElement(shm);
|
||||
|
||||
|
@ -222,20 +233,28 @@ IpcResourceUpdateQueue::IpcResourceUpdateQueue(ipc::IShmemAllocator* aAllocator,
|
|||
: mWriter(Move(aAllocator), aChunkSize)
|
||||
{}
|
||||
|
||||
void
|
||||
bool
|
||||
IpcResourceUpdateQueue::AddImage(ImageKey key, const ImageDescriptor& aDescriptor,
|
||||
Range<uint8_t> aBytes)
|
||||
{
|
||||
auto bytes = mWriter.Write(aBytes);
|
||||
if (!bytes.length()) {
|
||||
return false;
|
||||
}
|
||||
mUpdates.AppendElement(layers::OpAddImage(aDescriptor, bytes, 0, key));
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
IpcResourceUpdateQueue::AddBlobImage(ImageKey key, const ImageDescriptor& aDescriptor,
|
||||
Range<uint8_t> aBytes)
|
||||
{
|
||||
auto bytes = mWriter.Write(aBytes);
|
||||
if (!bytes.length()) {
|
||||
return false;
|
||||
}
|
||||
mUpdates.AppendElement(layers::OpAddBlobImage(aDescriptor, bytes, 0, key));
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -244,22 +263,30 @@ IpcResourceUpdateQueue::AddExternalImage(wr::ExternalImageId aExtId, wr::ImageKe
|
|||
mUpdates.AppendElement(layers::OpAddExternalImage(aExtId, aKey));
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
IpcResourceUpdateQueue::UpdateImageBuffer(ImageKey aKey,
|
||||
const ImageDescriptor& aDescriptor,
|
||||
Range<uint8_t> aBytes)
|
||||
{
|
||||
auto bytes = mWriter.Write(aBytes);
|
||||
if (!bytes.length()) {
|
||||
return false;
|
||||
}
|
||||
mUpdates.AppendElement(layers::OpUpdateImage(aDescriptor, bytes, aKey));
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
IpcResourceUpdateQueue::UpdateBlobImage(ImageKey aKey,
|
||||
const ImageDescriptor& aDescriptor,
|
||||
Range<uint8_t> aBytes)
|
||||
{
|
||||
auto bytes = mWriter.Write(aBytes);
|
||||
if (!bytes.length()) {
|
||||
return false;
|
||||
}
|
||||
mUpdates.AppendElement(layers::OpUpdateBlobImage(aDescriptor, bytes, aKey));
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -268,11 +295,15 @@ IpcResourceUpdateQueue::DeleteImage(ImageKey aKey)
|
|||
mUpdates.AppendElement(layers::OpDeleteImage(aKey));
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
IpcResourceUpdateQueue::AddRawFont(wr::FontKey aKey, Range<uint8_t> aBytes, uint32_t aIndex)
|
||||
{
|
||||
auto bytes = mWriter.Write(aBytes);
|
||||
if (!bytes.length()) {
|
||||
return false;
|
||||
}
|
||||
mUpdates.AppendElement(layers::OpAddRawFont(bytes, aIndex, aKey));
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -34,7 +34,7 @@ public:
|
|||
void Clear();
|
||||
|
||||
protected:
|
||||
void AllocChunk();
|
||||
bool AllocChunk();
|
||||
layers::OffsetRange AllocLargeChunk(size_t aSize);
|
||||
|
||||
nsTArray<ipc::Shmem> mSmallAllocs;
|
||||
|
@ -67,21 +67,21 @@ public:
|
|||
// So we pick 64k - 2 * 4k = 57344 bytes as the defautl alloc
|
||||
explicit IpcResourceUpdateQueue(ipc::IShmemAllocator* aAllocator, size_t aChunkSize = 57344);
|
||||
|
||||
void AddImage(wr::ImageKey aKey,
|
||||
bool AddImage(wr::ImageKey aKey,
|
||||
const ImageDescriptor& aDescriptor,
|
||||
Range<uint8_t> aBytes);
|
||||
|
||||
void AddBlobImage(wr::ImageKey aKey,
|
||||
bool AddBlobImage(wr::ImageKey aKey,
|
||||
const ImageDescriptor& aDescriptor,
|
||||
Range<uint8_t> aBytes);
|
||||
|
||||
void AddExternalImage(wr::ExternalImageId aExtId, wr::ImageKey aKey);
|
||||
|
||||
void UpdateImageBuffer(wr::ImageKey aKey,
|
||||
bool UpdateImageBuffer(wr::ImageKey aKey,
|
||||
const ImageDescriptor& aDescriptor,
|
||||
Range<uint8_t> aBytes);
|
||||
|
||||
void UpdateBlobImage(wr::ImageKey aKey,
|
||||
bool UpdateBlobImage(wr::ImageKey aKey,
|
||||
const ImageDescriptor& aDescriptor,
|
||||
Range<uint8_t> aBytes);
|
||||
|
||||
|
@ -93,7 +93,7 @@ public:
|
|||
|
||||
void DeleteImage(wr::ImageKey aKey);
|
||||
|
||||
void AddRawFont(wr::FontKey aKey, Range<uint8_t> aBytes, uint32_t aIndex);
|
||||
bool AddRawFont(wr::FontKey aKey, Range<uint8_t> aBytes, uint32_t aIndex);
|
||||
|
||||
void DeleteFont(wr::FontKey aKey);
|
||||
|
||||
|
|
|
@ -516,7 +516,9 @@ WebRenderCommandBuilder::GenerateFallbackData(nsDisplayItem* aItem,
|
|||
Range<uint8_t> bytes((uint8_t*)recorder->mOutputStream.mData, recorder->mOutputStream.mLength);
|
||||
wr::ImageKey key = mManager->WrBridge()->GetNextImageKey();
|
||||
wr::ImageDescriptor descriptor(paintSize.ToUnknownSize(), 0, dt->GetFormat(), isOpaque);
|
||||
aResources.AddBlobImage(key, descriptor, bytes);
|
||||
if (!aResources.AddBlobImage(key, descriptor, bytes)) {
|
||||
return nullptr;
|
||||
}
|
||||
fallbackData->SetKey(key);
|
||||
} else {
|
||||
fallbackData->CreateImageClientIfNeeded();
|
||||
|
|
Загрузка…
Ссылка в новой задаче