Bug 1461775 - Create paint worker threads in response to a device reset instead of preemptively. r=bas

--HG--
extra : rebase_source : 83f98d01b416c8ac52c36809416be92d94120463
This commit is contained in:
Ryan Hunt 2018-05-15 13:36:11 -05:00
parent 7f81c73bae
commit 95f916f190
3 changed files with 31 additions and 4 deletions

View File

@ -167,10 +167,8 @@ PaintThread::Init()
// Only create paint workers for tiling if we are using tiling or could
// expect to dynamically switch to tiling in the future
if (gfxPlatform::GetPlatform()->UsesTiling() ||
gfxPrefs::LayersTilesEnabledIfSkiaPOMTP()) {
int32_t paintWorkerCount = PaintThread::CalculatePaintWorkerCount();
mPaintWorkers = SharedThreadPool::Get(NS_LITERAL_CSTRING("PaintWorker"), paintWorkerCount);
if (gfxPlatform::GetPlatform()->UsesTiling()) {
InitPaintWorkers();
}
nsCOMPtr<nsIRunnable> paintInitTask =
@ -187,6 +185,14 @@ PaintThread::InitOnPaintThread()
sThreadId = PlatformThread::CurrentId();
}
void
PaintThread::InitPaintWorkers()
{
MOZ_ASSERT(NS_IsMainThread());
int32_t count = PaintThread::CalculatePaintWorkerCount();
mPaintWorkers = SharedThreadPool::Get(NS_LITERAL_CSTRING("PaintWorker"), count);
}
void
DestroyPaintThread(UniquePtr<PaintThread>&& pt)
{
@ -236,6 +242,18 @@ PaintThread::IsOnPaintWorkerThread()
return mPaintWorkers && mPaintWorkers->IsOnCurrentThread();
}
void
PaintThread::UpdateRenderMode()
{
if (!!mPaintWorkers != gfxPlatform::GetPlatform()->UsesTiling()) {
if (mPaintWorkers) {
mPaintWorkers = nullptr;
} else {
InitPaintWorkers();
}
}
}
void
PaintThread::PrepareBuffer(CapturedBufferState* aState)
{
@ -363,6 +381,7 @@ PaintThread::PaintTiledContents(CapturedTiledPaintState* aState)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aState);
MOZ_ASSERT(mPaintWorkers);
if (gfxPrefs::LayersOMTPDumpCapture() && aState->mCapture) {
aState->mCapture->Dump();

View File

@ -270,6 +270,8 @@ public:
static bool IsOnPaintThread();
bool IsOnPaintWorkerThread();
void UpdateRenderMode();
void PrepareBuffer(CapturedBufferState* aState);
void PaintContents(CapturedPaintState* aState,
@ -308,6 +310,7 @@ private:
bool Init();
void ShutdownOnPaintThread();
void InitOnPaintThread();
void InitPaintWorkers();
void AsyncPrepareBuffer(CompositorBridgeChild* aBridge,
CapturedBufferState* aState);

View File

@ -41,6 +41,7 @@
#include "gfxGDIFont.h"
#include "mozilla/layers/CompositorThread.h"
#include "mozilla/layers/PaintThread.h"
#include "mozilla/layers/ReadbackManagerD3D11.h"
#include "gfxDWriteFontList.h"
@ -493,6 +494,10 @@ gfxWindowsPlatform::UpdateRenderMode()
UpdateBackendPrefs();
if (PaintThread::Get()) {
PaintThread::Get()->UpdateRenderMode();
}
if (didReset) {
mScreenReferenceDrawTarget =
CreateOffscreenContentDrawTarget(IntSize(1, 1), SurfaceFormat::B8G8R8A8);