зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1734811 - consider to use higher priority for the imglib tasks r=tnikkel
Depends on D127935 Differential Revision: https://phabricator.services.mozilla.com/D127936
This commit is contained in:
Родитель
1f8f9929c9
Коммит
77bb9e9b0e
|
@ -139,7 +139,7 @@ class DecodingTask final : public Task {
|
|||
explicit DecodingTask(RefPtr<IDecodingTask>&& aTask)
|
||||
: Task(false, aTask->Priority() == TaskPriority::eLow
|
||||
? EventQueuePriority::Normal
|
||||
: EventQueuePriority::MediumHigh),
|
||||
: EventQueuePriority::RenderBlocking),
|
||||
mTask(aTask) {}
|
||||
|
||||
bool Run() override {
|
||||
|
|
|
@ -84,7 +84,7 @@ void IDecodingTask::NotifyProgress(NotNull<RasterImage*> aImage,
|
|||
|
||||
// We're forced to notify asynchronously.
|
||||
NotNull<RefPtr<RasterImage>> image = aImage;
|
||||
mEventTarget->Dispatch(CreateMediumHighRunnable(NS_NewRunnableFunction(
|
||||
mEventTarget->Dispatch(CreateRenderBlockingRunnable(NS_NewRunnableFunction(
|
||||
"IDecodingTask::NotifyProgress",
|
||||
[=]() -> void {
|
||||
image->NotifyProgress(progress, invalidRect,
|
||||
|
@ -125,7 +125,7 @@ void IDecodingTask::NotifyDecodeComplete(NotNull<RasterImage*> aImage,
|
|||
|
||||
// We're forced to notify asynchronously.
|
||||
NotNull<RefPtr<RasterImage>> image = aImage;
|
||||
mEventTarget->Dispatch(CreateMediumHighRunnable(NS_NewRunnableFunction(
|
||||
mEventTarget->Dispatch(CreateRenderBlockingRunnable(NS_NewRunnableFunction(
|
||||
"IDecodingTask::NotifyDecodeComplete",
|
||||
[=]() -> void {
|
||||
image->NotifyDecodeComplete(
|
||||
|
|
|
@ -537,7 +537,7 @@ void ImageResource::SendOnUnlockedDraw(uint32_t aFlags) {
|
|||
tracker->OnUnlockedDraw();
|
||||
}
|
||||
});
|
||||
eventTarget->Dispatch(CreateMediumHighRunnable(ev.forget()),
|
||||
eventTarget->Dispatch(CreateRenderBlockingRunnable(ev.forget()),
|
||||
NS_DISPATCH_NORMAL);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -153,28 +153,28 @@ class AsyncNotifyRunnable : public Runnable {
|
|||
nsTArray<RefPtr<IProgressObserver>> mObservers;
|
||||
};
|
||||
|
||||
ProgressTracker::MediumHighRunnable::MediumHighRunnable(
|
||||
ProgressTracker::RenderBlockingRunnable::RenderBlockingRunnable(
|
||||
already_AddRefed<AsyncNotifyRunnable>&& aEvent)
|
||||
: PrioritizableRunnable(std::move(aEvent),
|
||||
nsIRunnablePriority::PRIORITY_MEDIUMHIGH) {}
|
||||
nsIRunnablePriority::PRIORITY_RENDER_BLOCKING) {}
|
||||
|
||||
void ProgressTracker::MediumHighRunnable::AddObserver(
|
||||
void ProgressTracker::RenderBlockingRunnable::AddObserver(
|
||||
IProgressObserver* aObserver) {
|
||||
static_cast<AsyncNotifyRunnable*>(mRunnable.get())->AddObserver(aObserver);
|
||||
}
|
||||
|
||||
void ProgressTracker::MediumHighRunnable::RemoveObserver(
|
||||
void ProgressTracker::RenderBlockingRunnable::RemoveObserver(
|
||||
IProgressObserver* aObserver) {
|
||||
static_cast<AsyncNotifyRunnable*>(mRunnable.get())->RemoveObserver(aObserver);
|
||||
}
|
||||
|
||||
/* static */
|
||||
already_AddRefed<ProgressTracker::MediumHighRunnable>
|
||||
ProgressTracker::MediumHighRunnable::Create(
|
||||
already_AddRefed<ProgressTracker::RenderBlockingRunnable>
|
||||
ProgressTracker::RenderBlockingRunnable::Create(
|
||||
already_AddRefed<AsyncNotifyRunnable>&& aEvent) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
RefPtr<ProgressTracker::MediumHighRunnable> event(
|
||||
new ProgressTracker::MediumHighRunnable(std::move(aEvent)));
|
||||
RefPtr<ProgressTracker::RenderBlockingRunnable> event(
|
||||
new ProgressTracker::RenderBlockingRunnable(std::move(aEvent)));
|
||||
return event.forget();
|
||||
}
|
||||
|
||||
|
@ -200,7 +200,7 @@ void ProgressTracker::Notify(IProgressObserver* aObserver) {
|
|||
mRunnable->AddObserver(aObserver);
|
||||
} else {
|
||||
RefPtr<AsyncNotifyRunnable> ev = new AsyncNotifyRunnable(this, aObserver);
|
||||
mRunnable = ProgressTracker::MediumHighRunnable::Create(ev.forget());
|
||||
mRunnable = ProgressTracker::RenderBlockingRunnable::Create(ev.forget());
|
||||
mEventTarget->Dispatch(mRunnable, NS_DISPATCH_NORMAL);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -209,20 +209,21 @@ class ProgressTracker : public mozilla::SupportsWeakPtr {
|
|||
|
||||
// Wrapper for AsyncNotifyRunnable to make it have medium high priority like
|
||||
// other imagelib runnables.
|
||||
class MediumHighRunnable final : public PrioritizableRunnable {
|
||||
explicit MediumHighRunnable(already_AddRefed<AsyncNotifyRunnable>&& aEvent);
|
||||
virtual ~MediumHighRunnable() = default;
|
||||
class RenderBlockingRunnable final : public PrioritizableRunnable {
|
||||
explicit RenderBlockingRunnable(
|
||||
already_AddRefed<AsyncNotifyRunnable>&& aEvent);
|
||||
virtual ~RenderBlockingRunnable() = default;
|
||||
|
||||
public:
|
||||
void AddObserver(IProgressObserver* aObserver);
|
||||
void RemoveObserver(IProgressObserver* aObserver);
|
||||
|
||||
static already_AddRefed<MediumHighRunnable> Create(
|
||||
static already_AddRefed<RenderBlockingRunnable> Create(
|
||||
already_AddRefed<AsyncNotifyRunnable>&& aEvent);
|
||||
};
|
||||
|
||||
// The runnable, if any, that we've scheduled to deliver async notifications.
|
||||
RefPtr<MediumHighRunnable> mRunnable;
|
||||
RefPtr<RenderBlockingRunnable> mRunnable;
|
||||
|
||||
// mMutex protects access to mImage and mEventTarget.
|
||||
mutable Mutex mMutex;
|
||||
|
|
|
@ -1141,7 +1141,7 @@ void VectorImage::SendFrameComplete(bool aDidCache, uint32_t aFlags) {
|
|||
GetMaxSizedIntRect());
|
||||
} else {
|
||||
NotNull<RefPtr<VectorImage>> image = WrapNotNull(this);
|
||||
NS_DispatchToMainThread(CreateMediumHighRunnable(NS_NewRunnableFunction(
|
||||
NS_DispatchToMainThread(CreateRenderBlockingRunnable(NS_NewRunnableFunction(
|
||||
"ProgressTracker::SyncNotifyProgress", [=]() -> void {
|
||||
RefPtr<ProgressTracker> tracker = image->GetProgressTracker();
|
||||
if (tracker) {
|
||||
|
@ -1504,7 +1504,7 @@ void VectorImage::InvalidateObserversOnNextRefreshDriverTick() {
|
|||
nsCOMPtr<nsIRunnable> ev(NS_NewRunnableFunction(
|
||||
"VectorImage::SendInvalidationNotifications",
|
||||
[=]() -> void { self->SendInvalidationNotifications(); }));
|
||||
eventTarget->Dispatch(CreateMediumHighRunnable(ev.forget()),
|
||||
eventTarget->Dispatch(CreateRenderBlockingRunnable(ev.forget()),
|
||||
NS_DISPATCH_NORMAL);
|
||||
}
|
||||
|
||||
|
|
|
@ -1001,7 +1001,7 @@ imgRequest::OnDataAvailable(nsIRequest* aRequest, nsIInputStream* aInStr,
|
|||
} else {
|
||||
nsCOMPtr<nsIRunnable> runnable =
|
||||
new FinishPreparingForNewPartRunnable(this, std::move(result));
|
||||
eventTarget->Dispatch(CreateMediumHighRunnable(runnable.forget()),
|
||||
eventTarget->Dispatch(CreateRenderBlockingRunnable(runnable.forget()),
|
||||
NS_DISPATCH_NORMAL);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -265,12 +265,13 @@ nsresult imgRequestProxy::DispatchWithTargetIfAvailable(
|
|||
// rather we need to (e.g. we are in the wrong scheduler group context).
|
||||
// As such, we do not set mHadDispatch for telemetry purposes.
|
||||
if (mEventTarget) {
|
||||
mEventTarget->Dispatch(CreateMediumHighRunnable(std::move(aEvent)),
|
||||
mEventTarget->Dispatch(CreateRenderBlockingRunnable(std::move(aEvent)),
|
||||
NS_DISPATCH_NORMAL);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_DispatchToMainThread(CreateMediumHighRunnable(std::move(aEvent)));
|
||||
return NS_DispatchToMainThread(
|
||||
CreateRenderBlockingRunnable(std::move(aEvent)));
|
||||
}
|
||||
|
||||
void imgRequestProxy::AddToOwner(Document* aLoadingDocument) {
|
||||
|
|
|
@ -138,10 +138,10 @@ PrioritizableRunnable::GetPriority(uint32_t* aPriority) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIRunnable> mozilla::CreateMediumHighRunnable(
|
||||
already_AddRefed<nsIRunnable> mozilla::CreateRenderBlockingRunnable(
|
||||
already_AddRefed<nsIRunnable>&& aRunnable) {
|
||||
nsCOMPtr<nsIRunnable> runnable = new PrioritizableRunnable(
|
||||
std::move(aRunnable), nsIRunnablePriority::PRIORITY_MEDIUMHIGH);
|
||||
std::move(aRunnable), nsIRunnablePriority::PRIORITY_RENDER_BLOCKING);
|
||||
return runnable.forget();
|
||||
}
|
||||
|
||||
|
|
|
@ -510,7 +510,7 @@ class PrioritizableRunnable : public Runnable, public nsIRunnablePriority {
|
|||
uint32_t mPriority;
|
||||
};
|
||||
|
||||
extern already_AddRefed<nsIRunnable> CreateMediumHighRunnable(
|
||||
extern already_AddRefed<nsIRunnable> CreateRenderBlockingRunnable(
|
||||
already_AddRefed<nsIRunnable>&& aRunnable);
|
||||
|
||||
namespace detail {
|
||||
|
|
Загрузка…
Ссылка в новой задаче