Bug 1524554 - Part 2: Ensure DrawTarget validity for DTs created inside Canvas. r=rhunt

Differential Revision: https://phabricator.services.mozilla.com/D21901

--HG--
extra : rebase_source : a363764a3f131c778db0222c9d933f5c76697291
This commit is contained in:
Bas Schouten 2019-03-04 10:49:46 +01:00
Родитель 027d1994fb
Коммит 0e82824fec
1 изменённых файлов: 25 добавлений и 4 удалений

Просмотреть файл

@ -359,7 +359,12 @@ class AdjustedTargetForFilter {
mTarget = mFinalTarget->CreateSimilarDrawTarget(mSourceGraphicRect.Size(),
SurfaceFormat::B8G8R8A8);
if (!mTarget) {
if (mTarget) {
// See bug 1524554.
mTarget->ClearRect(gfx::Rect());
}
if (!mTarget || !mTarget->IsValid()) {
// XXX - Deal with the situation where our temp size is too big to
// fit in a texture (bug 1066622).
mTarget = mFinalTarget;
@ -381,7 +386,13 @@ class AdjustedTargetForFilter {
RefPtr<DrawTarget> dt = mFinalTarget->CreateSimilarDrawTarget(
aRect.Size(), SurfaceFormat::B8G8R8A8);
if (!dt) {
if (dt) {
// See bug 1524554.
dt->ClearRect(gfx::Rect());
}
if (!dt || !dt->IsValid()) {
aRect.SetEmpty();
return nullptr;
}
@ -470,7 +481,12 @@ class AdjustedTargetForShadow {
mTarget = mFinalTarget->CreateShadowDrawTarget(
mTempRect.Size(), SurfaceFormat::B8G8R8A8, mSigma);
if (!mTarget) {
if (mTarget) {
// See bug 1524554.
mTarget->ClearRect(gfx::Rect());
}
if (!mTarget || !mTarget->IsValid()) {
// XXX - Deal with the situation where our temp size is too big to
// fit in a texture (bug 1066622).
mTarget = mFinalTarget;
@ -4085,7 +4101,12 @@ static already_AddRefed<SourceSurface> ExtractSubrect(SourceSurface* aSurface,
RefPtr<DrawTarget> subrectDT = aTargetDT->CreateSimilarDrawTarget(
roundedOutSourceRectInt.Size(), SurfaceFormat::B8G8R8A8);
if (!subrectDT) {
if (subrectDT) {
// See bug 1524554.
subrectDT->ClearRect(gfx::Rect());
}
if (!subrectDT || !subrectDT->IsValid()) {
RefPtr<SourceSurface> surface(aSurface);
return surface.forget();
}