Bug 1623254 - Re-create DrawTarget of CanvasRenderingContext2D when the DrawTarget becomes invalid r=nical

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
sotaro 2020-03-18 10:38:32 +00:00
parent 89848fa4f9
commit b7a705dcef
3 changed files with 6 additions and 3 deletions

View File

@ -1296,7 +1296,7 @@ bool CanvasRenderingContext2D::EnsureTarget(const gfx::Rect* aCoveredRect,
RestoreClipsAndTransformToTarget();
}
if (mTarget) {
if (mTarget && mTarget->IsValid()) {
return true;
}
}

View File

@ -90,6 +90,9 @@ DrawTargetD2D1::~DrawTargetD2D1() {
}
bool DrawTargetD2D1::IsValid() const {
if (mInitState != InitState::Uninitialized && !IsDeviceContextValid()) {
return false;
}
if (NS_IsMainThread()) {
// Uninitialized DTs are considered valid.
return mInitState != InitState::Failure;
@ -2274,7 +2277,7 @@ void DrawTargetD2D1::PushD2DLayer(ID2D1DeviceContext* aDC,
nullptr);
}
bool DrawTargetD2D1::IsDeviceContextValid() {
bool DrawTargetD2D1::IsDeviceContextValid() const {
uint32_t seqNo;
return mDC && Factory::GetD2D1Device(&seqNo) && seqNo == mDeviceSeq;
}

View File

@ -244,7 +244,7 @@ class DrawTargetD2D1 : public DrawTarget {
// This function is used to determine if the mDC is still valid; if it is
// stale, we should avoid using it to execute any draw commands.
bool IsDeviceContextValid();
bool IsDeviceContextValid() const;
IntSize mSize;