mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
Bug 1521368: Forego drawing if our drawtarget is invalid, this can happen on a devicereset. r=rhunt
Differential Revision: https://phabricator.services.mozilla.com/D17224 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
6e5e033cec
commit
587e039c49
@ -87,6 +87,15 @@ DrawTargetD2D1::~DrawTargetD2D1() {
|
||||
}
|
||||
}
|
||||
|
||||
bool DrawTargetD2D1::IsValid() const {
|
||||
if (NS_IsMainThread()) {
|
||||
// Uninitialized DTs are considered valid.
|
||||
return !mIsInitialized || mDC;
|
||||
} else {
|
||||
return const_cast<DrawTargetD2D1 *>(this)->EnsureInitialized();
|
||||
}
|
||||
}
|
||||
|
||||
already_AddRefed<SourceSurface> DrawTargetD2D1::Snapshot() {
|
||||
if (!EnsureInitialized()) {
|
||||
return nullptr;
|
||||
@ -1307,9 +1316,12 @@ void DrawTargetD2D1::FlushInternal(bool aHasDependencyMutex /* = false */) {
|
||||
|
||||
bool DrawTargetD2D1::EnsureInitialized() {
|
||||
if (mIsInitialized) {
|
||||
return true;
|
||||
return !!mDC;
|
||||
}
|
||||
|
||||
// Don't retry.
|
||||
mIsInitialized = true;
|
||||
|
||||
HRESULT hr;
|
||||
|
||||
RefPtr<ID2D1Device> device = Factory::GetD2D1Device(&mDeviceSeq);
|
||||
@ -1388,8 +1400,6 @@ bool DrawTargetD2D1::EnsureInitialized() {
|
||||
mDC->Clear();
|
||||
}
|
||||
|
||||
mIsInitialized = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,7 @@ class DrawTargetD2D1 : public DrawTarget {
|
||||
DrawTargetD2D1();
|
||||
virtual ~DrawTargetD2D1();
|
||||
|
||||
virtual bool IsValid() const override;
|
||||
virtual DrawTargetType GetType() const override {
|
||||
return DrawTargetType::HARDWARE_RASTER;
|
||||
}
|
||||
|
@ -196,8 +196,13 @@ void PaintThread::AsyncPaintTask(CompositorBridgeChild* aBridge,
|
||||
gfx::DrawTargetCapture* capture = aTask->mCapture;
|
||||
gfx::DrawTarget* target = aTask->mTarget;
|
||||
|
||||
target->DrawCapturedDT(capture, Matrix());
|
||||
target->Flush();
|
||||
if (target->IsValid()) {
|
||||
// Do not replay to invalid targets. This can happen on device resets and
|
||||
// the browser will ensure the graphics stack is reinitialized on the main
|
||||
// thread.
|
||||
target->DrawCapturedDT(capture, Matrix());
|
||||
target->Flush();
|
||||
}
|
||||
|
||||
if (gfxPrefs::LayersOMTPReleaseCaptureOnMainThread()) {
|
||||
// This should ensure the capture drawtarget, which may hold on to
|
||||
|
Loading…
Reference in New Issue
Block a user