mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-14 20:22:00 +00:00
Bug 1575838: Check that we can create a similar DrawTarget first in canvas Adjusted targets. r=mattwoodrow
This also fixes DrawTargetSkia::CanCreateSimilarDrawTarget because currently if only one of the height or width is negative then it doesn't get caught. Differential Revision: https://phabricator.services.mozilla.com/D43075 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
4ad6464c7c
commit
2bee21f74c
@ -359,6 +359,14 @@ class AdjustedTargetForFilter {
|
||||
mSourceGraphicRect.SizeTo(1, 1);
|
||||
}
|
||||
|
||||
if (!mFinalTarget->CanCreateSimilarDrawTarget(mSourceGraphicRect.Size(),
|
||||
SurfaceFormat::B8G8R8A8)) {
|
||||
mTarget = mFinalTarget;
|
||||
mCtx = nullptr;
|
||||
mFinalTarget = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
mTarget = mFinalTarget->CreateSimilarDrawTarget(mSourceGraphicRect.Size(),
|
||||
SurfaceFormat::B8G8R8A8);
|
||||
|
||||
@ -481,6 +489,14 @@ class AdjustedTargetForShadow {
|
||||
bounds.RoundOut();
|
||||
bounds.ToIntRect(&mTempRect);
|
||||
|
||||
if (!mFinalTarget->CanCreateSimilarDrawTarget(mTempRect.Size(),
|
||||
SurfaceFormat::B8G8R8A8)) {
|
||||
mTarget = mFinalTarget;
|
||||
mCtx = nullptr;
|
||||
mFinalTarget = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
mTarget = mFinalTarget->CreateShadowDrawTarget(
|
||||
mTempRect.Size(), SurfaceFormat::B8G8R8A8, mSigma);
|
||||
|
||||
|
@ -1598,7 +1598,9 @@ already_AddRefed<DrawTarget> DrawTargetSkia::CreateSimilarDrawTarget(
|
||||
|
||||
bool DrawTargetSkia::CanCreateSimilarDrawTarget(const IntSize& aSize,
|
||||
SurfaceFormat aFormat) const {
|
||||
return size_t(std::max(aSize.width, aSize.height)) < GetMaxSurfaceSize();
|
||||
auto minmaxPair = std::minmax(aSize.width, aSize.height);
|
||||
return minmaxPair.first >= 0 &&
|
||||
size_t(minmaxPair.second) < GetMaxSurfaceSize();
|
||||
}
|
||||
|
||||
RefPtr<DrawTarget> DrawTargetSkia::CreateClippedDrawTarget(
|
||||
|
Loading…
x
Reference in New Issue
Block a user