mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bug 1034593 - Prevent clips with huge extents to be passed to a cairo context from CanvasRenderingContext2D. r=jrmuizel
This commit is contained in:
parent
65e4f664f6
commit
1fc33e677f
@ -975,6 +975,15 @@ CanvasRenderingContext2D::EnsureTarget()
|
||||
}
|
||||
|
||||
mTarget->ClearRect(mgfx::Rect(Point(0, 0), Size(mWidth, mHeight)));
|
||||
if (mTarget->GetBackendType() == mgfx::BackendType::CAIRO) {
|
||||
// Cairo doesn't play well with huge clips. When given a very big clip it
|
||||
// will try to allocate big mask surface without taking the target
|
||||
// size into account which can cause OOM. See bug 1034593.
|
||||
// This limits the clip extents to the size of the canvas.
|
||||
// A fix in Cairo would probably be preferable, but requires somewhat
|
||||
// invasive changes.
|
||||
mTarget->PushClipRect(mgfx::Rect(Point(0, 0), Size(mWidth, mHeight)));
|
||||
}
|
||||
// Force a full layer transaction since we didn't have a layer before
|
||||
// and now we might need one.
|
||||
if (mCanvasElement) {
|
||||
@ -1062,6 +1071,11 @@ CanvasRenderingContext2D::InitializeWithSurface(nsIDocShell *shell,
|
||||
mTarget = sErrorTarget;
|
||||
}
|
||||
|
||||
if (mTarget->GetBackendType() == mgfx::BackendType::CAIRO) {
|
||||
// Cf comment in EnsureTarget
|
||||
mTarget->PushClipRect(mgfx::Rect(Point(0, 0), Size(mWidth, mHeight)));
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user