Bug 1232231 - BorrowDrawTarget can return nullptr - be ready for it. r=nical

This commit is contained in:
Milan Sreckovic 2016-01-04 09:50:00 -05:00
parent 1cb4a86fa6
commit ae119212a2
2 changed files with 14 additions and 3 deletions

View File

@ -40,7 +40,12 @@ TextureWrapperImage::GetAsSourceSurface()
return nullptr;
}
return mTextureClient->BorrowDrawTarget()->Snapshot();
RefPtr<DrawTarget> dt = mTextureClient->BorrowDrawTarget();
if (!dt) {
return nullptr;
}
return dt->Snapshot();
}
TextureClient*

View File

@ -372,8 +372,14 @@ public:
*/
already_AddRefed<gfx::DataSourceSurface> GetAsSurface() {
Lock(OpenMode::OPEN_READ);
RefPtr<gfx::SourceSurface> surf = BorrowDrawTarget()->Snapshot();
RefPtr<gfx::DataSourceSurface> data = surf->GetDataSurface();
RefPtr<gfx::DataSourceSurface> data;
RefPtr<gfx::DrawTarget> dt = BorrowDrawTarget();
if (dt) {
RefPtr<gfx::SourceSurface> surf = dt->Snapshot();
if (surf) {
data = surf->GetDataSurface();
}
}
Unlock();
return data.forget();
}