mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-16 13:56:29 +00:00
Bug 1167356 - Handle return value of DataSourceSurface::Map wherever possible. r=Bas
--HG-- extra : rebase_source : fe4fcb9c3a89e2573e6fde423ed8d96f31e00f14
This commit is contained in:
parent
4a8e2edd09
commit
1013161996
@ -7431,7 +7431,9 @@ nsContentUtils::GetSurfaceData(mozilla::gfx::DataSourceSurface* aSurface,
|
|||||||
size_t* aLength, int32_t* aStride)
|
size_t* aLength, int32_t* aStride)
|
||||||
{
|
{
|
||||||
mozilla::gfx::DataSourceSurface::MappedSurface map;
|
mozilla::gfx::DataSourceSurface::MappedSurface map;
|
||||||
aSurface->Map(mozilla::gfx::DataSourceSurface::MapType::READ, &map);
|
if (NS_WARN_IF(!aSurface->Map(mozilla::gfx::DataSourceSurface::MapType::READ, &map))) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
mozilla::gfx::IntSize size = aSurface->GetSize();
|
mozilla::gfx::IntSize size = aSurface->GetSize();
|
||||||
mozilla::CheckedInt32 requiredBytes =
|
mozilla::CheckedInt32 requiredBytes =
|
||||||
mozilla::CheckedInt32(map.mStride) * mozilla::CheckedInt32(size.height);
|
mozilla::CheckedInt32(map.mStride) * mozilla::CheckedInt32(size.height);
|
||||||
|
@ -177,7 +177,10 @@ public:
|
|||||||
RefPtr<DataSourceSurface> surf = Factory::CreateDataSourceSurface(GetSize(), GetFormat());
|
RefPtr<DataSourceSurface> surf = Factory::CreateDataSourceSurface(GetSize(), GetFormat());
|
||||||
|
|
||||||
DataSourceSurface::MappedSurface mappedSurf;
|
DataSourceSurface::MappedSurface mappedSurf;
|
||||||
surf->Map(DataSourceSurface::MapType::WRITE, &mappedSurf);
|
if (!surf->Map(DataSourceSurface::MapType::WRITE, &mappedSurf)) {
|
||||||
|
gfxCriticalError() << "DrawTargetTiled::GetDataSurface failed to map surface";
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
RefPtr<DrawTarget> dt =
|
RefPtr<DrawTarget> dt =
|
||||||
|
@ -1095,7 +1095,10 @@ FilterNodeTransformSoftware::Render(const IntRect& aRect)
|
|||||||
}
|
}
|
||||||
|
|
||||||
DataSourceSurface::MappedSurface mapping;
|
DataSourceSurface::MappedSurface mapping;
|
||||||
surf->Map(DataSourceSurface::MapType::WRITE, &mapping);
|
if (!surf->Map(DataSourceSurface::MapType::WRITE, &mapping)) {
|
||||||
|
gfxCriticalError() << "FilterNodeTransformSoftware::Render failed to map surface";
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
RefPtr<DrawTarget> dt =
|
RefPtr<DrawTarget> dt =
|
||||||
Factory::CreateDrawTargetForData(BackendType::CAIRO,
|
Factory::CreateDrawTargetForData(BackendType::CAIRO,
|
||||||
|
@ -182,7 +182,10 @@ DataSourceSurfaceD2D1::Map(MapType aMapType, MappedSurface *aMappedSurface)
|
|||||||
}
|
}
|
||||||
|
|
||||||
D2D1_MAPPED_RECT map;
|
D2D1_MAPPED_RECT map;
|
||||||
mBitmap->Map(D2D1_MAP_OPTIONS_READ, &map);
|
if (FAILED(mBitmap->Map(D2D1_MAP_OPTIONS_READ, &map))) {
|
||||||
|
gfxCriticalError() << "Failed to map bitmap.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
aMappedSurface->mData = map.bits;
|
aMappedSurface->mData = map.bits;
|
||||||
aMappedSurface->mStride = map.pitch;
|
aMappedSurface->mStride = map.pitch;
|
||||||
|
|
||||||
@ -215,7 +218,10 @@ DataSourceSurfaceD2D1::EnsureMapped()
|
|||||||
if (mMapped) {
|
if (mMapped) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mBitmap->Map(D2D1_MAP_OPTIONS_READ, &mMap);
|
if (FAILED(mBitmap->Map(D2D1_MAP_OPTIONS_READ, &mMap))) {
|
||||||
|
gfxCriticalError() << "Failed to map bitmap.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
mMapped = true;
|
mMapped = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,7 +217,10 @@ static void
|
|||||||
SwapRAndBComponents(DataSourceSurface* surf)
|
SwapRAndBComponents(DataSourceSurface* surf)
|
||||||
{
|
{
|
||||||
DataSourceSurface::MappedSurface map;
|
DataSourceSurface::MappedSurface map;
|
||||||
MOZ_ALWAYS_TRUE( surf->Map(DataSourceSurface::MapType::READ_WRITE, &map) );
|
if (!surf->Map(DataSourceSurface::MapType::READ_WRITE, &map)) {
|
||||||
|
MOZ_ASSERT(false, "SwapRAndBComponents: Failed to map surface.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
MOZ_ASSERT(map.mStride >= 0);
|
MOZ_ASSERT(map.mStride >= 0);
|
||||||
|
|
||||||
const size_t rowBytes = surf->GetSize().width*4;
|
const size_t rowBytes = surf->GetSize().width*4;
|
||||||
@ -288,8 +291,11 @@ CopyDataSourceSurface(DataSourceSurface* aSource,
|
|||||||
|
|
||||||
DataSourceSurface::MappedSurface srcMap;
|
DataSourceSurface::MappedSurface srcMap;
|
||||||
DataSourceSurface::MappedSurface destMap;
|
DataSourceSurface::MappedSurface destMap;
|
||||||
MOZ_ALWAYS_TRUE( aSource->Map(DataSourceSurface::MapType::READ, &srcMap) );
|
if (!aSource->Map(DataSourceSurface::MapType::READ, &srcMap) ||
|
||||||
MOZ_ALWAYS_TRUE( aDest->Map(DataSourceSurface::MapType::WRITE, &destMap) );
|
!aDest->Map(DataSourceSurface::MapType::WRITE, &destMap)) {
|
||||||
|
MOZ_ASSERT(false, "CopyDataSourceSurface: Failed to map surface.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
MOZ_ASSERT(srcMap.mStride >= 0);
|
MOZ_ASSERT(srcMap.mStride >= 0);
|
||||||
MOZ_ASSERT(destMap.mStride >= 0);
|
MOZ_ASSERT(destMap.mStride >= 0);
|
||||||
|
|
||||||
|
@ -287,7 +287,9 @@ YCbCrImageDataDeserializer::ToDataSourceSurface()
|
|||||||
}
|
}
|
||||||
|
|
||||||
DataSourceSurface::MappedSurface map;
|
DataSourceSurface::MappedSurface map;
|
||||||
result->Map(DataSourceSurface::MapType::WRITE, &map);
|
if (NS_WARN_IF(!result->Map(DataSourceSurface::MapType::WRITE, &map))) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
gfx::ConvertYCbCrToRGB32(GetYData(), GetCbData(), GetCrData(),
|
gfx::ConvertYCbCrToRGB32(GetYData(), GetCbData(), GetCrData(),
|
||||||
map.mData,
|
map.mData,
|
||||||
|
@ -851,7 +851,11 @@ DataTextureSourceD3D11::Update(DataSourceSurface* aSurface,
|
|||||||
}
|
}
|
||||||
|
|
||||||
DataSourceSurface::MappedSurface map;
|
DataSourceSurface::MappedSurface map;
|
||||||
aSurface->Map(DataSourceSurface::MapType::READ, &map);
|
if (!aSurface->Map(DataSourceSurface::MapType::READ, &map)) {
|
||||||
|
gfxCriticalError() << "Failed to map surface.";
|
||||||
|
Reset();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (aDestRegion) {
|
if (aDestRegion) {
|
||||||
nsIntRegionRectIterator iter(*aDestRegion);
|
nsIntRegionRectIterator iter(*aDestRegion);
|
||||||
|
@ -484,9 +484,11 @@ imgFrame::Optimize()
|
|||||||
}
|
}
|
||||||
|
|
||||||
DataSourceSurface::MappedSurface mapping;
|
DataSourceSurface::MappedSurface mapping;
|
||||||
DebugOnly<bool> success =
|
if (!surf->Map(DataSourceSurface::MapType::WRITE, &mapping)) {
|
||||||
surf->Map(DataSourceSurface::MapType::WRITE, &mapping);
|
gfxCriticalError() << "imgFrame::Optimize failed to map surface";
|
||||||
NS_ASSERTION(success, "Failed to map surface");
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
RefPtr<DrawTarget> target =
|
RefPtr<DrawTarget> target =
|
||||||
Factory::CreateDrawTargetForData(BackendType::CAIRO,
|
Factory::CreateDrawTargetForData(BackendType::CAIRO,
|
||||||
mapping.mData,
|
mapping.mData,
|
||||||
@ -910,9 +912,11 @@ imgFrame::Deoptimize()
|
|||||||
}
|
}
|
||||||
|
|
||||||
DataSourceSurface::MappedSurface mapping;
|
DataSourceSurface::MappedSurface mapping;
|
||||||
DebugOnly<bool> success =
|
if (!surf->Map(DataSourceSurface::MapType::WRITE, &mapping)) {
|
||||||
surf->Map(DataSourceSurface::MapType::WRITE, &mapping);
|
gfxCriticalError() << "imgFrame::Deoptimize failed to map surface";
|
||||||
NS_ASSERTION(success, "Failed to map surface");
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
RefPtr<DrawTarget> target =
|
RefPtr<DrawTarget> target =
|
||||||
Factory::CreateDrawTargetForData(BackendType::CAIRO,
|
Factory::CreateDrawTargetForData(BackendType::CAIRO,
|
||||||
mapping.mData,
|
mapping.mData,
|
||||||
|
@ -75,7 +75,9 @@ nsImageToPixbuf::SourceSurfaceToPixbuf(SourceSurface* aSurface,
|
|||||||
|
|
||||||
RefPtr<DataSourceSurface> dataSurface = aSurface->GetDataSurface();
|
RefPtr<DataSourceSurface> dataSurface = aSurface->GetDataSurface();
|
||||||
DataSourceSurface::MappedSurface map;
|
DataSourceSurface::MappedSurface map;
|
||||||
dataSurface->Map(DataSourceSurface::MapType::READ, &map);
|
if (!dataSurface->Map(DataSourceSurface::MapType::READ, &map))
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
uint8_t* srcData = map.mData;
|
uint8_t* srcData = map.mData;
|
||||||
int32_t srcStride = map.mStride;
|
int32_t srcStride = map.mStride;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user