Bug 965914 - Don't crash when we can't allocate a new surface in CloneAligned. r=Bas

This commit is contained in:
Markus Stange 2014-02-04 21:03:12 +01:00
parent 5200455be2
commit 1e4341fcaa

View File

@ -235,7 +235,9 @@ CloneAligned(DataSourceSurface* aSource)
{
RefPtr<DataSourceSurface> copy =
Factory::CreateDataSourceSurface(aSource->GetSize(), aSource->GetFormat());
CopyRect(aSource, copy, IntRect(IntPoint(), aSource->GetSize()), IntPoint());
if (copy) {
CopyRect(aSource, copy, IntRect(IntPoint(), aSource->GetSize()), IntPoint());
}
return copy;
}
@ -730,6 +732,13 @@ FilterNodeSoftware::GetInputDataSourceSurface(uint32_t aInputEnumIndex,
RefPtr<DataSourceSurface> result =
GetDataSurfaceInRect(surface, surfaceRect, aRect, aEdgeMode);
if (result &&
(result->Stride() != GetAlignedStride<16>(result->Stride()) ||
reinterpret_cast<uintptr_t>(result->GetData()) % 16 != 0)) {
// Align unaligned surface.
result = CloneAligned(result);
}
if (!result) {
#ifdef DEBUG_DUMP_SURFACES
printf(" -- no input --</section>\n\n");
@ -737,12 +746,6 @@ FilterNodeSoftware::GetInputDataSourceSurface(uint32_t aInputEnumIndex,
return nullptr;
}
if (result->Stride() != GetAlignedStride<16>(result->Stride()) ||
reinterpret_cast<uintptr_t>(result->GetData()) % 16 != 0) {
// Align unaligned surface.
result = CloneAligned(result);
}
SurfaceFormat currentFormat = result->GetFormat();
if (DesiredFormat(currentFormat, aFormatHint) == SurfaceFormat::B8G8R8A8 &&
currentFormat != SurfaceFormat::B8G8R8A8) {